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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << "\t|";
    __f(comma + 1, args...);
}

#define print(x) for(auto it : x) cout<< it << ' '; cout << '\n';
typedef long long ll;
typedef unsigned long long ull;
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll) (a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll) mod(mod(a) * mod(b));}


//int visited[100005];
int dp[100005];
vector<int> adj[100005]; // array of vector

int dfs(int node) {
    if (dp[node] > 0)
        return dp[node];
//    visited[node] = 1;
    int ans = 0;
    for (auto kid : adj[node]) {
        ans = max(ans, 1 + dfs(kid));
    }
    dp[node] = ans;
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        adj[x].push_back(y);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dfs(i));
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 11420
#include<stdio.h>

int main(void)
{
int ck_a,ck_b,ck_c,count_max=0;

scanf("%d",&ck_a);
scanf("%d",&ck_b);
scanf("%d",&ck_c);
if(ck_c<=ck_a+ck_b-1)
{
  count_max = ck_b + ck_c;
}
else
{
  while(1)
  {
  if(ck_c!=0)
  {
    ck_c -= 1;
    count_max += 1;
  }
  
    if(ck_a!=0)
    {
      ck_a -= 1;
    }
    else if(ck_b!=0)
    {
      ck_b -= 1;
      count_max += 1;
    }
    else
    {
      break;
    }
  }
}


printf("%d",count_max);

  return 0;
}


Measured memory_bytes: 128
a, b, c = map(int, input().split())
k = int(input())

if a < b < c:
    print("Yes")
else:
    for i in range(k):
        if a >= b:
            b *= 2
        elif b >= c:
            c *= 2
    if a < b < c:
        print("Yes")
    else:
        print("No")
        


Measured memory_bytes: 9128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main (){
  int N;
  string str;
  cin >> N >> str;
  int pos = 0;
  int cnt = 0;
  while (pos < N) {
    int t = str.find("ABC", pos);
    if (t == string::npos) {
      break;
    } else {
      ++cnt;
      pos = t + 3;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<char>C1(3);
    vector<char>C2(3);
    for(int i=0;i<3;i++){
        cin>>C1[i];
    }
    for(int i=0;i<3;i++){
        cin>>C2[i];
    }
    if((C1[1]==C2[1])&&(C1[0]==C2[2])&&(C1[2]==C2[0])){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    return 0;
}

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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
    }
    else {
    cout << "consonant" << endl;
    }

 }

Measured memory_bytes: 3628
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
const int MAX_N = 1e5 + 5;
struct Node {int to; ll c;};
vector<Node> g[MAX_N];
ll dep[MAX_N];
void dfs(int x, int f)
{
    for (int i = 0; i < g[x].size(); i++) if (g[x][i].to != f)
    {
        dep[g[x][i].to] = dep[x] + g[x][i].c;
        dfs(g[x][i].to, x);
    }
}
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) g[i].clear();
    for (int i = 1; i < n; i++)
    {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        g[a].push_back(Node{b, c});
        g[b].push_back(Node{a, c});
    }
    int q, k;
    scanf("%d%d", &q, &k);
    memset(dep, 0, sizeof(dep));
    dfs(k, 0);
    while (q--)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        ll ans = dep[a] + dep[b];
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   int x = 0;
   int ans = 0;
   rep(i,n){
      if(s[i] == 'I') x++;
      else x--;
      ans = max(ans,x);
   }
   cout << ans << endl;


   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int s, n, i = 1;
    scanf("%d", &s);
    if (s == 1 || s == 2)
        n = 4;
    else
    {
        while (s != 1)
        {
            if (s % 2 == 0)
            {
                s = s / 2;
            }
            else
            {
                s = 3 * s + 1;
            }
            i++;
        }
        n = i + 1;
    }
    printf("%d\n", n);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
long long cmmdc(long long cazan,long long cacamuta)
{
    int rest;
    while(cacamuta)
    {
        rest=cazan%cacamuta;
        cazan=cacamuta;
        cacamuta=rest;
    }
    return cazan;
}
int main()
{
    long long N,k,a1,ac,m,n,max,i;
    bool ok=0;
    cin>>N>>k;
    cin>>a1;
    max=a1;
    for(i=2;i<=N;i++)
    {
        cin>>ac;
        if(max<ac)
        max=ac;
        a1=cmmdc(a1,ac);
    }
    if(k%a1==0&&max>=k)
    cout<<"POSSIBLE";
    if(max<k||k%a1!=0)
    cout<<"IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll cun[1000000];
ll hero[1000000];
int main()
{
	int n;
	ll sum=0;
	scanf("%d",&n);
	for(int i=0;i<n+1;i++)
	{
		scanf("%lld",&cun[i]);
	}
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&hero[i]);
	}
	
	for(int i=0;i<n;i++)
	{
		if(hero[i]>cun[i])
		{
			sum+=cun[i];
			hero[i]-=cun[i];
			cun[i]=0;
			//printf("heroi1=%d\n",hero[i]);
			
			if(cun[i+1]>hero[i])
			{
				sum+=hero[i];
			//	printf("heroi2=%d\n",hero[i]);
				cun[i+1]-=hero[i];
				hero[i]=0;
			}
			else
			{
				sum+=cun[i+1];
				hero[i]-=cun[i+1];
				cun[i+1]=0;
			}
		}
		else
		{
			sum+=hero[i];
			cun[i]-=hero[i];
		}
	//	printf("test%d %d\n",sum,hero[i]);
	}
	printf("%lld",sum);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
