akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	int tmp = a * b;
	if (tmp % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(void) {
	int n, x;
	int count = 0;

	cin >> n >> x;

	vector<int> m(n);

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

	sort(m.begin(), m.end());

	for (int i = 0; i < n; i++) {
		x -= m[i];
		count++;
	}

	count += x / m[0];

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int a=0,b=0;
	char d[4];
	cin>>d;
	if(d[0]=='0')
	{
		if(d[1]<=57&&d[1]>48)
		{
			a=1;
		}
	}
	if(d[0]=='1')
	{
		if(d[1]<=50&&d[1]>=48)
		{
			a=1;
		}
	}
	if(d[2]=='0')
	{
		if(d[3]<=57&&d[3]>48)
		{
			b=1;
		}
	}
	if(d[2]=='1')
	{
		if(d[3]<=50&&d[3]>=48)
		{
			b=1;
		}
	}
	if(a==1&&b==1)
	{
		cout<<"AMBIGUOUS";
	}
	else if(a==1&&b==0)
	{
		cout<<"MMYY";
	}
	else if(a==0&&b==1)
	{
		cout<<"YYMM";
	}
	else
	{
		cout<<"NA";
	}
	//cout<<a<<b<<d;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

flag = True

for i in range(len(a)):
    if a[i]%2 == 0:
        if a[i]%3!=0 and a[i]%5!=0:
            flag = False
            break

if flag:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3060
import sys
import math
#sys.stdin=open('input.txt','r')
#sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
n=ii1()
arr=iia()
dp=[0]*100005
for i in range(n):
    dp[arr[i]]+=1
q=ii1()
s=sum(arr)
for i in range(q):
    b,c=iia()
    s+=(dp[b]*(c-b))
    dp[c]+=dp[b]
    dp[b]=0
    print(s)




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

int main()
{
	char a[5];
	cin >> a;
	if (a[0] == a[1]&&a[1]==a[2] || a[1] == a[2]&&a[2]==a[3] || a[0] == a[1]&&a[1]== a[2]&&a[2] == a[3])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
 
public class Main {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt(); // Scanner has functions to read ints, longs, strings, chars, etc.
        int m = in.nextInt();
        in.nextLine();

        char[][] maze = new char[n][m];
        for (int i = 0; i < n; i++) {
            maze[i] = in.nextLine().toCharArray();
        }
        System.out.println(getMax(maze));
    }

    private static int getMax(char[][] maze) {
        int m = maze.length;
        int n = maze[0].length;
        int res = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (maze[i][j] == '.') {
                    res = Math.max(res, bfs(maze, i, j));
                }
            }
        }
        return res;
    }

    private static int bfs(char[][] maze, int i, int j) {
        int m = maze.length;
        int n = maze[0].length;
        int[] dx = {1, 0, -1, 0};
        int[] dy = {0, 1, 0, -1};
        Queue<int[]> q = new LinkedList<>();
        q.offer(new int[]{i, j});
        boolean[][] visited = new boolean[m][n];
        visited[i][j] = true;
        int res = 0;

        while (!q.isEmpty()) {
            int size = q.size();
            for (int k = 0; k < size; k++) {
                int[] cur = q.poll();
                for (int d = 0; d < 4; d++) {
                    int ni = cur[0] + dx[d];
                    int nj = cur[1] + dy[d];
                    if (ni >= 0 && ni < m && nj >= 0 && nj < n && !visited[ni][nj] && maze[ni][nj] == '.') {
                        q.offer(new int[]{ni, nj});
                        visited[ni][nj] = true;
                    }
                }
            }
            res++;
        }
        return res - 1;
    }

}


Measured memory_bytes: 31068
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	long N = Long.parseLong(scan.next());
	long M = Long.parseLong(scan.next());

	long count = 0;
	if(2*N >= M) count = M / 2;
	else {
	    count += N;
	    long rest = M - 2 * N;
	    count += rest / 4;
	}

	System.out.println(count);
	scan.close();
    }
}


