akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  cin>>a;
  vl ans(1,-LINF);
  rep(si,2) {
    vp p;
    for (int i = si; i < n; i += 2) p.eb(a[i],i);
    if (sz(p) == 0) continue;
    sort(rrng(p));
    vi s;
    ll now = 0;
    rep(i,sz(p)) {
      if (i && p[i].fi < 0) break;
      s.pb(p[i].se+1);
      now += p[i].fi;
    }
    if (now < ans[0]) continue;
    sort(rrng(s));
    ans = vl();
    for (int i = n; i > s[0]; --i) ans.pb(i);
    srep(i,1,sz(s)) {
      int w = s[i-1]-s[i];
      rep(j,w/2-1) ans.pb(s[i]+2);
      ans.pb(s[i]+1);
    }
    rep(i,s.back()-1) ans.pb(1);
    ans.insert(ans.begin(), sz(ans));
    ans.insert(ans.begin(), now);
  }
  for (ll x : ans) cout<<x<<endl;
  return 0;
}






















Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		if(a<=5) {
			System.out.println(0);
		}else if(a<=12) {
			System.out.println(b/2);
		}else {
			System.out.println(b);
		}
	}
}



Measured memory_bytes: 21332
import java.util.Scanner;

class Main {

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

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        int kosu = 0;
        for (int x = a; x <= b; x++) {
            if(c % x == 0){
                kosu++;
            }
        }
        System.out.println(kosu);
    }
}



Measured memory_bytes: 26052
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
const int MX = 200005;
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------

void Main(){
  int n;
  cin>>n;
  int t0=0,t1=0,x0=0,x1=0,y0=0,y1=0;
  rep(i,n){
    cin>>t1>>x1>>y1;
    int time = (t1-t0);
    int dist = ( abs(x1-x0) + abs(y1-y0) );
    bool f = time>=dist and time%2 == dist%2;
    if(f){
      t0=t1;
      x0=x1;
      y0=y1;
    }else{
      cout<<"No"<<endl;
      return;
    }   
  }
  cout<<"Yes"<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
#graphの頂点vertex(インデックス、0オリジン)を深さ優先探索。dis_time:最初に訪れた時のtimeを管理するリスト
#fin_time:その頂点に対して、探索が終わった時のtimeを管理するリスト　tmp_time:現在のtime(関数内で変更できるようにリスト)
def DPS(graph,vertex,dis_time,fin_time,tmp_time):
    tmp_time[0]+=1
    dis_time[vertex]=tmp_time[0]
    for i in range(len(graph[0])):
        if(graph[vertex][i] !=0 and dis_time[i]==0):#枝先の頂点が探索済みでなかったら、
            DPS(graph,i,dis_time,fin_time,tmp_time)
    
    tmp_time[0]+=1
    fin_time[vertex]=tmp_time[0]



#グラフの作成
n=int(input())
graph=[[0]*n for loop in range(n)]
for loop in range(n):
    tmp_ope=list(map(int,input().split()))
    for j in range(tmp_ope[1]):
        graph[tmp_ope[0]-1][tmp_ope[j+2]-1]=1


dis_time=[0]*n
fin_time=[0]*n
tmp_time=[0]
for i in range(n):
    if(dis_time[i]==0):
        DPS(graph,i,dis_time,fin_time,tmp_time)

for i in range(n):
    print(f"{i+1} {dis_time[i]} {fin_time[i]}")


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll r, d, x;
	cin >> r >> d >> x;
	REP(i, 10) {
		x = r * x - d;
		cout << x << endl;
	}
}

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

const int MAXN = 100005;

int N;
long long A[MAXN], B[MAXN];

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%lld", &A[i]);
		B[i] = A[i];
	}
	
	long long r1 = 0, r2 = 0;
	for(int i = 59, k = 0; i >= 0; i--){
		int ind = -1, p = 0;
		
		for(int j = 0; j < N; j++)if(B[j] & (1LL << i))
			p ^= 1;
		
		for(int j = k; j < N; j++)if(A[j] & (1LL << i)){
			ind = j;
			break;
		}
		
		if(p == 1){
			r1 += 1LL << i;
			continue;
		}
		if(ind == -1)continue;
		
		swap(A[ind], A[k]);
		if(!(r2 & (1LL << i)))r2 ^= A[k];
		
		for(int j = k + 1; j < N; j++)
			if(A[j] & (1LL << i))A[j] ^= A[k];
		
		k++;
	}
	r2 &= ~r1;
	
	printf("%lld\n", r1 + 2 * r2);
	
	return 0;
}


