akhauriyash/Code-Regression huggingface dataset:
class DisjointSparseTable():
    def __init__(self,data,f):
        from math import ceil,log#2
        self.n=n=len(data)
        m=ceil(log(n,2)) # ceil(log2(n))
        self.f=f
        self.h=[0,0]
        for i in range(2,2**m):self.h.append(self.h[i//2]+1)
        self.data=[data]
        for i in range(1,m):
            d=[0]*n
            w=2**i
            for j in range(0,n,w*2):
                c=min(j+w,n)
                d[c-1]=data[c-1]
                for k in range(c-2,j-1,-1):d[k]=f(data[k],d[k+1])
                if c<n:
                    d[c]=data[c]
                    for k in range(c+1,min(j+w*2,n)):d[k]=f(data[k],d[k-1])
            self.data.append(d)
    def get(self,l,r): # [l,r)
        r-=1
        if l==r:return self.data[0][l]
        d=self.data[self.h[l^r]]
        return self.f(d[l],d[r])
def main():
    from fractions import gcd
    n,*a=map(int,open(0).read().split())
    f=DisjointSparseTable(a,gcd).get
    m=max(f(1,n),f(0,n-1))
    for i in range(n-2):
        m=max(m,gcd(f(0,i+1),f(i+2,n)))
    print(m)
main()

Measured memory_bytes: 96824
fun main(args: Array<String>) {
    var (a, b) = readLine()!!.split(" ").map { it.toLong() }

    if (a < b) {
        val tmp = a
        a = b
        b = tmp
    }

    val x: Long = (a * b)
    var r = (a % b).toInt()

    while (r != 0) {
        a = b
        b = r.toLong()
        r = (a % b).toInt()
    }
    println(x / b)
}

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

int main(){
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  if(s[K-1] == 'A'){
    s[K-1] = 'a';
  }
  else if(s[K-1] == 'B'){
    s[K-1] = 'b';
  }
  else{
    s[K-1] = 'c';
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a;
	
	cin >> a;
	
	if (a >= 1000) {
		cout << "ABD" << endl;
	}
	else {
		cout << "ABC" << endl;

	}

	

}

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

#define ll              long long
#define mod             1000000007
#define inf             1e18

bool cmp(pair<ll, ll> &a, pair<ll, ll> &b){
    if(a.first == b.first)  return a.second > b.second;
    return a.first < b.first;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
    ll n, wt;
    cin>>n>>wt;

    ll w[n], v[n];
    vector<pair<ll, ll>> q;
    for(int i=0; i<n; i++){
        cin>>w[i]>>v[i];
        q.push_back(make_pair(w[i], v[i]));
    }   
    
    sort(q.begin(), q.end(), cmp);
    int z = 0;
    for(auto it=q.begin(); it!=q.end(); it++){
        w[z] = it->first;
        v[z] = it->second;
        z++;
    }
    
    ll dp[n+1][wt+1];
    for(ll i=0; i<=n; i++){
        for(ll j=0; j<=wt; j++){
            if(i==0 || j==0)    dp[i][j] = 0;
            else{
              if(j-w[i-1] < 0)  dp[i][j] = dp[i-1][j];
              else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]] + v[i-1]);
            } 
        }
    }
    cout<<dp[n][wt]<<endl;
    return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	char c;
	for(int i=1;i<=n;i++)
	{
		cin>>c;
		if(c=='Y')
		{
			cout<<"Four";
			return 0;
		}
	}
	cout<<"Three";
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
L = 0
R = N
for i in range(M):
    l, r = map(int,input().split())
    L = max(L, l)
    R = min(R, r)

ans = R - L + 1
if ans >= 0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 3060
#include <stdio.h> 
int main() 
{ 
	int k, a, b, i;	
	scanf("%d %d %d", &k, &a, &b);	
	for(i = 0; ; i++){
		if(k * i >= a && k * i <= b){
			printf("OK");break;
		}
		else if(k * i > b){
			printf("NG");break;
		}
	}	
	return 0;
}

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

int main() {
		long long X, count=0;
        long long M=100;
  		cin >> X;
 		while (X>M){
         	M += M/100 ; 
            count++;
        }
  		cout << count << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)
//using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1 ,rr =1;
    for(ll i=0;i<k;++i) {
      r*=(n-i);
      rr*=(i+1);
      //r %= 1000000007;
      //rr %= 1000000007;
    }
    r/=rr;
    //r %= 1000000007;
    return r;
}