typedef long long ll;
ll a[maxn],dig[63];
int vis[63];
void add(ll x){
    for(int i=61;i>=0;i--){
        if(!vis[i]) continue;
        if(x&(1ll<<i)){
            if(dig[i]) x^=dig[i];
            else{
                dig[i]=x;
                break;
            }
        }
    }
}
ll get(){
    ll res=0;
    for(int i=60;i>=0;i--){
        if(vis[i] && ( !(res&(1ll<<i)) ) )
            res^=dig[i];
    }
    return res;
}
int main()
{
    int n;
    ll sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        sum^=a[i];
    }
    for(int i=0;i<=61;i++){
        if(!(sum&(1ll<<i))) vis[i]=1;
    }
    for(int i=1;i<=n;i++) add(a[i]);
    ll res=get();
    printf("%lld\n",res+(res^sum));
    return 0;
}

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

int main() {
  int n;
  long int a, b;
  long int ca, cb, sa, sb, ma, mb;
  long int mag;
  cin >> n;
  cin >> a >> b;
  n--;
  ca = a, cb = b;
  for (unsigned i = 0; i < n; i++) {
    cin >> a >> b;
    sa = ca / a, ma = ca % a;
    sb = cb / b, mb = cb % b;
    if (ma != 0)
      sa++;
    if (mb != 0)
      sb++;
    mag = max(sa, sb);
    ca = a * mag, cb = b * mag;
  }
  cout << ca + cb << endl;
  return 0;
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("d",&a,&b)
#define sfff(a,b,c)     scanf("d%d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define PRINT_CASE printf("Case %d: ",z)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)3000+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

double DP[maxn][maxn];

double p[maxn];
bool visited[maxn][maxn];
int n;

double cal(int pos, int cnt){
    if(pos==n){
        if(n/2<cnt){
            return 1.0;
        }
        return 0.0;
    }

    double &res = DP[pos][cnt];
    if(visited[pos][cnt]) return res;
    visited[pos][cnt]=1;

    res=cal(pos+1, cnt)*(1-p[pos]);
    res+=cal(pos+1, cnt+1)*p[pos];
    return res;
}

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

    cin>>n;

    f0(i,n){
        cin>>p[i];
    }
    cout<<fixed<<setprecision(15)<<cal(0,0)<<endl;

    return 0;
}



Measured memory_bytes: 79616
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
count = 0 
for _ in range(N):
    A = list(map(int, input().split()))
    p = C
    for i in range(M):
        p += A[i] * B[i]
    if p > 0:
        count += 1
