akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>


class prime
{
public:
    static void calc_prime() {//??????????´???°?????????????±????????????????
        
        numbers.at(0) = false;//??????????´???°??§???????????§false;
        for (int i = 1; i < max_prime; i++) {//????????¶true??§?????????
            numbers.at(i) = true;
        }
        
        for (int i = 2; i <= max_prime; i++) {
            if (numbers.at(i - 1) == true) {//??????i????´???°?????£??????
                static int prime_found = 0;
                prime_numbers.at(prime_found) = i;//?´???°?????§????????????
                prime_found++;
                
                for(int baisu = i; baisu <= max_prime; baisu +=i) {//?????°????±???????
                    numbers.at(baisu - 1) = false;//false????????????
                }
            }
        }
        
    }
    
    static int get_prime(int n) {
        return prime_numbers.at(n-1);
    }
    
private:
    static const int max_prime = 104729;
    static std::array<int, 104729> numbers;//.at(i)??????i+1?????\????????????
    static std::array<int, 10000> prime_numbers;//.at(i)??????i+1??????????´???°?????\????????????
};
std::array<int, 104729> prime::numbers;
std::array<int, 10000> prime::prime_numbers;
int main()
{
    int input;
    std::cin >> input;
    
    prime::calc_prime();//?????????
    
    while(input !=0) {
        int sum = 0;
        for (int i = 1; i <= input; i++) {
            sum += prime::get_prime(i);
        }
        std::cout << sum << std::endl;
        std::cin >> input;
    }
}

Measured memory_bytes: 1608
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int,readline().rstrip().decode()))

minimal_sets = []
for n in range(1<<N):
    s = n
    is_min = (A[n] == 0)
    while s:
        s = (s - 1) & n
        if A[n] == 1 and A[s] == 0:
            print('Impossible')
            exit()
        if A[s] == 0:
            is_min = False
    if is_min:
        minimal_sets.append(n)

def make(nums, x):
    if not nums:
        return [(x,0)]
    path = []
    if len(nums) == 1:
        n = nums[0]
        for i in range(x, n+1):
            path.append((i,0))
        path += [(n+1,0),(n+1,1),(n,1),(n,0)]
        for i in range(n-1,x-1,-1):
            path.append((i,0))
        return path
    n = nums[0]
    for i in range(x, n+1):
        path.append((i,0))
    P = make(nums[1:], n+1)
    path += P
    path += [(n,0), (n,1), (n+1,1), (n+1, 0)]
    path += P[::-1][1:]
    path += [(n+1,1), (n,1), (n,0)]
    for i in range(n-1,x-1,-1):
        path += [(i,0)]
    return path

path = [(0,0)]
for n in minimal_sets:
    path += make([i for i in range(N) if n & (1<<i)], 0)[1:]

print('Possible')
print(len(path) - 1)
print('\n'.join('{} {}'.format(x,y) for x,y in path))

Measured memory_bytes: 4084
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int a = nextInt(), b = nextInt();

        System.out.println(Math.max(a + b, Math.max(a - b, a * b)));
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N;
	cin >> N;
	vector<long long> ANS;
	for (long long i = 2; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (i * i != N) ANS.push_back(N / i);
		}
		else if ((N - 1) % i == 0) {
			ANS.push_back(i);
			if (i * i + 1 != N) ANS.push_back((N - 1) / i);
		}
	}
	ANS.push_back(N - 1);
	ANS.push_back(N);
	sort(ANS.begin(), ANS.end());
	ANS.erase(unique(ANS.begin(), ANS.end()), ANS.end());
	long long COUNT = 0;
	for (int i = 0; i < ANS.size(); i++) {
		if (ANS[i] == 1) continue;
		long long NOW = N;
		while (NOW % ANS[i] == 0) NOW /= ANS[i];
		if (NOW % ANS[i] == 1) COUNT++;
	}
	cout << COUNT << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;


#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define write(x) printf("%d\n",x)



int n, m, cnt, ans, flag = 1, a[100001];
vector<int>v[100001];

