akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)
	//i=m -> n-1(昇順)
#define RREP(i,m,n) for(LL i=(m);i>=(n);i--)
	//i=m -> n(降順)

int main(){
  LL n;
  cin >> n;
  VLL l(n+10);
  l[0] = 2;
  l[1] = 1;
  
  REP(i,2,n+1){
    l[i] = l[i-1] + l[i-2];
  }
  
  cout << l[n] << endl;
  
  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	string s;
	int r=0, b=0;
	cin >> s;
	for(int i=0; i<s.size(); i++){
		if(s[i]=='0'){
			r++;
		} else {
			b++;
		}
	}
	cout << 2*min(r, b) << endl;

	return 0;
}

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

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

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

  return res;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll C(ll n, ll k) {
  ll res = 1;

  for (ll i = 0; i < k; ++i) {
    res = (res * (n - i)) % mod;
  }
  for (ll i = 0; i < k; ++i) {
    auto inv = modinv(k-i, mod);
    res = res * inv;
    res %= mod;
  }

  return res;
}

int main() {

  ll n, a, b;
  cin >> n >> a >> b;

  auto ans = modpow(2, n, mod);
  // cout << ans << endl;
  ans += mod - 1;
  ans %= mod;

  auto p1 = C(n, a);
  // cout << p1 << endl;
  auto p2 = C(n, b);
  // cout << p2 << endl;

  ans += mod - p1;
  ans %= mod;
  ans += mod - p2;
  ans %= mod;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>

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

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int num = 0;
    while (B >= A) {
        num++;
        if (num >= C) break;
        B -= A;
    }   
    cout << num << endl;
}

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

int main(){
    int D, T, S;
    cin >> D >> T >> S;
    if( D <= S*T ) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
from collections import deque
from bisect import bisect
ref=deque([2])
refref=deque()
for i in range(3,100000,2):
	flag=1
	for j in range(2,int(i**0.5)+1):
		if i%j==0:
			flag=0
			break
	if flag:
		ref.append(i)
for p in ref:
	if (p+1)//2 in ref:
		refref.append(p)
q,*li=map(int,open(0).read().split())
for l,r in zip(li[::2],li[1::2]):
	print(bisect(refref,r+1)-bisect(refref,l-1))

Measured memory_bytes: 26280
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int t = 0;
    while(s.size() > 0){
        int x = s.find("ABC");
        if(x == int(std::string::npos)) break;
        t++;
        s = s.substr(x + 3);
    }
    cout << t << "\n";
}

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

#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using ll = long long;

inline void Main() {
  // code
  ll H, X = 1, R = 1;
  cin >> H;

  while(H > 1) {
    X *= 2;
    R += X;
    H /= 2;
  }

  cout << R << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll S; cin >> S;
    ll L = S/100;
    ll R = S%100;
    bool f1 = false,f2 = false;
    if(L <= 99 && 0 < R && R <= 12) f1 = true;
    if(0 < L && L <= 12 && R <= 99) f2 = true;
    if(f1 && f2) return "AMBIGUOUS";
    if(f1 && !f2) return "YYMM";
    if(!f1 && f2) return "MMYY";
    return "NA";
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a,b,c,d,e;
signed main()
{
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e);
	if(a==0)
	printf("1");
	if(b==0)
	printf("2");
	if(c==0)
	printf("3");
	if(d==0)
	printf("4");
	if(e==0)
	printf("5");
    return 0;
}