print(count)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] f = new int[n];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 10; j++) {
                    f[i] <<= 1;
                    f[i] |= in.nextInt();
                }
            }

            int[][] p = in.nextIntArrayArray(n, 11);

            int ans = Integer.MIN_VALUE;
            for (int i = 1; i < 1 << 10; i++) {
                int tmp = 0;
                for (int j = 0; j < n; j++) {
                    tmp += p[j][Integer.bitCount(i & f[j])];
                }
                ans = Math.max(ans, tmp);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public int[][] nextIntArrayArray(int n, int m) {
            int[][] res = new int[n][m];
            for (int i = 0; i < n; i++) {
                res[i] = nextIntArray(m);
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int H,W,K;
string fld[10];

signed main(){
	cin>>H>>W>>K;
	rep(i,H)cin>>fld[i];
	int ans=0;

	rep(bh,1<<H){
		rep(bw,1<<W){
			int cnt=0;
			rep(i,H)rep(j,W){
				if(bh>>i&1)continue;
				if(bw>>j&1)continue;
				cnt+=fld[i][j]=='#';
			}
			if(cnt==K)ans++;
		}
	}
	cout<<ans<<endl;
    return 0;
}



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

int main() {
  int n,c=0;
  cin >>n;
  vector<int> l(n);
  for(int i=0 ; i < n ; i++) cin >> l.at(i);
  sort(l.begin(), l.end());
  int b = l.at(0);
  for(int i=0; i < n-2 ; i++){
    for(int j=i+1; j < n-1; j++){
      for(int k=j+1; k < n; k++){
        if(l.at(i)!=l.at(j) && l.at(i)!=l.at(k) && l.at(k)!=l.at(j)){
          if((l.at(i) + l.at(j) > l.at(k)) && (l.at(k) + l.at(j) > l.at(i)) && (l.at(i) + l.at(k) > l.at(j))) c++;
        }
      }
    }
  }
  cout << c;
}



Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main(){
	int N;
	cin >> N;
	vector<vector<int>>g(N);
	REP(i,N - 1){
		int a,b;
		cin >> a >> b;
		--a;--b;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	vector<vector<int>>v(3);
	REP(i,N){
		v[(i + 1) % 3].emplace_back(i + 1);
	}
	vector<int>col(N);
	vector<int>dist(N);
	int flg = 1;
	auto dfs = [&](auto&&f,int now,int par,int rank)->void{
		if(flg)col[now] = rank % 2;
		dist[now] = rank;
		for(auto e:g[now]){
			if(e == par)continue;
			f(f,e,now,rank + 1);
		}
	};
	dfs(dfs,0,-1,0);
	int ma = -INF,s = 0;
	REP(i,N){
		if(CHMAX(ma,dist[i]))s = i;
	}
	flg = 0;
	dist = vector<int>(N,INF);
	dfs(dfs,s,-1,0);
	ma = -INF;
	REP(i,N)CHMAX(ma,dist[i]);
	int cnt0 = 0,cnt1 = 0;
	REP(i,N){
		if(col[i] == 0)cnt0++;
		else cnt1++;
	}
	if(ma <= 2){
		REP(i,N){
			if(i)cout << " ";
			cout<<i + 1;
		}
		cout << endl;
		return 0;
	}
	vector<int>ans(N);
	if(max(cnt0,cnt1) > v[1].size() + v[0].size()){
		if(cnt0 >= cnt1){
			REP(i,N){
				if(col[i] == 1){
					ans[i] = v[0].back();
					v[0].pop_back();
				}else{
					RREP(j,3){
						if(v[j].size()){
							ans[i] = v[j].back();
							v[j].pop_back();
							break;
						}
					}
				}
			}
		}else{
			REP(i,N){
				if(col[i] == 0){
					ans[i] = v[0].back();
					v[0].pop_back();
				}else{
					RREP(j,3){
						if(v[j].size()){
							ans[i] = v[j].back();
							v[j].pop_back();
							break;
						}
					}
				}
			}
		}
	}else{
		if(cnt0 >= cnt1){
			REP(i,N){
				if(v[col[i] + 1].size() == 0){
					ans[i] = v[0].back();
					v[0].pop_back();
				}else{
					ans[i] = v[col[i] + 1].back();
					v[col[i] + 1].pop_back();
				}
			}
		}else{
			REP(i,N){
				if(v[2 - col[i]].size() == 0){
					ans[i] = v[0].back();
					v[0].pop_back();
				}else{
					ans[i] = v[2 - col[i]].back();
					v[2 - col[i]].pop_back();
				}
			}
		}
	}
	REP(i,ans.size())cout << ans[i] << " \n"[i+1 == ans.size()];
}

Measured memory_bytes: 21980
n = int(input())
a,b = [],[]
d = dict()
s = set()
for i in range(n):
    bn,an = map(int,input().split())
    a.append(an)
    b.append(bn)
    if an not in d.keys():
        d.setdefault(an,bn)
    else:
        d[an] += bn

    s.add(an)

s = list(s)
s.sort()

counter = 0

for i in s:
    counter += d[i]
    if counter > i:
        print("No")
        break
else:
    print("Yes")




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

using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

typedef long long ll;

int lr[2002][2002], rr[2002][2002], uc[2002][2002], dc[2002][2002];

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

    int n, m;
    cin >> n >> m;


    vector<string> A(n);

    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }

    for(int i = 0; i < n; i++) {
        int last = -1;

        for(int j = 0; j < m; j++) {
            if(A[i][j] == '#') last = j;

            lr[i][j] = last;
        }

    }

    for(int i = 0; i < n; i++) {
        int last = m;

        for(int j = m - 1; j >= 0; j--) {
            if(A[i][j] == '#') last = j;

            rr[i][j] = last;
        }

    }

    for(int i = 0; i < m; i++) {
        int last = -1;

        for(int j = 0; j < n; j++) {
            if(A[j][i] == '#') last = j;

            uc[j][i] = last;
        }

    }


    for(int i = 0; i < m; i++) {
        int last = n;

        for(int j = n - 1; j >= 0; j--) {
            if(A[j][i] == '#') last = j;

            dc[j][i] = last;
        }

    }

    int ans = 0;
    for(int i = 0; i < n; i++) {

        for(int j = 0; j < m; j++) {
            if(A[i][j] == '#') continue;

            int cur = 0;

            cur += j - lr[i][j];

            cur += rr[i][j] - j;

            cur += i - uc[i][j];

            cur += dc[i][j] - i;

            ans = max(ans, cur);
        }

    }

    cout << ans - 3 << endl;

}


/**
 * .#.....
 * 0123456
 *
*/

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

int dp[100100][8];
int abc[100100][8];
int n;

int dfs ( int pos, int bef ) {
    if ( ~dp[pos][bef] ) return dp[pos][bef];
    if ( pos == n ) return 0;

    int rec = -1;
    for ( int i = 0; i < 3; i++ ) {
        if ( bef != i ) {
            rec = max ( rec, dfs ( pos+1, i ) + abc[pos][i] );
        }
    }
    return dp[pos][bef] = rec;
}

signed main ( ) {

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < 3; j++ ) {
            cin >> abc[i][j];
        }
    }

    memset(dp, -1, sizeof(dp));

    int ans = 0;
    for ( int i = 0; i < 3; i++ ) {
        ans = max ( ans, dfs ( 0, i ) );
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main(){
  int n, i;

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

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}


Measured memory_bytes: 2104
A = list(input())
N = len(A)
F = N-1
s = 0
if N%2 == 0:
    for i in range(int(N/2)):
        if A[i] != A[N-1-i]:
            s = s+1
else:
    for j in range(int(F/2)):
    
        if A[j] != A[N-1-j]:
            s = s+1
            
print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int, bool>P;
 
int s[5], dx[]{ 1,-1,0,0, }, dy[]{ 0,0,1,-1 };
vector<vector<int>>a(5, vector<int>(5));
int Max,n;
void dfs(int x, int y, int c) {
	if(c==0||n%2!=0){
    vector<vector<P>>b(5, vector<P>(5));
    rep(i, 5)rep(j, 5)b[i][j].first = a[i][j];
    bool update = true;
    int p = 0;
    for (int v = 1; update; v++) {
        update = false;
        rep(i, 5) {
            int back = 0, cnt = 0;
            rep(j, b[i].size()) {
                if (back != b[i][j].first) {
                    if (cnt >= 3) {
                        for (int k = 1; k <= cnt; k++)
                            b[i][j - k].second = 1;
                    }
                    cnt = 0;
                }
                back = b[i][j].first; cnt++;
            }
            if (cnt >= 3) {
                for (int k = 1; k <= cnt; k++)
                    b[i][b[i].size() - k].second = 1;
            }
        }
        rep(i, 5) {
            int back = 0, cnt = 0;
            rep(j, 5) {
                if (b[j].size() <= i || back != b[j][i].first) {
                    if (cnt >= 3) {
                        for (int k = 1; k <= cnt; k++)
                            b[j - k][i].second = 1;
                    }
                    cnt = 0;
                }
                if (i < b[j].size()) {
                    back = b[j][i].first; cnt++;
                }
            }
            if (cnt >= 3) {
                for (int k = 1; k <= cnt; k++)b[5 - k][i].second = 1;
            }
        }
        rep(i, 5)rep(j, b[i].size()) {
            if (b[i][j].second == 1) {
                p += v*s[b[i][j].first];
                b[i].erase(b[i].begin() + j); update = true; j--;
            }
        }
    }
    Max = max(Max, p);}
    if (c == 0)return;
    rep(i, 4) {
        int nx = x + dx[i], ny = y + dy[i];
        if (0 <= nx&&nx < 5 && 0 <= ny&&ny < 5) {
            swap(a[x][y], a[nx][ny]);
            dfs(nx, ny, c - 1);
            swap(a[x][y], a[nx][ny]);
        }
    }
}
int main() {
    while (scanf("%d", &n), ~n) {
        Max = 0;
        rep(i, 5)rep(j, 5)scanf("%d", &a[j][i]), a[j][i]--;
        rep(i, 5)reverse(a[i].begin(), a[i].end());
        rep(i, 5)scanf("%d", &s[i]);
        rep(i, 5)rep(j, 5)dfs(i, j, n);
        printf("%d\n", Max);
    }
}

Measured memory_bytes: 3284
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	map<int, int> cnt;
	for(int i = 1; (i * i) <= n; i++)
	for(int j = 1; (j * j) <= n; j++)
	for(int k = 1; (k * k) <= n; k++)
		cnt[sq(i) + sq(j) + sq(k) + i * j + j * k + i * k]++;
	repn(i, 1, n + 1) cout << cnt[i] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 5496
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        // long N = s.nextLong();
        int M = s.nextInt();
        int[] a = new int[M];
        for (int i = 0; i < M-1; i++) {
            a[i] = s.nextInt();
        }

        int[] b = new int[a.length+1];
        Arrays.fill(b, 0);
        for (int i = 0; i < M; i++) {
            int l = a[i];
            b[l] += 1;
        }

        for (int i = 1; i < b.length; i++) {
            System.out.println(b[i]);
        }
    }
}