Measured memory_bytes: 21844
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val t = readLine()!!.toInt()
    val e = readLine()!!.toInt()
    val r = readLine()!!.toInt()
    var a = 0

    for(i in 1..N){
        if(i > t){
            a += r
        }else{
            a += e
        }
    }
    println(a)
}


Measured memory_bytes: 33776
//https://atcoder.jp/contests/abc123/tasks/abc123_a

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>


using namespace std;

int main(){
	int a,b,c,d,e,k;
	string ans;
	cin>>a>>b>>c>>d>>e>>k;
	if(k>=(e-a)) ans="Yay!";
	else ans=":(";
	cout<<ans<<endl;
}






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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

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

	auto V=in(),E=in();
	ConnectNodeInfo connect(V);
	REP(i,E){
		int u=in(),v=in(),d=in();
		connect.AddDirectionalConnection(u,v,d);
	}

	ll minD = 1ll<<60;
	REP(n,V){
		int L=1<<V;
		vvll dp(L,vll(V,1ll<<60));
		dp[0][n] = 0;

		REP(i,L){
			REP(j,V){
				for(auto& x:connect[j]){
					// 今jにいて次x.firstに行く
					if((i|1<<x.first)!=i) chmin(dp[i | 1<<x.first][x.first],dp[i][j]+x.second);
				}
			}
		}
		minD = min(minD,dp[L-1][n]);
	}

	out(minD>=1ll<<60 ? -1 : minD);
	return 0;
}



Measured memory_bytes: 7852
/* Creator - Glitched */

#include "bits/stdc++.h"
using namespace std;

#define testcases ll t;cin>>t;while(t--)
#define queries ll q;cin>>q;while(q--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
bool prime(long long int x){

    for(long long int i = 2; i<=sqrt(x); i++){
        if(x%i==0)
            return false;
    }
    return true;
}

int main(){
  long long int x;
  cin>>x;

  while(prime(x)==false){
    x++;
  }
  cout<<x;
  cout<<endl;
}
  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int n, m; scanf("%d%d", &n, &m);
	dsu d(n);
	REP(i, m) {
		int a, b; scanf("%d%d", &a, &b);
		d.merge(a-1, b-1);
	}
	printf("%d\n", d.groups().size() - 1);
}


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

const int maxn = 105;
const ll INF = 1LL<<55;
int n; 

ll a[maxn];
vector<int> adj[maxn];

struct FF
{
    ll cap[maxn][maxn];
    bool visited[maxn], seen[maxn];
    ll source, sink;
    FF() {
        source = 0;
        sink = n + 1;
        //fill with zeros
        memset(cap,0,sizeof(cap));
        memset(visited,false,sizeof(visited));
        //add edges
        for (int i = 1; i <= n; i++) {
            if (a[i] <= 0) {
                cap[source][i] = -a[i];                    
            }
            else {
                cap[i][sink] = a[i];
            }
            for (int j: adj[i]) {
                cap[i][j] = INF;
            }
        }

        /*
        cout << '\n';
        for (ll i = 0; i <= sink; i++) {
            for (ll j = 0; j <= sink; j++) {
                cout << cap[i][j] << ' ';
            }
            cout << '\n';
        }
        */
    }

    ll dfs(ll i, ll bneck) {
        if (i == sink) {
            return bneck;
        }
        if (visited[i]) return 0;
        visited[i] = true;
        for (int j = 0; j <= sink; j++) {
            if (cap[i][j] > 0) {
                ll f = dfs(j,min(bneck,cap[i][j]));
                if (f > 0) {
                    //update, recurse upwards
                    cap[i][j] -= f;
                    cap[j][i] += f;
                    return f;
                }
            }
        }
        return 0;
    }

    ll getflow() {
        ll flow = 0;
        while (true) {
            memset(visited,false,sizeof(visited));
            ll f = dfs(source,INF);
            if (f == 0) break;
            flow += f;
        }
        return flow;
    }

