akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
static constexpr int MOD = 998244353;
static constexpr int N = 100000;

inline int add( int a, int b ) {
	return a + b >= MOD ? a + b - MOD : a + b ;
}
inline int sub( int a, int b ) {
	return a - b < 0 ? a - b + MOD : a - b;
}
inline int mul( int64_t a, int64_t b ) {
	return static_cast< int >( a * b % MOD );
}
inline int qPow( int a, int64_t k ) {
	int ret = 1;
	while ( k ) {
		if ( k & 1 ) ret = mul( ret, a );
		k >>= 1; a = mul( a, a );
	}
	return ret;
}

int jie[ N ], inv_jie[ N ], inv[ N ];

void init() {
	jie[ 0 ] = 1;
	for ( int i = 1 ; i < N ; ++ i )
		jie[ i ] = mul( jie[ i - 1 ], i );
	inv_jie[ N - 1 ] = qPow( jie[ N - 1 ], MOD - 2 );
	for ( int i = N - 1 ; i >= 1 ; -- i )
		inv_jie[ i - 1 ] = mul( inv_jie[ i ], i );
	for ( int i = 1 ; i < N ; ++ i )
		inv[ i ] = mul( inv_jie[ i ], jie[ i - 1 ] );
}

inline int comb( int n, int k ) {
	if ( n < k ) return 0;
	return mul( jie[ n ], mul( inv_jie[ k ], inv_jie[ n - k ] ) );
}