Measured memory_bytes: 58404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll MOD= 1000000007;
#define pb push_back
#define mpr make_pair

ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll a,b;
	cin>>a>>b;
	cout<<a*b/gcd(a,b)<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

typedef long long ll;

using namespace std;

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



int main(int argc, const char * argv[]) {
    
    int N;
    
    cin>>N;
    
    int a[N];
    int count=0;
    
    rep(i,N){
        cin>>a[i];
        if(i%2==0){
            if(a[i]%2==1){
                ++count;
            }
        }
    }
    
    cout<<count<<endl;

}


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

int main(){
  int n, q, ans = 0, input;
  cin >> n;
  vector<int> s(n);
  rep(i, n) cin >> s.at(i);
  cin >> q;
  rep(i, q){
    cin >> input;
    if(binary_search(s.begin(), s.end(), input)) ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3132
import sys
sys.setrecursionlimit(10**7)

k,n = map(int,input().split())
ai = [int(i) for i in input().split()]

sukima = ai[0] + k - ai[n-1]

for i in range(n-1):
    sukima = max(sukima,ai[i+1]-ai[i])
    
print(k-sukima)

Measured memory_bytes: 26436
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, t, l, b;
    while(cin >> n >> t >> l >> b, n){
        map<int, int> m;
        for (int i = 0; i < l; ++i) {
            int x;
            cin >> x;
            m[x] = 1;
        }
        for (int i = 0; i < b; ++i) {
            int x;
            cin >> x;
            m[x] = 2;
        }
        auto dp = make_v(t+2, n+1, 0.0L);
        dp[0][0] = 1;
        double ans = 0;
        for (int i = 0; i < t; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int k = 1; k <= 6; ++k) {
                    int to = min(n, j+k)-max(j+k-n, 0);
                    dp[i+1+(m[to] == 1)][to] += dp[i][j]/6;
                }
            }
            for (int j = 0; j < n; ++j) {
                if(m[j] == 2) {
                    dp[i+1][0] += dp[i+1][j];
                    dp[i+1][j] = 0;
                }
            }
        }
        for (int i = 0; i <= t; ++i) {
            ans += dp[i][n];
        }
        printf("%.6f\n", ans);
    }
    return 0;
}