void dfs(int u, int fa)
{
	for (auto i : v[u])
	{
		if (i == fa)continue;
		if (a[i] == -1)
		{
			a[i] = (a[u] ^ 1);
			dfs(i, u);
		}
		else
		{
			if (a[i] == a[u])flag = 0;
		}
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i<m; i++)
	{
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	memset(a, -1, sizeof(a));
	a[1] = 0;
	dfs(1, 0);
	if (flag)
	{
		for (int i = 1; i <= n; i++)if (a[i])cnt++;
		cout << 1ll * cnt*(n - cnt) - m;
	}
	else
	{
		cout << 1ll * n*(n - 1) / 2 - m;
	}
	return 0;
}

Measured memory_bytes: 6912
import java.util.*;

public class Main{
    int N,M,L,K,A,H;
    long[][] d;
    List<String> f;

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

    void solve(){
	Scanner sc = new Scanner(System.in);
	N = sc.nextInt();
	while(N!=0){
	    M = sc.nextInt();
	    L = sc.nextInt();
	    K = sc.nextInt();
	    A = sc.nextInt();
	    H = sc.nextInt();
	    f = new ArrayList<String>();
	    for(int i=0; i<L; i++){
		f.add(sc.nextInt()+"");
	    }
	    f.add(A+"");
	    f.add(H+"");
	    
	    d = new long[N][N];
	    for(int i=0; i<N; i++){Arrays.fill(d[i],Integer.MAX_VALUE);}
	    for(int i=0; i<K; i++){
		int x = sc.nextInt();
		int y = sc.nextInt();
		int t = sc.nextInt();
		d[y][x] = t;
		d[x][y] = t;
	    }

	    for(int i=0; i<N; i++)d[i][i] = 0;

	    warshall_floyd();

	    for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
		    if(d[i][j]>M || !(f.contains(i+"") && f.contains(j+""))){
			d[i][j] = Integer.MAX_VALUE;
		    }
		}
	    }

	    warshall_floyd();

	    if(d[A][H]==Integer.MAX_VALUE){
		System.out.println("Help!");
	    }else{
		System.out.println(d[A][H]+Math.max(0,d[A][H]-M));
	    }

	    N = sc.nextInt();
	}
    }

    void warshall_floyd(){
	for(int k=0; k<N; k++)
	    for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)d[i][j] = Math.min(d[i][j],d[i][k]+d[k][j]);
    }
}
	    

Measured memory_bytes: 16000
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int r,c,n,x,y,ans[200][200];

int main(void)
{
    scanf("%d%d%d",&r,&c,&n);
    x=1,y=1;
    for(int i=1,cnt;i<=n;i++){
        scanf("%d",&cnt);
        while(cnt--){
            ans[x][y]=i;
            if(y==c&&x%2==1)
                y=c,x++;
            else if(y==1&&x%2==0)
                y=1,x++;
            else if(x&1)
                y++;
            else
                y--;
        }
    }
    for(int i=1;i<=r;i++)
    for(int j=1;j<=c;j++)
        printf("%d%c",ans[i][j],j==c?'\n':' ');
    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

x, y = list(map(int  , input().split()))

if y > 4*x :
    print("No")
elif y < 2*x :
    print("No")
else :
    if (y-2*x)%2 !=0 :
        print("No")
    elif (4*x - y)%2 != 0 :
        print("No")
    else :
        print("Yes")


                    
                
                
            
                
                                   
                    
                    
               

                
            
            
        








        
                
                  
                
            
            
    
    
        


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

vector<int> tsort(vector<vector<int>> g) {
  int n = g.size();
  vector<int> ret;

  vector<int> in(n, 0);
  for (int i=0; i<n; i++) {
    for (auto v : g[i]) in[v]++;
  }

  queue<int> que;
  for (int i=0; i<n; i++) {
    if (in[i] == 0) que.push(i);
  }

  while (!que.empty()) {
    int v = que.front(); que.pop();
    for (auto u : g[v]) {
      in[u] -= 1;
      if (in[u] == 0) que.push(u);
    }
    ret.push_back(v);
  }

  return ret;
}

int main()
{
  int n,e; cin>>n>>e;
  vector<vector<int>> g(n);
  rep(i, e) {
    int u,v; cin>>u>>v;
    g[u].push_back(v);
  }
  vector<int> sv = tsort(g);
  for (auto v : sv) cout << v << endl;

  return 0;
}



Measured memory_bytes: 4112
class MaxFlowDinic:
    class edge:
        def __init__(self, to, rev, cap):
            self.to, self.rev, self.cap = to, rev, cap

    def __init__(self, v):
        self.V = v
        self.G = [[] for i in xrange(self.V)]

    def add(self, frm, to, cap):
        self.G[frm].append(self.edge(to, len(self.G[to]), cap))
        self.G[to].append(self.edge(frm, len(self.G[frm]) - 1, 0))

    def add_dual(self, frm, to, cap):
        self.G[frm].append(self.edge(to, len(self.G[to]), cap))
        self.G[to].append(self.edge(frm, len(self.G[frm]) - 1, cap))

    def bfs(self, s):
        self.level = [-1] * self.V
        self.level[s] = 0
        que = []
        que.append(s)
        while (que):
            v = que.pop(0)
            for i in xrange(len(self.G[v])):
                e = self.G[v][i];
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[v] + 1;
                    que.append(e.to)


    def dfs(self, v, t, f):
        if v == t: return f
        for i in xrange(self.itr[v], len(self.G[v])):
            self.itr[v] = i
            e = self.G[v][i]
            if e.cap > 0 and self.level[v] < self.level[e.to]:
                d = self.dfs(e.to, t, min(f, e.cap))
                if d > 0:
                    e.cap -= d
                    self.G[e.to][e.rev].cap += d
                    return d
        return 0

    def max_flow(self, s, t):
        inf = float("inf")
        flow = 0
        while 1:
            self.bfs(s)
            if self.level[t] < 0: return flow

            self.itr = [0] * self.V
            f = self.dfs(s, t, inf)
            while f > 0:
                flow += f
                f = self.dfs(s, t, inf)

V, E = map(int, raw_input().split())
mf = MaxFlowDinic(V)
for i in xrange(E):
    u, v, c = map(int, raw_input().split())
    mf.add(u, v, c)
print mf.max_flow(0, V - 1)

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  ll N,M; cin>>N>>M;
  vector<ll> A(N); rep(i,N)cin>>A.at(i);
  sort(begin(A),end(A));
  vector<pair<ll,ll>> Q;
  rep(i,M){
    ll b,c; cin>>b>>c;
    Q.push_back(make_pair(c,b));
  }
  sort(begin(Q),end(Q));
  reverse(begin(Q),end(Q));
  ll start = 0;
  for(auto p: Q){
    ll num = p.first;
    ll count = p.second;
    ll flag = count;
    for(ll i = start; i < N; i++){
      if(A.at(i)<num){
        A.at(i)=num;
        count--;
        start = i;
      }
      if(count==0)break;
    }
    if(count==flag)break;
  }
  ll res = 0;
  rep(i,N)res+=A.at(i);
  cout<<res<<endl;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    int n;
    cin >> n;
    
    string s[n];
    rep(i, n) cin >> s[i];
    
    int c = 0;
    rep(b, n) {
        string t[n];
        rep(k, n) rep(l, n) { // tのk, l番目
            t[k] += s[k][(l + b) % n];
            if (k > l) {
                if (t[k][l] != t[l][k]) {
                    goto nxt;
                }
            }
        }
        c += n;
    nxt:
        continue;
    }
    cout << c << '\n';
}