int solve( int n, int k, int m ) {
	/* ------ m為奇數ver ------ */
	if ( m % 2 == 0 ) return 0;
	int ret = 0;
	for ( int t = 0 ; t + t <= m ; ++ t ) {
		int w = comb( n - 2 * t + k - 1, k - 1 );
		int coe = comb( m / 2, t );
		if ( t & 1 )
			ret = sub( ret, mul( coe, w ) );
		else
			ret = add( ret, mul( coe, w ) );
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio( false );
	cin.tie( nullptr );
	init(); int k, n; cin >> k >> n;
	if ( k == 1 ) {
		cout << "0\n";
		return 0;
	}
	for ( int i = 2 ; i <= k ; ++ i )
		cout << solve( n, k, i + !( i % 2 ) ) << '\n';
	if( k & 1 ) cout << add( solve( n, k - 1, k ), solve( n - 1, k - 1, k ) ) << '\n';
	else cout << solve( n, k, k + 1 ) << '\n';
	for ( int i = k ; i >= 2 ; -- i )
		cout << solve( n, k, i + !( i % 2 ) ) << '\n';
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1 << 30);

int main(){
    int N;
    scanf("%d", &N);
    int ans = 0;
    int id = 1;
    while (N > ans){
        ans += id;
        id ++;
    }
    for (int i = 1; i < id; i++) {
        if (i == (ans - N)) continue;
        else printf("%d\n", i);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#define endl '\n'
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int R;
    cin >> R;
    cout << fixed <<  setprecision(3) << 2*R*M_PI;

    return 0;
}



Measured memory_bytes: 3804
def solve
  a, b, c, k = gets.split.map!(&:to_i)
  max_sum = 0

  if a >= k
    max_sum += k * 1
    return max_sum
  elsif a < k
    max_sum += a * 1
    k -= a
    if b >= k
      max_sum += k * 0
      return max_sum
    elsif b < k
      max_sum += b * 0
      k -= b
    end
  end

  max_sum += k * - 1

  max_sum
end
print solve



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

//longを知らないとかいう
int main() {
    int N;
    cin >>N;
    vector<long long> A(N);

    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    //Ai、隣り合う2数の符号を反転を任意回、その最大和
    //つまり任意の2数の符号を同時に入れ替え
    //任意回操作後の負数の偶奇は一定
    long long sum=0;
    long long A_min=A.at(0);
    if(A_min<0)A_min*=-1;
    int howm=0;
    rep(i,N){
        if(A.at(i)<0){
            howm++;
            A.at(i)=-A.at(i);
        }
        sum+=A.at(i);
        if(A_min>A.at(i))A_min=A.at(i);
    }
    if(howm%2==1){
        sum-=A_min*2;
    }
    cout << sum;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define Z 11000
using namespace std;
int d[Z+1];
int main(){
	int n,m,k,r,l;
	while(true){
		cin>>n>>k>>m>>r;
		if(!(n+m+k+r))break;
		rep(i,0,Z)d[i]=0;
		k=1,l=n;
		rep(i,0,Z)d[i]+=k/l,k%=l,k*=10;
		if(m)rep(i,1,n){k=1,l=i*n;rep(j,0,Z)d[j]+=k/l,k%=l,k*=10;}
		for(int i=Z;i>0;i--)d[i-1]+=d[i]/10,d[i]%=10;
		cout<<d[0]<<".";
		rep(i,1,r+1)cout<<d[i];
		cout<<endl;
	}
	return 0;
}

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

int main(){
  int x;
  cin >> x;
  ll ansa=0, ansb=0;
  while(1){
    ll a5 = ansa * ansa * ansa * ansa * ansa;
    ll b5 = a5;
    while(a5 - b5 < x){
      --ansb;
      b5 = ansb * ansb * ansb * ansb * ansb;
    }
    if(a5-b5 == x) break;
    ++ansa;
    ansb = ansa;
  }
  cout << ansa << " " << ansb << endl;
}

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

int main(void) {
    int N;cin>>N;
    int before = 1e9 + 7;
    int swit = 0;
    int result = 1;
    for (int i = 0; i < N; i++) {
        int A;cin>>A;
        if (before < 1e9 + 7) {
            if (swit > 0 && before > A) {
                result++;
                swit = 0;
            } else if (swit < 0 && before < A) {
                result++;
                swit = 0;
            } else {
                if (before < A) swit = 1;
                else if (before > A) swit = -1;
            }
        }
        before = A;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 888
def chk(mat,exp,y,x)
  if mat[y][x]==1
    exp.push([x,y])
    mat[y][x]=0
  end
  return mat,exp
end
ds,cnt=gets.to_i,0
ds.times do
  mat,=[],gets
  8.times{mat << gets.chomp.split("").map(&:to_i)}
  exp=[[gets.to_i-1,gets.to_i-1]]
  while !exp.empty?
    e=exp.pop
    mat[e[1]][e[0]]=0
    3.times do |i|
      mat,exp=chk(mat,exp,[e[1]-3+i,0].max,e[0])
      mat,exp=chk(mat,exp,e[1],[e[0]-3+i,0].max)
      mat,exp=chk(mat,exp,[e[1]+1+i,7].min,e[0])
      mat,exp=chk(mat,exp,e[1],[e[0]+1+i,7].min)
    end
  end
  puts "Data #{cnt+=1}:"
  mat.each{|i|
    puts i.join
  }
end

Measured memory_bytes: 8796
#include<bits/stdc++.h>
#define ll long long
#define oo 0x7fffffff
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char cc=getchar();
	while ((cc>'9'||cc<'0')&&cc!='-')
		cc=getchar();
	if (cc=='-')
		{
			fh=-1;
			cc=getchar();
		}
	while (cc>='0'&&cc<='9')
		{
			out=out*10+cc-'0';
			cc=getchar();
		}
	return out*fh;
}
const int MAXN=(1<<18)+10;
int n;
int a[MAXN],mx[MAXN],r[MAXN],s[MAXN];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int lim=read();
	n=1<<lim;
	for(int i=0;i<n;++i)
		a[i]=read();
	for(int i=0;i<n;++i)
		for(int j=i;j<n;j=(j+1)|i)
			r[j]=max(r[j],a[i]+mx[j]),mx[j]=max(mx[j],a[i]);
	for(int i=1;i<n;++i)
		{
			r[i]=max(r[i],r[i-1]);
			printf("%d\n",r[i]);
		}
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  int a;
  cin >> a;
  cout << a/2 + a%2<< endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    int A[4][4],i,j,k,N,b[101],bingo[4][4],ans = 0;

    for(i = 0;i < 3;i++){
        for(j = 0;j < 3;j++){
            scanf("%d",&A[i][j]);
            bingo[i][j] = 0;
        }
    }
    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&b[i]);
    }

    for(i = 0;i < 3;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < N;k++){
                if(A[i][j] == b[k]){
                    //printf("当たり\n");
                    bingo[i][j] = 1;
                }
            }
        }
    }

    if(bingo[0][0] == 1 && bingo[0][1] == 1 && bingo[0][2] == 1) ans =  1;
    else if(bingo[1][0] == 1 && bingo[1][1] == 1 && bingo[1][2] == 1) ans =  1;
    else if(bingo[2][0] == 1 && bingo[2][1] == 1 && bingo[2][2] == 1) ans =  1;
    else if(bingo[0][0] == 1 && bingo[0][1] == 1 && bingo[0][2] == 1) ans =  1;
    else if(bingo[0][0] == 1 && bingo[1][0] == 1 && bingo[2][0] == 1) ans =  1;
    else if(bingo[0][1] == 1 && bingo[1][1] == 1 && bingo[2][1] == 1) ans =  1;
    else if(bingo[0][2] == 1 && bingo[1][2] == 1 && bingo[2][2] == 1) ans =  1;
    else if(bingo[0][0] == 1 && bingo[1][1] == 1 && bingo[2][2] == 1) ans =  1;
    else if(bingo[0][2] == 1 && bingo[1][1] == 1 && bingo[2][0] == 1) ans =  1;

    if(ans == 1) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 1;
        while(sc.hasNextInt()){
            int x = sc.nextInt();
            if (x != 0){
                System.out.println("Case "+i+": "+x);
                i++;
            } else {
                break;
            }
        }
    }
}