    void findReachable(int i) {
        seen[i] = true;
        for (int j = 0; j <= sink; j++) {
            if (!seen[j] && cap[i][j] > 0) {
                findReachable(j);
            }
        }
    }
};

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] > 0) sum += a[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 2*i; j <= n; j += i) {
            adj[i].push_back(j);
            //adj[j].push_back(i);
        }
    }
    FF graph = FF();
    ll flow = graph.getflow();
    /*
    graph.findReachable(graph.source);
    ll r = 0;
    for (int i = 1; i <= n; i++) {
        if (graph.seen[i]) {
            r += a[i];
            //cout << i << ' ' << a[i] << '\n';
        }
    }
    cout << r << '\n';
    */
    //flow = min(0LL,flow);
    //cout << flow << '\n';
    cout << (sum-flow) << '\n';
}



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

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

int main()
{
    string s;
    cin >> s;
    cout << ((s[2]==s[3]) && (s[4]==s[5]) ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a + b > c + d) {
    cout << "Left" << endl;
  }
  else if (a + b == c + d) {
    cout << "Balanced" << endl;
  }
  else if (a + b < c + d) {
    cout << "Right" << endl;
  }
    
}


Measured memory_bytes: 256
p,q= input().split()
a,b =(int(p), int(q))
ans_list = []
for i in range(a):
    c = input().split()
    if int(c[1]) <= b:
        ans_list.append(int(c[0]))

if len(ans_list) is not 0:
    print(min(ans_list))
else:
    print('TLE')

Measured memory_bytes: 3060
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100000
#define MAX 100

int prim(void);

int A[MAX][MAX]={0},color[MAX],d[MAX],p[MAX];
int a,i,j,n,m,min;

int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
      if(A[i][j] == -1){
	A[i][j] = N;
      }
      
    }
  } 
  printf("%d\n",prim());
  
  return 0;
}


int prim(){
  int i,m,y=0,k;
  
  for(i=0;i<n;i++){
    color[i] = WHITE;
    p[i] = -1;
    d[i] = N;
  }
  d[0] = 0;
  
  while(1){
    min = N;
    m = -1;
    for(i=0;i<n;i++){
      if(min > d[i] && color[i] != BLACK){
	m = i;
	min = d[i];
      }
    }
    if(m == -1) break;
    color[m] = BLACK;

    for(k=0;k<n;k++){
      if(color[k] != BLACK && A[m][k] != N){
	if(d[k] > A[m][k]){
	  d[k] = A[m][k];
	  p[k] = m;
	  color[k] = GRAY;
	}
      }
    }
    
  }

  for(i=0;i<n;i++){
    if(p[i] != -1){
      y += A[i][p[i]];
    } 
  }
  return y;  
}



Measured memory_bytes: 2052
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S, T;
  cin >> S >> T;
  if(S+T[T.size()-1]==T){
    cout << "Yes";
  }else{
    cout << "No";
  }

  return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int main()
{
	ios::sync_with_stdio(false);
	string a,b;
	int la,lb;
	cin>>a>>b;
	la=a.size();
	lb=b.size();
	for(register int i=0;i<lb;i++)
	{
		putchar(a[i]);
		putchar(b[i]);
	}
	if(la>lb) putchar(a[la-1]);
	puts("");
    return 0;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d %d %d %d" (fun x1 y1 x2 y2 ->
      let (x3, y3, x4, y4) = 
      match (x1, y1, x2, y2) with
      | (x1, y1, x2, y2) when (x1 <= x2 && y2 >= y1) ->
       (x2 - (y2 - y1), y2 + (x2 - x1), x1 - (y2 - y1), y1 + (x2 - x1))
      | (x1, y1, x2, y2) when (x1 <= x2)-> 
      (x2 + (y1 - y2), y2 + (x2 - x1), x1 + (y1 - y2), y1 + (x2 - x1))
      | (x1, y1, x2, y2) when (y2 >= y1)->  
      (x2 - (y2 - y1),y2 - (x1 - x2), x1 - (y2 - y1) ,y1 - (x1 - x2))
      | _ -> 
      (x2 + (y1 - y2), y2 - (x1 - x2), x1 + (y1 - y2), y1  - (x1 - x2))
      in
      Printf.printf "%d %d %d %d" x3 y3 x4 y4)