Measured memory_bytes: 632
#include<stdio.h>
#include<string.h>
#define LEN 3000

int max(int a, int b){return (a>b)?a:b;}

int lcs[LEN+1][LEN+1]={0};
char word[LEN]="";

int main(void){
	int i;
	int j;
	int k;
	int s_len;
	int t_len;
	char s[LEN];
	char t[LEN];
	scanf("%s%s",s,t);
	s_len=strlen(s);
	t_len=strlen(t);
	for(i=0;i<s_len+1;i++){
		lcs[i][0]=0;
	}
	for(i=0;i<t_len+1;i++){
		lcs[0][i]=0;
	}
	for(i=1;i<s_len+1;i++){
		for(j=1;j<t_len+1;j++){
			if(s[i-1]==t[j-1]){
				lcs[i][j]=lcs[i-1][j-1]+1;
			}else{
				lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
			}
		}
	}
	i=s_len;
	j=t_len;
	k=1;
	while((i>0)&&(j>0)){
		if(lcs[i][j]==lcs[i][j-1]){
			j--;
		}else if(lcs[i][j]==lcs[i-1][j]){
			i--;
		}else{
			word[lcs[s_len][t_len]-k]=s[i-1];
			i--;
			j--;
			k++;
		}
	}
	printf("%s",word);
	return 0;
}