Measured memory_bytes: 43380
#include<iostream>
#include <algorithm>
using namespace std;
int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a +3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i <= b; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
//B - 121: 
//Assunto:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string a, b;
    int num, sq;
    double aux;
    cin >> a >> b;
    num = stoi(a+b);
    sq = sqrt(num);
    aux = sqrt(num);
    if(sq == aux) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>

#define ll long long

using namespace std;

void solve() {
    string s;
    cin >> s;
    int res = 0, cur = 0;
    for(auto &i : s) {
        if(i == 'R') {
            cur++;
        } else {
            cur = 0;
        }
        res = max(res, cur);
    }
    cout << res << endl;
}

int main() {
    
    // int T;
    // cin >> T;
    // while(T--) {
        // solve();
    // }
    solve();
    
    return 0;
};


Measured memory_bytes: 3584
import bisect
import sys
input = sys.stdin.readline
N, T = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]

"""
a_x = 1 and b_x is t_i = 2*(t_i +2) 
n 店舗回るのに 2^nはかかる
30店舗以上は回れない
"""

a0 = []
nab = []
for a, b in AB:
    if a == 0:
        a0.append(b)
    else:
        nab.append(((b + 1) / a, a, b))
a0.sort()

nab.sort()

a0sum = []  # key: n of visit, value : cost
_sum = 0
for b in a0:
    _sum += 1 + b
    a0sum.append(_sum)

INF = 1 << 32
dp = [0] + [INF] * 29
for index, (_, a, b) in enumerate(nab):
    # print(a, b)
    ndp = [0] + [INF] * 29
    for count in range(1, 29):
        ndp[count] = min(dp[count],
                         dp[count - 1] + 1 + (dp[count - 1] + 1) * a + b)
    dp = ndp

ans = 0
# print(a0sum)
# print(nab)
# print(dp)
for count, t in enumerate(dp):
    if t > T:
        continue
    v = bisect.bisect_right(a0sum, T - t)
    ans = max(ans, v + count)
print(ans)


Measured memory_bytes: 101852
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9

int main(){

    long long n; cin >> n;
    vector<long long> a(n + 2);
    a[0] = a[n + 1] = 0;
    for(int i = 1; i <= n; i++) cin >> a[i];
    long long m = 0;
    for(int i = 1; i <= n + 1; i++){
        if(a[i] - a[i - 1] > 0) m += a[i] - a[i - 1];
        else m += a[i - 1] - a[i];
    }

    for(int i = 1; i <= n; i++){
        
        if(a[i - 1] == a[i + 1] && a[i + 1] < a[i]) cout << m - 2 * (a[i] - a[i + 1]) << endl;
        else if(a[i - 1] == a[i + 1] && a[i + 1] > a[i]) cout << m - 2 * (a[i + 1] - a[i]) << endl;
        else if(a[i - 1] < a[i + 1] && a[i + 1] < a[i]) cout << m - 2 * (a[i] - a[i + 1]) << endl;
        else if(a[i] < a[i - 1] && a[i - 1] < a[i + 1]) cout << m - 2 * (a[i - 1] - a[i]) << endl;
        else if(a[i] < a[i + 1] && a[i + 1] < a[i - 1]) cout << m - 2 * (a[i + 1] - a[i]) << endl;
        else if(a[i + 1] < a[i - 1] && a[i - 1] < a[i]) cout << m - 2 * (a[i] - a[i - 1]) << endl;
        else cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
public class Main{
 static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {

            return Long.parseLong(next());
        }

        BigInteger nextBigIntger() {
            BigInteger bb = new BigInteger(next());
            return bb;
        }
    }
public static void main(String[] args){
 FastReader sc = new FastReader();
        int a =sc.nextInt();
        int b =sc.nextInt();
      int c = sc.nextInt();
if(a==b)
System.out.println(c);
else if(c==b)
System.out.println(a);
if(a==c)
System.out.println(b);

}
}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	long long N, T;
	cin>> N >> T;
	long long Time = 0;
	long long l = 0, r = 0;
	while (N--){
		long long Ti = 0;
		cin>> Ti;
		if (Ti < l && Ti + T >= l){
			l = Ti;
		} else if (Ti <= r && Ti + T > r){
			r = Ti + T;
		} else{
			Time += r - l;
			l = Ti;
			r = Ti + T;
		}
	}
	Time += r - l;
	cout<< Time <<endl;
	return 0;	
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int h, w;
  cin >> h >> w;

  string s;
  for (int i = 0; i < h; ++i) {
    cin >> s;
    cout << s << endl << s << endl;
  }
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
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():
    aa,bb,m = LI()
    a = LI()
    b = LI()
    xyc = [LI() for _ in range(m)]
    r = min(a) + min(b)
    for x,y,c in xyc:
        t = a[x-1] + b[y-1] - c
        if r > t:
            r = t

    return r


print(main())





Measured memory_bytes: 40908
def c_iroha_obsession(N, K, D):
    for ans in range(N, 10 * N + 1):
        for digit in str(ans):  # 1桁ずつ調べる
            if int(digit) in D:  # 嫌いな数字があった
                break
        else:  # 嫌いな数字がなかった。このときのansが解
            break
    return ans
N,K = [int(i) for i in input().split()]
D = [int(i) for i in input().split()]
print(c_iroha_obsession(N, K, D))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  char string[50];
  int flag = 1;
  scanf("%[^\n]", string);

  for (int i = 0; string[i] != '\0'; i++)
  {
    if (string[i] == ' ' && (string[i - 1] != string[i + 1]))
    {
      flag = 0;
    }
  }
  if (flag == 0)
  {
    printf("NO\n");
  }
  else
  {
    printf("YES\n");
  }
  return 0;
}


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