Measured memory_bytes: 1792
MOD = 1_000_000_007
s = gets.to_i

dp = Array.new(s + 1) { Array.new(s + 1, 0) }
dp[0][0] = 1

s.times do |i|
  tmp = 0
  3.upto(s) do |m|
    tmp = (tmp + dp[i][m - 3]) % MOD
    dp[i+1][m] = tmp
  end
end

sum = 0
s.times do |i|
  sum = (sum + dp[i][s]) % MOD
end

p sum


Measured memory_bytes: 45412
import sys

input = sys.stdin.readline


def main():
    N, W = [int(x) for x in input().split()]
    wv = [[int(x) for x in input().split()] for _ in range(N)]

    dp = [[0] * (W + 1) for j in range(N + 1)]

    for j in range(N):
        for i in range(W + 1):
            if i < wv[j][0]:
                dp[j + 1][i] = dp[j][i]
            else:
                dp[j + 1][i] = max(dp[j][i], dp[j][i - wv[j][0]] + wv[j][1])

    print(dp[N][W])

if __name__ == '__main__':
    main()


Measured memory_bytes: 118512
s = gets.chomp
len = s.length
ans = []
cnt = 0
num = 0
if s[0] == "<"
  ans << num
end
(len-1).times do |i|
  if s[i] == "<" && s[i+1] == "<"
    num += 1
    ans << num
  elsif s[i] == "<" && s[i+1] == ">"
    num += 1
  elsif s[i] == ">" && s[i+1] == "<"
    cnt += 1
    cnt.times do |j|
      if j == 0 && num > cnt-j
        ans << num
      else
        ans << cnt-j
      end
    end
    cnt = 0
    num = 0
    ans << num
  elsif s[i] == ">" && s[i+1] == ">"
    cnt += 1
  end
end
if s[-1] == ">"
  cnt += 1
  cnt.times do |j|
    if j == 0 && num > cnt-j
      ans << num
    else
      ans << cnt-j
    end
  end
  ans << 0
else
  num += 1
  cnt += 1
  cnt.times do |j|
    if j == 0 && num > cnt-j
      ans << num
    else
      ans << cnt-j
    end
  end
end
puts ans.inject(:+)

Measured memory_bytes: 19664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    long sum[n];
    sum[0] = a[0];
    for(int i=1;i<n;i++)sum[i] = sum[i-1] + a[i];
    set<long>s;
    map<long,int>m;
    for(int i=0;i<n;i++){
        s.insert(sum[i]);
        m[sum[i]]++;
    }
    long ans = 0;
    for(long i:s){
        long tmp = m[i];
        ans += tmp * (tmp-1)/2;
    }
    ans += m[0];
    cout << ans << endl;
    
}

Measured memory_bytes: 25216
#include<stdio.h>

int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<b) printf("a < b\n");
    if(a>b) printf("a > b\n");
    if(a==b) printf("a == b\n");
 
    return 0;
}

Measured memory_bytes: 580
#include <cstdio>
#include <iostream>

using namespace std;

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

  // row: S, H, C, D
  bool a[4][13] = {false};

  char kind;
  int v;
  for (int i = 0; i < n; ++i) {
    cin >> kind >> v;
    switch (kind) {
      case 'S':
        a[0][v-1] = true;
        break;
      case 'H':
        a[1][v-1] = true;
        break;
      case 'C':
        a[2][v-1] = true;
        break;
      case 'D':
        a[3][v-1] = true;
        break;
    }
  }
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 13; ++j) {
      if (!a[i][j]) {
        if (i == 0) printf("S");
        else if (i == 1) printf("H");
        else if (i == 2) printf("C");
        else printf("D");

        printf(" %d\n", j + 1);
      }
    }
  }

  return 0;
}

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