Measured memory_bytes: 3268
import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int res = 0;
			int[] array = new int[m+1];
			for(int i = 0;i<n;i++) {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			}
			for(int score : array) {
				if(score==n) {
					res++;
				}
			}
			System.out.println(res);
			
			
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 22228
n=int(input())
alist=list(map(int,input().split()))
blist=list(map(int,input().split()))
clist=list(map(int,input().split()))

sum=0
bef=-2

for a in alist:
    sum += blist[a-1]
    if bef + 1 == a:
        sum += clist[bef-1]
    bef = a

print(sum)

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

int main() {
  vi a(5);
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  int ans = 1;
  rep(i,5){
    if(a[i] == 0){
      break;
    }
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
n,c,k= map(int,input().split())
t=sorted([int(input()) for i in range(n)])
cnt=1
lim=0
ti=t[0]
for i in range(n-1):
	lim+=1
	if ti+k<t[i+1] or lim==c:
		#print(t[i],cnt,lim)
		ti=t[i+1]
		cnt+=1
		lim=0

print(cnt)


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

#define prtd(d) printf("%d\n", d)
#define prts(s) printf("%s\n", s.c_str())
#define cout(s) cout << s << endl
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int combi(int n, int k);

int main(void) {

	int X, Y;
	cin >> X >> Y;

	int prize=0;
	if(X > 4 && Y>4){
		prtd(0);
		return 0;
	}
	if(X == 1){
		prize += 300000;

	}else if(X==2){
		prize +=200000;
	}else if(X==3){
		prize +=100000;
	}
	if(Y == 1){
		prize += 300000;

	}else if(Y==2){
		prize +=200000;
	}else if(Y==3){
		prize +=100000;
	}
	if(X == 1 && Y == 1){
		prize += 400000;
	}

	prtd(prize);

    return 0;
}

//nCkの計算関数
int combi(int n, int k){
	if(n == k || k == 0){
		return 1;
	}
	else{
		return combi(n-1, k-1) + combi(n-1, k);
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), sum(n+1);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }
    ll min_diff = 4e18;
    for(int i = 0; i < n; i++){
        if(min_diff > abs(sum[n]-2*sum[i])){
            min_diff = abs(sum[n]-2*sum[i]);
        }
    }
    cout << min_diff << endl;
    return 0;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define ull unsigned ll
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define iiii2 pair<int,iii>
#define lii pair<ll,ii>
#define lolo pair<ll,ll>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 998244353
#define inf 1000000001
#define N 100005
#define LOG 20
#define KOK 350
#define EPS 0.000000000001
#define pw(x) (1<<(x))
#define PI 3.1415926535
using namespace std;

int main() {

	#if 0

	freopen("input.txt","r",stdin);

	#endif

	int t;
	ll a,b,c,d;

	scanf("%d",&t);

	while(t--) {

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

		if(b>a || b>d) {

			printf("No\n");

			continue ;

		}

		if(b<=c+1) {

			printf("Yes\n");

			continue ;

		}

		ll gcd=__gcd(b,d);

		a%=b;

		b-=a;
		c-=a;

		b--;

		ll dv1=c/gcd;
		ll dv2=b/gcd;

		if(dv1!=dv2 || (b>=0 && c+1<=0)) printf("No\n");
		else printf("Yes\n");

	}

}

Measured memory_bytes: 256
#include <stdint.h>
#include <stdio.h>
#include <unordered_map>

int main() {
    int N;
    if (scanf("%d", &N) != 1) {
        return 1;
    }

    std::unordered_map<int64_t, uint64_t> M;
    uint64_t result = 0;
    int64_t offset = 0;
    while (N--) {
        int x;
        if (scanf("%d", &x) != 1) {
            return 1;
        }
        offset -= x;
        ++M[offset + x];
        auto it = M.find(offset);
        if (it != M.end()) {
            result += it->second;
        }
    }
    printf("%llu\n", (long long unsigned)result);
}


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

int main(){
    string S;
    cin >> S;
    vector<int> count(2*100000,0);
    string pre = "";
    string target = "";
    int _count =0;
    for(int i=0; i<S.size(); i++){
        target += S[i];
        if(i<4){
            if(target != pre){
                _count += 1;
                count[i] = _count;
                pre = target;
                target = "";
            }else{
                count[i] = _count;
            }
        }else{
            if(S[i] != S[i-1]){
                count[i] = count[i-1] + 1;
            }else{
                count[i] = count[i-3] + 2;
            }
        }

    }
    cout << count[S.size()-1] << endl;
    return 0;
}


Measured memory_bytes: 4692
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.Collection;
import java.util.Scanner;
import java.util.Set;
import java.util.Queue;
import java.util.ArrayDeque;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DarkRoom solver = new DarkRoom();
        solver.solve(1, in, out);
        out.close();
    }

    static class DarkRoom {
        int[] D;
        Set<Integer> Dset;
        int[][] v;
        int N;
        int M;
        int K;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            N = in.nextInt();
            M = in.nextInt();
            K = in.nextInt();
            D = new int[M];
            Dset = new HashSet<>();
            for (int i = 0; i < M; i++) {
                D[i] = in.nextInt() - 1;
                Dset.add(D[i]);
            }
            v = new int[N][K];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < K; j++) {
                    v[i][j] = in.nextInt() - 1;
                }
            }
            final int INF = (int) 1e9;
            int[] minDist = new int[1 << M];
            Arrays.fill(minDist, INF);
            minDist[(1 << M) - 1] = 0;
            Queue<Integer> que = new ArrayDeque<>();
            que.add((1 << M) - 1);
            while (!que.isEmpty()) {
                int now = que.poll();
                for (int i = 0; i < K; i++) {
                    int nxtBit = 0;
                    for (int j = 0; j < M; j++) {
                        if ((now & (1 << j)) != 0 && Dset.contains(v[D[j]][i])) {
                            for (int k = 0; k < M; k++)
                                if (v[D[j]][i] == D[k])
                                    nxtBit |= (1 << k);
                        }
                    }
                    if (minDist[now] + 1 < minDist[nxtBit]) {
                        minDist[nxtBit] = minDist[now] + 1;
                        que.add((nxtBit));
                    }
                }
            }
            out.println(minDist[0]);
        }

    }
}