#define int long long

#define pii pair<int, int>

#define x1 x1228
#define y1 y1228

#define left left228
#define right right228

#define pb push_back
#define eb emplace_back

#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   

#define matr vector<vector<int> > 

#define all(x) x.begin(), x.end()


using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 1e3 + 7, mod = 1e9 + 7, MAXN = 1e6 + 7;
const double eps = 1e-9;                                                                    
const ll inf = 1e18;
mt19937 rnd(time(0));
int n;   
vector<string> ans[8]; 

vector<string> solve(int x) {
    if (x <= 7) {
        return ans[x];        
    }   
    vector<string> t1 = solve(x / 2); 
    vector<string> t2 = solve(x - x / 2); 
    vector<string> cur(x); 
    string pp = ""; 
    for (int i = 0; i < x; ++i) {
        pp += '.';  
    }
    for (int i = 0; i < x; ++i) {
        cur[i] = pp; 
    }
    for (int i = 0; i < x / 2; ++i) {
        for (int j = 0; j < x / 2; ++j) {
            cur[i][j] = t1[i][j]; 
        }
    }
    for (int i = 0; i < x - x / 2; ++i) {
        for (int j = 0; j < x - x / 2; ++j) {
            cur[i + x / 2][j + x / 2] = t2[i][j]; 
        }
    }                                      
    return cur; 
} 

void solve() {        
    cin >> n; 
    if (n == 2) {                               
        cout << "-1"; 
        return; 
    }               
    if (n == 3) {
        cout << "aa.\n..a\n..a";
        return;      
    }   
    ans[4] = {"aaba", "ccba", "deff", "degg"}; 
    ans[5] = {"a.abb", "a.a.c", "ee.dc", "fggd.", "fhhll"}; 
    ans[6] = {"aab.cc", "f.b..d", "f.ee.d", "gghhee", ".m.lf.", ".m.lf."}; 
    ans[7] = {"a..bb.c", "a...d.c", ".ee.dn.", "ff.g.n.", "t..g.ll", "t.kkz..", ".mm.zff"}; 
    vector<string> ANS = solve(n);
    for (int i = 0; i < n; ++i) {
        cout << ANS[i]; 
        cout << '\n'; 
    }
}                               
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

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