int main()
{
        int N;
        cin >> N;
        int x[N];
        int y[N];
        for (int i = 0; i < N; ++i) {
                cin >> x[i] >> y[i];
        }

        if (N == 1) {
                cout << 1 << endl;
                exit(0);
        }

        long long ans = -1;
        for (int i = 0; i < N; ++i) {

                for (int j = 0; j < N; ++j) {

                        if (i == j) continue;

                        long long p = x[j] - x[i];
                        long long q = y[j] - y[i];
                        long long cnt = 0;
                        for (int ii = 0; ii < N; ++ii) {

                                for (int jj = 0; jj < N; ++jj) {

                                        if (ii == jj) continue;

                                        long long pp = x[jj] - x[ii];
                                        long long qq = y[jj] - y[ii];

                                        if (p == pp && q == qq) {

                                                cnt++;
                                        }
                                }
                        }

                        if (ans == -1) {
                                ans = N - cnt;
                        }
                        else {
                                if (ans > N - cnt) {
                                        ans = N - cnt;
                                }
                        }

                }
        }
        cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200001
#define MOD 1000000007

typedef long long int lli;

long double Predict(int x) {
  long double sum = (1 + x) * x / 2;
  return sum / (long double)x;
}

int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);
  int p[MAX];
  rep(i, 0, n) scanf("%d", &p[i]);

  long double pre = 0;
  rep(i, 0, k) {
    pre += Predict(p[i]);
  }
  long double ans = pre;
  rep(i, 0, n) {
    int f = i;
    int nl = i + k;
    if (nl > n - 1) break;
    pre -= Predict(p[f]);
    pre += Predict(p[nl]);
    ans = max(ans, pre);
  }
  printf("%.7Lf\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,s=0;
cin>>a>>b;
int c[b];
for(int i=0;i<b;i++){
	cin>>c[i];
	s=s+c[i];
}
if(s>=a)cout<<"Yes";
else cout<<"No";
return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int r; cin >> r;
    
    cout << 3 * r * r << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		if(n>=30)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 35696
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef  long long LL;
typedef  vector<int> VI;
typedef  vector<double> VD;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
#define POW2(a) pow(a, 2.0)
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int x;
	cin >> x;
	REP(i,x)
	{
		VD tri;
		REP(i, 3)
		{
			double temp;
			cin >> temp;
			tri.push_back(temp);
		}
		SORT(tri);
		if (tri[2] == sqrt(POW2(tri[0]) + POW2(tri[1])))
		{
			COUT("YES");
		}
		else
		{
			COUT("NO");
		}
	}
	
#ifdef _DEBUG
	while(1);
#endif // _DEBUG

	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int a = (C - 1) / B + 1;
  int b = (A - 1) / D + 1;
  cout << (a <= b ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    const int m = 3;
    vi tar(m); for(auto& e : tar) cin >> e;
    vi L(n); for(auto& e : L) cin >> e;

    int res = inf;
    rep(k, bit(2 * n)){
        vi cur(m), cnt(m);
        rep(i, n){
            int stat = (k >> (2 * i) & 3);
            if(stat == 3) continue;
            cur[stat] += L[i];
            cnt[stat]++;
        }
        bool ok = true;
        int cost = 0;
        rep(i, m){
            if(cnt[i] == 0){ ok = false; break; }
            cost += 10 * (cnt[i] - 1);
            cost += 1 * abs(tar[i] - cur[i]);
        }

        if(ok) chmin(res, cost);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, m, k;
int fa[100005], siz[100005];
int ff[100005] = {0};
vector<int> kk[100005];
int Find(int x){
    return (fa[x] == x ? x: (fa[x] = Find(fa[x])));
}
void Union(int x, int y){
    int u = Find(x), v = Find(y);
    if (u == v) return ;
    if (siz[u] > siz[v])
        fa[v] = u, siz[u] += siz[v];
    else
        fa[u] = v, siz[v] += siz[u];
}
void init(){
    n = read(), m = read(), k = read();
    for (int i = 1; i <= n; ++i)
        fa[i] = i, siz[i] = 1;
    for (int i = 1; i <= m; ++i){
        int u = read(), v = read();
        ++ff[u], ++ff[v];
        Union(u, v);
    }
    for (int i = 1; i <= k; ++i){
        int u = read(), v = read();
        kk[u].push_back(v), kk[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i)
        Find(i);
}
void solve(){
    for (int i = 1; i <= n; ++i){
        int s = siz[fa[i]];
        s -= ff[i];
        for (int x: kk[i])
            if (fa[x] == fa[i]) --s;
        printf("%d ", s - 1);
    }
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, a;
  cin >> n >> a;
  if (n%500 <= a) dump("Yes");
  else dump("No");
  
  return 0;
}


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

using namespace std;

typedef long long ll;

double sol[301][301][301];
double n;

double solve(ll a, ll b, ll c) {
    if (a+b+c == 0) {
        return sol[0][0][0] = 0;
    }

    if (sol[a][b][c] != -1) {
        return sol[a][b][c];
    }
    double total = (a+b+c);
    double p = (n/total);

    sol[a][b][c] = 0;
    if (a>0) {
        sol[a][b][c] += (a/total)*(p+solve(a-1, b, c));
    }

    if (b>0) {
        sol[a][b][c] += (b/total)*(p+solve(a+1,b-1,c));
    }

    if (c>0) {
        sol[a][b][c] += (c/total)*(p+solve(a,b+1,c-1));
    }

    return sol[a][b][c];
}

int main() {

    int a[4] = {0};

    cin >> n;
    int sushi;

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

    for (ll i=0; i<=300; i++) {
        for (ll j=0; j<=300; j++) {
            for (ll k=0; k<=300; k++) {
                sol[i][j][k] = -1;
            }
        }
    }
    cout.precision(20);
    cout << solve(a[1], a[2], a[3]) << endl;

}

Measured memory_bytes: 213376
#include <cstdio>
#include <algorithm> 
using namespace std;
int n,ans=24,a[24];
int main(){
	scanf("%d",&n);
	if (n>=24){puts("0");return 0;}
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);++n;
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i++){
		if (i&1) a[i]=24-a[i];
		if (a[i]==24) a[i]=0; 
	}
	sort(a+1,a+1+n);
	for (int i=2;i<=n;i++) ans=min(ans,a[i]-a[i-1]);
	printf("%d\n",ans);
	return 0;
}

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

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
int main()
{
	int x;
	cin>>x;
	int ans = 0;
	ans += x/500*1000;
	x%=500;
	ans += x/5*5;
	cout<<ans<<"\n";
	return 0;
}



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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
//---------------------------------------------------------------
int main(){
  double N;
  cin>>N;
  double pi =  3.14159265358979323846;
  N = 2*N*pi;
  prt_dbl(4,N)

}


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

int main(){
 string s,tmp;
 int m,h;
 while(cin >> s && s != "-"){
  cin >> m;
  for(int i=0; i<m; i++){
   cin >> h;
   tmp = s.substr(0,h);
   s.erase(0,h);
   s = s + tmp;
  }
  cout << s << endl;
 }
}


Measured memory_bytes: 3240
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_086_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(12).
    01 maxlen PIC 9(1)  VALUE 2.
    01 cur    PIC 9(12)  VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 len    PIC 9(12).

    01 ab1.
        03 ab11 OCCURS 2.
            05 ab PIC 9(5).

    01 x      PIC 9(9).
    01 d      PIC 9(9).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO AB(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    MULTIPLY AB(1) BY AB(2) GIVING x.
    DIVIDE 2 INTO x GIVING x REMAINDER d.

    IF d = 0 THEN
        DISPLAY "Even"
    ELSE
        DISPLAY "Odd"
    END-IF.

    STOP RUN.


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

int main(){
  int a,b;
  cin >> a >> b;
  string s="";
  if(a<b){
    for(int i=0;i<b;i++){
      s+=to_string(a);
    }
  }else{
    for(int i=0;i<a;i++){
      s+=to_string(b);
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <numeric>
using namespace std;
using ll = long long;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+8
#define PI acos(-1)
#define TAU PI * 2
const ll MOD = 1000000007;

int main(){
    double a, b, x;
    cin >> a >> b >> x;


    double ans = 0;
    if(x > a * a * b / 2){
        double h = 2 * (a * a * b - x) / (a * a);
        ans = atan(h / a) * 180.0 / PI;
    }else{
        double k = 2 * x / (a * b);
        ans = atan(b / k) * 180.0 / PI;
    }

    printf("%.12lf", ans);
}

Measured memory_bytes: 512
import fractions

a, b, c, d = [int(i) for i in input().split()]

if c == 1 or d == 1:
    print(0)
    exit()

c_left = max(0, [a // c - 1, a // c][a % c != 0])
c_right = b // c

d_left = max(0, [a // d - 1, a // d][a % d != 0])
d_right = b // d

cdgcd = (c * d) // fractions.gcd(c, d)

cd_left = max(0, [a // cdgcd - 1, a // (cdgcd)][a % (cdgcd) != 0])
cd_right = b // (cdgcd)

c_number = c_right - c_left
d_number = d_right - d_left
cd_number = cd_right - cd_left

print(b - a + 1 - (c_number + d_number - cd_number))


Measured memory_bytes: 5048
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int n, m, l;
    double c;
    int **a, **b;

    scanf ("%d %d %d", &n, &m, &l);
    a = (int **) malloc (sizeof(int *) * n);
    for (int i=0; i<n; i++) {
        a[i] = (int *) malloc (sizeof(int) * m);
        for (int j=0; j<m; j++) {
            scanf ("%d", &a[i][j]);
        }
    }
        
    b = (int **) malloc (sizeof(int *) * m);
    for (int i=0; i<m; i++) {
        b[i] = (int *) malloc (sizeof(int) * l);
        for (int j=0; j<l; j++) {
            scanf ("%d", &b[i][j]);
        }
    }

    for (int i=0; i<n; i++) {
        for (int j=0; j<l; j++) {
            c = 0;
            for (int k=0; k<m; k++) {
                c += a[i][k] * b[k][j];
            }
            if (j==l-1) printf ("%.0lf\n", c);
            else printf ("%.0lf ", c);
        }
    }

    for (int i=0; i<n; i++)
        free(a[i]);
    free(a);
    for (int i=0; i<m; i++)
        free(b[i]);
    free(b);

    return 0;
}


Measured memory_bytes: 2144
N = int(input())

txy = [[0,0,0]]

for i in range(N):

    new = list(map(int,input().split()))

    txy.append(new)

ans = "Yes"
for i in range(N):

    leng = abs(txy[i+1][1]-txy[i][1]) + abs(txy[i+1][2]-txy[i][2])
    time = txy[i+1][0]-txy[i][0]



    if leng > time or (leng-time)%2 != 0 :
        ans = "No"
        #print(leng,time)
        break

print (ans)


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

int main() {
  array<int, 32> a = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                      1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin >> k;
  --k;

  cout << a[k] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	auto a = vector<int>(n);
	int total = 0;
	for(auto&& aa : a){
		cin >> aa;
		total += aa;
	}
	sort(a.begin(), a.end(), greater<int>());
	cout << (a[m - 1] * 4 * m < total ? "No" : "Yes") << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N, M;
char A[50][50];
char B[50][50];

bool f(int x, int y) {
  for (int i=0; i<M; i++) {
    for (int j=0; j<M; j++) {
      if (B[i][j] != A[i+x][j+y]) return false;
    }
  }
  return true;
}

int main() {
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) cin >> A[i][j];
  }
  for (int i=0; i<M; i++) {
    for (int j=0; j<M; j++) cin >> B[i][j];
  }
  for (int x=0; x<=N-M; x++) {
    for (int y=0; y<=N-M; y++) {
      if (f(x, y)) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
  return 0;
}


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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}

//--------------------------------------------------//

int main() {
  use_cio();
  int n;
  cin >> n;
  vector<pii> va(n);
  rep(i, n) cin >> va[i].first, va[i].second = i;
  sort(all(va));
  rep(i, n) {
    if (i == va.back().second)
      cout << va[va.size() - 2].first << endl;
    else
      cout << va.back().first << endl;
  }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> F(50);
    F.at(0) = 1;
    F.at(1) = 1;
    for (int i = 2; i <= n; i++) {
        F.at(i) = F.at(i-1) + F.at(i-2);
    }
    cout << F.at(n) << endl;

    return 0;
}


Measured memory_bytes: 3124
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};


int main() {

	int x; cin >> x;
	cout << ((x >= 30) ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 3132
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
#define INFTY 1<<29
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 10000007;
// static const int MAX = 100005;
static const int NMAX = 1005;
static const int KEY = 4096;


// typedef priority_queue<int, greater<int>> RevQ;
int N, M;
int a, b;
vector<int> q[NMAX], p(NMAX), C(NMAX);


// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }

int main(){
  cin >> a >> b;
  if (a>9 || b > 9) {
    cout << -1 << endl;
  } else {
    cout << a*b << endl;
  }

}


Measured memory_bytes: 256
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        # 4/N - 1/h - 1/n = 1/w
        # (4hn - Nn - Nh) / nhN = 1/w
        # w = nhN / (4hn - Nn - Nh)

        if (4*h*n - N*(n + h)) > 0 and (n*h*N) % (4*h*n - N*(n + h)) == 0:
            w = (n*h*N) // (4*h*n - N*(n + h))
            print(h, n, w)
            exit(0)


Measured memory_bytes: 3060
/*
約数の個数はsqrt(N)であると考えて良い。

*/

/*
約数の個数はsqrt(N)であると考えて良い。

*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */

map<ll, ll> ret;
map<ll, ll> ret1;
void divisor(long long n)
{
    map<ll, ll> ret_;
    ret = ret_;

    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret[i] = 1;
            if (i * i != n)
                ret[n / i] = 1;
        }
    }
}
void divisor2(long long n)
{
    map<ll, ll> ret_;
    ret1 = ret_;
    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret1[i] = 1;
            if (i * i != n)
                ret1[n / i] = 1;
        }
    }
}

int main()
{
    ll n;
    cin >> n;
    ll co = n;
    divisor(n - 1);

    divisor2(n);
    ll ans = ret.size() - 1; //1以外の約数の個数
                             //とりあえず全列挙の計算量が見えないとダメすぎる。
    for (auto x : ret1)      //約数
    {
        if (x.first == 1)
        {
            continue;
        }
        while (n % x.first == 0)
        {
            n /= x.first;
        }
        if (n == 1)
        {
            ans += 1;
            n = co;
            continue;
        }
        if (n < x.first)
        {
            n = co;
            continue;
            // cout << n << " " << x.first << endl;
        }

        divisor(n - 1);
        if (ret[x.first] != 0) //存在するならば、
        {

            ans += 1;
        }

        n = co;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3848
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
long long out;
int a,b;
scanf("%d %d",&a,&b);
for(out=1;;out++){
    if((a*out)%b==0){printf("%lld",a*out);break;}
}
return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>

int main(void) {
 long long int H,W;
 scanf("%lld %lld",&H,&W);
 long long int a = H*W;
 if (W>1 && H>1){
 if (a%2==0)printf("%lld",a/2);
 else printf("%lld",(a+1)/2);
 }
 else if (W==1 && H>1)printf("1");
 else if (H==1)printf("1");
 return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

typedef long long ll;

using namespace std;

int main(){

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

    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

constexpr int QUESTION = (1 << 25);

void solve(vector<vector<int>> &matrix) {
	const int h = matrix.size();
	const int w = matrix[0].size();

	vector<vector<bool>> is_question(h - 1, vector<bool>(w - 1, false));
	vector<pair<int, int>> questions; // r, c
	vector<int> num_qr(h - 1, 0), num_qc(w - 1, 0);
	vector<int> sum_r(h - 1, 0), sum_c(w - 1, 0);

	for(int i = 0; i < h - 1; ++i) {
		sum_r[i] += matrix[i][w - 1];
	}

	for(int i = 0; i < w - 1; ++i) {
		sum_c[i] += matrix[h - 1][i];
	}

	for(int i = 0; i < h - 1; ++i) {
		for(int j = 0; j < w - 1; ++j) {
			if(matrix[i][j] == QUESTION) {
				questions.emplace_back(i, j);
				++num_qr[i];
				++num_qc[j];
				is_question[i][j] = true;
			}
			else {
				sum_r[i] -= matrix[i][j];
				sum_c[j] -= matrix[i][j];
			}
		}
	}

	while(!questions.empty()) {
		bool unloop = true;
		int i = 0;

		while(i < questions.size()) {
			const int r = questions[i].first;
			const int c = questions[i].second;

			int value = QUESTION;
			if(num_qr[r] == 1) {
				value = sum_r[r];
			}
			else if(num_qc[c] == 1) {
				value = sum_c[c];
			}

			if(value == QUESTION) {
				++i;
				continue;
			}

			matrix[r][c] = value;
			sum_r[r] -= value;
			sum_c[c] -= value;
			--num_qr[r];
			--num_qc[c];
			unloop = false;
			questions.erase(questions.begin() + i);
		}

		if(unloop) break;
	}

	if(questions.empty()) { // unique answer
		for(int i = 0; i < h - 1; ++i) {
			for(int j = 0; j < w - 1; ++j) {
				if(is_question[i][j]) {
					cout << matrix[i][j] << endl;
				}
			}
		}
	}
	else {
		cout << "NO" << endl;
	}
}

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

	bool first = true;
	for(int p, s; cin >> p >> s && p;) {
		if(!first) cout << endl;
		first = false;

		vector<vector<int>> matrix(p + 1, vector<int>(s + 1));
		for(auto &row : matrix) {
			for(auto &e : row) {
				string input;
				cin >> input;
				e = (input == "?" ? QUESTION : stoi(input));
			}
		}

		solve(matrix);
	}

	return 0;
}

Measured memory_bytes: 1260
import collections

n=int(input())
lb=[input() for i in range(n)]
m=int(input())
lr=[input() for i in range(m)]

for i in range(len(lr)):
    if lr[i] in lb:
        lb.remove(lr[i])
    else:
        pass
if lb==[]:
    ans=0
else:
    s=collections.Counter(lb)
    ans=s.most_common()[0][1]      

print(ans)

Measured memory_bytes: 3316
//============================================================================
// Name        : abcC70series.cpp
// Author      : sep
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>

using namespace std;

inline void main072C() {

	int n;
	int a;
	int num[100002] = { 0 };
	int i;
	int res = 0;
	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> a;
		++num[a];
		++num[a + 1];
		++num[a + 2];
	}
	for (i = 0; i < 100002; i++) {
		res = max(res, num[i]);
	}

	cout << res;

}

int main() {

#ifdef TEST
	struct timespec startTime, endTime;
	while (1) {
		clock_gettime(CLOCK_REALTIME, &startTime);
#endif

		main072C();

#ifdef TEST
		cout << flush;
		cerr << flush;
		cerr << endl << "Elapsed Time:";
		clock_gettime(CLOCK_REALTIME, &endTime);
		if (endTime.tv_nsec < startTime.tv_nsec) {
			cerr << endTime.tv_sec - startTime.tv_sec - 1 << "."
					<< endTime.tv_nsec + 1000000000 - startTime.tv_nsec << "s"
					<< endl;
		} else {
			cerr << endTime.tv_sec - startTime.tv_sec << "."
					<< endTime.tv_nsec - startTime.tv_nsec << "s" << endl;
		}

		cerr << endl;
	}
#endif

	return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using Pair = pair<int, int>;
const ll mod = 1e9 + 7;


template<class T>
T gcd(T a, T b)
{
  if(a && b) {
    return gcd(min(a, b), max(a, b) % min(a, b));
  } else {
    return a;
  }
}

template<class T>
T lcm(T a, T b)
{
  return a / gcd(a, b) * b;
}

ll power(ll base, ll exponent, ll module)
{
  if(exponent % 2) {
    return power(base, exponent - 1, module) * base % module;
  } else if(exponent) {
    ll root_ans = power(base, exponent / 2, module);
    return root_ans * root_ans % module;
  } else {
    return 1;
  }
}

struct combination
{
  vector<ll> fact, inv;
  combination(int sz) : fact(sz + 1), inv(sz + 1)
  {
    fact[0] = 1;
    for(int i = 1; i <= sz; i++) {
      fact[i] = fact[i - 1] * i % mod;
    }
    inv[sz] = power(fact[sz], mod - 2, mod);
    for(int i = sz - 1; i >= 0; i--) {
      inv[i] = inv[i + 1] * (i + 1) % mod;
    }
  }
  ll Pair(int n, int r)
  {
    if(r < 0 || n < r) return 0;
    return (fact[n] * inv[n - r] % mod);
  }
  ll C(int p, int q)
  {
    if(q < 0 || p < q) return 0;
    return (fact[p] * inv[q] % mod * inv[p - q] % mod);
  }
};

template<typename T>
void print_vec(vector<T>& v)
{
  for(const auto& e: v) {
    cout << e << " ";
  }
  cout << endl;
}
template<typename T>
void print_2dvec(vector<vector<T>>& m)
{
  for(const auto& v: m) {
    for(const auto& e: v) {
      cout << e << " ";
    }
    cout << endl;
  }
}


int main(int argc, char const* argv[])
{
  ll h, n, sum = 0;

  cin >> h >> n;
  for (ll i = 0; i < n; i++) {
    ll a;
    cin >> a;
    sum += a;
  }

  if (h - sum > 0) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

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


/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);

    rep(i, n) cin >> a[i];

    deque<ll> dq;
    rep(i, n) {
        ll idx = lower_bound(dq.begin(), dq.end(), a[i]) - dq.begin();
        if (idx == 0) dq.push_front(a[i]);
        else dq[idx - 1] = a[i];
    }
    cout << dq.size() << endl;
    return 0;
}

Measured memory_bytes: 1792
import           Data.List
import           Control.Applicative
import           Control.Monad
import           Control.Monad.State

replaceComma :: String -> String
replaceComma []         = []
replaceComma (',' : xs) = ' ' : replaceComma xs
replaceComma (x   : xs) = x : replaceComma xs

readTpl :: IO (Int, Int)
readTpl = do
  (n1 : n2 : _) <- map read . words . replaceComma <$> getLine
  return (n1 - 1, n2 - 1)

elementAt :: Eq a => Int -> [a] -> a
elementAt 0 (a : as) = a
elementAt n (a : as) = elementAt (n - 1) as

changeAt :: Eq a => Int -> a -> [a] -> [a]
changeAt 0 a (_ : ts) = a : ts
changeAt n a (t : ts) = t : changeAt (n - 1) a ts

change :: (Int, Int) -> [Int] -> [Int]
change (a, b) xs = changeAt b a1 $ changeAt a b1 xs
 where
  a1 = elementAt a xs
  b1 = elementAt b xs

changeIO :: StateT [Int] IO ()
changeIO = do
  tpl <- lift readTpl
  modify (change tpl)

main = do
  w       <- readLn
  n       <- readLn
  (_, ns) <- runStateT (replicateM n changeIO) [1 .. w]
  mapM_ print ns



Measured memory_bytes: 4060
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
   ll a,b;
   cin>>a>>b;
   if(a>b)swap(a,b);
   if(b>9)cout<<-1<<endl;
   else cout<<a*b<<endl;
return 0;
}


Measured memory_bytes: 4992
import sys

for i in sys.stdin:
    n = int(i)
    if n == 0:
        break
    max = -100000
    sum = int(input())
    for i in range(n-1):
        m = int(input())
        if sum < 0 and sum < m:
            sum = m
        elif m < 0 and max < sum:
            max = sum
            sum += m
        else:
            sum += m
    if sum > max:
        max = sum
    print(max)

Measured memory_bytes: 7564
a = []
3.times{a += gets.split.map(&:to_i)}
gets.to_i.times do
  i = a.index(gets.to_i)
  a[i] = nil if i
end
if (a[0].nil? && a[1].nil? && a[2].nil?) ||
   (a[3].nil? && a[4].nil? && a[5].nil?) ||
   (a[6].nil? && a[7].nil? && a[8].nil?) ||
   (a[0].nil? && a[3].nil? && a[6].nil?) ||
   (a[1].nil? && a[4].nil? && a[7].nil?) ||
   (a[2].nil? && a[5].nil? && a[8].nil?) ||
   (a[0].nil? && a[4].nil? && a[8].nil?) ||
   (a[2].nil? && a[4].nil? && a[6].nil?)
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 3836