Measured memory_bytes: 3648
def resolve():
    A, B, M = [int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    zyc = [list(map(int, input().split())) for _ in range(M)]

    minAB = min(a) + min(b)
    for z, y, c in zyc:
        tmp = a[z - 1] + b[y - 1] - c
        minAB = min(minAB, tmp)
    print(minAB)


resolve()


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

class Solver {
  final long n;
  
  Solver(long n) {
    this.n = n;
  }
  
  public long solve() {
    if (n % 2 == 1) {
      return 0;
    }
    long answer = 0;
    
    int count = 1;
    long fivePow = 5;
    while (n > fivePow) {
      long v = n / fivePow;
      answer += v / 2;
      fivePow *= 5;
    }
    return answer;
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    long n = reader.nextLong();
    out.println(new Solver(n).solve());
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        if (input == "SUN")
        {
            Console.WriteLine(7);
        }
        if (input == "MON")
        {
            Console.WriteLine(6);
        }
        if (input == "TUE")
        {
            Console.WriteLine(5);
        }
        if (input == "WED")
        {
            Console.WriteLine(4);
        }
        if (input == "THU")
        {
            Console.WriteLine(3);
        }
        if (input == "FRI")
        {
            Console.WriteLine(2);
        }
        if (input == "SAT")
        {
            Console.WriteLine(1);
        }
    }
}


Measured memory_bytes: 11220
import fractions

def lcm(x,y):
    return (x*y) // fractions.gcd(x,y)

N = int(input())
a = list(map(int, input().split()))
L = a[0]
f = 0

for i in range(N-1):
    L = lcm(L,a[i+1])

for i in range(N):
    f = f + (L-1)%a[i]

print(f)

Measured memory_bytes: 5560
from itertools import accumulate

MOD = 10**9 + 7
N, K = map(int, input().split())
cumsum = list(accumulate(range(N+1)))
ans = 0
for k in range(K, N+2):
    ans += (cumsum[N] - cumsum[max(N-k, 0)]) - cumsum[k-1] + 1; ans %= MOD
print(ans)

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

int main()
{
    string S;
    cin >> S;
    S = S.substr(0, S.size() - 2);

    string tmp;
    for(int i = S.size(); 2 <= i; i -= 2)
    {
        tmp = S.substr(0, i);
        tmp = tmp.substr(0, tmp.size() / 2);
        if (tmp + tmp == S.substr(0, i)) break;
    }
    cout << tmp.size()*2 << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func sumInt(a []int) int {
  s := 0
  for _, v := range a {s += v}
  return s
}

func main() {
  t := make([]int, 3)
  for i := 0; i < 3; i++ {
    fmt.Scan(&t[i])
  }
  fmt.Println(sumInt(t) - maxInt(t...))
}

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

using namespace std;

int main(void)
{
	int n, m, k;
	cin >> n >> m >> k;
	vector<set<int>> G(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		G[a-1].insert(b-1);
		G[b-1].insert(a-1);
	}
	vector<set<int>> B(n);
	for (int i = 0; i < k; i++) {
		int c, d;
		cin >> c >> d;
		B[c-1].insert(d-1);
		B[d-1].insert(c-1);
	}




	bool visited[n];
	fill(visited, visited+n, false);
	set<int> todo;
	for (int i = 0; i < n; i++)
		todo.insert(i);

	queue<int> q;
	int visit_count = 0;

	vector<set<int>> groups;
	vector<int> groups_number(n);

	while (!todo.empty()) {
		auto it = todo.begin();
		q.push(*it);
		groups.resize(groups.size()+1);
		while (!q.empty()) {
			int v = q.front();
			q.pop();
			if (visited[v] == false) {
				todo.erase(v);
				groups.back().insert(v);
				groups_number[v] = groups.size()-1;
				visited[v] = true;
				visit_count++;
				for (int e : G[v]) {
					if (visited[e] == false)
						q.push(e);
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		int ans = groups[groups_number[i]].size() - G[i].size();
		for (int b : B[i]) {
			if (groups[groups_number[i]].find(b) != groups[groups_number[i]].end()) {
				if (G[i].find(b) == G[i].end()) { // not found
					ans--;
				}
			}
		}
		cout << ans-1;
		if (i < n-1)
			cout << " ";
		else
			cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 42892
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9L+7;
int n;
vector<vector<ll>> inp;
vector<vector<vector<ll>>> dp;

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        /*inp.assign(r+2,vector<ll> (c+2,0));
        dp.assign(r+2,vector<vector<ll>> (c+2,vector<ll> (4,-1)));
        */
        ll x,k,d;
        cin>>x>>k>>d;

        x = abs(x);

        if(k< x/d) cout<< x - k*d<<endl;
        else
        {
            ll ans1 = x%d;
            ll ans2 = abs(ans1 - d);
            k -= x/d;

            if(k%2 == 0)
            {
                cout<<ans1<<endl;
            }
            else
            {
                cout<<ans2<<endl;
            }
            
        }
        

    }
    
}


Measured memory_bytes: 3564
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
    ll h ,w ;
    cin >> h >> w;
    ll ans = 1000000000;
    if(h % 3 == 0 || w % 3 == 0){
        ans = 0;
    }

    ans = min(ans,h);
    ans = min(ans,w);

    FOR(i,1,h + 1) {
        ll b;
        b = abs(w * i - w / 2 * (h - i));
        if(w % 2 == 1)
            b = max(b,abs(w * i - (w + 1) / 2 * (h - i)));
        ans = min(b,ans);
    }
    FOR(i,1,w + 1) {
        ll b;
        b = abs(h * i - h / 2 * (w - i));
        if(h % 2 == 1)
            b = max(b,abs(h * i - (h + 1) / 2 * (w - i)));
        ans = min(b,ans);
    }
    cout << ans << endl;

}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			char[] n = sc.next().toCharArray();
			if (n[0] == n[1] && n[1] == n[2] && n[2] == n[3]) {
				if (n[0] == '0')
					break;
				else {
					System.out.println("NA");
					continue;
				}
			}
			int cnt = 0;
			for (;;) {
				if (Integer.parseInt(new String(n)) == 6174)
					break;
				int L = calcL(n);
				int S = calcS(n);
				cnt++;
				n = String.format("%04d", (L - S)).toCharArray();
			}
			System.out.println(cnt);
		}
	}

	int calcS(char[] cs) {
		char ds[] = new char[4];
		for (int i = 0; i < cs.length; i++) {
			ds[i] = cs[i];
		}
		Arrays.sort(ds);
		StringBuilder sb = new StringBuilder();
		sb.append(ds);
		return Integer.parseInt(sb.toString());
	}

	int calcL(char[] cs) {
		char ds[] = new char[4];
		for (int i = 0; i < cs.length; i++) {
			ds[i] = cs[i];
		}
		Arrays.sort(ds);
		StringBuilder sb = new StringBuilder();
		sb.append(ds);
		return Integer.parseInt(sb.reverse().toString());
	}

	public static void main(String[] args) {

		new Main().run();
	}
}

Measured memory_bytes: 63268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e4+7;
int N[maxn];
int main()
{
	int n;cin>>n;int maxx=0;int cnt=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&N[i]);
		if(N[i]>=maxx) cnt++;
		maxx=max(N[i],maxx);
	}
	cout<<cnt<<endl;
}


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