int main()
{
    int N, T, ans;
    bool S = true;
    cin >> N;
    T = 0;
    ans = 0;

    int *A = new int[N];
    int *B = new int[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    while (S)
    {
        for (int i = 0; i < N; i++)
        {
            B[i] = A[i] % 2;
        }

        for (int i = 0; i < N; i++)
        {
            if (B[i] == 1)
            {
                break;
            }
            else
            {
                T += 1;
                A[i] /= 2;
            }
        }
        if (T == N)
        {
            ans += 1;
            T = 0;
            S = true;
        }
        else
        {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);

  if (n == 1) {
    writeln("Hello World");
  } else {
    int a; readV(a);
    int b; readV(b);
    writeln(a+b);
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <set>
#include <map>


using namespace std;


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


    for( int i = 0; i < 4; ++i ){
        cout << s[i];
    }

    cout << " ";

    for( int i = 4; i < s.length(); ++i ){
        cout << s[i];
    }

    cout << endl;


    return 0;
}

Measured memory_bytes: 256
W,H,x,y = input().split()
W,H,x,y = int(W),int(H),int(x),int(y)

cw = W/2
cH = H/2

if(cw==x):
    print(W*H/2)
    if(cH==y):
        print(1)
    else:
        print(0)

else:
    y0 = y-((y-cH)/(x-cw))*x
    y1 = y-((y-cH)/(x-cw))*(x-W)
    print((y0+y1)*W/2)
    print(0)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <deque>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int doubling[64][200010];

int main(void){
	int n;
	ll k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		doubling[0][i+1] = a;
	}
	for(int k=0;k<60;k++){
		for(int i=1;i<=n;i++){
			doubling[k+1][i] = doubling[k][doubling[k][i]];
		}
	}
	int now = 1;
	for(ll i=60;i>=0;i--){
		if((k>>i)&1){
			now = doubling[i][now];
		}
	}
	cout<<now<<endl;
	return 0;
}

Measured memory_bytes: 51280
import sys
N,M,C = map(int,input().split())
array_b = list(map(int,input().split()))
array2_a = [ list(map(int,input().split())) if ( -100 <= I <= 100 ) else sys.exit() for I in range(N) ] 

if not ( 1 <= N <= 20 and 1 <= M <= 20 ): sys.exit()
for J in range(len(array_b)): 
    if not ( -100 <= array_b[J] <= 100 ): sys.exit()

count = 0
for K in range(N):
    sum = 0
    for L in range(len(array2_a[K])):
        sum += array_b[L] * array2_a[K][L]
    if sum + C > 0: count += 1

print(count)

Measured memory_bytes: 9140
#include<iostream>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>

using namespace std;


int main(){

    long long n;
    vector< vector<long long> > map(100,vector<long long>(100));
    long long a,b,c;
    vector<long long> v(100);
    fill(v.begin(),v.end(),1<<20);
    while(true){
	fill(map.begin(),map.end(),v);
	cin >> n;
	long long ma=0;
	if(n == 0) break;
	for(long long i=0;i<n;i++){
	    cin >> a >> b >> c;
	    map[a][b] = c;
	    map[b][a] = c;
	    ma = max(ma,b);
	}
	for(long long i=0;i<ma;i++){
	    map[i][i] = 0;
	}
	ma++;
	for(int l = 0;l<2;l++){
	for(long long i=0;i<ma;i++){
	    for(long long j=0;j<ma;j++){
		for(long long k=0;k<ma;k++){
			map[i][j] = min(map[i][j] ,map[i][k] + map[k][j] );
		}
	    }
	}
	}

	long long res = 1<<30,t=0;
	for(long long i=0;i<ma;i++){
	    a =0;
	    for(long long j=0;j<ma;j++){
		a += map[i][j];
	    }
	    if(a!=0 && res>a){
		res = a;
		t = i;
	    }
	}
	cout << t<<" " << res << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1292
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll a, b;
    cin >> a >> b;
    if(a<=0 && 0<=b){
        cout << "Zero" << el;
    }else if(a<=0 && b<=0 && (b-a)%2==0){
        cout << "Negative" << el;
    }else{
        cout << "Positive" << el;
    }
}



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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int a[3]; REPI(i, 3) cin >> a[i];
    int k; cin >> k;

    sort(a, a + 3);
    REPI(i, k) a[2] *= 2;

    cout << (a[0] + a[1] + a[2]);
}


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

using namespace std;

const int N = 1e2+2;
const int MAX = 1e5 + 3;

long long dp[N][MAX], w[N], c[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, W;
    cin >> n >> W;
    for (int i = 1; i <= n; ++i) {
        cin >> w[i] >> c[i];
    }        
    for (int wht = 0; wht <= W; wht++) {
        for (int i = 1; i <= n; i++) {
            dp[i][wht] = dp[i - 1][wht];
            if (wht - w[i] >= 0)
                dp[i][wht] = max(dp[i][wht], dp[i - 1][wht - w[i]] + c[i]);
        }    
    }
    cout << *max_element(dp[n], dp[n]+W+1);
    return 0;
}

Measured memory_bytes: 78336
/* AtCoder Panasonic Programming Contest 2020. Task A. */
#include <bits/stdc++.h>

using namespace std;

#define COUT_PRECISION 10

namespace abreto {

void main(void) {
    int K;

    vector<int> seq({1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51});

    cin >> K;
    cout << seq[K - 1] << '\n';
}

}

int main(void) {
    cin.sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(COUT_PRECISION);
    abreto::main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (ll i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll x = 0;
    rep(i, n) {
        if (i<=1) continue;
        x ^= a[i];
    }
    ll s = a[0] + a[1];
    ll aa = s - x;
    if (aa%2==1) {
        cout << -1 << endl;
        return 0;
    }
    aa /= 2;
    ll z = aa;
    //debug(aa);
    //debug(x);
    if (aa & x) {
        cout << -1 << endl;
        return 0;
    }
    if (z>a[0]) {
        cout << -1 << endl;
        return 0;
    }
    
    rrep(i, 60) {
        if (x>>i&1) {
            if ((z|(1LL<<i))<=a[0]) {
                z |= (1LL<<i);
            }
        }
    }
    if (z==0) {
        cout << -1 << endl;
        return 0;
    }
    
    
    ll ans = a[0] - z;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
     
#define int  long long
#define endl '\n'
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 25 + 1;

void solve(){
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) 
    cin >> v[i];
  int ret = 1;
  for (int i = 0; i < n; i++)
	for (int j =  i + 1; j < n; j++)
	  ret += v[i] * v[j]; 
  cout << ret - 1 << endl;
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();	
}


Measured memory_bytes: 256
input = readlines()

n = input.shift.chomp.to_i
list = input.shift.chomp.split("\s").map{|x| x.to_i}

cnt = 0
list.each_with_index do |l, i|
  next if i < 2
  tmp = [list[i - 2], list[i - 1], l].sort()
  cnt += 1 if tmp[1] == list[i - 1]
end

puts cnt

Measured memory_bytes: 14340
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
const int INF = 1e9 + 7;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];

int main() {
    int n = readInt();
    int mx = -INF;
    int id_of_mx = 0;
    int mn = INF;
    int id_of_mn = 0;
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
    	if (a[i] > mx) {
    		mx = a[i];
    		id_of_mx = i;
    	}
    	if (a[i] < mn) {
    		mn = a[i];
    		id_of_mn = i;
    	}
    }
    mx = abs(mx);
    mn = abs(mn);
	if (mx >= mn) {
		cout << 2 * n - 1 << "\n";
		for (int i = 1; i <= n; i++) {
			cout << id_of_mx << ' ' << i << "\n";
		}
		for (int i = 2; i <= n; i++) {
			cout << i - 1 << ' ' << i << "\n"; 
		}
	} else {
		cout << 2 * n - 1 << "\n";
		for (int i = 1; i <= n; i++) {
			cout << id_of_mn << ' ' << i << "\n";
		}
		for (int i = n - 1; i >= 1; i--) {
			cout << i + 1 << ' ' << i << "\n";
		}		
	}
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			 System.out.println(a!=2&&b!=2?"Yes":"No");
		}
	}
}

