akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, M;
    vector<ll> T;
    cin >> N;
    T.resize(N);
    for(ll i = 0;i < N;i++) cin >> T[i];
    cin >> M;
    for(ll i = 0;i < M;i++) {
        ll p, x;
        ll sum = 0;
        cin >> p >> x;
        for(ll j = 0;j < N;j++) {
            if(j + 1 == p) sum += x;
            else sum += T[j];
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(2 * M);

  for (int i = 0; i < 2 * M; i++){
    cin >> vec.at(i);
  }

  for (int i = 0; i < N; i++){
    int A = 0;
    for (int j = 0; j < 2 * M; j++){
      if (i == vec.at(j) - 1){
        A += 1;
      }
    }
    cout << A << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(N: int, X: int, T: int):
    return (N // X + (N % X != 0)) * T


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    print(f'{solve(N, X, T)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75056
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int dp[607][607];

int main(){
    ll N,K,T,C=0;
    cin >> N;
    string S[607];
    rep(i,N){
        cin >> S[i];
        S[i+N]=S[i]+S[i];
        S[i]=S[i+N];
    }
    rep(i,2*N){
        rep(j,2*N){
            if(i==0||j==0){
                dp[i][j]=0;
            }
            else{
                K=dp[i-1][j-1];
                T=0;
                rep(k,K+1){
                    if(S[i][j-k-1]!=S[i-k-1][j]){
                        T=k+1;
                        break;
                    }
                }
                if(T==0){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j]=T-1;
                }
            }
        }
    }
    rep(i,2*N){
        rep(j,2*N){
            if(dp[i][j]>=N){
                C++;
            }
        }
    }
    cout << C << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<pair<ll, ll>> ans;

  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  for (int i = 1; i < n - 1; ++i) {
    if (a[i] > 0) {
      ans.emplace_back(a[0], a[i]);
      a[0] -= a[i];
    } else {
      ans.emplace_back(a[n - 1], a[i]);
      a[n - 1] -= a[i];
    }
  }

  ans.emplace_back(a[n - 1], a[0]);
  cout << a[n - 1] - a[0] << endl;
  for (auto b : ans) printf("%d %d\n", b.first, b.second);
  return 0;
}


Measured memory_bytes: 6136
primes = []
numberlist = []
for i in range(2, 101):
	numberlist.append(i)
while numberlist[0] <= 10:
	now = numberlist.pop(0)
	primes.append(now)
	newnumberlist = []
	for i in range(0, len(numberlist)):
		if numberlist[i]%now != 0:
			newnumberlist.append(numberlist[i])
	numberlist = newnumberlist
primes = primes + numberlist
counters = []
for i in range(0, len(primes)):
	counters.append(0)
N = int(input())
for i in range(1, N+1):
	m = i
	for j in range(0, len(primes)):
		while m % primes[j] == 0:
			counters[j] += 1
			m //= primes[j]
ans = 0
for i in range(0, len(primes)):
	if counters[i] >= 74:
		ans += 1
	for j in range(i+1, len(primes)):
		if counters[i] >= 2 and counters[j] >= 24:
			ans += 1
		if counters[j] >= 2 and counters[i] >= 24:
			ans += 1
		if counters[i] >= 4 and counters[j] >= 14:
			ans += 1
		if counters[j] >= 4 and counters[i] >= 14:
			ans += 1
		for k in range(j+1, len(primes)):
			if counters[i] >= 2 and counters[j] >= 4 and counters[k] >= 4:
				ans += 1
			if counters[i] >= 4 and counters[j] >= 2 and counters[k] >= 4:
				ans += 1
			if counters[i] >= 4 and counters[j] >= 4 and counters[k] >= 2:
				ans += 1
print(ans)

Measured memory_bytes: 39664
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	static char [][]grid;
	static int h,w;
	static int [][]graph;
	static char [][]map;
	static ArrayDeque<point> dq;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		h = Integer.parseInt(sc.next());
		w = Integer.parseInt(sc.next());
		

		grid = new char [h][w];
		
		for(int i = 0 ;i < h ;i++) {
			String s = sc.next();
			for(int j = 0; j < s.length();j++) {
				grid[i][j] = s.charAt(j);
			}
		}
		
		int ans = 0;
		
		for(int i = 0  ;i < h ;i++) {
			for(int j = 0 ; j < w ;j++) {
				map();
				if(map[i][j] == '#')  continue;
				else {
					dq = new ArrayDeque<point>();
					point st = new point(j,i);
					graph = new int[h][w];
					map[i][j] ='#';
					BFS(st);
					int max = searchMax(0);
					ans = Math.max(max, ans);
					//cheak();
				}
			}
		}
		
		System.out.println(ans);
	}
	
	static void map() {
		map = new char [h][w];
		for(int i = 0 ; i < h ;i++) {
			for(int j = 0 ;j < w ;j++) {
				char c = grid[i][j]; 
				map[i][j] = c;
			}
		}
	}
	static void BFS(point e) {
		int []dx = {1,0,-1,0};
		int []dy = {0,1,0,-1};
		
		for(int i = 0 ;i < 4 ;i++) {
			int px = e.Getx() + dx[i];
			int py = e.Gety() + dy[i];
			if(!judge(py,px)) {
				continue;
			}
			else {
				graph[py][px] = graph[e.Gety()][e.Getx()] + 1;
				point f = new point(px,py);
				dq.addLast(f);
				map[py][px] = '#';
			}
		}
			if(dq.size() == 0) {
				return;
			}
		BFS(dq.pop());
		
		}
	
	static int searchMax(int temp) {
		for(int i = 0; i < h ;i++) {
			for(int j = 0 ; j< w ;j++) {
				temp = Math.max(graph[i][j], temp);
			}
		}
		return temp;
	}
	
	static boolean judge(int py , int px) {
		if(py < 0 || px < 0 || py >= h || px >= w) {
			return false;
		}
		if(map[py][px] == '#') {
			return false;
		}
		else {
			return true;
		}
	}
	
	static void cheak() {
		for(int i = 0; i < h ;i++) {
			for(int j = 0 ; j < w ; j++) {
				System.out.print(graph[i][j]);
			}
			System.out.println();
		}
	}
}

class point {
	private int x;
	private int y;
	
	public point (int x , int y){
		this.x = x;
		this.y = y;
	}
	
	public int Getx() {
		return x;
	}
	public int Gety() {
		return y;
	}
}



Measured memory_bytes: 37284
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define db double
#define ldb long double
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define si set<int>
#define sll set<ll>
#define ins insert
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    int n,k;
    cin>>n>>k;
    int a[n];
    int p=-1;
    rep(i,n){
    	cin>>a[i];
	}
    int r=0;
    if((n-1)%(k-1) !=0)
    r=1;
    int ans=ceil((n-1)/(k-1))+r;
    cout<<ans;
	return 0;
}

Measured memory_bytes: 640
N,D = map(int,input().split())

Xss = []
for _ in range(N):
	Xs = list(map(int,input().split()))
	Xss.append(Xs)
	
#print(Xss)

count = 0
for i in range(N):
	for j in range(N):
		if i >= j:
			continue
		
		tmp = 0
		for d in range(D):
			#print(Xss[i][d],Xss[j][d])
			tmp += ((Xss[i][d]-Xss[j][d])**2)
			
		tmp = tmp**(1/2)
		
		#print(tmp)
		if float.is_integer(tmp):
			count += 1
			
print(count)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main(){
int a,b,c,d,r1=0,r2=0;
cin>>a>>b>>c>>d;
r1=a*b;
r2=c*d;
if (r1>=r2)
cout<<r1<<endl;
else
    cout<<r2<<endl;
return 0;
}


Measured memory_bytes: 256
# import itertools
# import math

import sys
input = sys.stdin.readline


def solve(A, B):
    K = (A + B) / 2
    if int(K) == K:
        return int(K)
    return 'IMPOSSIBLE'


# N = int(input())
# S = input()
A, B = map(int, input().split())
# A = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(A, B))


Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;

int main() {
    int N; cin>>N;
    vector<ll>T(N);
    rep(i,N)cin>>T[i];
    ll a=1;
    for(int i=0;i<N;i++){
        a =T[i]/__gcd(T[i],a)*a;
    }
    cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;

    vector<int> l(n);
    for(int i=0; i<n; i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());

    int ans = 0;
    for(int i=0; i<k; i++){
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(string[] args) {
    int n = readln.chomp.to!int;
    string p = readln.chomp;
    string s = readln.chomp;

    for(int i = 0; i < n; i++){
        if(p[i..$] == s[0..$-i]){
            writeln(n+i);
            return;
        }
    }
    writeln(2*n);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
int main()
{
    ll cnt = 0;
    while(1)
    {
        cnt++;
        ll x;cin >> x;
        if(x==0)
        {
            cout << cnt << endl;
            break;
        }
    }
    
    
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void) {
	int n;
	while(scanf("%d",&n)==1 && n!=0) {
		char input[500][12];
		int P[26][26]={{0}}; /* [] > [] */
		int i,j,k;
		int ok=1;
		for(i=0;i<n;i++)scanf("%s",input[i]);
		/* zyunzyho kankei wo chuusyutu suru */
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) {
				int k;
				for(k=0;input[i][k]!='\0' || input[j][k]!='\0';k++) {
					if(input[i][k]!=input[j][k]) {
						if(input[i][k]!='\0') {
							if(input[j][k]!='\0') {
								P[input[j][k]-'a'][input[i][k]-'a']=1;
							} else {
								/* no way, example: ab < a */
								ok=0;
							}
						}
						break;
					}
				}
			}
		}
		/* suiiritu */
		for(k=0;k<26;k++) {
			for(i=0;i<26;i++) {
				for(j=0;j<26;j++) {
					if(P[i][k]!=0 && P[k][j]!=0)P[i][j]=1;
				}
			}
		}
		/* check */
		for(i=0;i<26;i++) {
			if(P[i][i]!=0)ok=0;
		}
		puts(ok?"yes":"no");
	}
	return 0;
}

Measured memory_bytes: 592
def hashvalue(key,i)#ハッシュ値を求める。
    m = 1046527
    #h1h2はhでハッシュ関数を求める為の値オープンアドレス、ダブルハッシュ法
    h1 = key%m
    h2 = 1+(key%(m-1))
    #配列の添字を求めるiはハッシュの値を求めるたびに加算されてハッシュ値の為の変数
    h = (h1+i*h2)%m
    return h
end

def insert(arr,key)
    i = 0
    while true
        j =hashvalue(key,i)
        if arr[j] == nil
           arr[j] = key
            return j
        else
            i +=1
        end
    end
end

def search(t,key)
    i = 0
    m =t.count
    while true
        j =hashvalue(key,i)
        if t[j] == key
            return j
        elsif t[j] ==nil ||i >= m
            return nil
        else
            i += 1
        end
    end
end

#T.each do |obj|
#    j = insert(T,obj,arr)
#end

def str2key(str)
    str.chars.map do |c|
      case c
      when 'A'; 1;
      when 'C'; 2;
      when 'G'; 3;
      when 'T'; 4;
      else
      end
    end.each.with_index.inject(0) do |acc, (n, idx)|
      acc += n * 5 ** idx
    end
  end

n = gets.to_i
store = []
n.times do
  c, str = gets.split
  case c
  when 'insert'
    key = str2key(str)
    insert(store, key)
  when 'find'
    key = str2key(str)
    if search(store, key) == nil
        puts 'no'
    else
        puts "yes"
    end
  else
  end
end


Measured memory_bytes: 17008
package main

import (
	"fmt"
)

func main() {
	var s1, f1, s2, f2 int
	fmt.Scan(&s1, &f1, &s2, &f2)
	both := 0
	startMax := max(s1, s2)
	finishMin := min(f1, f2)
	both = finishMin - startMax
	if both > 0 {
		fmt.Printf("%d", both)
	} else {
		fmt.Printf("%d", 0)
	}
}

func max(a int, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a int, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>

using namespace std;

int n, m, odd[209], even[209], lft[209], rgt[209];
bool C[209];
map < int, bool > b;
vector < int > v[209];
const int lim = 10000001;
unsigned char cr[(lim + 10) >> 3];

bool pairUp (int nod)
{
    if (C[nod]) return 0;
    C[nod] = 1;
    for (auto i : v[nod])
        if (lft[i] == 0 || pairUp (lft[i]))
        {
            lft[i] = nod, rgt[nod] = i;
            return 1;
        }
    return 0;
}

int maxMatch ()
{
    bool ok = 1;
    while (ok)
    {
        ok = 0;
        for (int i=1; i<=n; i++)
            C[i] = 0;
        for (int i=1; i<=n; i++)
            if (rgt[i] == 0)
                ok |= pairUp (i);
    }
    int ans = 0;
    for (int i=1; i<=n; i++)
        ans += (rgt[i] > 0);
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

int N;
scanf ("%d", &N);
for (int i=1; i<=N; i++)
{
    int x;
    scanf ("%d", &x);
    b[x] ^= 1, b[x + 1] ^= 1;
}
for (auto it : b)
    if (it.second)
    {
//        printf ("%d\n", it.first);
        if (it.first & 1) odd[++n] = it.first;
        else even[++m] = it.first;
    }
for (int i=2; i * i<=lim; i++)
    if (cr[i >> 3] & (1 << (i & 7))) ;
    else
    {
        for (int j=i * i; j<=lim; j+=i)
            cr[j >> 3] |= 1 << (j & 7);
    }
for (int i=1; i<=n; i++)
    for (int j=1; j<=m; j++)
    {
        int val = odd[i] - even[j];
        if (val < 0) val = -val;
        if (val <= 2 || (cr[val >> 3] & (1 << (val & 7)))) ;
        else v[i].push_back (j);
    }
int T1 = maxMatch ();
n -= T1, m -= T1;
int T3 = n & 1, T2 = n / 2 + m / 2;
printf ("%d\n", T1 + 2 * T2 + 3 * T3);
return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int c[10]={0,2,5,5,4,5,6,3,7,6};

int main(){
  int n,m;
  cin>>n>>m;
  int a[m];
  rep(i,0,m) cin>>a[i];
  sort(a,a+m);
  reverse(a,a+m);
  string dp[n+1];
  rep(i,0,n+1) dp[i]="x";
  dp[0]="o";
  rep(i,1,n+1){
    rep(j,0,m){
      if(i>=c[a[j]] && dp[i-c[a[j]]]!="x"){
        if(dp[i].size()<=dp[i-c[a[j]]].size()){
          dp[i]=dp[i-c[a[j]]]+char('0'+a[j]);
        }
        else if(dp[i].size()==dp[i-c[a[j]]].size()+1){
          dp[i]=max(dp[i],dp[i-c[a[j]]]+char('0'+a[j]));
        }
      }
    }
  }
  rep(i,1,dp[n].size()) cout<<dp[n][i];
  cout<<endl;
}

Measured memory_bytes: 57708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

string s;
bool ch[10];
ll ans=0;
void cal(){
	ll cnt=0;
	ll now=0;
	for(ll i=0;i<s.size();i++){
		now+=s[i]-'0';
		if(i!=s.size()-1&&ch[i]){
			now*=10;
		}
		else{
			cnt+=now;
			now=0;
		}
	}
	ans+=cnt;
}
void dep(ll now){
	if(now==s.size()-1){
		cal();
		return ;
	}
	ch[now]=0;dep(now+1);
	ch[now]=1;dep(now+1);
}
int main() {
	cin>>s;
	dep(0);
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N;
vector<vector<pair<int,int>>> G;
vector<int> color;
ll maxc;
/*------------------------------------/
for library*/

/*------------------------------------*/

void dfs(int i, int pre, ll pre_c){
    int cnt = 1;
    for(auto ni: G[i]){
        if(ni.first == pre)continue;
        if(cnt == pre_c){
            cnt++;
        }
        color[ni.second] = cnt;
        //color[ni.second] = (pre_c == maxc) ? pre_c-1:pre_c + 1;
        dfs(ni.first, i, color[ni.second]);
        cnt++;
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin>>N;
    G.resize(N);
    color.resize(N-1);
    rep(i,N-1){
        int a,b; cin>>a>>b;
        a--;b--;
        G[a].push_back({b,i});
        G[b].push_back({a,i});
    }
    maxc = 0;
    int start = 0;
    rep(i,N){
        if(maxc < (ll)G[i].size()){
            chmax(maxc, (ll)G[i].size());
            start = i;
        }
    }
    cout<<maxc<<endl;

    dfs(start, -1, -1);
    rep(i,N-1){
        cout<<color[i]<<endl;
    }
}


Measured memory_bytes: 7424
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#define ll long long
#define For(i, j, k) for(int i = j; i <= (int)k; ++ i)
#define Forr(i, j, k) for(int i = j; i >= (int)k; -- i)
#define INF 0x3f3f3f3f
using namespace std;

const int maxn = 2e5 + 5;

int n, m;
int a[maxn], b[maxn];

inline void file(){
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
}

inline int Read(){
	int x = 0;	char c = getchar();
	for(; !isdigit(c); c = getchar());
	for(; isdigit(c); c = getchar())	x = (x << 3) + (x << 1) + (c ^ 48);
	return x;
}

int main(){
	n = Read();
	For(i, 1, n)	a[i] = Read();
	m = Read();
	For(i, 1, m)	b[i] = Read();
	
	sort(a + 1, a + 1 + n);   sort(b + 1, b + 1 + m);
	int i = 1,  j = 1;
	while(i <= n && j <= m){
		while(a[i] < b[j] && i <= n)	++ i;
		if(a[i] > b[j] || i > n){
			puts("NO");    return 0;
		}
		++ i;	++ j;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 1792
N = int(input())
S = []
T = []
ans = 0
for _ in range(N):
  s, t = input().split()
  t = int(t)
  S.append(s)
  T.append(t)
X = input()
index = S.index(X)
for i in range(index+1,N):
  ans += T[i]
print(ans)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int deg[5];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    for (int i = 0; i < 3; i++) {
        int a, b; cin >> a >> b;
        deg[a]++;
        deg[b]++;
    }
    int numOdd = 0;
    for (int i = 1; i <= 4; i++) if (deg[i]&1) numOdd++;
    cout << (numOdd==0||numOdd==2?"YES":"NO") << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=200050;
vector<int> E[N],lis;
int a[N],ans[N];
void DFS(int u,int p){
	bool pop=0;
	int las=0;
	int i=lower_bound(lis.begin(),lis.end(),a[u])-lis.begin();
	if(i==lis.size()){
		pop=1;
		lis.pb(a[u]);
	}else{
		las=lis[i];
		lis[i]=a[u];
	}
	ans[u]=lis.size();
	for(int v:E[u])if(v!=p)DFS(v,u);
	if(pop)lis.pop_back();
	else lis[i]=las;
}
int main(){
	int n;
	scanf("%i",&n);
	for(int i=1;i<=n;i++)scanf("%i",&a[i]);
	for(int i=1,u,v;i<n;i++)scanf("%i %i",&u,&v),E[u].pb(v),E[v].pb(u);
	DFS(1,0);
	for(int i=1;i<=n;i++)printf("%i\n",ans[i]);
	return 0;
}

Measured memory_bytes: 30616
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];
    if(p > q) swap(p, q);
    int ans = 0;
    while(p != q){
        next_permutation(p.begin(), p.end());
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char tmp[2000];
int main() {
//	freopen("in","r",stdin);
	cin.getline(tmp,1300,'\n');		
	for(int i=0;i<strlen(tmp);i++) {
		if('a'<=tmp[i]&&tmp[i]<='z') tmp[i] -= 32;
		else if('A'<=tmp[i]&&tmp[i]<='Z') tmp[i] += 32;
	}
	cout<<tmp<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


ll t;

int main(){
	cin>>t;
	int k=0;
	int mk=0;
	ll m=t;
	int ans=0;
	while(m>0){
		ans+=m%10;
		m/=10;
		k++;
		if(10<=m)mk=m/10;
	}
	//cout<<k<<endl;
	if(t==10){
		cout<<9<<endl;
		return 0;
	}
	cout<<max(ans,(k-1)*9+mk-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inv(x) power(x,Mod-2)
#define NO() {puts("0");return 0;}
using namespace std;
typedef long long ll;
const int Mod=1e9+7;
int add(int a,const int b){a+=b;if(a>=Mod)a-=Mod;return a;}
int sub(int a,const int b){a-=b;if(a<0)a+=Mod;return a;}
int mul(const int a,const int b){return (ll)a*b%Mod;}
int power(int x,int cs)
{
	int ras=1;
	while(cs)
	{
		if(cs&1) ras=mul(ras,x);
		x=mul(x,x);cs>>=1;
	}
	return ras;
}
const int N=2e5+50;
int n,m,tag=0,mx,ans=0;
char s[N];
int val[N],dp[N],sum[N];
int q(int l,int r)
{
	if(l>r) return 0;
	int ras=sum[r];
	if(l!=0) ras=sub(ras,sum[l-1]);
	return ras;
}
int main()
{
	
	int i,x,pos;
	scanf("%d%d",&n,&m);	
	
	scanf("%s",s+1);
	if(s[1]=='B') tag=1;
	for(i=1;i<=m;i++)
	{
		if(s[i]=='R') val[i]=(1^tag);
		else val[i]=(0^tag);
	}
	for(x=1;x<=m&&val[x]==1;x++);
	x--;
	if(x==m)
	{
		mx=n;ans=1;
		dp[0]=1;sum[0]=1;
		for(i=1;i<=n;i++)
		{
			dp[i]=q(max(i-mx,0),i-2);
			sum[i]=add(sum[i-1],dp[i]);
		}
		//printf("%d %d\n",dp[1],dp[2]);
		for(i=2;i<=mx;i++)
		{
			ans=add(ans,mul(i,dp[n-i]));
		}
	}
	else
	{
		if(n&1) NO();
		if(x&1) mx=x;
		else mx=x+1;
		for(i=x+1;i<=m;)
		{
			if(val[i]==0) 
			{
				i++;continue;
			}
			pos=i;
			while(val[pos]==1) pos++;
			pos--;
			if(pos==m) break;
			if((pos-i+1)&1) mx=min(mx,pos-i+1);
			i=pos+1;
		}
		n=(n+1)/2;mx=(mx+1)/2;
		dp[0]=1;sum[0]=1;
		for(i=1;i<=n;i++)
		{
			dp[i]=q(max(i-mx,0),i-1);
			sum[i]=add(sum[i-1],dp[i]);
		}
		for(i=1;i<=mx;i++)
		{
			ans=add(ans,mul(i<<1,dp[n-i]));
		}
	}
	//printf("n%d mx%d\n",n,mx);
	
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Linq;

namespace Volume0_0017
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            while ( (input = Console.ReadLine()) != null)
            {
                var analyzer = new Analyzer(input);
                Console.WriteLine(analyzer.Solve());
            }
        }
    }

    public class Analyzer
    {
        List<string> Keys = new List<string>() { "the", "this", "that" };
        public string Encrypted { get; protected set; }

        public Analyzer(string input)
        {
            Encrypted = input;
        }

        public static string ShiftString(string str, int shift)
        {
            return new string
                (
                    str.Select(c => char.IsLower(c) ? ShiftChar(c, shift) : c).ToArray()
                );
        }

        protected static char ShiftChar(char c, int shift)
        {
            var shifted = c - shift;
            if (shifted < 97) shifted += 26;
            else if (122 < shifted) shifted -= 26;
            return (char)shifted;
        }

        public string Solve()
        {
            foreach (var key in Keys)
            {
                var targets = Encrypted.Split(' ').Where(s => s.Length == key.Length);
                foreach(var target in targets )
                {
                    int tryShift = target[0] - key[0];
                    if (ShiftString(target, tryShift) == key)
                    {
                        return ShiftString(Encrypted, tryShift);
                    }

                }
            }

            throw new Exception();
        }
    }
}

Measured memory_bytes: 9408
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
//char s[2000000];

using namespace std;

#define ll long long
#define pi pair<ll,ll>
 
vector<ll>v[200005];
ll arr[500005];
ll brr[500005];
//char str[2000000]; 
map<char,ll>mp;
//map<char,ll>cnt;
ll digits[13];
vector<string>names;
ll inp[200009];
//vector<ll>cnt;
int main()
{
   ll i,j,k,l,p,q,r,s=1,t,n,money,x,y,solve;
   string str1,str2;
   cin>>n;
   for(i=1;i<=n;i++)
   {
       cin>>inp[i];	
   }
   for(i=1,j=0;i<=n&&j<=n;i++)
   {
      if(inp[i]==j+1)
      {
         j++;	
      }	
   }
   if(j==0)
     cout<<"-1";
     else
     cout<<n-j;
  
   	
}

Measured memory_bytes: 7680
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)

s = set()
cnt = Counter(a)

for i in range(n):
    if a[i] in s:
        continue
    if cnt[a[i]] >= 2:
        s.add(a[i])
    for j in range(2,10**6//a[i]+1):
        s.add(a[i]*j)

ans = 0
for i in range(n):
    if a[i] in s:
        continue
    ans += 1

print(ans)


Measured memory_bytes: 219404
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s, t;
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        switch (s[i]) {
            case '0':
                t.push_back('0');
                break;
            case '1':
                t.push_back('1');
                break;
            case 'B':
                if (t.empty()) {
                    break;
                } else {
                    t.pop_back();
                }
            default:
                break;
        }
    }

    cout << t << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second
int INF=1e9;
string s;
P dp[222][222],init=P(INF,-INF);

P dfs(int l,int r){
	if(l==r)return P(s[l]-'0',s[l]-'0');
	if(dp[l][r]!=init)return dp[l][r];
	P res=init;
	if(s[l]=='('&&r-l>2) res=dfs(l+1,r);
	if(s[r]==')'&&r-l>2) res=dfs(l,r-1);
	for(int i=l+1;i<r;i++){
		if(!(s[i]=='-'||s[i]=='+'))continue;
		P a=dfs(l,i-1);
		P b=dfs(i+1,r);
		if(s[i]=='-'){
			res.F=min(res.F,a.F-b.S);
			res.S=max(res.S,a.S-b.F);
		}
		if(s[i]=='+'){
			res.F=min(res.F,a.F+b.F);
			res.S=max(res.S,a.S+b.S);
		}
	}
	return dp[l][r]=res;
}

int main(){
	cin>>s;
	for(int i=0;i<222;i++)
		for(int j=0;j<222;j++)dp[i][j]=init;
	cout<<dfs(0,s.size()-1).S<<endl;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef long long ll;

bool is_prime(ll x) {
  for (ll i = 2; i*i <= x; i++) {
    if (x % i == 0) { return false; }
  }
  return x != 1;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int x; cin >> x;
  
  for (int i = x; i < x*10; i++) {
    if ( is_prime(i) ) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
        import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        int ans_int = 0;
        String ans = "";
        if(((int1*int2)%2) == 0){
            ans = "Even";
        }else{
            ans = "Odd";
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21844
n=int(input())
arr = list(map(int,input().split()))
som = sum(arr)
q=int(input())
freq = {}
for i in range(n):
    if arr[i] in freq:
        freq[arr[i]]+=1
    else:
        freq[arr[i]]=1
for _ in range(q):
    b,c=map(int,input().split())
    if b in freq:
        som = som + freq[b]*(c-b)
        if c in freq:
            freq[c] += freq[b]
        else:
            freq[c] = freq[b]
        freq[b]=0
        print(som)
    else:
        print(som)

Measured memory_bytes: 20812
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y,ans=0;
  cin >> x >> y;
  if(x==1)ans+=300000;
  if(y==1)ans+=300000;
  if(x==2)ans+=200000;
  if(y==2)ans+=200000;
  if(x==3)ans+=100000;
  if(y==3)ans+=100000;
  if(x==1&&y==1)ans+=400000;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

string S;
ll cnt[200001];

signed main(){
    cin >> S;
    ll ans = 0;
    for(int i=S.size()-1; i>=0; i--){
        if(S[i] == 'A') ans += (cnt[i] = cnt[i+1]);
        if(S[i] == 'B'){
            cnt[i] = 0;
            if(i+1 < S.size() && S[i+1] == 'C')
                cnt[i] = cnt[i+2] + 1;
        }
        if(S[i] == 'C') cnt[i] = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5296
#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define MOD 1000000007LL

bool absg(int x, int y){
    return x < y;
}

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<pii>> map(H, vector<pii>(W));
    REP(y,0,H){
        REP(x,0,W){
            int A;
            cin >> A;
            map[y][x].first = A;
        }
    }
    REP(y,0,H){
        REP(x,0,W){
            int B;
            cin >> B;
            map[y][x].second = B;
        }
    }

    vector<vector<bitset<(int)6E5>>> state(H, vector<bitset<(int)6E5>>(W, bitset<(int)6E5>(0)));
    vector<int> ret;
    queue<pair<pii, int>> q;
    q.push(make_pair(make_pair(0,0), 0));
    while (!q.empty())
    {
        auto a = q.front(); q.pop();
        int x = a.first.first;
        int y = a.first.second;
        int d = a.second;
        auto &s = state[y][x];
        if(s.test(d)){
            continue;
        }
        s.set(d);

        int dd = map[y][x].first - map[y][x].second;
        if(x < W - 1){
            q.push(make_pair(make_pair(x+1,y), abs(d+dd)));
            q.push(make_pair(make_pair(x+1,y), abs(d-dd)));
        }
        if(y < H - 1){
            q.push(make_pair(make_pair(x,y+1), abs(d+dd)));
            q.push(make_pair(make_pair(x,y+1), abs(d-dd)));
        }
        if(x == W-1 && y == H-1){
            ret.push_back(abs(d+dd));
            ret.push_back(abs(d-dd));
        }
    }

    sort(ret.begin(), ret.end());
    cout << ret[0] << endl;

    return 0;
}

Measured memory_bytes: 482588
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

class State{
public:
  int x1,y1,x2,y2,cost;

  State(int tx1,int ty1,int tx2,int ty2,int tcost){
    x1 = tx1;
    y1 = ty1;
    x2 = tx2;
    y2 = ty2;
    cost = tcost;
  }
};

int w,h;
bool t[52][52];
bool closed[52][52][52][52];

int dx1[] = {-1,1,0,0};
int dx2[] = {1,-1,0,0};
int dy1[] = {0,0,1,-1};
int dy2[] = {0,0,-1,1};

int main(void){
  while(cin>>w>>h && (w||h)){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    x1--; y1--; x2--; y2--;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin>>t[i][j];
      }
    }

    int ans = -1;
    queue<State> open;

    memset(closed,0,sizeof(closed));
    closed[x1][y1][x2][y2] = true;
    open.push(State(x1,y1,x2,y2,0));

    while(!open.empty()){
      State st = open.front(); open.pop();
      if(st.cost >= 100) break;

      if(st.x1 == st.x2 && st.y1 == st.y2){
        ans = st.cost;
        break;
      }

      for(int i=0;i<4;i++){
        int nx1 = st.x1 + dx1[i];
        int ny1 = st.y1 + dy1[i];
        int nx2 = st.x2 + dx2[i];
        int ny2 = st.y2 + dy2[i];
        State nst = st;
        nst.cost++;

        if(nx1>=0 && nx1<w && ny1>=0 && ny1<h && !t[ny1][nx1]){
          nst.x1 = nx1;
          nst.y1 = ny1;
        }
        if(nx2>=0 && nx2<w && ny2>=0 && ny2<h && !t[ny2][nx2]){
          nst.x2 = nx2;
          nst.y2 = ny2;
        }

        if(!closed[nst.x1][nst.y1][nst.x2][nst.y2]){
          closed[nst.x1][nst.y1][nst.x2][nst.y2] = true;
          open.push(nst);
        }
      }
    }

    if(ans == -1)
      cout<<"NA\n";
    else
      cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 10408
# -*- coding: utf-8 -*-
#ARC65C
import copy
import sys
#import math

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
#print(hoge)
a=hoge[0]
b=hoge[1]
c=hoge[2]

print(max(c-(a-b),0))


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


// クラスカル法　O(ElogV)
#define MAX_E (100000)
struct edge { int u, v, cost; };
edge es[MAX_E];
int V, E; // V:頂点数、E:辺数

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int kruskal() {
	sort(es, es + E, comp); // 辺をコストが小さい順に並べておく
    UnionFind G(V); // 集合XをUnionFindで管理
    int res = 0;
    for (int i = 0; i < E; i++) {
        edge e = es[i];
        if (!G.same(e.u, e.v)) { // コストが最も小さく、閉路が出来ない辺を選ぶ
            G.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}


int main() {

    cin >> V >> E;

	for (int i = 0; i < E; i++) {
		cin >> es[i].u >> es[i].v >> es[i].cost;
	}

	int total_cost = kruskal();

	cout << total_cost << endl;

	return 0;

}



Measured memory_bytes: 4320
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll dp[100000+1][2];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  string L;
  cin>>L;
  dp[0][0]=2;
  dp[0][1]=1;
  int n = L.size();
  const ll p = 1e9+7;
  repeat(i,1,n) {
    // calc dp[i][0]
    if(L[i]=='1') {
      dp[i][0]=2*dp[i-1][0];
    } else {
      dp[i][0]=dp[i-1][0];
    }
    dp[i][0]%=p;
    // calc dp[i][1]
    if(L[i]=='1') {
      dp[i][1]=(3*dp[i-1][1]+dp[i-1][0]);
    } else {
      dp[i][1]=(3*dp[i-1][1]);
    }
    dp[i][1]%=p;
  }
  // debug
  // rep(i,n) {
  //   cout << "dp["<<i<<"][0]="<<dp[i][0] << endl;
  //   cout << "dp["<<i<<"][1]="<<dp[i][1] << endl;
  // }
  cout << (dp[n-1][0]+dp[n-1][1])%p << endl;
  return 0;
}


Measured memory_bytes: 2000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Toggling_Cases
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            foreach (char item in input)
            {
                if (char.IsUpper(item))
                {
                    Console.Write(item.ToString().ToLower());
                }
                else if (char.IsLower(item))
                {
                    Console.Write(item.ToString().ToUpper());
                }
                else
                {
                    Console.Write(item);
                }                
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 13836
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<algorithm>
#include<memory.h>
#include<vector>
#include<stdio.h>
#include<cstdlib>
#include<map>
#include <set>
#include<stack>
#include<cmath>
#include<queue>
#include<bitset>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const int MOD = 1e9 + 7;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
const int N = 1e9 + 1;

bool p[100002];
vector<int> prime;


int main() {
	memset(p, true, sizeof p);
	p[0] = p[1] = false;
	for (int i = 2; i*i < 100000; i++){
		if (p[i])
			for (int j = i*i; j < 100000; j += i)
				p[j] = false;
	}
	for (int i = 0; i < 100000; i++)
		if (p[i])
			prime.push_back(i);
	int n;
	scanf("%d", &n);
	int cnt = 0;
	for (int i = 0; i < prime.size(); i++){
		if (prime[i] % 5 == 1){
			printf("%d ", prime[i]);
			++cnt;
			if (cnt == n)
				break;
		}
	
	}
	puts("");

	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;


float dist(vector<float> x1, vector<float> x2) {
    float ans = 0.0;
    for (int i = 0; i < x1.size(); i++) {
        ans += (x1[i] - x2[i]) * (x1[i] - x2[i]);
    }
    return sqrt(ans);
}


bool isInteger(float x) {
    if (x - (int)x < 1e-6) return true;
    return false;
}


int main(){
    int N, D; cin >> N >> D;
    vector<vector<float>> coordinates(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            float elem ; cin >> elem;
            coordinates[i].push_back(elem);
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (isInteger(dist(coordinates[i], coordinates[j]))) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  if (N > M) { swap(N, M); }
  ll ans = 0;
  if (abs(N - M) <= 1) {
    vector<ll> fact(N + 5, 1);
    for (int i = 2; i < N + 5; ++i) {
      fact[i] = (i * fact[i - 1]) % MOD;
    }
    ans = (fact[N] * fact[M]) % MOD;
    if (N == M) {
      ans = (ans * 2) % MOD;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<string> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	vector<string> b(m);
	for(int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	
	bool yes = false;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			if( i + m - 1 >= n || j + m - 1 >= n ) continue;
			
			bool match = true;
			
			for(int x = 0; x < m; ++x) {
				for(int y = 0; y < m; ++y) {
					if( a[i + x][j + y] != b[x][y] ) match = false;
				}
			}
			
			if( match ) yes = true;
		}
	}
	
	if( yes ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
L=int(input())
N=1
X=1
while X*2<=L:
  N+=1
  X*=2
G=[[(i+1,0),(i+1,1<<i)] for i in range(N)]
G[-1]=[]
L-=X
for i in range(N):
  if L&(1<<i):
    G[i].append((N-1,X))
    X+=(1<<i)
print(N,sum([len(G[i]) for i in range(N)]))
for i in range(N):
  for j in range(len(G[i])):
    print(i+1,G[i][j][0]+1,G[i][j][1])

Measured memory_bytes: 61916
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N, i, ans = 0, sum = 0;
	scanf("%d", &N);
	vector<string> s(N);
	vector<int> t(N);
	for(i = 0; i < N; i++){
		cin >> s[i];
		scanf("%d", &t[i]);
		sum += t[i];
	}
	string X;
	cin >> X;
	for(i = 0; i < N; i++){
		ans += t[i];
		if(X == s[i]){
			break;
		}
	}
	printf("%d\n", sum - ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;

int main(){
  int N;
  cin >> N;
  int s,t;
  s=N/4;
  t=N/7;
  int res = 0;;  
  for(int i=0;i<=s;i++){
    for(int j=0;j<=t;j++){
      int total=0;
      total=4*i + 7*j;
      if(total==N)res=1;
    }
  }
  if(res==1)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, x: usize, t: usize
    };

    let res = (n + x - 1) / x * t;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2220
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007
lcm = 1
for a in A:
    lcm = a // gcd(lcm, a) * lcm
ans = 0
for a in A:
    ans += lcm // a
ans %= MOD
print(ans)

Measured memory_bytes: 6112
#include <cstdio>

const int MOD = 1000000007;

int N, A, B, C, D;
int dp[1010][1010]; // last number, remain number
int fac[1010], inv[1010], facinv[1010];

int pow_mod(int x, int y){
  int res = 1, pw = x;
  for(; y > 0; y /= 2){
    if(y % 2 == 1) res = 1LL * res * pw % MOD;
    pw = 1LL * pw * pw % MOD;
  }
  return res;
}

int inv_mod(int x){ return pow_mod(x, MOD - 2); }

int dfs(int now, int rem){
  if(rem == 0) return 1;
  if(rem < 0) return 0;
  if(dp[now][rem] != -1) return dp[now][rem];

  if(now == A){
    if(rem % now == 0){
      int v = rem / now;
      if(v < C || v > D){ dp[now][rem] = 0; return 0; }
      int res = 1LL * fac[rem] * inv_mod(pow_mod(fac[now], v)) % MOD * facinv[v] % MOD;
      dp[now][rem] = res; return res;
    }
    else{ dp[now][rem] = 0; return 0; }
  }

  int res = 0;

  // 0
  res += dfs(now - 1, rem);

  for(int i = C; i <= D; i++){
    if(now * i > rem) break;
    res += 1LL * dfs(now - 1, rem - now * i) * fac[rem] % MOD * inv_mod(fac[rem - now * i]) % MOD * inv_mod(pow_mod(fac[now], i)) % MOD * facinv[i] % MOD;
    res %= MOD;
  }

  dp[now][rem] = res; return res;
}

int main(){
  scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
  inv[1] = 1;
  for(int i = 2; i <= N; i++) inv[i] = MOD - 1LL * (MOD / i) * inv[MOD % i] % MOD;

  fac[0] = facinv[0] = 1;
  for(int i = 1; i <= N; i++){
    fac[i] = 1LL * fac[i - 1] * i % MOD;
    facinv[i] = 1LL * facinv[i - 1] * inv[i] % MOD;
  }

  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N; j++) dp[i][j] = -1;
  }

  printf("%d\n", dfs(B, N));
  return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    string l;
    cin >> l;
    ll mod = 1000000007;
    ll len = l.size();
    ll dp[2][len];
    dp[0][0] = 2;
    dp[1][0] = 1;
    rep(i, len - 1){
        if(l[i+1] == '1'){
            dp[0][i+1] = dp[0][i] * 2;
            dp[1][i+1] = dp[0][i] + dp[1][i] * 3;
        }else{
            dp[0][i+1] = dp[0][i];
            dp[1][i+1] = dp[1][i] * 3;
        }
        dp[0][i+1] %= mod;
        dp[1][i+1] %= mod;
    }
    ll ans = dp[0][len-1] + dp[1][len-1];
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 5316