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

const int maxn = 3000 + 5;
char s[maxn], t[maxn];
int dp[maxn][maxn];

int main() {
    scanf("%s%s", s + 1, t + 1);
    int n = strlen(s + 1), m = strlen(t + 1);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s[i] == t[j]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    }
    stack<char> st;
    int x = n, y = m;
    while (x && y) {
        if (dp[x][y] == dp[x - 1][y - 1] + 1 && s[x] == t[y]) st.push(s[x]), --x, --y;
        else if (dp[x - 1][y] > dp[x][y - 1]) --x;
        else --y;
    }
    while (st.size()) putchar(st.top()), st.pop();
    puts("");
    return 0;
}


Measured memory_bytes: 35456
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())


def main():
    if m1 == 12:
        if m2 == 1 and d2 == 1:
            return True
        else:
            return False
    else:
        if (m1 + 1) == m2 and d2 == 1:
            return True
        else:
            return False


if __name__ == "__main__":
    if main():
        print('1')
    else:
        print('0')

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

using namespace std;

int main(){
	int N, M, K, A, kind = 0;
	int count[30] = {0};
	bool flg;
	cin >> N >> M;
	for(int i = 0; i < N; i++){
		cin >> K;
		for(int j = 0; j < K; j++){
			cin >> A;
			count[A - 1]++;
		}
	}
	for(int i = 0; i < M; i++){
		if(count[i] == N) kind++;
	}
	cout << kind;
	return 0;
}

Measured memory_bytes: 256
def main():
    num = sorted(map(int, input().split()))

    cnt = 0
    a = num[2] - num[1]
    cnt += a
    num[0] += a

    if (num[2] - num[0]) % 2 == 0:
        cnt += (num[2] - num[0]) // 2
    else:
        cnt += (num[2] - num[0]) // 2 + 2

    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9016
n,m,l = [int(s) for s in input().split(' ')]
A,B,C = [],[],[]
[A.append([int(s) for s in input().split(' ')]) for i in range(n)]
[B.append([int(s) for s in input().split(' ')]) for i in range(m)]

BT = [[row[i] for row in B] for i in range(l)]
for i in range(n):
	Ci = []
	for j in range(l):
		cij = sum([a*b for a,b in zip(A[i],BT[j])])
		Ci.append(cij)
	C.append(Ci)

C_s = [' '.join([str(i) for i in Ci]) for Ci in C]
[print(row) for row in C_s]