Measured memory_bytes: 384
D, G = (int(i) for i in input().split())  
PC = [[int(i) for i in input().split()] for i in range(D)] 

s = 0
Q = []
for i, (p, c) in enumerate(PC):
    s += p
    Q.append((i+1, p, c))
    
dp = [-10**18]*(s+1)
dp[0] = 0

for i, p, c in Q:
  for j in range(s, -1, -1): # 解きうる問題総数をイテレート
    for k in range(1, p+1): # 解く問題数をイテレート
      if k == p:
        cc = 100*i*k + c
      else:
        cc = 100*i*k
      if j - k >= 0:
        dp[j] = max(dp[j], dp[j - k] + cc)

for i, total in enumerate(dp):
  if total >= G:
    print(i)
    break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    int sum = 0,j = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(abs(A[i]) > sum) {
            j = i;
            sum = abs(A[i]);
        }
    }
    cout << 2*N << endl;
    if(A[j] < 0) {
        cout << j+1 << " " << N << endl;
        cout << j+1 << " " << N << endl;
        for(int i = N; i >= 2; i--) {
            cout << i << " " << i-1 << endl;
            cout << i << " " << i-1 << endl;
        }
    }
    else {
        cout << j+1 << " " << 1 << endl;
        cout << j+1 << " " << 1 << endl;
        for(int i = 1; i <= N-1; i++) {
            cout << i << " " << i+1 << endl;
            cout << i << " " << i+1 << endl;
        }
    }
}

Measured memory_bytes: 3608
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    s = get_lc()
    if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
        print("Bad")
    else:
        print("Good")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


Measured memory_bytes: 65728
using Yorukatsu052.Questions;
using Yorukatsu052.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu052.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine().ToList();
            s.Sort();
            yield return s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ? "Yes" : "No";
        }
    }
}


namespace Yorukatsu052
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu052.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu052.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13268
n = int(input())
ans = ""
S1 = input()
alp = {}

if n == 1:
    for x in sorted(S1):
        ans += x
    print(ans)   
else:
    for x in S1:
        if x not in alp.keys():
            alp[x] = 1
        else:
            alp[x] += 1
    for i in range(n-1):
        S = input()
        empty = []
        for x in alp.keys():
            n = S.count(x)
            if n == 0:
                empty.append(x)
            elif n < alp[x]:
                alp[x] = n
        for x in empty:
            del alp[x]
    for x in sorted(alp.keys()):
        for i in range(alp[x]):
            ans += x
    print(ans)

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

double d;

int main(){
  cin >> d;
  cout << fixed << setprecision(10) << (d/3)*(d/3)*(d/3) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define pai 3.141592653589793238462643383279

int main(){
  int N; cin >> N; int cnt = 0; string S; cin >> S;
  rep(i, N){
    if(S[i]=='R') cnt++;
  }
  int ans = 0;
  rep(i, N){
    if(i<cnt && S[i]!='R') ans++;
    if(i>=cnt && S[i]!='W') ans++;
  }
  cout << ans/2 << endl;
}



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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int n = 0;
  cin >> n;
  pr(pow(n, 3));
  return 0;
}