int main() {
  ll N,K;
  cin>>N>>K;
  ll a = (N-1)*(N-2)/2;
  if(K>a){
    cout<<-1<<endl;
    return 0;
  }
  ll ii = a-K;
  ll m = ii+N-1;
  cout<<m<<endl;
  FORi(N-1){
    cout<<"1 "<<i+2<<endl;
  }
  for(ll i=2;i<=N;++i){
    for(ll j=i+1;j<=N;++j){
      if(ii==0){
        i=10000;
        break;
      }
      cout<<i<<" "<<j<<endl;
      ii--;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  double tl[N+2],tr[N+2],v[N+2];
  tl[0] = 0;
  tr[0] = 0;
  int endt = 0;
  for(int i=1;i<=N;i++){
    double tmp;
    cin >> tmp ;
    tl[i] = tr[i-1];
    tr[i] = tl[i] + tmp;
    endt += tmp;
  }
  tl[N+1] = tr[N];
  tr[N+1] = tl[N+1];
  for(int i=1;i<=N;i++){
    cin >> v[i];
  }
  v[0] = 0;
  v[N+1] = 0;

  double spd[2*endt+1];
  for(int i=0;i<=2*endt;i++){
    for(int j=0;j<N+2;j++){
      double tmp;
      double tnow = double(i)/2;
      //cout << "tnow" << tnow << endl;
      //cout << tl[j] << tr[j] << endl;
      if(tnow < tl[j]){
        tmp = v[j] + tl[j] - tnow;
      } else if (tr[j] < tnow){
        tmp = v[j] + tnow - tr[j];
      } else {
        tmp = v[j];
      }

      if(j==0) spd[i] = tmp;
      else spd[i] = min(spd[i],tmp);
    }
    //cout << "i=" << i << " " << spd[i] << endl;
  }

  /*for(int i=0;i<N+2;i++){
    cout << tl[i] << " " << tr[i] << " " << v[i] << endl;
  }*/

  double sum = 0;
  for(int i=1;i<=2*endt;i++){
    sum += (spd[i]+spd[i-1]) * 0.25;
  }

  printf("%.15lf\n",sum);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
#define INF 999999999
typedef  long long ll;
 
int main() {
	ll dig = 0, num = 0,sum = 0,n = 0;
	std::cin >> n;
	num = n;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	if (n%sum == 0) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=1e3+4;

ll dp[N][N]; //dp[i][j] stores the no. of ways to reach the cell (i,j).

string s[N];

int n,m;

bool is_valid(int i,int j)
{
    i--; j--;
    
    if(i>=0 and i<n and j>=0 and j<m)
    return s[i].at(j)=='.';
    
    return false;
}

int main()                  
{
    scn(n); scn(m);
    
    dp[1][1]=1;
    
    rep(i,0,n)
    cin>>s[i];
    
    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            if(!is_valid(i,j))
            continue;
            
            if(is_valid(i+1,j))
            dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
            
            if(is_valid(i,j+1))
            dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
        }
    }
    
    ll ans=dp[n][m];
    
    lpri(ans);
    
} 

Measured memory_bytes: 9088
import math
#3
#0 1 1 2

N = int(input())+1
leaves = list(map(int, input().split()))

nod = 0
total = 0

maxx = [0]*(N+1)
#toward
maxx[0] = 1
if N == 1 and leaves[0] == 1:
    total = 1
else:
    for i in range(1, N):
        notleave = maxx[i-1] - leaves[i-1]
        if notleave <= 0:
            total = -1
            break
        maxx[i] = notleave*2
        if maxx[i] < leaves[i]:
            total = -1
            break
        # if i == N-1:
        #     total += leaves[i]
        # else:
        #     total += maxx[i]



    #backward
    for i in range(1, N+1):
        ii = N-i
        #at least need newnod nodes
        newnod = int((nod+1)/2) + leaves[ii]
        if newnod > maxx[ii]:
            total = -1
            break
        #maximum is?
        newnod = nod + leaves[ii]
        if newnod > maxx[ii]: newnod = maxx[ii]
        if newnod <= 0:
            total = -1
            break
        total += newnod
        nod = newnod


if total <= 0: total = -1
print(total)


Measured memory_bytes: 674324
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[222];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	if(n%2==0)
	{
		for(int i=1;i<=n/2;i++)
		{
			a[i]=a[n+1-i]=i;
		}
	}
	else
	{
		for(int i=1;i<=n/2;i++)
		{
			a[i]=a[n-i]=i;
		}
		a[n]=n/2+1;
	}
	vector<ii> v;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(a[i]!=a[j]) v.pb({i,j});
		}
	}
	cout<<v.size()<<'\n';
	for(ii x:v)
	{
		cout<<x.fi<<' '<<x.se<<'\n';
	}
}