int32_t main()
{
    string s;
    cin>>s;
    
    if(s[0]==s[1] && s[1]==s[2] ||  s[1]==s[2]&&s[2]==s[3])
    puts("Yes");
    else
    puts("No");
        
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    long long n,W,w[200000],v[200000],dp[101][100001]={0},ans=0;
    cin>>n>>W;
    rep(i,n) cin>>w[i]>>v[i];
    rep(i,n)rep(j,1000*n+1) dp[i][j]=10000000000;
    dp[0][0]=0;
    rep(i,n)rep(j,n*1000+1){
        if(j>=v[i]) dp[i+1][j]=min(dp[i][j-v[i]]+w[i],dp[i][j]);
        else dp[i+1][j]=dp[i][j];
    }
    rep(i,n*1000+1) if(dp[n][i]<=W&&i>ans) ans=i;
    cout<<ans<<endl;
}

Measured memory_bytes: 82176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;	cin >> a >> b;
  for(int i=1;i<2000;i++){
    if(i*8/100==a&&i*10/100==b){
      cout << i;
      return 0;
    }
  }
  cout << -1;
}

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

int main() {
  int A,B;
  
  cin >> A >> B;
  
  if (A < B){
     cout << "a" << " " << "<" << " "<< "b" << endl;
  }

  else if (A > B){
     cout << "a" << " " << ">" << " " << "b"<< endl;
   }
   
  else if (A == B){
     cout << "a" << " " << "==" << " " << "b" << endl; 
  }
  
}


Measured memory_bytes: 3104
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int n_cp = n;
        int sum = 0;
        while(n>0){
            sum += n%10;
            n = n/10;
        }
        if(n_cp%sum == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    ll A, B, K;
    cin >> A >> B >> K;
    ll remA = max(A - K, 0LL);
    K = max(K - A, 0LL);
    ll remB = max(B-K, 0LL);
    cout << remA << " " << remB << endl;
    return 0;
}

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


void solve()
{
int n,i;
    cin>>n;
    vector<int>a(n);
    for(int &x:a)cin>>x;
    int ans=0;
    for(i=0;i<n;i+=2)
        if(a[i]&1)ans++;
        cout<<ans<<endl;
}


int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
        solve();
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int n = 1e6;
int p[n + 1];