Measured memory_bytes: 25396
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();
		int countE = 0,countW = 0;
		int[] E = new int[N];
		int[] W = new int[N];
		int[] ans = new int[N];
		for( int i=0; i<N; i++ ){
			if( S.charAt(i)=='E' ){
				countE++;
				E[i] = countE;
				W[i] = countW;
			}else{
				countW++;
				W[i] = countW;
				E[i] = countE;
			}
		}
		for( int i=1; i<N-1; i++ ){
			if( S.charAt(i)=='E' ){
				ans[i] = W[i] + ( E[N-1] - E[i] );
			}
			if( S.charAt(i)=='W' ){
				ans[i] = W[i-1] + ( E[N-1] - E[i] );
			}
		}
		if( S.charAt(0)=='E' ){
			ans[0] = E[N-1] - 1;
		}else{
			ans[0] = E[N-1];
		}
		if( S.charAt(N-1)=='W' ){
			ans[N-1] = W[N-1] - 1;
		}else{
			ans[N-1] = W[N-1];
		}
		Arrays.sort(ans);
		System.out.println(ans[0]);
	}
}


Measured memory_bytes: 34644
#include <iostream>
#include <vector>
using namespace std;
#define int int64_t

vector<int> ballsToCombinations = {0};

int getNormal(vector<int> &quantities) {
    int counter = 0;
    for (int i = 0; i<quantities.size(); i++) {
        if(ballsToCombinations.size() > quantities[i]) {
            counter += ballsToCombinations[quantities[i]];
        }
        else {
            for (int j = ballsToCombinations.size(); j<=quantities[i]; j++) {
                ballsToCombinations.push_back(ballsToCombinations[j-1] + j-1);
            }
            counter += ballsToCombinations[quantities[i]];
        }
    }
    return counter;
}



int getSlowPossabilities(vector<int> &quantities, int missing) {
    int counter = 0;
    for (int i = 0; i<quantities.size(); i++) {
        if (missing == i) {
            if(ballsToCombinations.size() > quantities[i]-1) {
                counter += ballsToCombinations[quantities[i]-1];
            }
            else {
                for (int j = ballsToCombinations.size(); j<=quantities[i]-1; j++) {
                    ballsToCombinations.push_back(ballsToCombinations[j-1] + j-1);
                }
                counter += ballsToCombinations[quantities[i]-1];
            }
        }
        else {
            if(ballsToCombinations.size() > quantities[i]) {
                counter += ballsToCombinations[quantities[i]];
            }
            else {
                for (int j = ballsToCombinations.size(); j<=quantities[i]; j++) {
                    ballsToCombinations.push_back(ballsToCombinations[j-1] + j-1);
                }
                counter += ballsToCombinations[quantities[i]];
            }
        }
    }
    return counter;
}



int getPossabilities(int missing, vector<int> &quantities, int normal) {
    // int x = ballsToCombinations[quantities[missing]] - ballsToCombinations[quantities[missing]-1];
    return normal - quantities[missing] + 1;
}


signed main() {
    int normal = 0;
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    
    vector<int> quantities(n, 0);
    vector<int> balls;
    
    for (int i = 0; i<n; i++) {
        int tmp;
        cin>>tmp;
        balls.push_back(tmp);
        quantities[tmp] += 1;
        normal += quantities[tmp] -1;
    }
    
    
    for(int i = 0; i<n; i++) {
         cout << getPossabilities(balls[i], quantities, normal) << "\n";
//        cout << getNormal(quantities);
//        cout << getSlowPossabilities(quantities, balls[i]) << "\n";
    }
return 0;
}


Measured memory_bytes: 5872
#include<iostream>

using namespace std;