Measured memory_bytes: 512
#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;
  int n = sqrt(N);
  ll Min = INT_MAX;
  ll dev, sum;
  
  for(ll i=1; i<=n; ++i) {
    if(N%i == 0) {
      dev = N/i;
      Min = (Min, dev + i - 2);
    }else continue;
  }
  
  cout << Min << endl;
  
  return 0;
}
    


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(c==1){
        printf("Open\n");
    }
    else if(a == 1 && b == 1){
        printf("Open\n");
    }
    else printf("Close\n");
    
    return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H,W,N,h=0,w=0,a=0;
  cin>>H>>W;
  cin>>N;
  vector<int>M(N);
  vector<vector<int>> ans(H, vector<int>(W));
  for(int i=0;i<N;i++){
  	cin>>M.at(i);
  }
  for(int j=0;j<=N-1;j++){
    for(int k=1;k<=M.at(j);k++){
    	ans.at(h).at(w)=j+1;
    if(h!=H-1 && w%2==0){
    	h++;
      }else if(h==H-1 && w%2==0){
        w++;
        
      }else if(h!=0 && w%2==1){
        h--;
      }else {
        w++;
        
      }
    }
  }
  for(int l=0;l<H;l++){
  	for(int m=0;m<W-1;m++){
    	cout<<ans.at(l).at(m)<<" ";
    }
    cout<< ans.at(l).at(W-1)<<endl;
  }
   
}

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

int main(){
  int n;
  cin>> n;
  vector<int> d(n);
  for (int i=0; i<n; i++) cin>> d.at(i);
  
  sort(d.begin(),d.end());
  cout<< d.at(n/2)-d.at(n/2-1) <<endl;
}

