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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

ll min(ll a , ll b){
    if(a < b)   return a;
    return b;
}

ll n , a , b;

int main()
{
    _FastIO;
    cin >> n >> a >> b;
    ll k = a + b;
    ll h = n / k;
    ll ans = h * a;
    ans += min(a , n % k);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

void bubble(int *a,int n,int &d)
{
	int flag=1;
	while(flag==1)
	{
		flag=0;
		for(int j=n-1 ; j>0 ; j--)
		{
			if(a[j]<a[j-1])
			{
				int tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
				flag=1;
				d++;
			}
		}
	}
	forin(i,0,n-1)
	printf("%d ",a[i]);
	printf("%d",a[n-1]);
	newline;
}

int main()
{
	int n;
	scd(n);
	int a[20000];
	scarrd(a,n);
	int d=0;
	bubble(a,n,d);
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 3208
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int L[10], v1, v2;

int main() {
    while (scanf("%d", L) != EOF) {
        rep (i, 9) scanf(",%d", L+i+1);
        scanf(",%d,%d", &v1, &v2);
        double s = 0;
        rep (i, 10) s += L[i];
        const double t = s / (v1+v2);
        double x = t*v1;
        rep (i, 10) {
            if (x <= L[i]) {
                printf("%d\n", i+1);
                break;
            }
            x -= L[i];
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int n,m; cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define FORR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

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

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

int dp[MAX] = {};

signed main() {
	int n, k; cin >> n >> k;
	vector<int> a( n );
	REP( i, n ) cin >> a[i];

	fill( dp, dp + MAX, INF );
	dp[0] = 0;
	REP( i, n ) {
		FORE( j, 1, k ) {
			if( i + j < n ) {
				chmin( dp[i + j], dp[i] + abs( a[i] - a[i + j] ) );
			}
		}
	}
	
	cout << dp[n - 1] << endl;
	
}

Measured memory_bytes: 1792
using System;

class A{
  public static void Main(){
    int i = int.Parse(Console.ReadLine());
    int z, a, k;
    for (int j = 1; j <= 360; j++){
      a = 360 * j;
      k = a / i;
      if (k * i == a){
        Console.WriteLine(k);
        return;
      }
    }
  }
}


Measured memory_bytes: 17440
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Math.PI;

public class Main{
    public static void main(String[] args) {
	try {
	    BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
	    String line;
	    while ((line = stdReader.readLine()) != null) {
		String[] splits = line.split(" ");
		Integer a = Integer.parseInt(splits[0]);
		Integer b = Integer.parseInt(splits[2]);
		String op = splits[1];
		if (op.equals("?")) {
		    System.exit(0);
		} else {
		    if (op.equals("+")) {
			System.out.println( String.format("%d", a + b) );
		    } else if (op.equals("-")) {
			System.out.println( String.format("%d", a - b) );
		    } else if (op.equals("*")) {
			System.out.println( String.format("%d", a * b) );
		    } else if (op.equals("/")) {
			System.out.println( String.format("%d", a / b) );
		    }
		}
	    }
	    stdReader.close();
	} catch (Exception e) {
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 24624
#include<stdio.h>
#include<string.h>

long long down(const void *a,const void *b){
  return *(long long *)b - *(long long *)a;
}

int main(void){
  long long  n;
  scanf("%lld\n",&n);

  long long a[n];
  for(int i = 0;i < n;i ++){
    scanf("%lld",&a[i]);
  }

  qsort(a,n,sizeof(long long),down);

  /*for(int i = 0;i < n;i ++){
    printf("%lld\n",a[i]);
  }*/

  long long ans = 0;
  int count = 0;
  for(int i = 0;i < n-1;i ++){
    if(a[i] == a[i+1]){
      if(ans == 0){
        ans = 1;
      }
      ans *= a[i];
      i ++;
      count ++;
    }
    if(count > 1){
      i += n;
    }
  }
  if(count == 2){
  printf("%lld\n",ans);
  }
  
  else{
    printf("0\n");
  }
  return 0;
}

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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int a, b;
    cin >> a >> b;
    if (a > 0) {
        cout << "Positive" << EOL;
    } else if (a == 0 || b == 0 || (a < 0 && b > 0)) {
        cout << "Zero" << EOL;
    } else {
        if (abs(a - b) % 2 == 0) cout << "Negative" << EOL;
        else cout << "Positive" << EOL;
    } 
}


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

int main()
{
   string s;
   cin>>s;
   int len=s.size()/2;
   int cnt=0;
   for(int i=0,j=s.size()-1;i<len;i++,j--)
   {
      if(s[i]!=s[j])
         cnt++;

   }
   cout<<cnt<<endl;

}


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

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        final int H = sc.nextInt();
        final int N = sc.nextInt();
        int accum = 0;
        for (int i = 0; i < N; i++)
            accum += sc.nextInt();
        out.println(accum < H ? "No" : "Yes");
        out.flush();
    }
}

// FastScanner start
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
// FastScanner end

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

const int MOD=1e9+7,N=1e5,M=18,oo=1e9;

int dp[N];
bool us[N];

int lazy(int n){
    if(us[n])
        return dp[n];
    us[n]=true;
    for(int i=3;i<=n;i++){
        dp[n]=(dp[n]+lazy(n-i))%MOD;
    }
    return dp[n];
}

void smain() {

    int n;
    cin>>n;
    us[0]=true;
    dp[0]=1;
    cout<<lazy(n);

}



Measured memory_bytes: 3660
from copy import deepcopy

H, W, K = map(int, input().split())
C = []
for i in range(H):
    C.append(list(input().strip()))

ans = 0
for h in range(1<<H):
    for w in range(1<<W):
        # print('h={}, w={}'.format(h, w))
        C2 = deepcopy(C)
        for i in range(H):
            if h >> i & 1:
                for j in range(W):
                    C2[i][j] = "."
        for j in range(W):
            if w >> j & 1:
                for i in range(H):
                    C2[i][j] = "."

        cnt = 0
        for i in range(H):
            for j in range(W):
                if C2[i][j] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)


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

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

template <typename T, T (*op)(T, T), T id>
struct SegmentTree {
public:
    SegmentTree(int n) {
        size = 1;
        while (size < n) size <<= 1;
        node.resize(2 * size, id);
    }

    T operator[](int k) {
        return node[k + size];
    }

    void build(const vector<T>& v) {
        for (int k = 0; k < v.size(); k++) node[k + size] = v[k];
        for (int k = size - 1; k > 0; k--) node[k] = op(node[2 * k], node[2 * k + 1]);
    }

    void update(int k, const T& x) {
        k += size;
        node[k] = x;
        while (k >>= 1) node[k] = op(node[2 * k], node[2 * k + 1]);
    }

    T query(int l, int r) {
        T L = id, R = id;
        for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
            if (l & 1) L = op(L, node[l++]);
            if (r & 1) R = op(node[--r], R);
        }
        return op(L, R);
    }

    int find_first(int l, const function<bool(T)>& cond) {
        T L = id;
        int r = 2 * size;
        for (l += size; l < r; l >>= 1, r >>= 1) {
            if (l & 1) {
                T nxt = op(L, node[l]);
                if (cond(nxt)) return find_subtree(l, cond, L, 0);
                L = nxt;
                l++;
            }
        }
        return -1;
    }

    int find_last(int r, const function<bool(T)>& cond) {
        T R = id;
        int l = size;
        for (r += size; l < r; l >>= 1, r >>= 1) {
            if (r & 1) {
                r--;
                T nxt = op(node[r], R);
                if (cond(nxt)) return find_subtree(r, cond, R, 1);
                R = nxt;
            }
        }
        return -1;
    }

private:
    int size;
    vector<T> node;

    int find_subtree(int l, const function<bool(T)>& check, T& x, int type) {
        while (l < size) {
            T nxt = type ? op(node[2 * l + type], x) : op(x, node[2 * l + type]);
            if (check(nxt)) l = 2 * l + type;
            else x = nxt, l = 2 * l + 1 - type;
        }
        return l - size;
    }
};

int op(int a, int b) {
    return max(a, b);
}

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

    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    SegmentTree<int, op, 0> st(N);
    st.build(A);
    for (int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if (T == 1) {
            int X, V;
            cin >> X >> V;
            st.update(X - 1, V);
        } else if (T == 2) {
            int L, R;
            cin >> L >> R;
            cout << st.query(L - 1, R) << "\n";
        } else {
            int X, V;
            cin >> X >> V;
            int j = st.find_first(X - 1, [&](int v) { return v >= V; });
            cout << (j == -1 ? N + 1 : j + 1) << "\n";
        }
    }
}

Measured memory_bytes: 6128
#include <iostream>
int main()
{
  int a, b;
  std::cin >> a >> b;
  if(a < b) std::cout << "a < b\n";
  if(a > b) std::cout << "a > b\n";
  if(a == b) std::cout << "a == b\n";
  return (0);
}

Measured memory_bytes: 1124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

#include <complex>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

typedef double P_type;
typedef complex<P_type> P;
const P_type P_eps = 1e-8; //??´??°???????????????

bool operator<(const P &a, const P &b){
  return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
}

bool operator==(const P &a, const P &b){
  const double eps = P_eps;
  return abs(a.real() - b.real()) <= eps && abs(a.imag() - b.imag()) <= eps;
}

P rotate(P p, double theta){
  return p * P(cos(theta), sin(theta));
}

//??????
double dot(P a, P b) {
  return (a * conj(b)).real();
}

//??????
double cross(P a, P b) {
  return (a * conj(b)).imag();
}

/* ??????ab??¨???c????????¢ */
double distanceSP(P a, P b, P c) {
  if ( dot(b-a, c-a) < P_eps ) return abs(c-a);
  if ( dot(a-b, c-b) < P_eps ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}

/* ??´???ab??¨???c????????¢ */
double distanceLP(P a, P b, P c) {
  return abs(cross(b-a, c-a)) / abs(b-a);
}

/* ?????????????????? */
bool isIntersectedSS(P a1, P a2, P b1, P b2){
  
  //??????a ??¨ ??´???b
  P_type a = cross(b1-b2,a1-b1);
  P_type b = cross(b1-b2,a2-b1);
  
  //??????b ??¨ ??´???a
  P_type c = cross(a1-a2,b1-a1);
  P_type d = cross(a1-a2,b2-a1);
  
  return a*b < -P_eps && c*d < -P_eps; // T?????????????????? -P_eps
}

/* ??´???/???????????? */
P getCrosspointLL(P a1, P a2, P b1, P b2) {
  //assert(isIntersectedLL(a1, a2, b1, b2));
  //assert(isIntersectedSS(a1, a2, b1, b2));
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1-a1) / cross(b, a);
}

P getCrosspointSS(P a1, P a2, P b1, P b2){
  return getCrosspointLL(a1, a2, b1, b2);
}

bool solve(){
  int n;
  
  scanf("%d",&n);

  if(n == 0) return false;

  int ans = 1;

  int xa[SIZE],xb[SIZE],ya[SIZE],yb[SIZE];
  P A[SIZE],B[SIZE];
  
  for(int i=0;i<n;i++){

    scanf("%d%d%d%d",xa+i,ya+i,xb+i,yb+i);
    
    A[i] = P(xa[i],ya[i]);
    B[i] = P(xb[i],yb[i]);
    
    int c = 0;

    vector<P> points;

    for(int j=0;j<i;j++){
      if(isIntersectedSS(A[j],B[j],A[i],B[i])){
        
        P crosspoint = getCrosspointSS(A[j],B[j],A[i],B[i]);
        
        bool flag = false;
        
        for(int k=0;k<points.size();k++){
          if(abs(crosspoint - points[k]) < 1e-10){
            flag = true;
          }
        }
        
        if(!flag){
          c++;
        }
        points.push_back(crosspoint);
      }
    }
    
    ans += (c+1);    
  }

  printf("%d\n",ans);
  
  return true;
}

int main(){

  while(solve());
  
  return 0;
}

Measured memory_bytes: 6316
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>


using namespace std;

const int n_MAX = 21;
const int q_MAX = 20*2000+ 1;

int main(){
  int n;
  cin >> n;
  vector<int> A;
  int tmp;
  for(int i=0; i<n; i++){
    scanf("%d", &tmp);
    A.push_back(tmp);
  }

  int q;
  cin >> q;
  vector<int> m;
  for(int i=0;i<q; i++){
    scanf("%d", &tmp);
    m.push_back(tmp);
  }
  
  bool** dp = new bool*[n_MAX];
  for(int i=0; i<n_MAX; i++){
    dp[i] = new bool[q_MAX];
  }
  /*
  for(int row=0; row<n_MAX; row++){
    for(int col=0; col<q_MAX; col++){
      dp[row][col] = false;
    }
    }*/
  
  for(int col=0; col<q_MAX; col++){
    dp[0][col] = false;
  }

  for(int row=0; row<n_MAX; row++){
    dp[row][0] = true;
  }
  
  
  for(int row=1; row<=A.size(); row++){
    for(int col=0; col<q_MAX; col++){
      if(col-A[row-1] >= 0){
	dp[row][col] = dp[row-1][col-A[row-1]] || dp[row-1][col];
	//if(dp[row][col]) cout << "row: " << row << ", col: " << col << endl;
      }
      else dp[row][col] = dp[row-1][col];
    }
  }
  for(int i=0; i<m.size(); i++){
    int m_i = m[i];
    if(dp[n][m_i]) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  
  for(int i=0; i<n_MAX; i++){
    delete[]  dp[i];
  }      
  delete[] dp;
  
  return 0;
}



Measured memory_bytes: 3652
n = int(input())
A = [0] * n
B = [0] * n
ans = 0
mod = 0
for i in range(n):
    A[i], B[i] = map(int, input().split())

for i in range(n-1, -1, -1):
    ans += 0 if (A[i]+ans)%B[i]==0 else B[i] - (A[i]+ans)%B[i]
print(ans)

Measured memory_bytes: 10868
N = gets.to_i

CHARS = %w(a b c d e f g h i j k l)

def dfs(x, i)
  if x.length == N
    puts x
    return
  end

  0.upto(i) do |j|
    dfs(x + CHARS[j], i == j ? i + 1 : i)
  end
end

dfs('a', 1)


Measured memory_bytes: 14244
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int ans = 0;
    REP(i,s.length() - 1){
        if(s[i + 1] != s[i]) ans++; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

char s[2];
int main(void){
	rep(i,12){
		scanf("%c",s);
		if(i==4)printf(" ");
		printf("%c",s[0]);
	}
	puts("");
	return 0;
}






Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int 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;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    int a[200005];
    map<int, int>mp;
    int ans = 0;

    cin >> n;
    rep(i, n) {
        cin >> a[i];
        mp[a[i] - i]++;
    }
    rep(i, n) {
        mp[a[i] - i]--;
        ans += mp[(a[i] * -1) - i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 27816
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll maxn=2e5+100;
const ll mod=1e9+7;
ll t,a[maxn],sum[maxn];
int main(){
    //ios::sync_with_stdio(0),cout.tie(0),cin.tie(0);
    //freopen("in.txt","r",stdin);
    cin>>t;
    sum[0]=0;
    for(int i=1;i<=t;i++){
        cin>>a[i];
        sum[i]=(sum[i-1]+a[i]);
    }
    ll ans=0;
    for(int i=1;i<t;i++){
        ans+=a[i]*((sum[t]-sum[i])%mod)%mod;
        ans%=mod;
    }
    cout<<(ans+mod*100)%mod<<endl;
    return 0;
}

Measured memory_bytes: 6724
#include <stdio.h>

void call(int n) {
    int i = 1;
    while (i <= n) {
        if (i % 3 == 0) {
            printf(" %d", i);
        } else if (i % 10 == 3) {
            printf(" %d", i);
        } else if (i/10 % 10 == 3) {
            printf(" %d", i);
        } else if (i/100 % 10 == 3) {
            printf(" %d", i);
        } else if (i/1000 % 10 == 3) {
            printf(" %d", i);
        }
        i++;
    }
    printf("\n");
}


int main() {
    int n;
    scanf("%d", &n);

    call(n);
    return 0;
}


Measured memory_bytes: 2108
//Harjot Singh Student NIT JALANDHAR	

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long int ll;

int main()
{
    
   string a,b;
   cin>>a>>b;
   int n=a.length();
    int m=b.length();

   int dp[n+1][m+1];

   for(int i=0;i<=n;i++)
   	dp[i][0]=0;

    for(int i=0;i<=m;i++)
    	dp[0][i]=0;

    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    	{
    		if(a[i-1]==b[j-1])
    			dp[i][j]=1+dp[i-1][j-1];
    		else
    			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    	}

    }
    	

    string s="";
    int i=n,j=m;
    while(i>0&&j>0)
    {
       if(a[i-1]==b[j-1])
       {
       	s=b[j-1]+s;
        i--;j--;
       }
       else
       {
       	if(dp[i-1][j]>dp[i][j-1])
       		i--;
       	else
       		j--;
       }

    }	

    cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 35456
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <utility>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    long long int n,c=0;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(long long int i=0;i<n;){
        long long int dif=upper_bound(a.begin(),a.end(),a[i])-lower_bound(a.begin(),a.end(),a[i]);
        if(dif==a[i]){
            i+=dif;
        }else{
            if(dif<a[i]){
                c+=dif;
                i+=dif;
            }else{
                c+=dif-a[i];
                i+=dif;
            }
        }
        if(i>n){
            break;
        }
    }
    cout<<c;
}

Measured memory_bytes: 640
use proconio::{fastout, input};

const MOD_NUM: i64 = 1_000_000_000 + 7;

#[fastout]
fn main() {
    input! {
        n: usize,
        a_vec: [i64; n],
    };
    let mut a_acc = a_vec.iter().fold(0, |acc, a| (acc + a) % MOD_NUM);
    let mut ans = 0;
    for i in 0..a_vec.len() - 1 {
        a_acc = a_acc - a_vec[i];
        if a_acc < 0 {
            a_acc += MOD_NUM;
        }
        ans = (ans + (a_vec[i] * a_acc)) % MOD_NUM;
    }
    println!("{}", ans);
}


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

int main(){
	long long L, R;
	cin >> L >> R;
	//2019 = 3 * 673
	
	if(R - L + 1 >= 673) cout << 0 << endl;
	
	else{
		long long ans = 2019;
		
		for(long long i = L; i < R; i++){
			for(long long j = i + 1; j <= R; j++){
				long long x = (i * j) % 2019;
				ans = min(ans, x);
			}
		}
		cout << ans << endl;
	}
}

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

long long int N, a[2][333333], A;
string s;

int main(){
    scanf("%lld", &N);
    cin >> s;
    for(int i = 1; i <= N; ++i){
        ++a[!(s[i - 1] & 2)][i + ((s[i - 1] & 2) ? 1 : -1)];
    }
    reverse(a[1], a[2]);
    partial_sum(a[0], a[0] + 333333, a[0]);
    partial_sum(a[1], a[1] + 333333, a[1]);
    reverse(a[1], a[2]);
    A = 101010101010;
    for(int i = 1; i <= N; ++i){
        A = min(A, a[0][i] + a[1][i]);
    }
    cout << A << endl;
    return 0;
}

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

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt(),min = Integer.MAX_VALUE,max = Integer.MIN_VALUE,arr[] = new int[n];
        for(int i=0;i<n;i++) {arr[i] = obj.nextInt();if(min>arr[i])min = arr[i]; if(max<arr[i])max = arr[i];}
        TreeSet<Integer> data = new TreeSet<>();
        for(int i=min;i<=max;i++)
        {
            int sum =0;
            for(int j=0;j<n;j++)
                sum += (arr[j]-i)*(arr[j]-i);
            data.add(sum);
        }
        System.out.println(data.first());
    }
}


Measured memory_bytes: 20948
#include <stdio.h>
#include <string.h>

int main(void)
{
    char str01, str02, str03, str04, str05, str06;

    // 文字列の読み取り
    scanf("%c%c%c%c%c%c", &str01, &str02, &str03, 
                    &str04, &str05, &str06);

    if((str03 == str04) && (str05 == str06)){
        printf("Yes");
    }
    else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
import numpy as np

n, m, x, y = map(int, input().split())
px = np.array([int(i) for i in input().split()])
py = np.array([int(i) for i in input().split()])

res = 'War'
for i in range(x+1, y+1):
    if np.count_nonzero(px < i) == n and np.count_nonzero(py >= i) == m:
        res = 'No War'
        break
print(res)


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

if c>=a:
    c-=a
    a=0
    
else:
    a-=c
    c=0
#print(a,b,c)    
if c>=b:
    c-=b
    b=0
    
else:
    b-=c
    c=0
print(a,b)    

Measured memory_bytes: 38256
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc166_a
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3592
program ABC163B
    implicit none
    integer(8)::N,M,i
    integer(8),allocatable,dimension(:)::A
    read*,N,M
    allocate(A(M))
    read*,A
    do i=1,M
        N=N-A(i)
    end do

    if(N<0)then
        print'(i0)',-1
    else
        print'(i0)',N
    end if
end program ABC163B

Measured memory_bytes: 2964
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
#include <cstring>
#include <math.h>

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N, M;
    cin >> N >> M;

    int k[M], p[M];
    vector< vi > s;
    REP(i, M) {
        cin >> k[i];
        vi v;
        REP(j, k[i]) {
            int tmp; cin >> tmp;
            tmp--;
            v.pb(tmp);
        }
        s.pb(v);
    }
    REP(i, M) cin >> p[i];

    int pattern = pow(2, N);
    int ans = 0;
    REP(i, pattern) {
        bool ok = true;
        REP(j, M) {
            int cnt = 0;
            REP(_k, k[j]) {
                int tmp = i & (1 << s[j][_k]);
                if (tmp) cnt++;
            }
            if (cnt % 2 != p[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
}

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



int main() {
    int n;
    cin >> n;
    vector<int>s(n);
    rep(i,n) cin >> s[i];
    int q;
    cin >> q;
    vector<int>t(q);
    rep(i,q) cin >> t[i];
    int sum = 0;
    rep(i,q) {
        int left = -1;
        int right = s.size();
        while(right - left > 1) {
            int mid = left + (right - left) / 2;
            if(s[mid] >= t[i]) right = mid;
            else left = mid;
        }
        if(s[right] == t[i]) sum++;
    }
    cout << sum << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

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

    string S;
    cin >> S;
    bool flag = true;

    REP(i, S.size()){
    	if(i%2==0 && S[i]=='L') flag = false;
    	if(i%2==1 && S[i]=='R') flag = false;
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

int pos[100002];
int sum;

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

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string s;
ll DP[13], DP2[13];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  DP[0] = 1;
  for(char c:s){
    int i, r;
    if(c=='?') i=0, r=10;
    else i=c-'0', r=i+1;
    fill(DP2, DP2+13, 0);
    for(; i<r; i++) FOR(j, 0, 13) DP2[(j*10+i)%13] += DP[j];
    FOR(j, 0, 13) DP2[j] %= MOD;
    swap(DP, DP2);
  }
  cout << DP[5] << endl;
}

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

int main(){
    int n; cin >> n;
    n %= 10;
    if(n == 3) cout << "bon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N,M;
  cin >> N;
  string s[N];
  for(int i=0;i<N;i++) cin >> s[i];
  cin >> M;
  string t[M];
  for(int i=0;i<M;i++) cin >> t[i];
  int sa[N];
  for(int i=0;i<N;i++) sa[i] = 1;
  for(int i=1;i<N;i++){
    for(int j=0;j<i;j++){
      if(s[i] == s[j]){
        sa[j]++;
        sa[i]--;
        break;
      }
    }
  }
  for(int i=0;i<N;i++){
    if(sa[i]>0){
      for(int j=0;j<M;j++){
        if(s[i] == t[j]) sa[i]--;
      }
    }
  }
  int Ans = 0;
  for(int i=0;i<N;i++){
    if(Ans < sa[i]) Ans = sa[i];
  }
  cout << Ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  int N;
  cin >> N;

rep2(i,1,N+1){
if(N == floor(i * 1.08)){
cout << i << endl;
return 0;
}
}
cout << ":(" << endl; 

  return 0;
}


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

int main(){
    string s;
    cin >> s;
    
    vector<int> a(26,0);
    rep(i,s.size()){
        a[s[i]-'a']++;
    }
    
    string ans = "Yes";
    
    rep(i,26){
        if(a[i]%2!=0) {
            ans = "No";
            break;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int a,b;
  cin >> a >> b;

  if(b % a == 0){
    cout << a + b << endl;
  }
  else{
    cout << b - a << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int main()
{
    char S[12];
    int c_count=0,flg=0;
    scanf("%s",S);

    if( S[0] == 'A' ){
        for(int i=1;i<strlen(S);i++){
            if( S[i] < 'a' || S[i] > 'z' ){
                flg++;
            }
        }
        for(int i=2;i<strlen(S)-1;i++){
            if( S[i] == 'C' ){
                c_count++;
            }
        }
    }else{
        printf("WA\n");
        return 0;
    }

    if( flg == 1 && c_count == 1 ){
        printf("AC\n");
    }else{
        printf("WA\n");
    }

    return 0;
}

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

int main() {
    int n, m;
    while(true) {
        pair<int, int> guard[100000];
        int exp = 0;
        cin >> n >> m;
        if(n == 0 && m == 0) {
            break;
        }
        for(int i = 0; i < n; ++i) {
            cin >> guard[i].second >> guard[i].first;
            exp += guard[i].second * guard[i].first;
        }
        sort(guard, guard + n, greater<pair<int, int> >());
        for(int i = 0; i < n; ++i) {
            int cost = min(guard[i].second, m);
            m -= cost;
            exp -= cost * guard[i].first;
            if(m <= 0) {
                break;
            }
        }
        cout << exp << endl;
    }
    return 0;
}

Measured memory_bytes: 1944
#!/usr/bin/env python3
#ABC120 B

A,B,K = list(map(int,input().split()))
c = 0
for i in range(1,max(A,B)+1)[::-1]:
    if A % i == 0 and B % i == 0:
        c += 1
        if c == K:
            print(i)
            quit()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){

    int a,b,c,res;
    cin>>a>>b>>c;
    res=a-b;
    c=c-res;
    if(c<0){
        cout<<"0"<<endl;
    }
    else{
        cout<<c<<endl;
    }

}









Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,l,s,t,d[301][301],x[20],tim[20],dl[20][20],dp[1<<16][16],a,b,c;
int main(){
  while(cin>>n>>m>>l>>s>>t,n){
    r(i,(1<<l))r(j,16)dp[i][j]=1e8;
    int ans=0,p=0;s--;
    r(i,n)r(j,n)d[i][j]=1e8;
    r(i,m){
      cin>>a>>b>>c;
      d[--a][--b]=d[b][a]=c;
    }
    r(i,l)cin>>x[i]>>tim[i],x[i]--;
    r(k,n)r(i,n)r(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    r(i,l)r(j,l)dl[i][j]=d[x[i]][x[j]]+tim[j];
    r(i,l)dp[(1<<i)][i]=d[s][x[i]]+tim[i];
    r(i,(1<<l))r(j,l)if((1<<j)&i)r(k,l)if(j!=k&&dl[j][k]&&((1<<k)&i)==0)
      if(dl[j][k]+dp[i][j]<=t)dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+dl[j][k]);
    r(i,(1<<l))r(j,l)if(dp[i][j]+d[x[j]][s]<=t)ans=max(ans,__builtin_popcount(i));
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 7444