Measured memory_bytes: 9036
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if (n == 1){
        if (a == b) cout << 1 << endl;
        else cout << 0 << endl;
    }else if (a > b){
        cout << 0 << endl;
    }else{
        cout << a + (n-1) * b - (n-1) * a - b + 1 << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while(cin >> n,n){
    int ans=0;
    for(int k=1;k<=500;k++){
      for(int m=2;m<=50;m++){
        if(m*(2*k+m-1)/2 == n) ans++;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3012
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()

    return pow(n/3, 3)


print(main())





Measured memory_bytes: 6228
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const long long INF = 1LL<<61;
long long N, K;
vector<long long> A;

long long solve() {
    sort(A.begin(), A.end());
    long long left = -INF, right = INF;
    while (right - left > 1) {
        long long x = (left + right) / 2;
        long long S = 0, T = 0;
        for (int i = 0; i < N; ++i) {
            if (A[i] > 0) {
                int l2 = -1, r2 = N;
                while (r2 - l2 > 1) {
                    int m = (l2 + r2) / 2;
                    if (A[i] * A[m] <= x) l2 = m;
                    else r2 = m;
                }
                S += r2;
            }
            else if (A[i] < 0) {
                int l2 = -1, r2 = N;
                while (r2 - l2 > 1) {
                    int m = (l2 + r2) / 2;
                    if (A[i] * A[m] <= x) r2 = m;
                    else l2 = m;
                }
                S += N - r2;
            }
            else if (x >= 0) S += N;
            if (A[i] * A[i] <= x) ++T;
        }
        long long num = (S - T) / 2;
        if (num >= K) right = x;
        else left = x;
    }
    return right;
}

int main() {
    cin >> N >> K;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 1792
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

def judge(li):
    score = 0
    cnt = 0
    for i in range(len(li)):
        if li[i] == False:
            continue
        score += pc[i][1]
        score += pc[i][0]*(i+1)*(100)
        cnt += pc[i][0]
    return [cnt,score]
    
        
D,G = map(int,input().split())
pc = []
for i in range(D):
    p,c = map(int,input().split())
    pc.append([p,c])
ans = 100000000000000
for i in range(2**D):
    li = [False]*(D)
    for j in range(D):
        if (i>>j)&1:
            li[D-j-1] = True
    a = judge(li)
    j = D-1
    if a[1]<G:
        need = G-a[1]
        while True:
            if a[1]>=G:
                break
            if j == -1:
                break
            if li[j] == True:
                j-=1
                continue
            for k in range(pc[j][0]-1):
                a[1] += (j+1)*(100)
                a[0] += 1
                if a[1]>=G:
                    break
            j-=1
    if a[1]>=G:
        ans = min(ans,a[0])
print(ans)
    

Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int N,M,R;
    cin>>N>>M>>R;
    int r[R];
    rep(i,R){
        cin>>r[i];
        r[i]--;
    }
    ll G[210][210];
    rep(i,210){rep(j,210){
        if(i==j)    G[i][j]=0;
        else        G[i][j]=LINF;}}
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;a--;b--;
        G[a][b]=c;G[b][a]=c;
    }
    rep(k,N){rep(i,N){rep(j,N){
        G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
    }}}

    sort(r,r+R);
    //r0~rR-1までの街を一度ずつ訪れる最小を求める
    ll ans=LINF;
    do{
        ll tmp=0;
        for(int i=1;i<R;i++){
            tmp+=G[r[i-1]][r[i]];
        }
        ans=min(ans,tmp);
    }while(next_permutation(r,r+R));
    //next_permutationは辞書順に並べていくからこれをやる前にsort必須
    cout<<ans<<endl;
    return 0;
}


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

c = 0
for i in range(1, N-1):
    if P[i-1] < P[i] and P[i] < P[i+1]:
        c += 1
    if P[i-1] > P[i] and P[i] > P[i+1]:
        c += 1
print(c)


Measured memory_bytes: 38384
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b) { 
   if (b == 0) 
      return a; 
   return gcd(b, a % b);  
} 


void solve(){
    int n;
    cin >> n;

    map<string,int> cnt;

    for(int i = 0;i<n;i++){
        string s;
        cin >> s;
        vector<char>st;

        for(int j = 0;j<10;j++){
            st.push_back(s[j]);
        }
        sort(st.begin(),st.end());
        string t = "";
        for(auto j:st){
            t+=j;
        }
        cnt[t]++;

    }
    int ans =0;

    for(auto i:cnt){
        int t = i.second;
        //cout << i.first << " " << i.second << endl;
        ans+=t*(t-1)/2;
    }
    cout << ans << endl;
}

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 12800
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

ll N, A[3][3], B[3][3]={0}, ans=0;

signed main(){
    for(int i=0;i<3;i++) {
        for(int j=0;j<3;j++) cin >> A[i][j];
    }
    cin >> N;
    for(int i=0;i<N;i++) {
        int s;
        cin >> s;
        for(int i=0;i<3;i++) {
            for(int j=0;j<3;j++) {
                if(s==A[i][j]) B[i][j] = 1;
            }
        }
    }
    for(int i=0;i<3;i++) {
        int flag=0;
        for(int j=0;j<3;j++) {
            if(B[i][j]!=1) flag=1;
        }
        if(!flag) ans++;
    }
    for(int i=0;i<3;i++) {
        int flag=0;
        for(int j=0;j<3;j++) {
            if(B[j][i]!=1) flag=1;
        }
        if(!flag) ans++;
    }
    int flag=0;
    for(int i=0;i<3;i++) {
        if(B[i][i]!=1) flag=1;
    }
    if(!flag) ans++;
    
    flag=0;
    for(int i=0;i<3;i++) {
        if(B[2-i][i]!=1) flag=1;
    }
    if(!flag) ans++;
    if(ans>0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    int N = S.size();
    for (int i = 0; i < N; i++) {
        if (i == A && S.at(i) != '-') {
            cout << "No" << endl;
            return 0;
        }
        if (i != A && S.at(i) == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll sum;
int main()
{
 cin>>n;
 for(int a=1;a<=n;a++)
    for(int b=1;b<=n;b++)
     for(int c=1;c<=n;c++)
 {
 	 int x=a,y=b,z=c,r;
 	 r=x%y;
 	 while(r)
 	 {
 	 	x=y,y=r,r=x%y;
	  }
	  x=y,y=z;
	   r=x%y;
 	 while(r)
 	 {
 	 	x=y,y=r,r=x%y;
	  }
	  sum+=y;
	// sum+=__gcd(a,__gcd(b,c));
 }
 cout<<sum;
return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(){
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int ans = 0;
    int tmp = 0 ;
    reverse(v.begin(), v.end());
    for(int i=1; i<n; i++){
        if(v[i-1] <= v[i]) tmp++;
        else tmp=0;
        ans = max(ans, tmp);
    }
    cout << ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 100010;
int f[N];
set<int> s;
int son[N][2],root,tot;
char S[N];
ll L;
ll ans = 0;
void tra(int x,int len){
	//cout<<x<<' '<<len<<endl;
	for(int i =0;i<2;i++){
		if(son[x][i]!=0) tra(son[x][i],len+1);
		else{
			ll t = L-len;
			if(t==0) continue;
			ll tmp = 1;
			while(t%2==0){
				//cout<<t<<endl;
				t/=2;
				tmp<<=1;
			}
			ans^=tmp;
		}
	}
}
int main(){
	f[0]  =0;
	f[1] =1;
	for(int i =2;i<=100;i++){
		s.clear();
		for(int j = 1;j<=i;j++){
			int tmp = 0;
			s.insert(0);
			for(int k = j;k<=i-1;k++) tmp^=f[k];
			s.insert(tmp);
		}
		for(int j = 0;1;j++) if(!s.count(j)){
			f[i] = j;
			break;
		}
	}	
	//for(int i=1;i<=20;i++) cout<<i<<' '<<f[i]<<endl;
	int n;
	scanf("%d%lld",&n,&L);
	//cout<<"YYY"<<endl;
	tot = root =1;
	for(int i =0;i<n;i++){
		scanf("%s",S);
		int len =strlen(S);
		int now =1;
		for(int j = 0;j<len;j++){
			if(son[now][S[j]-'0']==0) son[now][S[j]-'0'] = ++tot;
			now =son[now][S[j]-'0'];
		}
	}
	//cout<<"YYY"<<endl;
	tra(1,0);
	if(ans) puts("Alice");
	else puts("Bob");
	return 0;
}

Measured memory_bytes: 5760
n=int(input())
lists=[]
for i  in range(n):
    x,y=map(int,input().split())
    lists.append((x-y,x+y))
lists=sorted(lists,key=lambda x:(x[1]))
A=1
P=lists[0]
for i in range(1,len(lists)):
    if lists[i][0]>=P[1]:
        A+=1
        P=lists[i]
print(A)

Measured memory_bytes: 57816
N = int(input())
L = []
for i in input().split():
	L.append(int(i))

L.sort()
L.reverse()

subsum = 0
for i, l in enumerate(L):
	if i == 0:
		l_max = l
	else:
		subsum += l

if l_max < subsum:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	
	int n;
	cin >> n;
	int x, y;
	cin >> x >> y;
	cout << y <<' '<< n <<' '<< x;
}

Measured memory_bytes: 256
N = int(input())
W = [input() for _ in range(N)]
flag = True
x = W[0][-1]
for i in range(1, N):
    if x != W[i][0]:
        flag = False
        break
    x = W[i][-1]

if len(set(W)) != N:
    print("No")
elif flag == False:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long i64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 5e1+5, P = 1e9+7;
int n, f[N][N]; i64 C[N][N];
int main()
{
    n = read(); 
    for(int i = 0; i <= n; ++i)
    {
        C[i][0] = 1;
        for(int j = 1; j <= i; ++j)
            C[i][j] = (C[i-1][j-1]+C[i-1][j])%P;
    }
    f[1][0] = f[1][1] = n;
    for(int i = 1; i < n; ++i)
        for(int j = 0; j <= i; ++j)
            for(int k = max(j, 1); k <= n-i; ++k)
            {
                if((k-j)&1) continue; int y = (k-j)/2;
                for(int x = 0; x <= k; ++x) (f[i+k][abs(x-y)] += C[n-i][k]*C[k][x]%P*f[i][j]%P) %= P;
            }
    printf("%d\n", f[n][0]);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  if (s.size() >= 2 && s.size() % 2 == 0) {
    bool b = true;
    rep(i, s.size()) {
      b = b && ((i % 2 == 0 && s[i] == 'h') || (i % 2 == 1 && s[i] == 'i'));
    }
    cout << (b ? "Yes" : "No") << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3028
n,m,x = gets.split.map &:to_i

cs = []
as = []

n.times {
	c, *at = gets.split.map &:to_i
	cs << c
	as << at
}

flag = false
min = Float::INFINITY

[0,1].repeated_permutation(n).each{ |ar|
	cost = 0
	exp = Array.new(m, 0)
	ar.each_with_index{ |i, ind|
		if i == 1 then
			cost += cs[ind]
			as[ind].each_with_index{ |x, ind2|
				exp[ind2] += x
			}
		end
	}
	
	if exp.all?{ |xx| xx >= x } then
		flag = true
		
		if min > cost then
			min = cost
		end
	end
}

if flag then
	puts min
else
	puts -1
end

Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
bool isprime(int k)
{
    if(k==2||k==3) return true;
    for(int i=2;i<=sqrt(k);i++)
        if(k%i==0) return false;
    return true;
}
int main()
{
    int n,cnt=0,t;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&t);
        if(isprime(t)) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3212
n=gets.to_i
h=gets.split.map &:to_i
dp=Array.new(n,0)
dp[1]=(h[1]-h[0]).abs
2.upto(n-1) do |i|
  dp[i]=[dp[i-1]+(h[i]-h[i-1]).abs,dp[i-2]+(h[i]-h[i-2]).abs].min
end
puts dp.last

Measured memory_bytes: 13444
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

struct Point {
  int x;
  int y;
};

int Dist(Point a, Point b) { return abs(a.x - b.x) + abs(a.y - b.y); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N, M;
  cin >> N >> M;

  vector<Point> students(N);
  vector<Point> check(M);

  for (int i = 0; i < N; ++i) cin >> students[i].x >> students[i].y;
  for (int i = 0; i < M; ++i) cin >> check[i].x >> check[i].y;

  for (int i = 0; i < N; ++i) {
    int nearest_id = 0;
    int min_d = INT_MAX;
    for (int j = 0; j < M; ++j) {
      const int d = Dist(students[i], check[j]);
      if (d < min_d) {
        min_d = d;
        nearest_id = j;
      }
    }
    cout << nearest_id + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    s = input()
    t = input()

    listS = []
    for i in range(len(s)):
        listS.append(s[i])

    listT = []
    for i in range(len(t)):
        listT.append(t[i])

    listS = sorted(listS)
    listT = sorted(listT, reverse=True)

    sortedS = ''
    for i in range(len(listS)):
        sortedS += listS[i]
    sortedT = ''
    for i in range(len(listT)):
        sortedT += listT[i]

    if sortedS < sortedT:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


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

int main(){
    int n, seq = 1;
    while(cin >> n, n){
        int x[n], y[n];
        double area = 0;
        for(int i = 0; i < n; i++)  cin >> x[i] >> y[i];

        for(int i = 0; i < n; i++){
            area += (y[(i+1)%n]*x[i])-(x[(i+1)%n]*y[i]);
        }

        cout << seq++ << " " << fixed << setprecision(1) << -area/2.0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3224
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
a = factorization(n)
ans = 0
if n == 1:
    ans = -1
for i in a:
    ans += 1
    k = 2
    l = i[1] - 1
    while l >= k:
        ans += 1
        l -= k
        k += 1
print(ans)

Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  vl v(2, 0);
  rep(i, s.size()) v[s[i] - '0']++;
  cout << min(v[0], v[1]) * 2 << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 150
#define NIL -1

int graph[MAX][MAX];
int a[MAX];
int n;
int Que[10000];
int head=0, tail=0;

void enQue(int q);
int deQue(void);
int size(void);
void bfs(int i);

int main()
{
  int b;
  int k;
  int i,j;
  int c;

  scanf("%d",&n);
  for(i=0;i<MAX;i++)
  { 
      a[i]=NIL;
  }
  for(i=0;i<n;i++)
  {
    scanf("%d",&b);
    scanf("%d",&k);
    for(j=0;j<k;j++)
    {
      scanf("%d",&c);
      graph[b-1][c-1]=1;
    } 
  }
  a[0]=0;
  bfs(0);
  while(size()!=0)
  {
    bfs(deQue());
  }
  for(i=0;i<n;i++)
  {
    printf("%d %d\n",i+1,a[i]);
  }
return 0;
}

void enQue(int q)
{
  Que[head]=q;
  head++;
}

int deQue(void)
{
  tail++;
  return Que[tail-1];
}

int size(void)
{
  return head-tail;
}


void bfs(int i)
{
  int j;
  for(j=0; j<n; j++)
  {
    if(graph[i][j]==1 && a[j]==NIL)
    {
      a[j]=a[i]+1;
      enQue(j);
    }
  }
}



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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 a, b; cin >> a >> b;
        cout << (a < b ? "a < b" : (a > b ? "a > b" : "a == b")) << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>

int main()
{
    int a,b,c,d,Ans=0;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if(a<b) Ans+=a;
    if(a>=b) Ans+=b;
    if(c<d) Ans+=c;
    if(c>=d) Ans+=d;

    printf("%d",Ans);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
    int n,a,b;
    int[] can;

    void solve(){
	Scanner sc = new Scanner(System.in);
	while(true){
	    n = sc.nextInt();
	    a = sc.nextInt();
	    b = sc.nextInt();
	    if(n==0 && a==0 && b==0) break;

	    can = new int[n+1];
	    can[0] = 1;
	    for(int i=0; i<=n; i++){
		if(can[i]==0)continue;
		if(i+a<=n)can[i+a] = 1;
		if(i+b<=n)can[i+b] = 1;
	    }

	    int unableCount = 0;
	    for(int i=1; i<=n; i++){
		if(can[i]==0)unableCount++;
	    }

	    System.out.println(unableCount);
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 16000
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    L = S()
    dp = [[0 for _ in range(2)] for ___ in range(len(L) + 1)]
    dp[0][0] = 1

    for i in range(len(L)):
        # place 0
        dp[i+1][1] += dp[i][1] * 2
        if int(L[i]) == 1:
            dp[i+1][0] += 2 * dp[i][0]
            dp[i+1][1] += dp[i][0]

        dp[i+1][0] %= mod
        dp[i+1][1] %= mod

        # place 1
        dp[i+1][1] += dp[i][1]
        if int(L[i]) == 0:
            dp[i+1][0] += dp[i][0]

        dp[i+1][0] %= mod
        dp[i+1][1] %= mod

    ans = dp[len(L)][0] + dp[len(L)][1]
    ans %= mod
    print(ans)
main()


Measured memory_bytes: 92348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
set<T> divisor(const T n) {
  set<T> st;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      st.insert(i);
      st.insert(n / i);
    }
  }

  return st;
}

int main() {
  ll N;
  cin >> N;

  set<ll> ans;

  for (auto num : divisor(N-1)) {
    if (num == 1) continue;
    ans.insert(num);
  }

  for (auto num : divisor(N)) {
    if (num == 1) continue;
    ll cpy = N;
    while (cpy > 0) {
      cpy /= num;
      auto m = cpy % num;
      if (m > 0) {
        if (m == 1) ans.insert(num);
        break;
      }
    }
  }

  cout << ans.size() << endl;
}

Measured memory_bytes: 3864
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  string s;
  getline(cin,s);
  
  int q;
  //string muda;
  //getline(cin, muda);
  scanf ("%d \n", &q);
  //q = 
  int jun = 1;

  string mae = "";

  for(int i=0; i<q ; i++){
    string fc;
    getline(cin, fc);//scanf("%d", &t);
    int t=fc[0]-'0';
    if(t==1){
      jun *= -1;
    }else{
  
      int f;
      char c;
      f = fc[2]-'0';
      c = fc[4];
      
      int jun2 = 1;
      if(f==1){
        jun2 = 1;
      }else{
        jun2 = -1;
      }

      if(jun * jun2 == 1){
        mae = mae + c;
      }else{
        s = s + c;        /* code */
      }
    }
  }

  //cout << jun << endl;
  if(jun == 1){
    for (int i = mae.size()-1; i>=0; i-- ){
      cout << mae[i];
    }
    for (int i = 0; i<s.size(); i++){
      cout << s[i];
    }
  }else{
    for (int i=s.size()-1; i>=0;i-- ){
      cout << s[i];
    }
    for (int i=0; i<mae.size(); i++){
      cout << mae[i];
    }
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 1532
#include <iostream>

const int inf = 0x3f3f3f3f;

using namespace std;

int N;
string s;
string s_original;
string crt_s;
int answer;

int main()
{
	cin >> s;
	s_original = s;
	N = s.length();
	crt_s = "";

	answer = inf;

	bool ok = true;
	for (int i = 1; i < N; ++i)
	{
		if (s[i] != s[i-1])
		{
			ok = false;
		}
	}
	if (ok)
	{
		cout << "0\n";
		return 0;
	}

	for (char last = 'a'; last <= 'z'; ++last)
	{
		s = s_original;
		//cout << "last: " << last << '\n';
		for (int len = N-1; len >= 1; --len)
		{
			crt_s = "";
			bool ok = true; 
			for (int i = 0; i < len; ++i)
			{
				if (s.at(i) == last)
				{
					crt_s += s[i];
					continue;
				}
				if (s.at(i + 1) == last)
				{
					crt_s += s[i+1];
					continue;
				}
				ok = false;
				crt_s += s[i];
			}
			//cout << crt_s << '\n';
			if (ok)
			{
				//cout << N - len << '\n';
				answer = min(answer, N - len);
				break;
			}
			s = crt_s;
		}
	}

	cout << answer << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int K,S;

int main(void){
    cin >> K >> S;
    int ans = 0;
    REP(x, K + 1) {
        int s = S - x;
        REP(y, K + 1) {
            if (s - y > K || s - y < 0) continue;
            //cout << x << " " << y << " " << s-y << endl;
            ans++;
        }
    }
    cout << ans;
}


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

using ll= long long;
const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    ll res=1;
    for(auto &x: A){
        cin >> x;
        if(x == 0) res=0;
    }
    for(int i=0; i<N; i++){
        if(res != 0 && A[i] > numeric_limits<ll>::max()/res){
            res=-1;
            break;
        }
        res*=A[i];
        if(res > (ll)1e18){
            res=-1;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff(i,n) for(i=0;i<n;i++)
#define pb push_back
ll bg =  99824435988983;
ll power(ll x,ll y)
{
    if(y==0)
	    return 1;
	ll d = power(x,y/2);
	ll f = (d*d);
	if(y%2==0)
	  return f;
	else
	  return (f*x);	 	
}
ll is(ll n, ll k) 
{ 
    if (n & (1 << (k))) 
        return 1; 
    else
        return 0; 
} 
int main()
{
	
	ll j,k,i,n,m,x;
	cin>>n>>m>>x;
	ll ss = power(2,n)-1;
	ll c[n],dp[n][m];
	ff(i,n)
	{
		cin>>c[i];
		ff(j,m)
		  cin>>dp[i][j];
	}
	ll flag=-1,am=bg;
	for(i=0;i<=ss;i++)
	{
	    ll cost = 0,tot[m]={0};
		for(j=0;j<n;j++)
		{
			if(is(i,j)==1)
			{
				cost+=c[j];
				ff(k,m)
				  tot[k]+=dp[j][k];
			}
		}
		ll check=1;
		for(j=0;j<m;j++)
		  if(tot[j]<x)
		    check=0;
		if(check==1)
		{
			flag=1;
			am = min(am,cost);	
		}		   
	}    
	if(flag==1)
	   cout<<am;
	else
	   cout<<flag;   
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s1, s2;
        if(!(cin >> s1 >> s2))
            return 0;

        int n = s1.size();
        int m = s2.size();

        int ret = 0;
        vector<vector<int> > len(n, vector<int>(m, 0));
        for(int i=0; i<n; ++i){
            for(int j=0; j<m; ++j){
                if(s1[i] == s2[j]){
                    if(i > 0 && j > 0)
                        len[i][j] = len[i-1][j-1] + 1;
                    else
                        len[i][j] = 1;
                    ret = max(ret, len[i][j]);
                }
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
import sys

input = sys.stdin.readline


def main():
    next_day = {
        "SAT": 1,
        "FRI": 2,
        "THU": 3,
        "WED": 4,
        "TUE": 5,
        "MON": 6,
        "SUN": 7,
    }

    S = input().rstrip()
    ans = next_day[S]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9064
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

struct UnionFInd{
    int size;
    vector<int> par, relate, rank;
    UnionFInd(int x){
        size = x;
        relate = vector<int> (x, 0);
        rank = vector<int> (x);
        par = vector<int> (x);
        rip(i,x,0) par[i] = i;
    }
    int root(int x){
        if(par[x] == x) return x;
        int ret = root(par[x]);
        relate[x] += relate[par[x]];
        return par[x] = ret;
    }
    void unite(int x, int y, int z){
        int X = root(x), Y = root(y);
        z -= relate[x] - relate[y];
        if(X == Y) return;
        if(rank[X] < rank[Y]){
            relate[X] = z;
            par[X] = Y;
        }
        else{
            relate[Y] = -z;
            par[Y] = X;
        }
        if(X == Y) rank[Y]++;
        return;
    }
    int diff(int x, int y){
        return relate[x] - relate[y];
    }
    bool check(int x, int y){
        return root(x) == root(y);
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    UnionFInd uf(n+1);
    rip(i,q,0){
        int c; cin >> c;
        if(c){
            int x, y; cin >> x >> y;
            if(uf.check(x,y))printf("%d\n", uf.diff(x,y));
            else printf("?\n");
        }
        else{
            int x, y, z; cin >> x >> y >> z;
            uf.unite(x, y, z);
        }
    }
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << "\n";
        return 0;
    }
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";

    return 0;
}

Measured memory_bytes: 256
import sys
import bisect
import numpy as np

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()
B = MAP()
C = MAP()

A.sort()
B.sort()
C.sort()

cand_a = [0] * N
for i,a in enumerate(A):
	cand_a[i] = N - bisect.bisect_right(B, a)
#print(cand_a)

cand_b = [0] * N
for i,b in enumerate(B):
	cand_b[i] = N - bisect.bisect_right(C, b)
	
cand_b = list(np.cumsum(list(reversed(cand_b))))
#print(cand_b)

ans = 0
for a in cand_a:
	if a: ans += cand_b[a-1]

print(ans)

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b;

signed main() {
	cin >> a >> b;
	int d = b-a;
	cout << d*(d+1)/2 - b << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 500;
int n, ans[N][N];
void f(int l, int r, int c){
  if(r-l < 2) return;
  int m = (l+r)/2;
  FOR(i, l, m)FOR(j, m, r) ans[i][j] = c;
  f(l, m, c+1);
  f(m, r, c+1);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  f(0, n, 1);
  FOR(i, 0, n){
    FOR(j, i+1, n) cout << ans[i][j] << " ";
    cout << endl;
  }
}

Measured memory_bytes: 1536
// ２つの整数 a, b を読み込んで、a と b の大小関係を出力するプログラムを作成して下さい。
// 【入力】
// 入力は空白で区切られた２つの整数 a, b から構成されています。
// 【出力】
// a より b の方が大きければ
//   a < b
// a より b の方が小さければ、
//   a > b
// a と b が等しければ、
//   a == b
// と出力して下さい。
// 【制約】
// -1,000 ≤ a, b ≤ 1,000
// 【例】
// 入力：1 2、出力：a < b
// 入力：4 3、出力：a > b
// 入力：5 5、出力：a == b
#include<stdio.h>

int main( void) {
  int a, b;

  scanf( "%d %d", &a, &b);

  if ( a < b) printf( "a < b\n");
  else if ( a > b) printf( "a > b\n");
  else printf( "a == b\n");

  return 0;
}



Measured memory_bytes: 2048
import java.util.*;
 
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int[] a = new int[N];
      for(int i = 0; i < N; i++){
        a[i] = sc.nextInt();
      }
      
      int n = 0;
      for(int j = 1; j <= N; j++){
        if(j % 2 == 1 && a[j-1] % 2 == 1){
          n++;
        }
      }
      System.out.println(n);
    }
}

Measured memory_bytes: 35784
N,H = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.sort(reverse=True)
B.sort(reverse=True)
ans = 0

for b in B:
    if b>A[0] and H>0:
        H -= b
        ans += 1

if H > 0:
    ans += -(-H//A[0])

print(ans)

Measured memory_bytes: 61656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
#include <atcoder/all>
using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

template <class T>
map<T, int> prime_factor(T n) {
    map<T, int> ret;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n; n *= 2;
    ll ans = n;
    vector<ll> r0{0, 1}, r1{1, 0}, m(2);
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        m[0] = p; m[1] = n / p;
        if (ll res = crt(r0, m).first; res != 0) chmin(ans, res);
        if (ll res = crt(r1, m).first; res != 0) chmin(ans, res);
    }
    cout << ans - 1 << "\n";

    /***************************************************/
    /* Submit this code from the browser if using ACL! */
    /***************************************************/
    return 0;
}

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

int main() {
  int n, m;
  map<string, int> mp;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    string t;
    cin >> t;
    mp[t]--;
  }
  int ans = 0;
  for (auto& x : mp) {
    ans = max(ans, x.second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.lang.Math

fun main(args: Array<String>)
{
    val (n) = readInts()


    println(n*n*n)
}

fun readInts(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun readLongs(): List<Long> = readLine()!!.split(" ").map(String::toLong)

fun readIntArr(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray()
fun readLongArr(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray()

fun readIntArrS(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArray()
fun readLongArrS(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArray()

fun readIntArrSD(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArrayDescending()
fun readLongArrSD(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArrayDescending()

fun readString() = readLine()!!


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var W = int.Parse(Console.ReadLine());
            for (var i = 0; i < S.Length; i += W) Console.Write(S[i]);
        }
    }
}

Measured memory_bytes: 11092
fib = [None] * 11
fib[0], fib[1] = 1, 2
for i in range(2, 11):
    fib[i] = fib[i-1] + fib[i-2]
mod = 1000000007
H, W, K = map(int, input().split())
if W == 1:
    print(1)
    quit()
dp = [[0] * W for i in range(H+1)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if 1 < j < W-2:
            dp[i+1][j] += dp[i][j] * fib[j-1] * fib[W-j-2] % mod
            dp[i+1][j] += dp[i][j-1] * fib[j-2] * fib[W-j-2] % mod
            dp[i+1][j] += dp[i][j+1] * fib[j-1] * fib[W-j-3] % mod
        elif j == 1:
            dp[i+1][j] += dp[i][j] * fib[j-1] * fib[W-j-2] % mod
            dp[i+1][j] += dp[i][j-1] * fib[W-j-2] % mod
            dp[i+1][j] += dp[i][j+1] * fib[j-1] * fib[W-j-3] % mod
        elif j == W-2:
            dp[i+1][j] += dp[i][j] * fib[j-1] * fib[W-j-2] % mod
            dp[i+1][j] += dp[i][j-1] * fib[j-2] * fib[W-j-2] % mod
            dp[i+1][j] += dp[i][j+1] * fib[j-1] % mod
        elif j == 0:
            dp[i+1][0] = dp[i][0] * fib[W-2] + dp[i][1] * fib[W-3]
        elif j == W-1:
            dp[i+1][W-1] = dp[i][W-1] * fib[W-2] + dp[i][W-2] * fib[W-3]
        dp[i+1][j] %= mod
print(dp[H][K-1])

Measured memory_bytes: 3192