Measured memory_bytes: 44904
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    ll p[100010], q[100010], r[100010];
    rep(i,0,A) cin >> p[i];
    rep(i,0,B) cin >> q[i];
    rep(i,0,C) cin >> r[i];
    sort(p, p+A);
    sort(q, q+B);
    sort(r, r+C);
    vector<lpair> lp;
    rep(i,0,A) lp.push_back({p[i], 1});
    rep(i,0,B) lp.push_back({q[i], 2});
    rep(i,0,C) lp.push_back({r[i], 3});
    sort(lp.begin(), lp.end(), greater<lpair>());
    ll ans = 0;
    ll c1 = 0, c2 = 0, c3 = 0;
    for(auto &e: lp){
        if(e.second == 1){
            if(c1 < X){
                c1++;
                ans += e.first;
            }
        }else if(e.second == 2){
            if(c2 < Y){
                c2++;
                ans += e.first;
            }
        }else{
            c3++;
            ans += e.first;
        }
        ll v1 = max(0LL, X - c1);
        ll v2 = max(0LL, Y - c2);
        if(v1 + v2 <= c3) break;
    }
    print(ans);
    

}

Measured memory_bytes: 12908
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  string s; cin >> s;
  int ans = 0;

  rep(i, 3) if (s[i] == '1') ++ans;
  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