int main()
{

    rep(i, n + 1) p[i] = 1;
    p[0] = 0, p[1] = 0;
    for (int i = 2; i <= (int)sqrt(n); i++)
    {
        if (p[i] == 1)
        {
            for (int j = 2; i * j <= n; j++)
            {
                p[i * j] = 0;
            }
        }
    }

    int x;
    cin >> x;
    for (int i = x; i < 1e6; i++)
    {
        if (p[i] == 1)
        {
            OP(i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4096
from itertools import product
import numpy as np

H, W = map(int, input().split())
grid = []
for _ in range(H):
  array = list(input())
  grid.append(array)
b = np.array(grid)
b = np.where(b == ".", 1, 0)

L = np.zeros((H,W), dtype=np.int)
R = np.zeros((H,W), dtype=np.int)
D = np.zeros((H,W), dtype=np.int)
U = np.zeros((H,W), dtype=np.int)

for i in range(1, H):
  L[i] += (L[i-1]+1)*b[i-1]

for i in range(H-2,-1,-1):
  R[i] += (R[i+1]+1)*b[i+1]

for i in range(1, W):
  U[:, i] += (U[:, i-1]+1)*b[:, i-1]

for i in range(W-2, -1, -1):
  D[:, i] += (D[:, i+1]+1)*b[:, i+1]

answer = ((L+R+U+D)*b).max()
  
print(answer+1)

Measured memory_bytes: 266520
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N;
    string S;
    cin >> N >> S;
    
    // calculation
    vector<int> vec(1, 0);
    int sum = 0, ans = 0;
    REP(i, N) {
        if (S[i] == 'I') {
            sum++;
        } else {
            sum--;
        }
        ans = max(sum, ans);
    }
    
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,w;
    while(scanf("%d%d%d",&w,&a,&b)==3&&w!=NULL)
    {
        if(a+w<b)
            printf("%d\n",b-a-w);
       else if(b+w<a)
            printf("%d\n",a-b-w);
        else
            printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 128
use std::collections::VecDeque;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let r: i64 = sc.read();
    let c: i64 = sc.read();
    let n: usize = sc.read();
    let mut edges = vec![];
    for _ in 0..n {
        let x1: i64 = sc.read();
        let y1: i64 = sc.read();
        let x2: i64 = sc.read();
        let y2: i64 = sc.read();
        let e1 = x1 == 0 || x1 == r || y1 == 0 || y1 == c;
        let e2 = x2 == 0 || x2 == r || y2 == 0 || y2 == c;
        if e1 && e2 {
            edges.push((x1, y1, x2, y2));
        }
    }

    let mut points = vec![];
    for (i, (x1, y1, x2, y2)) in edges.into_iter().enumerate() {
        for (x, y) in vec![(x1, y1), (x2, y2)].into_iter() {
            if y == 0 {
                points.push((0, x, i));
            } else if x == r {
                points.push((1, y, i));
            } else if y == c {
                points.push((2, -x, i));
            } else {
                points.push((3, -y, i));
            }
        }
    }

    points.sort();
    let mut stack = VecDeque::new();
    for (_, _, i) in points.into_iter() {
        if let Some(top) = stack.pop_front() {
            if top == i {
                continue;
            }
            stack.push_front(top);
        }
        stack.push_front(i);
    }

    if stack.is_empty() {
        println!("YES");
    } else {
        println!("NO");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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


int main(void) {
    int n;
    cin >> n;
    int ans = (int)sqrt(n);
    cout << ans * ans << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const ll INF = 1LL << 60;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    vector<ll> dp(H + 1, INF);
    dp[0] = 0;
    rep(i, H) {
        rep(j, N) {
            int ni = min(H, i + A[j]);
            chmin(dp[ni], dp[i] + B[j]);
        }
    }

    cout << dp[H] << endl;
}

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

int main() {
    int l, r; cin >> l >> r;
    int ans = 2020;
    for (int i = l; i < min(r, l+2020); i++) {
        for (int j = i+1; j <= min(r, i+2020); j++) {
            ans = min(ans, ((i%2019)*(j%2019))% 2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))

MOD = 10**9+7

ans = 1
robots = 0

for x in X:
    if x > 2*robots:
        robots += 1
    else:
        ans *= (robots+1)
        ans %= MOD

for n in range(1,robots+1):
    ans *= n
    ans %= MOD

print(ans)

Measured memory_bytes: 14596
solver::[Int]->Int->Int->Int
solver ls a b = let under_a = length (filter (a>=) ls) in
                let mid     = length (filter (\ x -> a<x && b>=x) ls) in
                let over_b  = length (filter (b<) ls) in
                minimum [under_a,mid,over_b]

main::IO()
main=do
  _<-getLine
  (a:b:_)<-return.(map read).words=<<getLine
  ls<-return.(map read).words=<<getLine
  print (solver ls a b)


Measured memory_bytes: 892
H,W = map(int,input().split())


def get_count(Ss,row,column):
    cs = 0
    for r in [-1,0,1]:
        for c in [-1,0,1]:
            if row + r < 0 or row + r >= H or column + c < 0 or column + c >= W:
                continue
            elif Ss[row + r][column + c] == '#':
                cs += 1
    return cs



Ss = []
for i in range(H):
    Ss.append(input())


for r in range(H):
    for c in range(W):
        if Ss[r][c] == '#':
            print('#',end ="")
        else:
            print(get_count(Ss,r,c),end="")
    print("")

Measured memory_bytes: 3444
n = int(input())
dic = {}
for i in range(1,n+1):
    if str(i)[-1] == 0:
        continue
    key = str(i)[0]
    key += "+" + str(i)[-1]
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1
res = 0
for i in range(1,n+1):
    if str(i)[-1] == 0:
        continue
    key = str(i)[-1]
    key += "+" + str(i)[0]
    if key in dic:
        res += dic[key]
print(res)

Measured memory_bytes: 9220
#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>;
const int MOD = 1000000007;

int main() {
    string S;
    cin >> S;
    set<char> data;
    for (char s : S) {
        data.insert(s);
    }
    string ans = "None";
    rep (i, 26) {
        if (data.count('a' + i) == 0) {
            ans = 'a' + i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

long long int N, M, R, a, b, c, i, cst[252][252];
vector<long long int> rs;
vector<pair<long long int, long long int>> ed[252];
priority_queue<long long int, vector<long long int>, greater<long long int>> pq;

int main(){
    scanf("%lld%lld%lld", &N, &M, &R);
    for(; i < R; ++i){
        scanf("%lld", &a);
        rs.push_back(a - 1);
    }
    sort(rs.begin(), rs.end());
    fill(cst[0], cst[252], 1145141919810LL);
    for(i = 0; i < M; ++i){
        scanf("%lld%lld%lld", &a, &b, &c);
        cst[--a][--b] = c;
        cst[b][a] = c;
    }
    for(i = 0; i <= N; ++i){
        for(int j = 0; j < N; ++j){
            for(int k = j; k < N; ++k){
                cst[k][j] = cst[j][k] = min(cst[j][k], cst[j][i] + cst[i][k]);
            }
        }
    }
    a = 1145141919810LL;
    do{
        b = 0;
        for(i = 0; ++i < R; b += cst[rs[i - 1]][rs[i]]);
        a = min(a, b);
    }while(next_permutation(rs.begin(), rs.end()));
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
	int L, A, B, C, D;
	int i, j;
	
	 scanf("%d %d %d %d %d", &L, &A, &B, &C, &D);
	 
	 i = 0;
	 while (1){
	 	
		if (A <= 0 && B <= 0){
			break;
	 	}
		A -= C;
		B -= D;
		i++;
	 }
	 
	 L -= i;
	 
	 printf("%d\n", L);
	 
	 return (0);
}
	 	

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

const int SZ = 62,L=128;
string S="QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890";

int dist[SZ],tot;
string t[400];

int ask(const string& s){
	cout<<'?'<<' '<<s<<endl;
	int res;
	cin>>res;
	return res;
}
void guess(const string& s){
	cout<<'!'<<' '<<s<<endl;
	exit(0);
}
void solve(int idx,int l,int r){
	if(l==r)	return t[idx].resize(dist[l],S[l]),void();
	int mid=(l+r)>>1;
	solve(idx<<1,l,mid),solve(idx<<1|1,mid+1,r);
	string ls=t[idx<<1],rs=t[idx<<1|1];
	int j=0;
	for(int i=0;i<ls.size();i++){
		while(j<rs.size()){
			string todo=t[idx]+rs[j];
			for(int k=i;k<ls.size();k++)
				todo+=ls[k];
			if(ask(todo)==tot-todo.size())
				t[idx]+=rs[j++];
			else
				break;
		}
		t[idx]+=ls[i];
	}
	while(j<rs.size())	t[idx]+=rs[j++];
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	tot=L*SZ;
	for(int i=0;i<SZ;i++){
		string s(L,S[i]);
		dist[i]=ask(s);
		tot-=dist[i];
		dist[i]=L-dist[i];
	}
	solve(1,0,SZ-1);
	guess(t[1]);
}


Measured memory_bytes: 3796
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

#define ll long long int
using namespace std;


ll power(ll x, ll y) { ll temp; if( y == 0) return 1; temp = power(x, y/2); if (y%2 == 0) return temp*temp; else return x*temp*temp; } 
const double pi=3.14159265358;


int main()
{
	fast;

	double r;
	cin>>r;
	cout<<setprecision(10)<<2*pi*r<<"\n";

}


Measured memory_bytes: 3784
from collections import Counter
N = int(input())
slist = []
for _ in range(N):
    s = sorted(input())
    s = ''.join(s)
    slist.append(s)
slist = Counter(slist)
ans = 0
for i in slist.values():
    if i == 1:
        continue
    ans += (i*(i-1)+2)//2-1

print(ans)


Measured memory_bytes: 24052
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(void) {
  int i, j, k, max = 0, min = 1000, a;
  for(i = 0; i < 5; ++i) {
    scanf("%lld", &a);
    if(max < a) max = a;
    if(min > a) min = a;
  }
  scanf("%lld", &k);
  printf("%s", max - min > k ? ":(" : "Yay!");
  return 0;
}

Measured memory_bytes: 128
s = input()
hoge = s[2:-1].find("C")
count = s[2:-1].count("C")
ss = s.replace("A", "a").replace("C", "c")
if(s[0] == "A" and hoge != -1 and ss.islower() and count == 1):
  print("AC")
else:
  print("WA")


Measured memory_bytes: 3060
n, m = map(int, input().split())
a = list(map(int, input().split()))
total_votes = sum(a)
count = 0
for i in range(n):
    if a[i] >= total_votes / (4 * m):
        count += 1
if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll 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;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	string s,t;
	cin>>s>>t;
	rep(i,0,s.size()){
		s.push_back(s[0]);
		s.erase(s.begin()+0);
		if(s==t){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

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

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	if((n - k) % (k - 1) == 0) cout << (n - k) / (k - 1) + 1 << '\n';
	else {
		k-- ;
		cout << (n + k - 1) / k << '\n';
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,x;
int dp[105][105][305],w[105],v[105];
int dfs(int i,int j,int k)
{
	if(1LL*j*x+k>m)return -2e9;
	if(dp[i][j][k])return dp[i][j][k];
	if(i==n)return 0;
	return dp[i][j][k]=max(dfs(i+1,j,k),dfs(i+1,j+1,k+w[i+1])+v[i+1]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&w[i],&v[i]);
    x=w[1];
	for (int i=1;i<=n;i++)w[i]-=x;
	printf("%d\n",dfs(0,0,0));
	return 0;
}

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

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int cnt = 0;
    for (int i = l; i <= r; i++) {
        if(i % d == 0) cnt++;
    }
    cout << cnt << endl;

return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
const int N=5e5+3;
char buf[4000000],*c,t[8];
int i,j,k,n,x,a[N],RT,ls[N],rs[N],fa[N],d[N],mi[N],siz[N];
inline int Read()
{
	while(*c<48)++c;
	for(x=0;*c>47;++c)x=x*10+*c-48;
	return x;
}
inline void W(int i)
{
	for(x=1;i;i/=10)t[x++]=i%10+48;
	for(;x--;*c++=t[x]);
}
inline void pup(int p)
{
	siz[p]=siz[ls[p]]+siz[rs[p]]+1;
	mi[p]=std::min(d[p],std::min(mi[ls[p]],mi[rs[p]]));
}
void L_rotate(int p)
{
	int i=fa[p],j=fa[i],t=siz[p];
	if(fa[p]=j)(ls[j]==i?ls[j]:rs[j])=p;else RT=p;
	if(ls[p])fa[ls[p]]=i;
	rs[i]=ls[p],ls[p]=i,fa[i]=p;
	pup(i),pup(p);
}
void R_rotate(int p)
{
	int i=fa[p],j=fa[i],t=siz[p];
	if(fa[p]=j)(ls[j]==i?ls[j]:rs[j])=p;else RT=p;
	if(rs[p])fa[rs[p]]=i;
	ls[i]=rs[p],rs[p]=i,fa[i]=p;
	pup(i),pup(p);
}
void splay(int p,int top=0)
{
	for(int i,j,q;fa[p]!=top;)
	{
		q=fa[p],i=ls[fa[p]]==p,j=ls[fa[q]]==q;
		if(i^j||fa[q]==top)i?R_rotate(p):L_rotate(p);else
		i?(R_rotate(q),R_rotate(p)):(L_rotate(q),L_rotate(p));
	}
}
int getnum(int x)
{
	for(int p=RT,t;p;)
	{
		if(t=siz[ls[p]]+1,x==t)return p;
		if(t<x)x-=t,p=rs[p];else p=ls[p];
	}
}
int Q(int p,int x)
{
	int res=0;
	for(;p;)
		if(mi[rs[p]]<x)res+=siz[ls[p]]+1,p=rs[p];else
		if(d[p]<x)return res+=siz[ls[p]]+2;else p=ls[p];
	return res+1;
}
void sft(int l,int r)
{
	splay(getnum(r-1)),splay(getnum(r+1),RT);
	ls[rs[RT]]=0,pup(rs[RT]),pup(RT);
	splay(getnum(l-1)),splay(getnum(l),RT);
	ls[rs[RT]]=i,fa[i]=rs[RT];
	pup(rs[RT]),pup(RT);
}
void dfs(int p)
{
	if(!p)return;
	dfs(ls[p]),a[d[p]]=++i,dfs(rs[p]);
}
int main()
{
	fread(buf,1,4e6,stdin),c=buf;
	n=Read(),k=Read();
	for(i=1;i<=n;d[Read()]=i++);
	rs[RT=n+2]=1,fa[1]=RT,*mi=n;
	for(siz[RT]=n+2,siz[n+1]=1,i=n;i;--i)
		rs[i]=i+1,fa[i+1]=i,siz[i]=n+2-i;
	for(i=2;i<=n;++i)
	{
		splay(getnum(1)),splay(getnum(i+1),RT);
		if((j=Q(ls[rs[RT]],k+d[i]))<i)sft(j+1,i+1);
	}
	splay(getnum(1)),splay(getnum(n+2),RT);
	i=0,dfs(ls[rs[RT]]);
	for(*t=10,c=buf,i=1;i<=n;W(a[i++]));
	fwrite(buf,1,c-buf,stdout);
}

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

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

  int memo[100010] = {};
  for(int i = 0;i < n;i++){
    memo[a[i]-1]++;
    memo[a[i]]++;
    memo[a[i]+1]++;
  }

  int ans = 0;
  for(int i = 0;i < 100010;i++){
    ans = max(ans,memo[i]);
  }

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


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static int cost(int[] heights){
        int[] cost = new int[heights.length];
        cost[0] = 0;
        cost[1] = Math.abs(heights[1] - heights[0]);
        for (int i = 2; i < heights.length; i++) {
            cost[i] = Math.min(cost[i-1] + Math.abs(heights[i] - heights[i-1]),
                    cost[i-2] + Math.abs(heights[i] - heights[i-2]));
        }
        return cost[heights.length - 1];
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        int[] h = new int[N];
        StringTokenizer st = new StringTokenizer(reader.readLine());
        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(st.nextToken());
        }
        System.out.println(cost(h));
    }
}


Measured memory_bytes: 31776
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
int main() {
    FIO;
    //test
    {
        ll n;
        cin>>n;
        vector<ll>a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        ll ans=0;
        ll sum=0;
        for(int i=0;i<n;i++){
            ans+=(sum*a[i]);
            ans%=mod;
            sum+=a[i];
            sum%=mod;
        }
        cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 4688
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vector<pint> kokyaku;
vector<int> pr,nw;

int main() {
	int n;
	string str;
	bool pre=true;
	while(getline(cin,str)){
		if(str.size()==0){
			pre=false;
			continue;
		}
		n=0;
		int i;
		for(i=0;str[i]!=',';i++){
			n=n*10+str[i]-'0';
		}
		for(i=0;i<kokyaku.size();i++){
			if(kokyaku[i].first==n){
				kokyaku[i].second++;
				break;
			}
		}
		if(i==kokyaku.size()){
			kokyaku.push_back(pint(n,1));
		}
		if(pre){
			for(i=0;i<pr.size();i++){
				if(pr[i]==n){
					break;
				}
			}
			if(i==pr.size()){
				pr.push_back(n);
			}
		}else{
			for(i=0;i<nw.size();i++){
				if(nw[i]==n){
					break;
				}
			}
			if(i==nw.size()){
				nw.push_back(n);
			}
		}
	}
	sort(kokyaku.begin(),kokyaku.end());
	sort(nw.begin(),nw.end());
	sort(pr.begin(),pr.end());
	int i;
	for(i=0;i<kokyaku.size();i++){
		if(find(pr.begin(),pr.end(),kokyaku[i].first)!=pr.end()&&find(nw.begin(),nw.end(),kokyaku[i].first)!=nw.end())
			cout<<kokyaku[i].first<<" "<<kokyaku[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
using namespace std;

string s;

ll dfs(int depth,vector<ll> ele,stack<int> lazy){
//    cout << ele.size()<<":"<< lazy.size() <<endl;
    ll res = 0;
    if(depth==s.size()-1){
        lazy.push(s[depth]-48);
        ll last = 0;
        int i = 0;
        while(!lazy.empty()){
            last += lazy.top()*pow(10,i++);
//            cout << "l " << lazy.top() << endl;
            lazy.pop();
        }
        ele.push_back(last);
        for(auto x:ele){
//            cout << "ele "<<  x<< endl;
            res += x;
        }
//        cout << res<< endl;
        return res;
    }
    lazy.push(s[depth]-48);
    res += dfs(depth+1,ele,lazy);
    lazy.pop();
    ll last = s[depth]-48;
    int i = 1;
    while(!lazy.empty()){
        last += lazy.top()*pow(10,i++);
        lazy.pop();
    }
    ele.push_back(last);
    res += dfs(depth+1,ele,lazy);
    return res;
}
void solve(){
    ll res = 0;
    vector<ll> v;
    stack<int> l;
    res = dfs(0,v,l);
    cout << res << endl;
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main (){
   string s;
   string t;
   cin >> s >> t;
   sort(t.begin(),t.end());
   reverse(t.begin(),t.end());
   sort(s.begin(),s.end());
   int v=s.size();
   if(v>t.size()){
       v=t.size();
   }
   for(int i=0;i<v;i++){
       if(s[i]<t[i]){
           cout << "Yes" << endl;
           return 0;
       }
       if(s[i]>t[i]){
           cout << "No" << endl;
           return 0;
       }
   }
   if(s.size()>=t.size()){
   cout <<"No"<<endl;
   }
   else{
       cout <<"Yes"<<endl;
   }
    return 0;
}

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

int main()
{
    int a , b = 0;
    cin >> a;
    for(int  i = 1 ; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            if(i*j == a) {
                return cout << "Yes" << endl, 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>

using namespace std;

bool inPaper(int x, int y) {
	return x >= 0 && x < 10 && y >= 0 && y < 10;
}

int main() {
	const pair<int, int> small[] = {
		        {0, -1},
		{-1, 0},{0, 0},{1, 0},
		        {0, 1}
	};
	const pair<int, int> medium[] = {
		{-1, -1}, {0, -1}, {1, -1},
		{-1,  0}, {0, 0},  {1,  0},
		{-1,  1}, {0, 1},  {1,  1}
	};
	const pair<int, int> large[] = {
            	   {0, -2},
		{ -1, -1 },{ 0, -1 },{ 1, -1 },
		{ -2, 0 }, { -1,  0 },{ 0, 0 },{ 1,  0 },{ 2, 0 },
		{ -1,  1 },{ 0, 1 },{ 1,  1 },
				   { 0, 2 },
	};

	int paper[10][10] = {};

	while (true) {
		int x, y, size;
		
		cin >> x;
		cin.ignore();
		cin >> y;
		cin.ignore();
		cin >> size;
		if (cin.eof()) {
			break;
		}

		const pair<int, int>* it_begin;
		const pair<int, int>* it_end;
		switch (size)
		{
		case 1:
			it_begin = begin(small);
			it_end = end(small);
			break;
		case 2:
			it_begin = begin(medium);
			it_end = end(medium);
			break;
		case 3:
			it_begin = begin(large);
			it_end = end(large);
			break;
		default:
			break;
		}
		for (auto it = it_begin; it != it_end; ++it) {
			int x2 = x + it->first, y2 = y + it->second;
			if (inPaper(x2, y2)) {
				++paper[x2][y2];
			}
		}
	}
	int zero_count = 0;
	for (auto& a : paper) {
		for (auto& b : a) {
			if (b == 0) {
				++zero_count;
			}
		}
	}
	cout << zero_count << endl;

	int maximum = 0;
	for (auto& a : paper) {
		for (auto& b : a) {
			if (b > maximum) {
				maximum = b;
			}
		}
	}
	cout << maximum << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, r, n) for (int i = (r); i <= (n); i++)

using ll = long long;
using namespace std;

ll white[100100], black[100100];
vector<int> G[100100];
const ll MOD = 1000000007;

pair<ll,ll> dfs(int v, int p = -1){
    ll white = 1;
    ll black = 1;
    for(auto nv : G[v]){
      if(nv == p) continue;
      pair<ll,ll> np = dfs(nv,v);
      white *= np.first + np.second;
      white %= MOD;
      black *= np.first;
      black %= MOD;      
    }
  return make_pair(white,black);
}

int main(){
    int n; cin >> n;
    rep(i,n-1){
        int x, y; cin >> x >> y; x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
  pair<ll,ll> p = dfs(0);
  cout << (p.first+p.second) % MOD << endl;
  return 0;
}

Measured memory_bytes: 15980
strs = input()
 
for i in range(len(strs)):
  if i % 2 != 0:
    if (strs[i] == "L") or (strs[i] == "U") or (strs[i] == "D"):
      continue
    else:
      print("No")
      break
  else:
    if (strs[i] == "R") or (strs[i] == "U") or (strs[i] == "D"):
      continue
    else:
      print("No")
      break
else:
  print("Yes")

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

struct edge {
    lli to;
    lli cost;
};

vector<edge> G[100001];
lli x[100001];

#define INF (-LLONG_MAX)

bool rec(lli num, lli cur_x) {
    REP(i, 0, G[num].size()) {
        if (x[G[num][i].to] != INF) {
            if (x[G[num][i].to] != cur_x + G[num][i].cost) {
                return false;
            }
            continue;
        }
        x[G[num][i].to] = cur_x + G[num][i].cost;
        if (!rec(G[num][i].to, x[G[num][i].to]))
            return false;
    }
    return true;
}

int main() {
    lli n,m;
    cin2(n, m);

    set<lli> s;
    lli l[m];
    lli r[m];
    lli d[m];
    ncin3(m, l, r, d);
    if (m == 0)
        goto YES;

    REP(i, 0, m) {
        G[l[i]].push_back({r[i], d[i]});
        s.insert(l[i]);
        s.insert(r[i]);
    }
    REP(i, 0, m) {
        s.erase(r[i]);
    }
    if (s.size() == 0)
        goto NO;

    // n 人目の位置
    REP(i, 0, 100001) {
        x[i] = INF;
    }

    REPIT(it, s) {
        if (x[*it] != INF)
            continue;

        x[*it] = 0;
        if (!rec(*it, 0))
            goto NO;
    }

YES:
    cout << "Yes" << endl;
    return 0;

NO:
    cout << "No" << endl;
}


Measured memory_bytes: 18176