Measured memory_bytes: 35328
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;
int N,A,B;
string s;
vector<int> v[100001];
int main(){
  cin >>A >> B;
  if(A+B>=10)cout << "error" << endl;
  else cout << A+B << endl;

  
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

//-------------------ここから回答する-----------------------

void solve(void)
{
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    rep(i, n - m + 1)
    {
        rep(j, n - m + 1)
        {
            int cta = 0;
            rep(k, m)
            {

                string tmp = a[k + i].substr(j, m);
                if (tmp == b[k])
                    cta++;
            }
            if (cta == m)
            {
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
    return;
}
int main(void)
{
    solve();
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};

int main()
{
    int n, i, cnt = 0;
    n = in();
    vector<int> ar(n);
    for (i = 0; i < n; i++){
        cin >> ar[i];
    }
    int mn = ar[0];
    for (i = 0; i < n; i++)
    {
        if(mn >= ar[i]){
            cnt++;
        }
        mn = min(mn, ar[i]);
    }
    cout << cnt << nl;
}

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

int main() {
	int k;
	cin >> k;
	vector<bool> l(k, false);
	int mod = 7 % k;
	l[mod] = true;
	int cnt = 1;

	while (!l[0]) {
		mod = (mod * 10 + 7) % k;
		cnt++;
		if (!l[mod]) l[mod] = true;
		else break;
	}
	if (l[0]) cout << cnt << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 3660
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int H,W;
string s[409];
ll memo[409][409];
ll memoW[409][409], memoB[409][409];
bool visit[409][409];
ll tmpW,tmpB;

void dfs(int i,int j){
    visit[i][j]=1;
    if(s[i][j]=='.') tmpW++;
    else tmpB++;
    if(i+1<H&&s[i][j]!=s[i+1][j]&&!visit[i+1][j]) dfs(i+1,j);
    if(j+1<W&&s[i][j]!=s[i][j+1]&&!visit[i][j+1]) dfs(i,j+1);
    if(i>0&&s[i][j]!=s[i-1][j]&&!visit[i-1][j]) dfs(i-1,j);
    if(j>0&&s[i][j]!=s[i][j-1]&&!visit[i][j-1]) dfs(i,j-1);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W;
    rep(i,H) cin>>s[i];
    
    mem(memoW,0);
    mem(memoB,0);
    mem(memo,0);
    mem(visit,0);
    
    ll ans=0;
    rep(i,H)rep(j,W){
        if(!visit[i][j]){
            tmpW=0;
            tmpB=0;
            dfs(i,j);
            ans+=tmpB*tmpW;
        }
    }
    cout1(ans)
}

Measured memory_bytes: 22016
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;

int N;
long long W, weight[110], value[110];

long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
    
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {
            
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }
            
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    
    cout << dp[N][W] << endl;
}


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

typedef unsigned long long ll;

ll md = 1000000007;

ll gcd(ll a, ll b)
{
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    while (b != 0) {
        a %= b;
        if (a == 0) return b;
        b %= a;
    }
    return a;
}
ll ggd(ll a, ll b){
    if( a == 0 && b == 0)return 0;
    return a / gcd(a, b) * b;
}

int main(int, char**)
{
	ll n;
	cin >> n;
	vector<pair<ll, ll>> j(n);
	for (int i = 0; i < n; ++i)
		cin >> j[i].second >> j[i].first;

	sort(j.begin(), j.end());
	ll t = 0;
	for (int i = 0; i < n; ++i) {
		t += j[i].second;
		if (j[i].first < t) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


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

int main() {
	int X,Y;
	cin >> X >> Y;

	rep(i,101) rep(j,101) {
		if (i+j==X && 2*i+4*j==Y) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(com[0] == 'f') {
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        } else if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 20540
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ld v[303][303][303]={0.0};
int main(){
    int n;
    cin>>n;
    v[0][0][0]=0;
    for(int z=0;z<=n;z++){
        for(int y=0;y<=n;y++){
            for(int x=0;x<=n;x++){
               if((x+y+z)!=0){v[x][y][z]=(ld)n/(x+y+z);}
               if(x!=0){v[x][y][z]+=x*v[x-1][y][z]/(x+y+z);}
               if(y!=0){v[x][y][z]+=y*v[x+1][y-1][z]/(x+y+z);}
               if(z!=0){v[x][y][z]+=z*v[x][y+1][z-1]/(x+y+z);}
            }
        }
    }
    int a[4]={0};
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        a[x]++;
    }
    cout<<fixed<<setprecision(10)<<v[a[1]][a[2]][a[3]]<<endl;

    return 0;

}


Measured memory_bytes: 432384
S = str(input())

int1 = int(S[0:2])
int2 = int(S[2:4])

YYMM = False
MMYY = False
if (0 <= int1 <= 99) and (1 <= int2 <= 12):
    YYMM = True
if (1 <= int1 <= 12) and (0 <= int2  <= 99):
    MMYY = True
    
if YYMM and MMYY:
    print('AMBIGUOUS')
if YYMM and not MMYY:
    print('YYMM')
if not YYMM and MMYY:
    print('MMYY')
if not YYMM and  not MMYY:
    print('NA')

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

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

int dp[333][333][333];
string s;
int k;

int dfs(int K,int L,int R)
{
//	cout << K << ' ' << L << ' ' << R << endl;
	if(K < 0)return -100000000;
	if(L > R)return 0;
	if(dp[K][L][R] != 0)return dp[K][L][R];
	int ret = 0;
	if(s[L] == s[R])ret = max(ret,dfs(K,L+1,R-1)+2);
	else ret = max(ret,dfs(K-1,L+1,R-1)+2);
	ret = max(ret,dfs(K,L+1,R));
	ret = max(ret,dfs(K,L,R-1));
	
	return dp[K][L][R] = ret;
}


int main()
{
	cin >> s >> k;
	
	REP(K,333)REP(i,333)dp[K][i][i] = 1;
	
	cout << dfs(k,0,s.size()-1) << endl;
	
	return 0;
}


Measured memory_bytes: 144512
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

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



int n, e;
vector<int> adj[100005];
bool done[100005];

void dfs(int v, vector<int>& path){
    done[v] = true;
    path.pb(v);
    for(auto vv : adj[v])
        if(!done[vv]){
            dfs(vv, path);
            break;
        }
}



int main(){

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

    cin>>n>>e;
    while(e--){
        int a, b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    vector<int> p1, p2;
    dfs(1, p1);
    dfs(1, p2);

    cout<<(int)p1.size()+(int)p2.size()-1<<endl;
    for(int i=(int)p1.size()-1;i>=0;i--)    cout<<p1[i]<<" ";
    for(int i=1;i<(int)p2.size();i++)    cout<<p2[i]<<" ";
    return 0;
}





Measured memory_bytes: 9720
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	string s;
	cin>>s;
	
	int d;
	if(s=="SUN") d=7;
	else if(s=="MON") d=6;
	else if(s=="TUE") d=5;
	else if(s=="WED") d=4;
	else if(s=="THU") d=3;
	else if(s=="FRI") d=2;
	else if(s=="SAT") d=1;
	cout<<d<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000003
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	ll N; cin >> N;
	set<ll> s;
	for(ll i = 1; i*i <= N; i++){
		if(N % i == 0){
			s.insert(i);
			s.insert(N/i);
		}
	}
	ll ans = 0;
	for(ll u : s){
		if(N/u >= 1 && N/u < u-1){
			ans += u-1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
ll k,n,a[maxn],b[maxn],r[maxn];
ll be,len,p=1,cnt;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	while(1)
	{
		if(b[a[p]]!=0)
		{
			be=b[a[p]];
			len=cnt-be+1;
			break;
		}
		r[++cnt]=a[p];
		b[a[p]]=cnt;
		p=a[p];
	}
	if(k<=be)cout<<r[k];
	else
	{
		int s=(k-be)%len;
		cout<<r[be+s];
	}
	return 0;
}

Measured memory_bytes: 8248
#include<stdio.h> 

int main(void){
	int i;
	char S[4];
	int eq[4] = {0,0};
	scanf("%s",S);
	for(i = 0 ; i < 4 ; i++){
		if (S[0] == S[i]) { 
			eq[0]++;
		}
		if (S[1] == S[i]) { 
			eq[1]++;
		}
		if (S[2] == S[i]) { 
			eq[2]++;
		}
		if (S[3] == S[i]) { 
			eq[3]++;
		}
	}
	if (eq[0] == 2 && eq[1] == 2 && eq[2] == 2 && eq[3] == 2) {
		 printf("Yes\n"); 
	} else { 
		printf("No\n");
	}
	return 0;
}

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

int main(){

int x;
int y;

cin >> x;
cin >> y;

if (x<y){
cout << "a" << " < " << "b" << endl;
}
else if(x>y){
cout << "a" << " > " << "b" << endl;
}
else {
cout << "a" <<  " == " << "b" << endl;

}
return 0;

}



Measured memory_bytes: 3108
import java.util.Scanner;
public class Main {
	public static long cel(long a, long b) {
		long ans;
		if(a % b == 0)
			return 2 * a - b;
		ans = a / b * 2 * b + cel(b, a % b);
		return ans;
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()) {
			long n, x, ans;
			n = cin.nextLong();
			x = cin.nextLong();
			ans = n + cel(n - x, x);
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define X first
#define Y second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<
#define debug(...) fprintf(stderr, __VA_ARGS__)

int tp = 0, xp = 0, yp = 0, t, x, y;

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &t, &x, &y);

    if (t - tp >= abs(x - xp) + abs(y - yp) && (t - tp - abs(x - xp) - abs(y - yp)) % 2 == 0) {
      ;
    }
    else {
      cout << "No";
      return 0;
    }

    tp = t;
    xp = x;
    yp = y;
  }
  cout << "Yes";
  return 0;
}


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

using namespace std;

int r,c;

int border(int x, int y){
	if(x==0){
		return 1;
	}
	else if(y==c){
		return 2;
	}
	else if(x==r){
		return 3;
	}
	else if(y==0){
		return 4;
	}
	else
		return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n; cin >> r >> c >> n;
	vector<pair<pair<int,int>,int>> a[5];
	
	for(int i=0;i<n;i++){
		int xa,ya,xb,yb;
		cin >> xa >> ya >> xb >> yb;
		
		if(border(xa,ya) && border(xb,yb)){
			a[border(xa,ya)].push_back({{xa,ya},i});
			a[border(xb,yb)].push_back({{xb,yb},i});
		}
	}
	
	stack<int> st;
	for(int i=1;i<=4;i++){
		sort(a[i].begin(),a[i].end());
		if(i>=3){
			reverse(a[i].begin(),a[i].end());
		}
		
		for(auto p:a[i]){
			if(st.empty()){
				st.push(p.second);
			}
			else if(st.top()==p.second){
				st.pop();
			}
			else{
				st.push(p.second);
			}
		}
	}
	
	cout << (st.empty()?"YES":"NO") << endl;
	
	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int p,q,a,n;

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y,x%y);
}

int dfs(int denom,int numer,int prev,int product,int num){
    if(num==0){
        int g=gcd(denom,numer);
        denom/=g;
        numer/=g;
        if(denom==q and numer==p) return 1;
        return 0;
    }

    {
        int tmp1=denom*prev,tmp2=numer*prev+denom*num;
        if((double)tmp2/tmp1<(double)p/q) return 0;
    }

    if((double)numer/denom>=(double)p/q) return 0;

    int res=0,x=prev;
    while(true){
        if(product*x>a) break;
        res+=dfs(denom*x,numer*x+denom,x,product*x,num-1);
        ++x;
    }
    return res;
}

void solve(){
    while(cin >> p >> q >> a >> n){
        if(p==0 and q==0 and a==0 and n==0) break;
        int g=gcd(p,q);
        p/=g;
        q/=g;

        int ans=0;
        rep(i,1,n+1) ans+=dfs(1,0,1,1,i);
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 3160
#include <stdio.h>

int main(void)
{
	int num[5];
	int i,j,temp;
	for(i=0;i<5;i++){
		scanf("%d",&num[i]);
	}
	for(i=0;i<5;i++){
		for(j=0;j<5;j++){
			if(num[i]>num[j]){
				temp=num[i];
				num[i]=num[j];
				num[j]=temp;
			}
		}
	}
	for(i=0;i<5;i++){
		printf("%d",num[i]);
		if(i!=4) printf(" ");
		if(i==4) printf("\n");
	}
	
	return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int>ans(n, k-q);
  rep(i,q) {
    int a;
    cin >> a;
    --a;
    ans[a]++;
  }
  rep(i,n){
    if(ans[i]>0) puts("Yes");
    else puts("No");
  }
  return 0;
}


Measured memory_bytes: 1024
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
n = int(input())
if n<1000:
    print("ABC")
else:
    print("ABD")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979

//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int r;
    cin >> r;
    cout << pow(r, 2) << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]

ac = [0] * n
wa = [0] * n

for p, s in ps:
    p = int(p) - 1
    if ac[p] == 0:
        if s == "AC":
            ac[p] = 1
        else:
            wa[p] += 1

wa = [ac[i] * wa[i] for i in range(n)]
print(sum(ac),sum(wa))

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

int visited[201];
vector <int> adj[201];
int n;
char board[201][201];

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

	cin >> n;

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin >> board[i][j];
			if(board[i][j]=='1')
			{
				adj[i].push_back(j);
			}
		}
	}

	int res = -1;

	for(int i=1;i<=n;i++)
	{
		memset(visited,-1,sizeof(visited));
		queue <int> que;
		que.push(i);
		visited[i] = 1;
		while(!que.empty())
		{
			int now = que.front();
			que.pop();

			for(auto next : adj[now])
			{
				if(visited[next]==-1)
				{
					visited[next] = visited[now] + 1;
					que.push(next);
				}
			}
		}

		bool ok = true;
		int number = 1;
		for(int i=1;i<=n;i++)
		{
			number = max(number,visited[i]);
			for(auto j : adj[i])
			{
				if(abs(visited[j]-visited[i])!=1)
				{
					ok = false;
					break;
				}
			}
			if(!ok)
			{
				break;
			}
		}
		if(ok)
		{
			res = max(res,number);
		}
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public String[][] codes = new String[][]{
			{"a", "f", "k", "p", "u", "z"},
			{"b", "g", "l", "q", "v", "."},
			{"c", "h", "m", "r", "w", "?"},
			{"d", "i", "n", "s", "x", "!"},
			{"e", "j", "o", "t", "y", " "}
	};
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<String> Ans = new ArrayList<String>();
		String line;
		
		while((line = in.readLine()) != null){
			if(line.length() == 0) break;
			
			if(line.length()%2 == 1){
				Ans.add("NA");
				continue;
			}
			
			String msg = "";
			for(int n=0; n<line.length(); n+=2){
				String a = line.substring(n, n+1);
				String b = line.substring(n+1, n+2);
				int x = Integer.parseInt(a);
				int y = Integer.parseInt(b);
				try{
					msg += codes[y-1][x-1];
				}catch(ArrayIndexOutOfBoundsException e){
					msg = "NA";
					break;
				}
			}
			
			Ans.add(msg);
		}
		
		for(int n=0; n<Ans.size(); n++){
			System.out.println(Ans.get(n));
		}
	}
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll s = 0;
    ll s_odd = 0;
    for (ll i = 0; i < n; ++i) {
        s += a[i];

        if (i % 2 != 0) {
            s_odd += a[i];
        }
    }

    vector<ll> ans(n);
    ans[0] = s - 2 * s_odd;

    for (ll i = 1; i < n; ++i) {
        ans[i] = 2 * a[i-1] - ans[i-1];
    }

    for (ll i = 0; i < n; ++i) {
        cout << ans[i] << ' ';
    }

    cout << endl;
}

Measured memory_bytes: 2944
#include <stdio.h>

int gcd2(int x, int y) {
    int tmp;
    if( x < y) { tmp = x; x = y; y = tmp; }
    if( y < 1) { return -1; }

    if(x % y == 0) {return y;}
    return gcd2( y, x%y);
}

int gcd1(int *a, int i, int j){
    if(j - i == 0) { return a[i]; }
    if(j - i == 1) { return gcd2(a[i], a[j]); }
    return gcd2( gcd1(a, i, i + (j-i)/2), gcd1(a, i + (j-i)/2 + 1, j));
}

int gcd(int *a, int size) {
    return gcd1(a, 0, size-1);
}

int main(void) 
{
    int n, x, i = 0;
    scanf("%d %d", &n, &x);
    int a[n];
    while(i < n) {
        scanf("%d", &a[i] ); a[i] -= x; 
        if(a[i] < 0) { a[i] *= -1; } i++;
    }
    printf("%d\n", gcd(a, n));
    return 0;
}

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

int main() {
 int N, R;
  cin >> N >> R;
  
  if(N < 10){
    cout << R + 100*(10-N) << endl;
  }  
      
  else if(N >= 10){
    cout << R << endl;
  }
}    

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
constexpr double PI = atan2(0, -1);
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, x;
    cin >> a >> b >> x;
    double y = 1.0 * x / a;
    double g;
    if (2 * y <= a * b)
        g = atan2(b, 2 * y / b);
    else
        g = atan2(2 * (a * b - y) / a, a);
    cout << setprecision(10) << fixed << g / PI * 180 << endl;
    return 0;
}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  int ans = 1e9;
  vector<int> a(n);
  ll sum = 0;
  for(int i = 0; i < n; i++) cin >> a[i], sum += a[i];
  ll s = 0;
  for(int i = 0; i < n - 1; i++) {
    s += a[i];
    sum-=a[i];
    ans = min<ll>(ans, abs(s - sum));
  }

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


Measured memory_bytes: 256
s = input()

_s = s
acgt = ["A","C", "G", "T"]
ans = 0
for i in range(10):
    for j in range(i+1, 11):
        _s = s[i:j]
        if all([__s in acgt for __s in _s]) and len(_s) >= ans:
            ans = len(_s)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key){
    int left=0;
    int right=n;
    int mid;
    while(left < right){
        mid = (left + right) / 2;
        if(key == A[mid]) return 1; //keyを発見
        if(key > A[mid]) left = mid + 1; //後半を探索
        else if(key < A[mid]) right = mid; //前半を探索
    }
    return 0;
}

int main(){
    int i, q, k, sum = 0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d", &k);
        if( binarySearch(k) ) sum++;        
    }
    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
using namespace std;
int a[1000000][2];
int main()
{
  int i,j,k,n;
  k = 0;
  for(i=2;i<1000000;i++){
    if(!a[i][0]){
      k++;
      for(j=2;i*j<1000000;j++){
	a[i*j][0] = 1;
      }
    }
    a[i][1] = k;
  }
  while(cin >> n){
    cout << a[n][1] << endl;
  }
  return 0;
}

Measured memory_bytes: 8560
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	string S;
	cin >> S;
	char tmp = '\0';
	for (size_t i = 0; i < S.length(); ++i)
	{
		if (S[i] == tmp)
		{
			cout << "Bad" << endl;
			return EXIT_SUCCESS;
		}
		tmp = S[i];
	}
	cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc067/submissions/1562911
#コピペコード
N = int(input())
ab = [[] for i in range(N+1)]
for i in range(N-1):              #隣接リスト作成
    a, b = map(int, input().split())
    ab[a].append(b)
    ab[b].append(a)
 
def calc_dist(K):
    # dist[i]:頂点Kから頂点iまでの距離
    dist = [-1 for i in range(N+1)]
    dist[K] = 0
 
    # 深さ優先探索（スタック）
    stack = []
    stack.append(K)
 
    while stack:
        v = stack.pop()
        for nxt in ab[v]:            #隣接リストから値をとっていく
            if dist[nxt] == -1:
                dist[nxt] = dist[v] + 1
                stack.append(nxt)
 
    return dist
 
dist1 = calc_dist(1)
distN = calc_dist(N)
 
Fennec = 0
Snuke = 0
for v in range(1,N+1):
    if dist1[v] <= distN[v]:     #vまで行くのにどちらが早いか
        Fennec += 1
    else:
        Snuke += 1
 
if Fennec > Snuke:
    print('Fennec')
else:
    print('Snuke')

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

int main(){

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

    
    int max;

    for( int i = M/N+1; i > 0; i-- ){
        if( M % i == 0 && M/i >= N ){
            max = i;
            break;
        }
    }
    
    cout << max << endl;

    return 0;

}

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

using namespace std;


int main() {
    int N;
    cin >> N;
    int o = 0;
    for(int i = 0 ; i < N ; i++){
        int x;
        cin >> x;
        o += x%2;
    }
    if(o%2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}


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

int main() {
	int x,y;
	cin>>x>>y;
	bool f=false;
	for(int i=0;i<=x;i++){
		for(int j=0;j<=x;j++){
			if(i+j==x && 2*i+4*j==y){
				cout<<"Yes"<<endl;
				f=true;
			}
		}
	}
	if(f==false){
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3600
import sys
from collections import defaultdict


def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    
    A = defaultdict(int)
    for i in map(int, input().split()):
        A[i] += 1
        
    for i in range(M):
        B, C = map(int, input().split())
        A[C] += B
        
    ret = 0
    count = 0
    for value, num_value in sorted(A.items(), key=lambda x:x[0])[::-1]:
        num_value = min(num_value, N - count)
        ret += value * num_value
        count += num_value
        if num_value == N:
            break
    
    print(ret)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42656
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#include <bitset>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int A,B,C,D,E;
    cin >> A >> B >> C >> D >> E;
    int a[5];
    a[0] = A%10;
    a[1] = B%10;
    a[2] = C%10;
    a[3] = D%10;
    a[4] = E%10;
    int maxx=0,I;
    sort(a,a+5);
    for(int i=0;i<5;i++){
        if(a[i]!=0){
            maxx = a[i];
            I = i;
            break;
        }
    }
    int ans = 0;
    ans = A+B+C+D+E;
    for(int i=0;i<5;i++){
        if(i!=I&&a[i]!=0){
            ans = ans+(10-a[i]);
        }
    }
    cout << ans << endl;
}

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

deque <int> De;
int cnt, cnt1, cnt2, front[105], back[105];
long long n;
void work(long long x)
{
	if (!x) return ;
	if (!(x & 1)) ++cnt, front[++cnt1] = cnt, work(x - 1);
	else ++cnt, back[++cnt2] = cnt, work(x >> 1);
}
int main()
{
	scanf("%lld", &n);
	work(n);
	printf("%d\n", cnt + 100);
	for (int i = 1; i <= cnt1; i++)
		printf("%d ", cnt - front[i] + 1);
	for (int i = cnt2; i >= 1; i--)
		printf("%d ", cnt - back[i] + 1);
	for (int i = 1; i <= 100; i++)
		printf("%d ", i);
	return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define ll long long int
#define fi first
#define se second
#define vec vector<lld>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //code :-
    ll n, i, sum = 0;
    cin >> n;
    map<string, ll>m;
    while (n--) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    for (auto x : m) {
        //cout<<x.fi<<"-"<<x.se<<endl;
        if (x.se > 1) {
            sum += (x.se * (x.se - 1)) / 2;
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 11396
#include<stdio.h>
#include<stdlib.h>
#include<string.h>



int main(){
	int H,W,N;

	scanf("%d %d",&H,&W);
 
	char S[200][100];
	char input[100];

	for (int i = 0; i < H; i++){
		scanf("%s",input);
		for(int j = 0; j < W; j++){
			if(input[j] == '*'){
				S[i*2][j] = '*';
				S[i*2+1][j] = '*';
				// printf("S[%d][%d] = %c\n",i,j,S[i][j]);
			}
			else{
				S[i*2][j] = '.';
				S[i*2+1][j] = '.';
				// printf("S[%d][%d] = %c\n",i,j,S[i][j]);
			}
		}
	}

	for (int i = 0; i < 2*H; i++){
		for (int j = 0; j < W; j++){
			printf("%c",S[i][j]);
		}
		printf("\n");
		
	}
	

	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define ll long long int

int main() {
int K;
string s;
cin>>K>>s;
cout<<(s.length()<=K ? s : s.substr(0,K)+"...")<<endl;
return 0;
}


Measured memory_bytes: 3044
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
N = int(input())						# 5
A = list( map(int, input().split()) )	# 1 2 3 4 5 ...

A=[0]+A
X=[0]*(N+1)
S = sum(A)


a=0
for i in range(2,N,2):
	a+=A[i]*2

X[1]=S-a

for i in range(1,N):
	X[i+1]=A[i]*2-X[i]


p("X",X)
print( " ".join(map(str, X[1:])) )



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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int a[200009];

void solve()
{
	int n,i,k;
	cin>>n>>k;
	for(i=0;i<n;i++) cin>>a[i];
	ll lo=1,hi=1e9,mid,ans=-1;
	while(lo<=hi)
	{
		mid=(lo+hi)/2;
		ll cnt=0;
		for(i=0;i<n;i++)
		{
			cnt += (a[i]-1)/mid;
		}
		if(cnt > k)
		{
			lo=mid+1;
		}
		else
		{
			ans=mid;
			hi=mid-1;
		}
	}
	assert(ans!=-1);
	cout<<ans<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 4416
N, M, C = map(int, input().split())
B_m = [int(b) for b in input().split()]
A_nm = [[int(a) for a in input().split()] for _ in range(N)]

count = 0
for n in range(N):
    f = sum([a * b for (a, b) in zip(A_nm[n], B_m)])
    if (f > -C):
        count += 1

print(count)

Measured memory_bytes: 3064