Measured memory_bytes: 640
function Main(input) {
    input = input.split("\n")
    var S = input[0];
    var T = input[1];
    var count = 0;
    if(S[0] == T[0]){
      count++
    }
    if(S[1] == T[1]){
      count++
    }
    if(S[2] == T[2]){
      count++
    }
    console.log(count)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22076
fun main(args: Array<String>) {
    val N = nextInt()
    val P = listOfInt(-1).joinToString(separator = "")
    val Q = listOfInt(-1).joinToString(separator = "")
    val A = IntArray(N)
    val R = mutableListOf<String>()
    fun Permutation(n: Int) {
        if (n == N) {
            R.add(A.joinToString(separator = ""))
        } else {
            for (m in 0 until N) {
                if (A.slice(0 until n).all { it != m }) {
                    A[n] = m
                    Permutation(n + 1)
                }
            }
        }
    }
    Permutation(0)
    var p = 0
    var q = 0
    for (a in R) {
        if (a == P) break;
        p += 1
    }
    for (a in R) {
        if (a == Q) break;
        q += 1
    }
    println(Math.abs(p - q))
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 56608
#include <iostream>
#include <vector>
#include <map>
using namespace std;

long long N, W;
long long w[111];
long long v[111];
long long dp[111111];
int main(){
    cin >> N >> W;
    for(int i=0; i<N; i++)
        cin >> w[i] >> v[i];

    fill_n(dp, 111111, 1LL<<60);
    dp[0] = 0;

    for(int i=0; i<N; i++)
        for(int j=111110; j>=0; j--){
            if(j+v[i] >= 111111) continue;
            dp[j+v[i]] = min(dp[j+v[i]], dp[j]+w[i]);
        }

    long long ans = 0;
    for(int i=0; i<111111; i++)
        if(dp[i] <= W)
            ans = i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> cnt(61);
	rep(i, n) {
		rep(j, cnt.size()) {
			if(1LL&(a[i])>>j) cnt[j]++;
		}
	}
	mint ans = 0;
	rep(i, cnt.size()) {
		mint now = cnt[i] * (n - cnt[i]);
		rep(j, i) now *= 2;
		ans += now;
	}
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{
  int a,b;
	int ans;

  cin >> a >> b;
	ans = max(a,b);
	if(a>b){
		a -= 1;
		ans += max(a,b);
	}else{
		b -= 1;
		ans += max(a,b);
	}

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


Measured memory_bytes: 256
def charToInt(c):
    return ord(c) - ord("a")
 
def stringToFlags(s):
    t = [False for i in range(26)]
    for i in range(len(s)):
        t[charToInt(s[i])] = True
    return t
 
def B(n, s):
    max = 0
    for i in range(1, n):
        xflags = stringToFlags(s[0:i])
        yflags = stringToFlags(s[i:n])
        
        count = 0
        for i in range(26):
            if xflags[i] and yflags[i]:
                count += 1
                if count > max:
                    max = count
    return max
 
n = int(input())
s = input()
print(B(n, s))

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

#include <numeric>
using namespace std;


int main(){
	long long N;
	char a, b;
	vector<long long> A;
	cin >> a>>b;
	/*
	for (long long i = 0; i < N; i++){
		long long inp;
		cin >> inp;
		A.push_back(inp);
	}
	std::sort(A.begin(), A.end());
	*/
	bool s = true;
	if (b == 'H') s = true;
	else s = false;
	if (a == 'D') s = !s;
	if (s)cout << "H"<<endl;
	else cout << "D" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int n,ans;

inline int calc(int x){
    int sum=0;
    while(x){
        sum+=x%10;
        x/=10;
    }
    return sum;
}

int main(){
    ios::sync_with_stdio(false);
    cin>>n;ans=1e9;
    for(int i=1;i<=n/2;i++){
        ans=min(ans,calc(i)+calc(n-i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W
 
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

H, W, D = l_inpl()
A = {}

for hi in range(H):
    l = l_inpl()
    for wi in range(W):
        A[l[wi]] = [wi, hi]

Q = i_inpl()
LR = []
for _ in range(Q):
    LRi = l_inpl()
    LR.append(LRi)

power = []
for i in range(1, H*W-D+1):
    power.append(abs(A[i+D][0] - A[i][0]) + abs(A[i+D][1] - A[i][1]))
    
r_cumsum = [0] * D
for i in range(len(power)):
    r_cumsum.append(r_cumsum[i] + power[len(power)-i-1])

cumsum = r_cumsum[::-1]

for l, r in LR:
    print(cumsum[l-1] - cumsum[r-1])

Measured memory_bytes: 91228
import java.util.*;

class Main {

    static String codeA (char c) {
        switch (c) {
            case ' ':   return "101";
            case '\'':  return "000000";
            case ',':   return "000011";
            case '-':   return "10010001";
            case '.':   return "010001";
            case '?':   return "000001";
            case 'A':   return "100101";
            case 'B':   return "10011010";
            case 'C':   return "0101";
            case 'D':   return "0001";
            case 'E':   return "110";
            case 'F':   return "01001";
            case 'G':   return "10011011";
            case 'H':   return "010000";
            case 'I':   return "0111";
            case 'J':   return "10011000";
            case 'K':   return "0110";
            case 'L':   return "00100";
            case 'M':   return "10011001";
            case 'N':   return "10011110";
            case 'O':   return "00101";
            case 'P':   return "111";
            case 'Q':   return "10011111";
            case 'R':   return "1000";
            case 'S':   return "00110";
            case 'T':   return "00111";
            case 'U':   return "10011100";
            case 'V':   return "10011101";
            case 'W':   return "000010";
            case 'X':   return "10010010";
            case 'Y':   return "10010011";
            case 'Z':   return "10010000";
        }
        return "";
    }

    static void solve (char[] line) {
        String tmp = "";

        for (char c : line) {
            tmp += codeA(c);    
        }

        switch (tmp.length() % 5) {
            case 1: tmp += "0000"; break;
            case 2: tmp += "000"; break;
            case 3: tmp += "00"; break;
            case 4: tmp += "0"; break;
        }


        char [] codeB = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 
            'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '.', ',', '-', '\'', '?' };

        String result = "";

        for(int i = 0; i < tmp.length() / 5; i++) {
            int num = 0;
            int mult = 16;
            for (int j = 0; j < 5; j++) {
                num += Integer.parseInt("" + tmp.charAt(5*i+j)) * mult;
                mult /= 2;
            }
            result += codeB[num];
        }


        System.out.println(result);
        
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            solve(sc.nextLine().toCharArray());
        }
    }
}

Measured memory_bytes: 12000
#include <cstdio>
#include <algorithm>
#define maxn 110
using namespace std;
int n,ans1,ans2;
char s[maxn];
int main() {
	scanf("%d",&n);
	scanf("%s",s);
	int del=0;
	ans1=0;
	for (int i=0;i<n;i++) {
		if (s[i]=='(')
			del++;
		else del--;
		if (del<0)
			ans1=max(ans1,-del);
	}
	del=0;
	ans2=0;
	for (int i=n-1;i>=0;i--) {
		if (s[i]==')')
			del++;
		else del--;
		if (del<0)
			ans2=max(ans2,-del);
	}
	for (int i=1;i<=ans1;i++)
		printf("(");
	printf("%s",s);
	for (int i=1;i<=ans2;i++)
		printf(")");	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
#define MAX_N 100
int d[MAX_N];
int f[MAX_N];

void init(){
	rep(i,MAX_N){
		d[i] = -1;
		f[i] = -1;
	}
}
	
int main()
{
	init();
	int n;
	cin>>n;
	vector<int> *adjList = new vector<int>[n];
	for(int i = 0; i < n; i++){
		int u;
		int k;
		cin>>u>>k;
		rep(j,k){
			int num;
			cin>>num;
			num--;
			adjList[i].push_back(num);
		}
	}
	int currentNode;
	stack<int> searchSt;
	int time = 0;
	rep(j,n){
		bool jIsDone = true;
		if(f[j] == -1){
			time++;
			searchSt.push(j);
		}else{
			continue;
		}
		while(searchSt.empty() != true){
			currentNode = searchSt.top();
			if( d[currentNode] == -1){
				d[currentNode] = time;
			}
			bool isEverythingDone = true;
			for(auto iter = adjList[currentNode].begin();iter != adjList[currentNode].end() ;iter++){
				if( d[*iter] == -1){
					time++;
					isEverythingDone = false;
					searchSt.push(*iter);
					break;
				}
			}
			if( isEverythingDone == true){
				time++;
				f[currentNode] = time;
				searchSt.pop();
			}
		}
	}
	
	rep(i,n){
		cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
	}

	return 0;
}




Measured memory_bytes: 3164
#include <iostream>
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
long double a,b,n,mx;
long double temp1,temp2;
int main()
{
     cin>>a>>b>>n;
 if(n<b)
{
     temp1=(a*n)/b;
    temp2=n/b;
}
else
{
temp1=(a*(b-1))/b;
temp2=(b-1)/b;
}
mx=floor(temp1)-a*floor(temp2);
cout<<mx<<endl;
     return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, i, j, k;
	cin >> n;
	vector<int> a(n);
	for (i = 0; i < n; i++) cin >> a[i];

	bool valid = true;

	for (i = n - 2; i >= 0; i--) {
		if (a[i] > a[i + 1]) {
			a[i]--;
			if (a[i] > a[i + 1]) valid = false;
		}
	}

	if (valid) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N,M;
    int ans=0;
    cin>>N>>M;
    if(N<10&&M<10){
        Out(N*M);
    }else{
        Out(-1);
    }
    

    return 0;
}


Measured memory_bytes: 256
S = list(input())
count = {}

for i in S:
  if count.get(i) is None:
    count[i] = 1
  else:
    count[i] += 1

num = 0
for i in count:
  if count[i] != 2:
    print("No")
    break
  else:
    num += 1
  if num == 2:
    print("Yes")

Measured memory_bytes: 3060
import numpy as np
import random
import sys
from functools import lru_cache

def main(n,k,a):

    mod = 10**9 + 7
    c1,c2 = 0,0
    for i in range(len(a)):
        for j in range(len(a)):
            # print('--- ---', i,j)
            if a[i] > a[j]:
                
                if i < j:
                    c1 += 1

                elif i > j:
                    c2 += 1
        
        count = (c1*k*(k+1)//2 + c2*k*(k-1)//2)%mod

    print(count)


if __name__ == '__main__':
    n,k = map(int,input().split(' '))
    a = list(map(int, input().split(' ')))
    main(n,k,a)

Measured memory_bytes: 13412
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    int N, M;
    std::cin >> N >> M;

    std::vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) {
        std::cin >> a[i] >> b[i];
    }

    std::vector<int> c(M), d(M);
    for (int i = 0; i < M; i++) {
        std::cin >> c[i] >> d[i];
    }

    std::vector<int> ans;
    for (int i = 0; i < N; i++) {
        int min = 1000000000;
        int memo = 0;
        for (int j = 0; j < M; j++) {
            int temp = std::abs(a[i] - c[j]) + std::abs(b[i] - d[j]);
            if (min > temp) {
                min = temp;
                memo = j;
            }
        }
        ans.push_back(memo);
    }

    for (int i = 0; i < ans.size(); i++) {
        std::cout << ans[i] + 1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
	double xa, xb, ya, yb, ra, rb, d;
	String[] input;
	for (int i = 0; i < n; i++) {
	    input = scan.nextLine().split(" ");
	    xa = Double.parseDouble(input[0]);
	    ya = Double.parseDouble(input[1]);
	    ra = Double.parseDouble(input[2]);
	    xb = Double.parseDouble(input[3]);
	    yb = Double.parseDouble(input[4]);
	    rb = Double.parseDouble(input[5]);
	    d = Math.sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
	    if (ra + rb < d) {
		System.out.println(0);
	    } else if (d < ra - rb) {
		System.out.println(2);
	    } else if (d < rb - ra) {
		System.out.println(-2);
	    } else {
		System.out.println(1);
	    }
	}
    }
}

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

#define vi vector<int>
#define ll long long int

int main() {

    int N;
    cin >> N;

    int h;
    vi H;
    int max_cnt = 0;
    int cnt = 0;
    int h_l = 0;
    for (int i = 0; i < N; i++) {
        cin >> h;
        if (h <= h_l ) cnt++;
        else {
            if (cnt > max_cnt) max_cnt = cnt;
            cnt = 0;
        }
        h_l = h;
        if (i == N-1 && cnt > max_cnt) max_cnt = cnt;
    }

    cout << max_cnt << endl;

    return 0;
}


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

using namespace std;

int main(){
    char a,b;
    cin>>a>>b;
    if(a>b) cout<<">"<<endl;
    else if(a<b) cout<<"<"<<endl;
    else cout<<"="<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MAX3(a, b, c) ((a) > (MAX(b, c)) ? (a) : (MAX(b, c)))
#define MIN3(a, b, c) ((a) < (MIN(b, c)) ? (a) : (MIN(b, c)))

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int n,m,X,Y;
    int x[100], y[100];
    cin>>n>>m>>X>>Y;
    for (int i = 0; i < n; i++)
        cin >> x[i];
    for (int i = 0; i < m; i++)
        cin >> y[i];
    sort(x, x + n);
    sort(y, y + m);
    if (x[n - 1] < y[0] && y[0] <= Y && X <= x[n - 1])
        cout << "No War" << endl;
    else
        cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <stdio.h>
 
#define BUF_SIZE 120000
 
using namespace std;
 
int main(){
 
    int n;
    scanf("%d",&n);
 
    int S[n];
 
    for(int i = 0; i < n; i++){
        scanf("%d",&S[i]);
    }
 
    int q;
    scanf("%d",&q);
 
    int count = 0;
    int tmp;
 
    for(int i = 0; i < q; i++){
        scanf("%d",&tmp);
        for(int k = 0; k < n; k++){
            if(tmp == S[k]){
                count++;
                break;
            }
        }
    }
 
    printf("%d\n",count);
 
}


Measured memory_bytes: 3192
#include<iostream> 
using namespace std;
int main(){
	int n,temp,flag=0;
	cin>>n;
	while(n--){
		cin>>temp;
		if(temp%2==0){
			if(temp%3!=0&&temp%5!=0){
				cout<<"DENIED";
				flag=1;
				break;
			}
		}
	}
	if(flag==0)cout<<"APPROVED";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll mod_pow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}

ll nCr(ll n,ll r){
    ll res=1;
    for(ll i=n;i>n-r;i--){
        res*=i;
        res%=mod;
    }
    for(ll i=1;i<=r;i++){
        res*=mod_pow(i,mod-2);
        res%=mod;
    }
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,a,b; cin >> n >> a >> b;
    ll ans=mod_pow(2,n)-1;
    //cout << ans << endl;
    //cout << nCr(4,3) << endl;
    ans-=nCr(n,a)+nCr(n,b);
    ans%=mod;
    cout << (ans+mod)%mod << endl;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#""# => r#""#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        k: usize,
        x: usize,
    }

    if k * 500 >= x {
        "Yes"
    } else {
        "No"
    }.to_string()
}

Measured memory_bytes: 4352
s = input()
end = "ABC"
while True:
  if s == end:
    print("Yes")
    break
  s = s.replace("ABC", "X")
  if ("X" not in s) or ("A" in s) + ("B" in s) + ("C" in s) != 2:
    print("No")
    break

  for c in "ABC":
    if c not in s:
      s = s.replace("X", c)
      break


Measured memory_bytes: 5568
from math import gcd
import sys

input=sys.stdin.readline

N=int(input())
dicplus={}
dicminus={}
dicinf=0
diczero=0
dicnan=0
for i in range(N):
    a,b=map(int,input().split())
    g=gcd(a,b)
    if a==0 and b==0:
        dicnan+=1
    elif a==0:
        diczero+=1
    elif b==0:
        dicinf+=1
    else:
        A=a//g
        B=b//g
        if A*B>0:
            A=abs(A)
            B=abs(B)
            if (A,B) not in dicplus:
                dicplus[(A,B)]=0
            dicplus[(A,B)]+=1
        elif A*B<0:
            A=abs(A)
            B=abs(B)
            if (A,B) not in dicminus:
                dicminus[(A,B)]=0
            dicminus[(A,B)]+=1


ans=1
mod=10**9+7
for a,b in dicplus:
    if (b,a) in dicminus:
        ans*=(pow(2,dicplus[(a,b)],mod)-1+pow(2,dicminus[(b,a)],mod)-1+1)
        ans%=mod
    else:
        ans*=pow(2,dicplus[(a,b)],mod)
        ans%=mod

for a,b in dicminus:
    if (b,a) not in dicplus:
        ans*=pow(2,dicminus[(a,b)],mod)
        ans%=mod

ans*=(pow(2,dicinf,mod)-1+pow(2,diczero,mod)-1+1)
ans%=mod
ans=ans-1+dicnan
ans%=mod

print(ans)

Measured memory_bytes: 111912
#include<stdio.h>
#include<string.h>
#define N 16

int main(void)
{
  char text[N + 1];
  char ans[N + 1] = "CODEFESTIVAL2016";
  gets(text);
  int count = 0;
  for(int i = 0; i < N; i++)
    if(ans[i] != text[i])
      count++;
  printf("%d\n",count);
  return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define F first
#define S second
#define MP m ake_pair
#define LB lower_bound
#define UB upper_bound

using namespace std;
typedef long long ll;
typedef pair<int , int> pii;
typedef long double DB;
const int N = 200100;
int a[N];
int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

	int n;
	cin >> n;

	for(int i = 0 ; i < n ; i++){
	   cin >> a[i];
	   if(a[i] > i || (i && a[i] - a[i-1] > 1)){
		  cout << "-1" << endl;
		  return 0;
	   }
	}
	
	ll ans(0);
	for(int i = 0 ; i < n ; i++){
	   if(i+1 == n || a[i] >= a[i+1])
		  ans += a[i];
	}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[1000000],n,sum=0;
int main(){
	cin>>n;
	for(int i=0;i<n*2;i++){
		cin>>a[i];
	}
	sort(a,a+n*2);
	for(int i=0;i<n*2;i++){
		sum+=a[i];
		i++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
for i in range(len(a)):
    a[i] -= i + 1
a.sort()
res = 10 ** 30
if n % 2 == 0:
    il = [n//2-1, n//2]
else:
    il = [n//2]
for i in il:
    total = 0
    for j in range(len(a)):
        total += abs(a[i] - a[j])
    res = min(res, total)
print(res)


Measured memory_bytes: 26184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    string s;
    cin >> s;
    int right=s.size()-1, count=0;;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[right--]) count++;
    }
    cout << count<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits, ascii_letters
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
import numpy as np
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()
ans = []

for s in S:
	ans.append(ascii_uppercase[(ascii_uppercase.index(s)+N)%26])

print(*ans, sep="")



Measured memory_bytes: 22452
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int main(){
    int n;
    cin >> n;
    int sz = 1;
    for(int i = 0; i < n; ++i)  sz *= 2;
    vector<int> a(sz);
    for(int i = 0; i < sz; ++i) cin >> a[i];
    
    int res = 0;
    for(int k = 1; k < sz; ++k){
        int firstmax = max(a[k], a[0]), secondmax = min(a[k], a[0]);
        int subset = (k - 1) & k;
        while(subset){      // 部分集合列挙
            int hoge = a[subset];
            if(hoge > firstmax)     swap(hoge, firstmax);
            if(hoge > secondmax)    swap(hoge, secondmax);
            subset = (subset - 1) & k;
        }
        chmax(res, firstmax + secondmax);
        cout << res << "\n";
    }
}

Measured memory_bytes: 4096
d = {
        0: [0, 1],
        1: [0, 1, 2],
        2: [1, 2, 3],
        3: [2, 3, 4],
        4: [3, 4, 5],
        5: [4, 5, 6],
        6: [5, 6, 7],
        7: [6, 7, 8],
        8: [7, 8, 9],
        9: [8, 9]
    }

def next_list(m):
    tail = int(str(m)[-1])
    return d[tail]

def lunlun(k):
    if k < 10:
        return k

    ans = [-1, [1,2,3,4,5,6,7,8,9]]
    cnt = 9
    for i in range(2,11):
        ans.append([])
        for pre in ans[i-1]:
            for n in next_list(pre):
                next = int( str(pre)+str(n) )
                ans[i].append(next)
                cnt += 1
                if cnt == K:
                    return next

K = int(input())
print(lunlun(K))


Measured memory_bytes: 7024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int a,b,c; cin>>a>>b>>c;
    if(a==b) cout<<c<<endl;
    else if(a==c) cout<<b<<endl;
    else cout<<a<<endl;
}

Measured memory_bytes: 3544
#include<stdio.h>
int main(void)
{
    int N,a[101]={0},b[101]={0},i,f=0;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        if(a[i]==b[i]){
            f++;
            if(f==3) {
                printf("Yes");
                return 0;
            }
        }
        else f=0;
    }
    printf("No");

    return 0;
}

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

vector<int> bfs(ll X, ll Y, ll N, int s){
    vector<int> ans(N, 1e9);
    queue<pair<int, int>> que;
    que.push({s, 0});
    while(!que.empty()){
        auto a = que.front();
        que.pop();
        if(a.second > ans[a.first])continue;
        ans[a.first] = min(ans[a.first], a.second);
        if(a.first != N-1){
            if(ans[a.first + 1] == 1e9){
                que.push({a.first + 1, a.second + 1});
            }
        }
        if(a.first != 0){
            if(ans[a.first - 1] == 1e9){
                que.push({a.first - 1, a.second + 1});
            }
        }
        if(a.first == X && ans[Y] == 1e9){
            que.push({Y, a.second + 1});
        }
        if(a.first == Y && ans[X] == 1e9){
            que.push({X, a.second + 1});
        }
    }
    return ans;
}

void solve(long long N, long long X, long long Y){
    X--, Y--;
    vector<set<pair<int, int>>> uku(N);
    for(int i = 0;i < N;i++){
        vector<int> d = bfs(X, Y, N, i);
        for(int j = 0;j < N;j++){
            uku[d[j]].insert({min(i, j), max(i, j)});
        }
    }
    for(int i = 1;i < N;i++){
        cout<<uku[i].size()<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, X, Y);
    return 0;
}


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

int main() {
  string s;
  while(cin>>s) {
    int joi=0,ioi=0;
    for(int i=0; i<s.length()-2; ++i) {
      if(s[i]=='J' && s[i+1]=='O' && s[i+2]=='I') joi++;
      if(s[i]=='I' && s[i+1]=='O' && s[i+2]=='I') ioi++;
    }
    cout<<joi<<endl;
    cout<<ioi<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> l(n);
	rep(i, 0, n - 1)cin >> l[i];
	sort(all(l), greater<int>());
	int sum = 0;
	rep(i, 1, n - 1)sum += l[i];
	if (l[0] < sum)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    int L = S.length();
    vector<int> count(2019, 0);
    long long ans = 0;
    for (int i = 0; i < L; ++i) {
        vector<int> next(2019, 0);
        ++next[S[i] - '0'];
        for (int j = 0; j < 2019; ++j) {
            int m = (j * 10 + (S[i] - '0')) % 2019;
            next[m] += count[j];
        }
        count.swap(next);
        ans += count[0];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3700
#include<cstdio>
#include<iostream>
using namespace std;
int N,ans=0;
int main(){
	scanf("%d",&N);
	for(int a=1;a<=N;a++)
		for(int b=1;b<=N;b++)
			for(int c=1;c<=N;c++)
				ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXK = 100 * 1000 + 10;
bool estOk[MAXK];
int main()
{
	int N , K;
	cin >> N >> K;
	int tab[N];
	for (int i = 0 ; i < N ; i++)
	{
		cin>>tab[i];
	}
	for (int i = 1 ; i <= K ; i++)
	{
		for (int j = 0 ; j < N ; j++)
		{
			if (i - tab[j] >= 0 && !estOk[i - tab[j]])
			{
				estOk[i] = true;
			}
		}
	}
	if (estOk[K]) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

Measured memory_bytes: 384
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int n;
    cin >> n;
    bool res = false;
    while (n > 0) {
        if (n % 10 == 9) {
            res = true;
            break;
        }
        n /= 10;
    }

    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

Measured memory_bytes: 3572
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while (true) {
            int H = sc.nextInt(),W= sc.nextInt();
            if (H==0 && W==0) {
                break;
            }
            for(int h=0;h<H;h++){
                for(int w=0;w<W;w++){
                    pr("#");
                }
                ln();
            }
            ln();
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


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

int n,m,l;
vector<vector<int> > A;
vector<vector<int> > B;
vector<vector<long> > C;

int main(){
    cin>>n>>m>>l;
    A.resize(n);
    for(int i=0;i<n;++i){
        A[i].resize(m);
        for(int j=0;j<m;++j){
            cin>>A[i][j];
        }
    }
    B.resize(m);
    for(int i=0;i<m;++i){
        B[i].resize(l);
        for(int j=0;j<l;++j){
            cin>>B[i][j];
        }
    }
    C.resize(n);
    for(int i=0;i<n;++i){
        C[i].resize(l);
        for(int j=0;j<l;++j){
                C[i][j]= 0;
            for(int k=0;k<m;++k){
                C[i][j]+= A[i][k]*B[k][j];
            }
            if(j!=0)cout<<" ";
            cout<<C[i][j];
        }
        cout<<endl;
    }

    return 0;
}



Measured memory_bytes: 3212
#include <iostream>

int main()
{
  int a, b, r;
  std::cin >> a >> b;
  r = (a % 2 + b % 2) % 2;
  
  if (r == 0) std::cout << (a+b)/2;
  else std::cout << "IMPOSSIBLE";
  
  return 0;
}
    
  

Measured memory_bytes: 256