Measured memory_bytes: 4268
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();

            if(a==0 && b==0)
                break;

            for(int i = 0;i<a;i++){
                for(int j = 0;j<b;j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



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

using namespace std;

int dp[100001];

vector<vector<int>> adj;

void dfs(int v, int u) 
{
	if (dp[v]) return;
	for (const auto& el : adj[v])
	{
		dfs(el, v);
		dp[v] = max(dp[v], dp[el] + 1);
	}
}


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

	adj.resize(n+1);
	while (m--)
	{
		int x, y; cin >> x >> y;
		adj[x].push_back(y);
	}

	for (auto i = 1; i <= n; i++)
		dfs(i, 0);

	cout << *max_element(begin(dp), end(dp)) << endl;
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	/*input*/
	int a, b;	cin >> a >> b;
	/*calculation*/
	int ans = 0;
	ans = max(a+b, max(a-b, a*b));
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

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

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,w;
    cin>>n>>w;
    vector<int> v(n),h(n);
    rep(i,n) cin>>v[i]>>h[i];
    vector<vector<int>> dp(n+1,vector<int>(w+1,-1));//dp[i][j]i made,omosa j no kati
    dp[0][0]=0;
    rep(i,n){
        rep(j,w+1){
            chmax(dp[i+1][j],dp[i][j]);
            if(j+h[i]>=w+1) continue;
            chmax(dp[i+1][j+h[i]],dp[i][j]+v[i]);
        }
    }
    int ans=-1;
    for(int i=w;i>=0;i--) chmax(ans,dp[n][i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 6680
re=0
tle=0
wa=0
ac=0
ip=[]
n=int(input())
for i in range(n):
  ip.append(input())
for i in range(n):
  if ip[i]=="AC":
    ac=ac+1
  if ip[i]=="TLE":
    tle=tle+1
  if ip[i]=="WA":
    wa=wa+1
  if ip[i]=="RE":
    re=re+1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

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

int main(){
   long long n, k;
   cin >> n >> k;
   long long h[n], i, sum=0;
   for(i=0; i<n; i++){
      cin>>h[i];
      sum=sum+h[i];
   }
   sort(h, h+n);
   if(n<=k){
      cout<<"0"<<endl;
      return 0;
   }
   for(i=n-1; i>=n-k; i--){
      sum=sum-h[i];
   }
   cout<<sum<<endl;
}

Measured memory_bytes: 1792
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(n);
	vvi d(10, vi(10)); // num[i][j]== cnt of numbers start with i and end with j

	for (int i = 1; i <= n; i++) {
		int r = i % 10;
		if (r > 0) {
			int k = i;
			while (k >= 10)
				k /= 10;

			d[k][r]++;
		}
	}

	ll ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ans += d[i][j] * d[j][i];
		}
	}
	cout << ans << endl;

}

int main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	solve();
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>


using namespace std;
typedef long long ll;

ll a[100005];
int main()
{
    ll n,i,sum=0,k=0;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+n+1);
    for(i=1;i<n;i++)
    {
        sum+=a[i];
        if(sum*2<a[i+1])
        {
            k=i;
        }
    }
    printf("%lld\n",n-k);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    ll n;
    cin >> n;
    ll ans = 10e5;
    for (ll i = 1; i < n; i++){
        ll a, b;
        a = i;
        b = n - i;
        ll suma = 0, sumb = 0;
        while (a > 0){
            suma += a % 10;
            a /= 10;
        }
        while(b > 0){
            sumb += b % 10;
            b /= 10;
        }
        //cout << suma << sumb << endl;
        ans = min(ans, suma + sumb);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
//string s[1e5+5];
int main()
{
    int n;
    string s;
    int ans_AC = 0,ans_WA = 0,ans_TLE = 0,ans_RE = 0;
    cin>>n;
    while(n--){
        cin>>s;
        if(s == "AC")
            ans_AC++;
        else if(s == "WA")
            ans_WA++;
        else if(s == "TLE")
            ans_TLE++;
        else if(s == "RE")
            ans_RE++;
    }
    cout<<"AC x "<<ans_AC<<endl;
    cout<<"WA x "<<ans_WA<<endl;
    cout<<"TLE x "<<ans_TLE<<endl;
    cout<<"RE x "<<ans_RE<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
  int N,T,c,t;
  int min=2000;
  
  scanf("%d %d",&N,&T);
  for(int i=0;i<N;i++){
    scanf("%d %d",&c,&t);
    if(t<=T && c<min)
      min = c;
  }

  if(min==2000)
    printf("TLE\n");
  else
    printf("%d\n",min);	 
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N, M, C; cin >> N >> M >> C;
    ll ok = 0;
    vector<ll> B(M); for (int i = 0; i < M; ++i) cin >> B[i];
    for (int i = 0; i < N; ++i) {
        ll sum = C;
        for (int j = 0; j < M; ++j) {
            ll tmp; cin >> tmp;
            sum += tmp * B[j];
        }
        if (sum > 0) ok++;
    }
    cout << ok << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  if(n>=1000){
    cout<<"ABD"<<"\n";
  }
  else{
    cout<<"ABC"<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3640
N,K=map(int,input().split())
A=list(map(int,input().split()))
ischecked=[0]*N
move=[]
move1=[]
now=0
count=0
count1=0
while 1:
    move.append(now+1)
    nex=A[now]-1
    ischecked[now]=1
    if ischecked[nex]==1:
        roop=nex+1
        break
    now=nex
for i in range(len(move))[::-1]:
    move1.append(move[i])
    if move[i]==roop:
        b=len(move)-i
        break
if K>=len(move):
    n=K-len(move)
    n=n%len(move1)
    print(move1[len(move1)-1-n])
else:
    print(move[K])

Measured memory_bytes: 32248
def t1():
    ll=list(map(int,input().split()))
    K=ll[-1]
    S=[1,0,-1]
    wa=0
    
    if K>ll[0]:
        wa+=ll[0]
        K-=ll[0]
        if K>ll[1]:
            K-=ll[1]
            wa-=K
        else:
            pass
    else:
        wa+=K
    

    print(wa)
        
            

      
if __name__ == '__main__':
    t1()
    

Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {


    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();//n?????????A?????????
		int m = scan.nextInt();//m?????????A????¨??????¨??????B?????????
		int l = scan.nextInt();//l?????????B????¨????
		
		int retu_a[][] = new int[n][m];//??????A
		int retu_b[][] = new int[m][l];//??????B
		long retu_c[][] = new long[n][l];//??????C
		
		//??????A???????????????????´?
		for (int cnt_n = 0; cnt_n < n; cnt_n++){
			for (int cnt_m = 0; cnt_m < m; cnt_m++) {
				retu_a[cnt_n][cnt_m] = scan.nextInt();
			}
		}
		//??????B???????????????????´?
		for (int cnt_m = 0; cnt_m < m; cnt_m++){
			for (int cnt_l = 0; cnt_l < l; cnt_l++) {
				retu_b[cnt_m][cnt_l] = scan.nextInt();
			}
		}
		//??????C????¨??????¨????´?
		for (int cnt_n = 0; cnt_n < n; cnt_n++){
			for (int cnt_l = 0; cnt_l < l; cnt_l++){
				for (int cnt_m = 0; cnt_m < m; cnt_m++) {
					retu_c[cnt_n][cnt_l] += retu_a[cnt_n][cnt_m] * retu_b[cnt_m][cnt_l];
				}
				System.out.print(retu_c[cnt_n][cnt_l]);
				//?????????????´???§???????????°?????????????????\??????
				if(cnt_l != l - 1)
					System.out.print(" ");
			}
			System.out.print("\n");
		}
		//????§????
		scan.close();
	}
}

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

//#define INF 100000000
//#define MOD (int) (1e9+7)
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 1000000;
const int MOD = 100000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    long long int r, c, a1, a2, b1, b2;
    cin >> r >> c >> a1 >> a2 >> b1 >> b2;

    long long int m = min(abs(b1 - a1), r - abs(b1 - a1));
    long long int n = min(abs(b2 - a2), c - abs(b2 - a2));

    // 前処理
    COMinit();

    long long int ans = COM(m+n, m);

    if (r == m*2) {
        ans = 2 * ans % MOD;
    }
    if (c == n*2) {
        ans = 2 * ans % MOD;
    }

    cout << ans << endl;

}


Measured memory_bytes: 26536
N,M = map(int,input().split())
AB = list(list(map(int,input().split()))for i in range(M))
AB.reverse()
node = [[i,[i]]for i in range(N)]
ans = [(N*(N-1))//2]
for a,b in AB:
    a,b = min(node[a-1][0],node[b-1][0]),max(node[a-1][0],node[b-1][0])
    if a != b:
        ans.append(ans[-1]-len(node[a][1])*len(node[b][1]))
        for i in node[b][1]:
            node[i][0] = a
            node[i][1] = [i]
            node[a][1].append(i)
    else:
        ans.append(ans[-1])
ans.reverse()

for i in ans[1:]:
    print(i)


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

using namespace std;

string s, t;
vector<string> cand;

int main(void)
{
	cin >> s >> t;
	
	if(s.size() < t.size()){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	
	for(int i = 0; i <= s.size() - t.size(); i++){
		for(int j = 0; j < t.size(); j++){
			if(s[i+j] != '?' && t[j] != '?' && s[i+j] != t[j]) goto NG;
		}
		cand.push_back(s);
		for(int j = 0; j < t.size(); j++) cand.back()[i+j] = t[j];
		for(int j = 0; j < s.size(); j++){
			if(cand.back()[j] == '?') cand.back()[j] = 'a';
		}
		NG:;
	}
	if(cand.size() == 0){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	
	sort(cand.begin(), cand.end());
	cout << cand[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
	int n;
	std::cin >> n;
	int ans=0;
	for (int i = 0; i < n; ++i){
		int a;
		std::cin >> a;
		bool f = true;
		for (int j = 2; j*j <= a; ++j){
			if (a%j == 0)f = false;
		}
		if (f)ans++;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m int
	var k int64
	fmt.Fscan(r, &n, &m, &k)
	a := make([]int64, n+1)
	b := make([]int64, m+1)
	for i := 0; i < n; i++ {
		var tmp int64
		fmt.Fscan(r, &tmp)
		a[i+1] = a[i] + tmp
	}
	for i := 0; i < m; i++ {
		var tmp int64
		fmt.Fscan(r, &tmp)
		b[i+1] = b[i] + tmp
	}
	var ans int
	j := m
	for i := 0; i <= n; i++ {
		if a[i] > k {
			break
		}
		for a[i]+b[j] > k {
			j--
		}
		if i+j > ans {
			ans = i + j
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
#define MAX_N 10
int main() {
	char s[MAX_N+1]; cin >> s;
	int ans = 0;
	for (int i = 0; i < strlen(s); i++) {
		for (int j = strlen(s)-1; j >= i; j--) {
			for (int k = i; k <= j; k++) {
				if (s[k] != 'A' && s[k] != 'C'
				    && s[k] != 'G' && s[k] != 'T') break;
				if (k == j) ans = max(ans, j-i+1);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P>  PP;
typedef pair<int,PP> PPP;
int n;
int a;
int main()
{
    cin>>n;
    if(n%2==0)a=n/2;
    else a=n/2+1;
    cout<<(double)a/(double)n<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <cstdio>

using namespace std;

int main() {
	int H, W, N, a[10000] = {}, i, j, point = 0, level = 1, b[100][100] = {};

	scanf("%d %d", &H, &W);
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0; i < H; i++) {
		if (i % 2 == 0) {
			for (j = 0; j < W; j++) {
				if (a[point] >= 1) {
					b[i][j] = level;
					a[point]--;
				}
				else {
					level++;
					point++;
					b[i][j] = level;
					a[point]--;
				}
			}
		}
		else {
			for (j = W - 1; j >= 0; j--) {
				if (a[point] >= 1) {
					b[i][j] = level;
					a[point]--;
				}
				else {
					level++;
					point++;
					b[i][j] = level;
					a[point]--;
				}
			}
		}
	}

	for (i = 0; i < H; i++) {
		for (j = 0; j < W - 1; j++) {
			printf("%d ", b[i][j]);
		}
		printf("%d\n", b[i][j]);
	}

	return 0;
}

Measured memory_bytes: 256
import sys

n, m = input().strip().split(" ")
n = int(n) ;m = int(m)

c = n

a = []
for line in sys.stdin :
    a.append(line)
    c -= 1
    if c == 0 :
        break

c = m

b = []
for line in sys.stdin :
    b.append(line)
    c -= 1
    if c == 0 :
        break

for i in range(0, len(a)) :
    a[i] = a[i].strip().split(" ")
    for j in range(0, len(a[i])) :
        a[i][j] = int(a[i][j])

for i in range(0, len(b)) :
    b[i] = int(b[i].strip())

for i in range(0, n) :
    sum = 0
    for j in range(0, m) :
        sum += a[i][j]*b[j]
    print(sum)



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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

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

    int n;
    cin >> n;
    cout << n + n * n + n * n * n << '\n';
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(){
	int a = 0;
	int b;
	int c;
	int d;
	scanf("%d", &a);
	b = a/3600;
	c = (a%3600)/60;
	d = (a%3600)%60;
	printf("%d:%d:%d\n", b, c, d);
	return 0;
}

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

using namespace std;
 
long long w[200], v[200], MaxSum[200][200000];
int N;
long long W;

int main() {	
	scanf("%d %llu", &N, &W);
	for (int i = 1; i <= N; i++) {
		scanf("%llu %llu", &w[i], &v[i]);
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			MaxSum[i][j] = MaxSum[i - 1][j];
			if (j >= w[i]) {
				MaxSum[i][j] = max(MaxSum[i][j], MaxSum[i - 1][j - w[i]] + v[i]);
			}
		}
	}
	printf("%llu", MaxSum[N][W]);
}

Measured memory_bytes: 156416
#B
n = int(input())

sp = [list(input().split()) for i in range(n)]
for i in range(n):
    sp[i].append(i + 1)
# print(sp)
sspp = sorted(sp, key=lambda x: int(x[1]), reverse=True)
sspp.sort(key=lambda x: x[0])
for i in range(n):
    print(sspp[i][2])

Measured memory_bytes: 3060
def find_sum_of_digits(n):
  sum = 0
  while(n>0):
    sum += n%10
    n = int(n/10)
  return sum

n, a, b = map(int, input().split())
count = 0

for i in range(1, n+1):
  x = find_sum_of_digits(i)
  if x >= a and x <= b:
    count += i
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	string s;cin >> s;
	int k=-1,l=-1;
	rep(i,n){
		if(s.at(i)=='#'){
			k=i;
			break;
		}
	}
	rep(i,n){
		if(s.at(n-1-i)=='.'){
			l=n-1-i;
			break;
		}
	}
	if(k==-1 || l==-1 || l<k){
		cout << 0 << endl;
		return 0;
	}
	int ans=20000000,cnt=0;
	vector<int> cnt1,cnt2;
	cnt1.pb(0);
	cnt2.pb(0);
	for(int i=k;i<=l;++i){
		if(s.at(i)=='#') cnt++;
		else{
			if(cnt) cnt1.pb(cnt);
			cnt=0;
		}
	}
	if(cnt) cnt1.pb(cnt);
	cnt=0;
	for(int i=k;i<=l;++i){
		if(s.at(i)=='.') cnt++;
		else{
			if(cnt) cnt2.pb(cnt);
			cnt=0;
		}
	}
	if(cnt) cnt2.pb(cnt);
	rep(i,cnt1.size()-1){
		cnt1.at(i+1)+=cnt1.at(i);
		cnt2.at(i+1)+=cnt2.at(i);
	}
	rep(i,cnt1.size()){
		ans=min(ans,cnt1.at(i)+(cnt2.at((int)cnt1.size()-1)-cnt2.at(i)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1680
i=map
n,m=i(int,input().split())
a,b=set(i(int,input().split())),set(i(int,input().split()))
c=1;N=M=0
for k in range(m*n,0,-1):
 A=k in a;B=k in b
 if A and B:N+=1;M+=1
 elif A:c*=M;N+=1
 elif B:c*=N;M+=1
 else:c*=M*N-m*n+k
 c%=10**9+7
print(c)

Measured memory_bytes: 3188
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e6+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
   
    ll a,b,c;
    string s;
    cin>>a>>b;
    if(a!=1 && b!=1)
    	cout<<1<<'\n';
    else if(a!=2 && b!=2)
    	cout<<2;
    else
    	cout<<3;
    
    return 0;
}

Measured memory_bytes: 256