ll gcd(ll x, ll y){
    //cout << "gcd now x = " << x << "y = " << y<< endl;
    return y ? gcd(y, x % y):x;
}

ll lcm(ll x, ll y){
    //cout << "lcm now" << endl;
    return x * y / gcd(x, y);
}

int main(void){
    for(int n; cin >> n, n;){
        vi d(n), v(n);
        rep(i, n) cin >> d[i] >> v[i];

        rep(i, n){
            int res = 1;
            COUNT(j, n - 1){
                int ind = (i + j) % n;
                res = lcm(res, v[i] * d[ind] / gcd(v[ind] * d[i], v[i] * d[ind]));
            }
            cout << res << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  if(n==1 and m>1)
  	cout<<n+((m*(m-1))/2)<<endl;
  else if(n>1 and m==1)
    cout<<((n*(n-1))/2)<<endl;
  else if(n==1 and m==1)
    cout<<0<<endl;
  else if(n==0 and m<2)
    cout<<0<<endl;
  else if(n>1 and m>1)
    cout<<((n*(n-1))/2)+((m*(m-1))/2)<<endl;
  else if(n==0 and m>1)
    cout<<((m*(m-1))/2)<<endl;
  else if(m==0 and n>1)
    cout<<((n*(n-1))/2)<<endl;
  return 0;
}

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

int main() {
    
   long int n,m,x;
   cin>>n>>m>>x;
   long int a[n][m];
   long int c[n];
   for(long int i=0;i<n;i++)
    {
        cin>>c[i];
        for(long int j=0;j<m;j++)
        cin>>a[i][j];
    }
    long int ans=1e9;
    for(long int i=0;i<(1<<n);i++)
    {
        long int d[m]={0};
        long int temp=0;
        for(long int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                temp+=c[j];
                for(long int k=0;k<m;k++)
                d[k]+=a[j][k];
            }
        }
        int kk=0;
        for(long int i=0;i<m;i++)
        if(d[i]>=x) kk++;
        if(kk==m)
        ans=min(ans,temp);
    }
    if(ans==1e9) ans=-1;
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  S[K-1] = S[K-1] - 'A' + 'a';
  cout << S << endl;
}


Measured memory_bytes: 3564
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int D = scn.nextInt();
		int N = scn.nextInt();
		System.out.println(N == 100?(long)Math.pow(100, D) * 101:(long)Math.pow(100, D) * N);
		scn.close();
	}
}


Measured memory_bytes: 21844
import itertools
N,M,Q=map(int,input().split())
q=[list(map(int,input().split())) for i in range(Q)]
point=0
for A in itertools.combinations_with_replacement(range(1,M+1),N):
    point=max(point,sum(d for a,b,c,d in q if A[b-1]-A[a-1]==c))
print(point)

Measured memory_bytes: 9104
//????¬????????????????????????§?????????, ??????????????????, ????°??????????????????¬.
//dp[i] = ??????i+1??\????????????????????´????????????i?????§???????°??????????, ??¨????????¨
//??????i?????§???????°??????????dp2[i] = min(dp[i], ???, dp[n])????????????
//dp2[i]????????????????¢???????????????? dp[i] = dp2[?§??????????i???????????????????§???????id???????°????] + d[i]????????????(i > s?????¨???)
//i ??? s?????¨??????, dp[i] = 0????????????
//?????£??????dp??¨???RMQ????????°????????????????????§?????£????????????????????´??°??????????????°?????????
//O(M + NlogN)

#include <iostream>
#include <algorithm>
using namespace std;

const int DEPTH = 17;
class SegTree {
	int d[1 << (DEPTH + 1)];
public:

	SegTree() { for (int i = 0; i < (1 << (DEPTH + 1)); i++) { d[i] = 1145141919; } }
	
	//?????????pos(??§0)?????????????????????x????????????
	void update(int pos, int x) {
		pos += (1 << DEPTH) - 1;
		d[pos] = x;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			d[pos] = min(d[pos * 2 + 1], d[pos * 2 + 2]);
		}
	}
	
	//?????????l, ???, r-1?????????????????????????°?????±???????.
	int getMin(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return 1145141919;
		if (l <= a && b <= r) return d[id];
		int u = getMin(l, r, a, a + (b - a) / 2, id * 2 + 1);
		int v = getMin(l, r, a + (b - a) / 2, b, id * 2 + 2);
		return min(u, v);
	}
};