int main() {
	int n;
	int ice[10] = {0};
	int hoge;
	while (cin >> n,n) {
		for ( int i = 0; i< 10; i++ ) {
			ice[i] = 0;
		}
		
		for ( int i = 0; i < n; i++ ) {
			cin >> hoge;
			ice[hoge]++;
		}
		
		for ( int i = 0; i < 10; i++ ) { 
			if ( !ice[i] ) { 
				cout << "-";
			} else {
				for ( int j = 0; j < ice[i]; j++ ) {
					cout << "*";
				}
			}
			cout << endl;
		}
	}
	
	return 0;
}

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

int main(void){
    int a,b,i,taxa,taxb,flag;
    flag = 1;
    cin >> a >> b;

    for(i=1; i<=1000; i++){

        taxa = (floor)(i * 0.08);
        taxb = (floor)(i * 0.10);

        if(taxa == a && taxb == b){
            cout << i << endl;
            flag = 0;
            break;
        }
    }

    if(flag == 1){
        cout << -1 << endl;
    }

    

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	ll k=n%m;
	puta(min(k,m-k));
}


Measured memory_bytes: 3656
#include <stdio.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a - 2*b > 0){
		printf("%d\n", a-2*b);
	}
	else{
		printf("%d\n", 0);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
using namespace std;

int main(){
  int a,b,c;
  cin  >> a >> b >> c;
  int sum = 0;
  sum = c - (a - b);
  if(sum < 0){
    sum = 0;
  }
  cout << sum <<endl;
    return 0;
}

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

typedef long long ll;
const int maxn = 100010, P = 1000000007;
int n, pre1[maxn], pre2[maxn];
ll A, B, a[maxn];
struct node { int sum; bool tag; } t1[maxn << 2], t2[maxn << 2];

#define mid (l + r >> 1)
#define ls (k << 1)
#define rs (k << 1 | 1)
void pushdown(node *t, int k) {
    t[ls].sum = t[rs].sum = 0;
    t[ls].tag = t[rs].tag = 1, t[k].tag = 0;
}

void modify(node *t, int k, int l, int r, int p, int v) {
    if (l == r) { t[k].sum = v; return; }
    if (t[k].tag) pushdown(t, k);
    if (mid >= p) modify(t, ls, l, mid, p, v);
    else modify(t, rs, mid + 1, r, p, v);
    t[k].sum = (t[ls].sum + t[rs].sum) % P;
}

void push(node *t, int k, int l, int r, int ql, int qr) {
    if (l >= ql && r <= qr) { t[k].sum = 0, t[k].tag = 1; return; }
    if (t[k].tag) pushdown(t, k);
    if (mid >= ql) push(t, ls, l, mid, ql, qr);
    if (mid < qr) push(t, rs, mid + 1, r, ql, qr);
    t[k].sum = (t[ls].sum + t[rs].sum) % P;
}

int query(node *t, int k, int l, int r, int ql, int qr) {
    if (l >= ql && r <= qr) return t[k].sum;
    if (t[k].tag) pushdown(t, k);
    int ans = 0;
    if (mid >= ql) ans = query(t, ls, l, mid, ql, qr);
    if (mid < qr) (ans += query(t, rs, mid + 1, r, ql, qr)) %= P;
    return ans;
}

int main() {
    scanf("%d %lld %lld", &n, &A, &B);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }
    a[0] = -1e18;
    for (int i = 1; i <= n; i++) {
        pre1[i] = pre1[i - 1], pre2[i] = pre2[i - 1];
        while (a[i] - a[pre1[i] + 1] >= A) pre1[i]++;
        while (a[i] - a[pre2[i] + 1] >= B) pre2[i]++;
    }
    modify(t1, 1, 0, n, 0, 1), modify(t2, 1, 0, n, 0, 1);
    for (int i = 2; i <= n; i++) {
        int s1 = query(t2, 1, 0, n, 0, pre1[i]);
        int s2 = query(t1, 1, 0, n, 0, pre2[i]);
        modify(t1, 1, 0, n, i - 1, s1);
        modify(t2, 1, 0, n, i - 1, s2);
        if (a[i] - a[i - 1] < A) push(t1, 1, 0, n, 0, i - 2);
        if (a[i] - a[i - 1] < B) push(t2, 1, 0, n, 0, i - 2);
    }
    printf("%d\n", (t1[1].sum + t2[1].sum) % P);
    return 0;
}

Measured memory_bytes: 9468
from collections import defaultdict

n, m = map(int, input().strip().split())
data = [list(map(int, input().strip().split())) for _ in range(m)]


# 島iから行ける島のリスト
reachables = defaultdict(set)
for a, b in data:
    reachables[a].add(b)
    reachables[b].add(a)

# 島1から行けるところ
reachables_from1 = reachables[1]
possible = False
for i in reachables_from1:
    if n in reachables[i]:
        possible = True
        break

if possible:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 113832
using System;
using System.Linq;

namespace ABC174
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            long[] nd = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = nd[0], d = nd[1];
            int ans = 0;
            for (long i = 0; i < n; i++)
            {
                double[] xy = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
                double x = xy[0] * xy[0], y = xy[1] * xy[1];
                if (d >= Math.Sqrt(x + y))
                    ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 41360
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,t,n,b,c,d,a,l,r;
    cin>>a>>b>>c;
    if(a<=b*c)
        cout<<"Yes"<<'\n';
    else
        cout<<"No"<<'\n';
}













Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

double dist(ll x1,ll y1,ll x2,ll y2){
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){
    ll n;
    cin>>n;
    vector<ll> x(n),y(n),perm(n);
    rep(i,n){
        cin>>x[i]>>y[i];
        perm[i]=i;
    }
    double sum=0;
    ll cnt=0;
    bool flag=1;
    while(flag){
        rep(i,n-1) sum+=dist(x[perm[i]],y[perm[i]],x[perm[i+1]],y[perm[i+1]]);
        flag=next_permutation(all(perm));
        cnt++;
    }
    printf("%.6lf",sum/cnt);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  string S;
  cin >> N >> S;
  vec< int > lis(300, INF);
  vec< int > dp(N + 1, 0);
  REP(i, N) {
    int prev = dp[i];
    dp[i + 1] = dp[i];
    // DEBUG(i - prev - 1);
    string p = S.substr(i - prev, prev + 1);
    int pos = S.find(p);
    // int pos = distance(S.begin(), itr);
    if (pos <= i - 2 * prev - 1) {
      dp[i + 1] = dp[i] + 1;
    }
    // DEBUG(pos);
  }
  print(dp[N]);
}

Measured memory_bytes: 384
n,q = (int(i) for i in input().split())
s = '#'+input()+'#'
l = 0
r = n+1
a = [list(input().split()) for i in range(q)]
for i in range(q-1, -1, -1):
    t,d = a[i]
    if s[l+1] == t and d =='L':
        l += 1
    elif s[l] == t and d == 'R':
        l -= 1
    if s[r] == t and d == 'L':
        r += 1
    elif s[r-1] == t and d == 'R':
        r -= 1
print(max(0,r-l-1))

Measured memory_bytes: 26832
import scala.io.{ StdIn => in}
import scala.annotation.tailrec
import scala.collection.mutable.HashMap

object Main extends App {
  val mod = 1000000007
  val n = in.readInt
  val map = HashMap.empty[Long,Long]

  (2 to n).map(i => primeFact(i)).foreach(m => {
    m.foreach(e => addOrUpdate(map, e._1, e._2))
  })

  val ans = if(n == 1) 1 else {
    map.values./:(1L)((acc,v) => {
      val m = acc * (v + 1)
      if(m > mod) m % mod else m
    })
  }

  println(ans)

  @inline
  def addOrUpdate
    (map:HashMap[Long,Long], key:Long, value:Long):HashMap[Long,Long] =
  {
    if(map.contains(key)) map(key) += value
    else map += (key -> value)
    map
  }

  def primeFact(n:Long):Map[Long,Long] = {

    @tailrec
    def rec(acc:HashMap[Long,Long], num:Long, root:Long):Map[Long,Long] = {

      if(root * root > num) addOrUpdate(acc, num, 1).toMap
      else {
        if(num % root == 0L) rec(addOrUpdate(acc, root, 1), num/root, root)
        else rec(acc, num, root+1L)
      }
    }

    val ret = HashMap.empty[Long,Long]
    rec(ret, n, 2L)
  }
}

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

int main()
{
    int n,m;
    cin>>n>>m;
    int arr[100000];
    long long int sum=0;
    for(int i=0;i<m;i++)
    cin>>arr[i];
    for(int i=0;i<m;i++)
    {
        sum+=arr[i];
    }
    if(sum>n)
    cout<<"-1";
    else
    {
        cout<<n-sum<<"\n";
    }
}

Measured memory_bytes: 3644
#include<iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int count=0;
    int s2 = s.length();
    char arr[100];
    for(int i=0 ; i<s2 ; i++){
        arr[i] = s[i];
    }
    int s3 = s2/2;
    for(int i=0 ; i<s3 ; i++){
        if(arr[i]!= arr[s2-i-1]){
            count++;
        }
    }
    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#pragma warning(disable:4996)

int main()
{
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	switch (a) 
	{
	case 1:switch (b) 
		{
	case 2:printf("3"); break;
	case 3:printf("2"); break;
		}break;
	case 2:switch (b)
	{
	case 1:printf("3"); break;
	case 3:printf("1"); break;
	}break;
	case 3:switch (b)
	{
	case 2:printf("1"); break;
	case 1:printf("2"); break;
	}break;
	}
}

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

int main() {
    long long int n;
    cin >> n;
    string s;
    while(n) {
        s += (n%26 + 'a' - 1 < 'a')?('z'):((char)(n%26 + 'a' - 1));
        if(n%26 == 0) n--;
        n /= 26;
    }
    for(int i = s.size()-1; i >= 0; --i) cout << s[i];
    cout << '\n';
    return 0;

}


Measured memory_bytes: 3620