int n, m, s, t;
int d[100000];
int minId[100000];
SegTree dp;

int main() {
	int i;
	
	cin >> n >> m >> s >> t; s--; t--;
	for (i = 0; i < n; i++) { cin >> d[i]; minId[i] = i; }
	for (i = 0; i < m; i++) {
		int a, b; cin >> a >> b; a--; b--;
		minId[b] = min(minId[b], a);
	}
	
	for (i = 0; i <= s; i++) {
		dp.update(i, 0);
	}
	for (i = s + 1; i < n; i++) {
		dp.update(i, dp.getMin(minId[i], n) + d[i]);
	}
	cout << dp.getMin(t, n) << endl;
	return 0;
}

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

class Dice {
  private:
    int *numbers;
  public:
    Dice(int *numbers) {
      this->numbers = numbers;
    }

    int getTop() {
      return numbers[0];
    }
    int getFront() {
      return numbers[1];
    }
    int getRight() {
      return numbers[2];
    }
    int getLeft() {
      return numbers[3];
    }
    int getBack() {
      return numbers[4];
    }
    int getBottom() {
      return numbers[5];
    }

    void roll(char direction) {
      switch (direction) {
        case 'N':
          rollToNorth();
          break;
        case 'S':
          rollToSouth();
          break;
        case 'E':
          rollToEast();
          break;
        case 'W':
          rollToWest();
          break;
      }
    }

    void rollToNorth() {
      swap(numbers[0], numbers[1]);
      swap(numbers[1], numbers[5]);
      swap(numbers[5], numbers[4]);
    }

    void rollToSouth() {
      swap(numbers[0], numbers[4]);
      swap(numbers[4], numbers[5]);
      swap(numbers[5], numbers[1]);
    }

    void rollToEast() {
      swap(numbers[0], numbers[3]);
      swap(numbers[3], numbers[5]);
      swap(numbers[5], numbers[2]);
    }

    void rollToWest() {
      swap(numbers[0], numbers[2]);
      swap(numbers[2], numbers[5]);
      swap(numbers[5], numbers[3]);
    }

    void turnRight() {
      swap(numbers[1], numbers[2]);
      swap(numbers[2], numbers[4]);
      swap(numbers[4], numbers[3]);
    }

    bool equals(Dice other) {
      return getTop() == other.getTop()
        && getFront() == other.getFront()
        && getRight() == other.getRight()
        && getLeft() == other.getLeft()
        && getBack() == other.getBack()
        && getBottom() == other.getBottom();
    }
};

int main() {
  int numbers1[6], numbers2[6];
  bool isSame = false;

  for (int i = 0; i < 6; i++) {
    cin >> numbers1[i];
  }
  for (int i = 0; i < 6; i++) {
    cin >> numbers2[i];
  }

  Dice dice1(numbers1);
  Dice dice2(numbers2);

  for (int i = 0; i < 6; i++) {
    if (dice1.equals(dice2)) isSame = true;
    if(i % 2 == 0) {
      dice1.rollToNorth();
    } else {
      dice1.rollToEast();
    }
    for (int i = 0; i < 4; i++) {
      if (dice1.equals(dice2)) isSame = true;
      dice1.turnRight();
    }
  }

  if (isSame == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
from collections import deque
 
n = int(input())
a = list(map(int, input().split()))
b = deque()

if(len(a) % 2 == 0):
  for i in range(n):
    if i % 2 != 0:
      b.appendleft(a[i])
    else:
      b.append(a[i])
else:
  for i in range(n):
    if i % 2 != 0:
      b.append(a[i])
    else:
      b.appendleft(a[i])

print(*b, sep=" ")

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

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

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c && a % 2 == 0) {
		cout << -1 << endl;
		return 0;
	} else {
		int count = 0;
		while (1) {
			if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
				cout << count << endl;
				return 0;
			} else {
				ll na = a;
				ll nb = b;
				ll nc = c;
				a = (nb + nc) / 2;
				b = (na + nc) / 2;
				c = (na + nb) / 2;
				na = a;
				nb = b;
				nc = c;
				count++;
			}
		}
	}
	return 0;
}



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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int H, W;
    cin >> H >> W;

    vector<vector<int>> c(10, vector<int>(10));
    rep(i, 10) {
        rep(j, 10) {
            int x;
            cin >> x;
            c[i][j] = x;
        }
    }

    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            int a;
            cin >> a;
            if (a == -1) continue;
            ans += c[a][1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256