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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string S[105], T[105];

int main()
{
    int N, M;
    cin >> N;
    REP(i, N)
    {
        cin >> S[i];
    }
    cin >> M;
    REP(i, M)
    {
        cin >> T[i];
    }

    int max = 0;
    REP(i, N)
    {
        int n = 0;
        REP(j, N)
        {
            if (S[i] == S[j])
                n++;
        }
        REP(j, M)
        {
            if (S[i] == T[j])
                n--;
        }
        max = std::max(max, n);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long long int s(long long int n){
  if(n==0)
    return 0;
  return n%10+s(n/10);
}

long long int f(long long int n){
  long long int box[136],i,num,ans;
  double mina;
  num=s(n);
  ans=n;
  mina=(double)n/num;
  num=n;
  if(num%10<9)
    num+=1;
  else if(num%100<99)
    num+=10;
  else if(num%1000<999)
    num+=100;
  else if(num%10000<9999)
    num+=1000;
  else if(num%100000<99999)
    num+=10000;
  else if(num%1000000<999999)
    num+=100000;
  else if(num%10000000<9999999)
    num+=1000000;
  else if(num%100000000<99999999)
    num+=10000000;
  else if(num%1000000000<999999999)
    num+=100000000;
  else if(num%10000000000<9999999999)
    num+=1000000000;
  else if(num%100000000000<99999999999)
    num+=10000000000;
  else if(num%1000000000000<999999999999)
    num+=100000000000;
  else if(num%10000000000000<9999999999999)
    num+=1000000000000;
  else if(num%100000000000000<99999999999999)
    num+=10000000000000;
  else if(num%1000000000000000<999999999999999)
    num+=100000000000000;
  for(i=s(n)+1;i<=135;i++){
    if((double)num/i<mina){
      mina=(double)num/i;
      ans=num;
    }
    if(num%10<9)
    num+=1;
  else if(num%100<99)
    num+=10;
  else if(num%1000<999)
    num+=100;
  else if(num%10000<9999)
    num+=1000;
  else if(num%100000<99999)
    num+=10000;
  else if(num%1000000<999999)
    num+=100000;
  else if(num%10000000<9999999)
    num+=1000000;
  else if(num%100000000<99999999)
    num+=10000000;
  else if(num%1000000000<999999999)
    num+=100000000;
  else if(num%10000000000<9999999999)
    num+=1000000000;
  else if(num%100000000000<99999999999)
    num+=10000000000;
  else if(num%1000000000000<999999999999)
    num+=100000000000;
  else if(num%10000000000000<9999999999999)
    num+=1000000000000;
  else if(num%100000000000000<99999999999999)
    num+=10000000000000;
  else if(num%1000000000000000<999999999999999)
    num+=100000000000000;
  }
  return ans;
}

int main(){
  long long int k,ans,i;
  scanf("%lld",&k);
  ans=1;
  for(i=0;i<k;i++){
    printf("%lld\n",ans);
    ans=f(ans+1);
  }
}



Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int N;
	scanf("%d",&N);
	if((N==1)||(N==2)||(N==3)||(N==5)||(N==6)||(N==9)||(N==10)||(N==13)||(N==17)){
		printf("No");
	}else{
		printf("Yes");
	}
return 0;
}

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

using namespace std;

typedef long long int ll;

const int N = (int) 1e5 + 10;
const ll oo = 1e18;

int n;
ll a[3][N];
ll memo[3][N];

ll dp(int at, int prev) {
    if(at == n) return 0;
    if(memo[prev][at] != -1) return memo[prev][at];
    ll ans = 0;
    for(int i = 0; i < 3; ++i) {
        if(i == prev) continue;
        ll cur = a[i][at] + dp(at + 1, i);
        ans = max(ans, cur);
    }
    return memo[prev][at] = ans;
}

void solve() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 3; ++j) {
            cin >> a[j][i];
        }
    }
    memset(memo, -1, sizeof(memo));
    ll ans = 0;
    for(int i = 0; i < 3; ++i) {
        ans = max(ans, dp(0, i));
    }
    cout << ans << endl;
}

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

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

void MV(char a[1001]){
  for(int i=200;i>=0;i--)a[i+1]=a[i];
}

int main(){
  int n;
  cin>>n;
  int idx=0;
  char s[2]={'.','#'};
  char a[1001],b[1001];
  int flg=1;
  while(1){

    string ans="F";
    a[idx+1]=b[idx+1]=0;
    for(int i=0;i<(1<<2)&&ans=="F"&&flg;i++){
      a[idx]=s[i%2],b[idx]=s[i>>1];
      printf("%s\n%s\n",a,b);fflush(stdout);
      cin>>ans;
      if(ans=="end")return 0;
    }
    
    if(ans=="F")MV(a),MV(b),flg=0;;
    a[idx+1]=b[idx+1]=0;
    for(int i=0;i<(1<<2)&&ans=="F";i++){
      a[0]=s[i%2],b[0]=s[i>>1];
      printf("%s\n%s\n",a,b);fflush(stdout);
      cin>>ans;
      if(ans=="end")return 0;
    }
    idx++;
    if(idx==n)break;
  }
  return 0;
}


Measured memory_bytes: 724
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;

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

		while (true) {
			final int n = Integer.parseInt(sc.nextLine());
			
			if(n == 0){
				break;
			}
			
			char[][] map = new char[n][];
			for(int i = 0; i < n; i++){
				map[i] = sc.nextLine().toCharArray();
			}
			
			LinkedList<Integer> stack = new LinkedList<Integer>();
			for(int i = n - 1; i >= 0; i--){
				int pos = 0;
				if(map[i][pos] != '.') { continue; }
				
				while(pos < map[i].length && map[i][pos] == '.'){
					pos++;
				}
				
				final int height = pos - 1;
				
				
				while(!stack.isEmpty()){
					if(stack.getLast() >= height){
						stack.removeLast();
					}else{
						break;
					}
				}
				
				for(int high : stack){
					map[i][high] = '|';
				}
				map[i][height] = '+';
				for(int j = 0; j < height; j++){
					if(map[i][j] == '.') { map[i][j] = ' '; }
				}
				
				stack.addLast(height);
			}
			
			for(int i = 0; i < n; i++){
				System.out.println(map[i]);
			}
		}
	}
}

Measured memory_bytes: 96060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, k;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	vector<pair<ll, ll> > v(n);
	FOR(i, n) cin >> v[i].first >> v[i].second;
	sort(ALL(v));
	ll ans = 5e18;
	FOR(i, n) FOR(j, i-k+2) {
		ll xlen = v[i].first-v[j].first;
		vector<ll> y;
		for (int p = j; p <= i; p++) y.push_back(v[p].second);
		sort(ALL(y));
		ll ylen = 5e18;
		FOR(p, y.size()-k+1) {
			ylen = min(ylen, y[p+k-1]-y[p]);
		}
		ans = min(ans, xlen*ylen);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b;
    cin >> a >> b;
    cout << a*a-b;
    return 0;
}


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

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

  for(int i = 0; i < 9; i++){
    if(111*i < n && n <= 111*(i+1)){
      cout << 111*(i+1) << endl;
      break;
    }
  }

  return 0;

}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int i,j,n;
  char s[100][8];
  scanf("%d",&n);
  for(i=0; i<n; i++){
      int count_o=0,count_s=0,count_r=0;
         for(j=0; j<100; j++){
                scanf("%s",s[j]);
                 if(s[j][1]=='I'){
                    count_r ++;
                    if(count_r>3){
                    count_s++;
                    count_r=3;
                    }
                  }
                if(s[j][1]=='O'){
                switch(count_r){
                case(0)  :{count_s++; count_r=0;} break;
                case(1)  :{count_s+=2; count_r=0;}break;
                case(2)  :{count_s+=3; count_r=0;}break;
                case(3)  :{count_s+=4; count_r=0;}break;
                }
                }
               if(s[j][1]=='U'){
                  count_o ++;
              }
              if(count_o == 3) break;
      } //内側のfor文の終了
   printf("%d\n",count_s);
}
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef int Weight;
typedef int Flow;
struct Edge {
	int src, dest, rev;
	Flow cap;
	Weight cost;
	bool operator < (const Edge &rhs) const
	{
		return cost > rhs.cost;
	}
	Edge(int s, int d) : src(s), dest(d) { ; }
	Edge(int s, int d, int c) : src(s), dest(d), cost(c) { ; }
	Edge(int s, int d, int r, Flow cp, Weight cst) : src(s), dest(d), rev(r), cap(cp), cost(cst) { ; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int src, int dest, Flow cap)
{
	g[src].push_back(Edge{ src, dest, (int)g[dest].size(), cap, 0 });
	g[dest].push_back(Edge{ dest, src, (int)g[src].size() - 1, 0, 0 });
}

Flow dfs(Graph &g, vector<bool> &used, int v, int t, Flow f)
{
	if (v == t) return f;
	used[v] = true;
	for (Edge& e : g[v])
	{
		if (!used[e.dest] && e.cap > 0)
		{
			Flow d = dfs(g, used, e.dest, t, min(f, e.cap));
			if (d > 0)
			{
				e.cap -= d;
				g[e.dest][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

Flow ford_fulkerson(Graph &g, int s, int t)
{
	Flow flow = 0;
	for (;;)
	{
		vector<bool> used(g.size(), false);
		Flow f = dfs(g, used, s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}

typedef long double ld;
const ld PI = acos(-1.0);
bool eq(ld a, ld b) { return abs(a - b) < EPS; }
typedef complex<ld> Point;


int main()
{
	int n, m;
	while (cin >> n >> m, n)
	{
		vector<Point> t, b;
		vector<ld> v;
		REP(i, n)
		{
			ld x, y, z; cin >> x >> y >> z;
			t.emplace_back(x, y);
			v.emplace_back(z);
		}
		REP(i, m)
		{
			ld x, y; cin >> x >> y;
			b.emplace_back(x, y);
		}
		ld lb = 0, ub = INF;
		REP(ii, 300)
		{
			ld mid = (lb + ub) / 2;
			Graph g(2 + n + m);
			REP(i, n) add_edge(g, n + m, i, 1);
			REP(i, m) add_edge(g, n + i, n + m + 1, 1);
			REP(i, n)REP(j, m)
			{
				if (mid - abs(t[i] - b[j]) / v[i] > EPS) add_edge(g, i, n + j, 1);
			}
			int f = ford_fulkerson(g, n + m, n + m + 1);
			if (f == m) ub = mid;
			else lb = mid;
		}
		cout << D10 << lb << endl;
	}
	return 0;
}

Measured memory_bytes: 3704
n=int(input())
a=list(map(int,input().split()))
a.sort()
kjn=0
b=0
mi=0
mi2=0
for i in range(0,n):
    if a[i]==kjn:
        b=3-b
    else:
        if b==2:
            mi2+=1
        b=1
        kjn=a[i]
        mi+=1
if b==2:
    mi2+=1
print(mi-mi2%2)

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

using namespace std;

int main()
{
    string N;std::cin >> N;
       for(int a = 0;a < 3;a++){
           if(N.at(a) == '1')cout<<"9";
           if(N.at(a) == '9')cout<<"1";
       }
       cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

ll n,a,b;
ll p[5010];
ll ip[5010];//pの逆引き
ll cnt[5010][5010];//cnt[i][j]=区間[i,j)に存在する、p[i]より小さいものの個数
ll memo[5010][5010];
ll f(int R,int K){
	if(R<=0||K<0)return 0;
	if(memo[R][K])return memo[R][K]-1;
	if(ip[K]>=R)return (memo[R][K]=f(R,K-1)+1)-1;
	
	ll ans;
	if(cnt[ip[K]][R]){
		ll v1=f(ip[K],K-1)+cnt[ip[K]][R]*b;
		ll v2=f(    R,K-1)+a;
		ans=min(v1,v2);
	}else{
		ans=f(R,K-1);
	}
	return (memo[R][K]=ans+1)-1;
}

int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		t--;
		p[i]=t;
		ip[t]=i;
	}
	rep(i,0,n){
		ll c=0;
		rep(j,i+1,n+1){
			cnt[i][j]=c;
			if(p[j]<p[i])c++;
		}
	}
	printf("%lld",f(n,n-1));
}

Measured memory_bytes: 391680
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
	int n;
	cin >> n;
	map<char, ll> mp;
	while (n--){
		ll a, b;
		char c;
		cin >> a >> c >> b;
		mp[c] += b;
		if (mp['('] == mp[')']) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    long long int ans = 0;
    map<long long int, int> memo;
    long long int sum = 0;
    memo[0] = 1;
    for(int i = 0; i < n; i++){
        sum += a[i];
        if(memo.count(sum) == 0){
            memo[sum] = 1;
        }else{
            memo.at(sum)++;
        }
    }
    
    for(auto p: memo){
        if(p.second >= 2){
            long long int q = p.second;
            ans += q*(q-1)/2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13568
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
int fact[200005],fact_inv[200005];
void pre(){
	fact[0]=1;
	fact_inv[0]=1;
	for(int i=1;i<200005;i++){
		fact[i]=fact[i-1]*i;
		fact[i]%=mod;
		fact_inv[i]=power(fact[i],mod-2);
	}
}
long long ncr(long long n,long long r){
	if(n<r){return 0;}
	if(n==r||r==0){return 1;}
	return (((fact[n]*fact_inv[n-r])%mod)*fact_inv[r])%mod;
	//return x;	
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string n;
    int k;
    cin>>n>>k;
    pre();
    int x=n.size();
    
    int ans=0;
    ans+=ncr(x-1,k)*power(9,k);
    for(int i=1;i<n[0]-'0';i++)
    ans+=ncr(x-1,k-1)*power(9,k-1);
    int z=1;
    for(int i=1;i<x;i++){
        if(z==k){break;}
        if(n[i]!='0'){
            z++;
            //cout<<ans<<" ";
            ans+=ncr(x-i-1,k-z+1)*power(9,k-z+1);
            for(int j=1;j<n[i]-'0';j++)
            ans+=ncr(x-i-1,k-z)*power(9,k-z);
            //cout<<ans<<" ";
        }
    }
    if(z==k)ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <numeric>
#define ll long long

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define pb emplace_back
#define mp make_pair

using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<ll, ll> P;

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;
}

ll R, C, N, M, K, Q;

vector<int> v[200005];
vector<int> res;

void dfs(int node, int p = 0){
    PRINT(node)
    PRINT(res[node])
    irep(itr,v[node]){
        if(*itr == p) continue;
        res[*itr] += res[node];
        dfs(*itr, node);
    }
    return;
}

signed main() {
    //cout << fixed << setprecision(10);
    cin >> N >> Q;

    rep(i, N-1){
        int from,to; cin >> from >> to;
        from --;
        to --;
        v[from].pb(to);
        v[to].pb(from);
    }
    res.assign(N,0); 
    rep(i,Q){
        int node, val; cin >> node >> val;
        res[--node] += val;
    }
    dfs(0);

    rep(i, N){
        cout << res[i] << endl;
    }

    //cout << max << endl;
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)

int main(){
  string s,t[4]={"dream","dreamer","erase","eraser"};cin>>s;
  bool f;
  
  while(s.size()){
    //cout<<"s:"<<s<<" ";
    f=0;
    REP(i,4){
      //cout<<"i:"<<i<<" ";
      if(!(s.find(t[i]))){
        //cout<<"arude ";
        string ss=s.substr(t[i].size());
        if(!(ss.size())){
          s=ss;
          f=1;
          break;
        }
        //cout<<"ss:"<<ss<<" ";
        REP(k,4) if(!(ss.find(t[k]))){
          //cout<<"k:"<<k<<endl;
          f=1;
        }
        if(f){
          s=ss;
          break;
        }
      }
    }
    if(!f) break;
  }
  
  cout<<(f?"YES":"NO");
}

Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }

int main() {
	int n, q, t, ans = 0;
	vector<int> v;
	cin >> n;
	v.resize(n);
	REP(i, n)
		cin >> v[i];
	cin >> q;
	while (q--) {
		cin >> t;
		if (find(all(v), t) != v.end())
			ans++;
	}

	cout << ans << endl;

	return 0;
}

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

#define all(v) (v).begin(), (v).end()
using namespace std;

struct store
{
    long long price, cans;

    store(){}

    const int operator<(const store &S)
    {
        return (price < S.price);
    }
};

int main()
{
    int no_of_stores, no_of_cans;
    cin >> no_of_stores >> no_of_cans;

    vector <store> S(no_of_stores);
    for(int i = 0; i < no_of_stores; i++)
        cin >> S[i].price >> S[i].cans;

    sort(all(S));

    long long total_price = 0, remaining_cans = no_of_cans;
    for(int i = 0; i < no_of_stores; i++)
    {
        long long cans_here = min(S[i].cans, remaining_cans);

        total_price += cans_here*S[i].price;

        remaining_cans = max(0LL, remaining_cans - S[i].cans);
    }

    cout << total_price;
    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n;cin >> n;
	vector<P> v(n);
	REP(i, n){
		cin >> v[i].FI;
		v[i].SE = i;
	}

	sort(ALL(v), greater<P>());
	vector<ll> ans(n, v[0].FI);
	ans[v[0].SE] = v[1].FI;

	REP(i, n)cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b;
  c = a * b;
  if (c % 2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> adj(n, std::vector<int>(n, 0));
    for(int i=0;i<n;i++){
        int unused, k;
        std::cin >> unused >> k;
        for(int j=0;j<k;j++){
            int p;
            std::cin >> p;
            adj[i][p-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            std::cout << adj[i][j];
            if(j==(n-1)) std::cout << "\n";
            else std::cout << " ";
            
        }
    }
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int n,d;
	cin>>n>>d;
	long long int res=0;
	while(n--){
		long long int p,q;
		cin>>p>>q;
		if(((p*p)+(q*q))<=(d*d)){
			res++;
		}
	}
	cout<<res;
	return 0;
}

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

using namespace std;

#define rep(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define drep(i, a, n) for (int i = a, _n = n; i >= n; --i)
#define debug(x) cout << #x <<" = "<< x << endl
#define M 200005

int n;

struct node {
	int a, b;
	bool operator < (const node& x1) const {
		return b > x1.b;
	}
} a[M];

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

	rep(i, 1, n)
		scanf ("%d%d", &a[i].a, &a[i].b);

	sort(a + 1, a + n + 1);

	int t = 2e9;
	rep(i, 1, n) {
		t = min(t, a[i].b) - a[i].a;
		if (t < 0) {
			puts("No");
			return 0;
		}
	}

	puts("Yes");

	return 0;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (W, H, x, y) = readLine()!!.split(" ").map { it.toDouble() }
    if (x==W/2 && y==H/2) {
        print(W * H / 2)
        print(" ")
        println(1)
    } else {
        print(W * H / 2)
        print(" ")
        println(0)
    }
}

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

int main(){
    string s; cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int input;
      int counter = 0;
      
      while(sc.hasNext()) {
         input = Integer.parseInt(sc.nextLine());
         counter = 0;
         for(int a = 0; a <= 9; a ++) {
            for(int b = 0; b <= 9; b ++) {
               for(int c = 0; c <= 9; c ++) {
                  for(int d = 0; d <= 9; d ++) {
                     if (a + b + c + d == input) {
                        counter ++;
                     }
                  }
               }
            }
         }
         
         System.out.println(counter);
      }
   }
}


Measured memory_bytes: 26764
import random
import copy
import time
def evaluateSatisfaction(d, c, s, ans):
    score = 0
    last = [-1 for i in range(26)]
        
    for i in range(d):
        
        score += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(26):
            if j != ans[i] or True:
                score -= c[j]*(i - last[j])
    return score
    
def valuationFunction(d,c,s,contestType,day,last):
    las = copy.copy(last)
    las[contestType] = day
    gain = s[day][contestType]
    lost = 0
    for i in range(13):
        for j in range(26):
            lost += c[j]*(i - las[j])
    return gain - lost

def Input():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    #s[3][25] =   contest(25+1) of day(3+1)
    return d, c, s

def evolution(d, c, s, ans):
    score_before = evaluateSatisfaction(d, c, s, ans)
    ans_after = copy.copy(ans)
    x = random.randint(0,(d-1)-10)
    idx1 = x
    idx2 = x+random.randint(0,5)
    
    tmp = ans_after[idx1]
    ans_after[idx1] = ans_after[idx2]
    ans_after[idx2] = tmp

    score_after = evaluateSatisfaction(d,c,s,ans_after)

    if score_after > score_before:
        return ans_after
    else:
        return ans

if __name__ == "__main__":
    
    d, c, s = Input()
    
    #print("val =", evaluateSatisfaction(d, c, s, [1, 17, 13, 14, 13]))

    #calc start
    t1 = time.time()
    ans = [0 for i in range(d)]
    last = [-1 for i in range(26)]
    for i in range(d):
        evalValueList = [0 for j in range(26)]
        for j in range(26):
            evalValueList[j] = valuationFunction(d, c, s, j,i,last)

        max_idx = 0
        max = evalValueList[0]

        for j in range(26):
            if (max < evalValueList[j]):
                max_idx = j
                max = evalValueList[j]
        
        ans[i] = max_idx
        last[ans[i]] = i


    
    #ans = [1, 2, 3, 4, 5]
    t2 = time.time()
    while(float(t2-t1) < 1.0):
        ans = evolution(d, c, s, ans)
        #print("ans = ",evaluateSatisfaction(d,c,s,ans))
        t2 = time.time()
    for x in ans:
        print(x + 1)
    #print(evaluateSatisfaction(d,c,s,ans))

Measured memory_bytes: 10052
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int dph[300005],dpw[300005];
vector<int> a,b;
set<P> p;
int main(){
    int H,W,m;
    cin >> H >> W>> m;
    rep(i,m){
        int h,w;
        cin>> h>> w;
        h--;w--; 
        dph[h]++;
        dpw[w]++;
        p.insert(mp(h,w));
    }
    int temph=-INF;
    
    rep(i,H){
        if(temph<dph[i]){
            temph=dph[i];
        }  
    }
    rep(i,H){
        if(temph==dph[i]){
            a.push_back(i);
        }
    }
    int tempw=-INF;
    
    rep(i,W){
        if(tempw<dpw[i]){
            tempw=dpw[i];
        }
    }
    rep(i,W){
        if(tempw==dpw[i]){
            b.push_back(i);
        }
    }
    int ans=temph+tempw;
    
    for(int i=0;i<a.size();i++){
        for(int j=0;j<b.size();j++){
            if(p.find(mp(a[i],b[j]))==p.end()){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    ans--;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 23792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,x;
	int j=1;
	cin>>k>>x;
    for(int i=x-k+1;i!=x;i++)
       printf("%d ",i);
    printf("%d ",x);
    for(int i =x+1;i!=x+k;i++)
       printf("%d ",i);
       return 0;
	
	    
	
	
}

Measured memory_bytes: 256
#include <stdio.h>

#define swap(a, b) {int tmp = a; a = b; b = tmp;}

int main(void)
{
	int n;
	
	while (scanf("%d", &n) * n != 0){
		int prize[10000] = {0};
		int i, j;
		int na_flag = 1;
		int maxi = n + 1;
		
		for (i = 0; i < n; i++){
			scanf("%d", prize + i);
			if (prize[i] == 0){
				maxi--;
			}
			if (prize[i] > 1){
				na_flag = 0;
			}
		}
		if (na_flag == 1){
			puts("NA");
		}
		else {
			printf("%d\n", maxi);
		}
	}
	
	return 0;
}

Measured memory_bytes: 660
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  let t = 0,
    h = 0;
  const n = Number(lines[0]);
  for (let i = 1; i <= n; i++) {
    const [a, b] = lines[i].split(" ");
    if (a === b) {
      t++;
      h++;
    } else if (a < b) {
      h += 3;
    } else {
      t += 3;
    }
  }
  console.log(`${t} ${h}`);
});



Measured memory_bytes: 17728
// AOJ 2088: Spirograph
// 2017.11.21 bal4u@uu

#include <stdio.h>
#include <math.h>

#define PI 3.1415926535897932384626433832795
#define DIV_NUM 20000
int P, Q, R;
double a, b, c;

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

double f(double x) 
{
	return sqrt(a*(b-c*cos(P*x/Q)));
}

int main()
{
	int i, g;
	double h, h2, ans, x, xmin, xmax;

	while (scanf("%d%d%d", &P, &Q, &R) && P > 0) {
		if (R == 0) { printf("%.10lf\n", 2*PI*(P-Q)); continue; }
		g = gcd(P-Q, Q), xmin = 0, xmax = 2*PI*Q/g;

		b = Q*Q;
		a = (P-Q)*(P-Q), a /= b;	// a = (p-q)^2 / q^2
		b += R*R;					// b = q^2 + r^2
		c = 2*Q*R;					// c = 2 * q * r

		h = (xmax - xmin) / (2.0*DIV_NUM), h2 = 2*h;
		x = xmin;
		ans = f(x);
		for (i = 1; i < DIV_NUM; i++) {
			ans += 4*f(x+h) + 2*f(x+h2);
			x += h2;
		}
		ans += 4*f(x+h) + f(x+h2);
		ans *= h/3; 
		printf("%.10lf\n", ans);
	}
	return 0;
}

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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    bool flag = true;
    if(N%2 == 0){
        for(int i = 0;i < N/2;++i){
            if(S[i] != S[i+N/2]) flag = false;
        }
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

public class Main {

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

		// 入力
		int N = sc.nextInt();
		List<String> listA = new ArrayList<String>();
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			listA.add(s);
		}
		List<String> listB = new ArrayList<String>(new HashSet<>(listA));
		
		System.out.println(listB.size());			
	}

	
	// ユークリッドの控除法(最大公約数を求める)
	private static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	// 複数の最大公約数を求める
	private static long gcdex(long param[]) {
		long g = gcd(param[0], param[1]);
		for (int i = 1; i < param.length-1; i++) {
			g = gcd(g, param[i+1]);
		}
		return g;
	}

	// 最小公倍数を求める
	private static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	//
	private static long all(long n, long count, int N) {
		if (count == N) {
			return count;
		}
		return all(1, count, N);
	}

}

Measured memory_bytes: 75804
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a<=0&&b>=0)
		printf("Zero");
	else	if(a<0)
			{
				if((b-a)%2==0)printf("Negative");
				else printf("Positive");
			}
			else	printf("Positive");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
/*
2019. 4/26
A Linear Search
*/

int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main() {
    int i, n, A[10000+1], q, key, sum = 0;

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

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

    return 0;
}



Measured memory_bytes: 2052
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int> > VVi;
typedef vector<vector<ll> > VVl;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 28;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

typedef pair<ll, int> pli;
using G = vector<vector<pli>>;

template <class Tdist>
void Dijkstra(int org, const G& g, vector<Tdist>& d);

int n;
G g;
Vl d;
const ll INF = linf;
Vi col;

void init()
{
	cin >> n;
	g.resize(n);

	REP(_i, n-1)
	{
		int a, b; ll c;
		cin >> a >> b >> c;
		--a; --b;
		g[a].PB(MP(c, b));
		g[b].PB(MP(c, a));
	}
}

template <class Tdist>
void Dijkstra(int org, const G& g, vector<Tdist>& d)
{
	using P = pair<Tdist, int>;

	vector<bool> done(n, false);
	d.assign(n, INF);
	d[org] = 0;

	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P((Tdist)0, org));

	while (!que.empty())
	{
		Tdist c = que.top().first;
		int v = que.top().second;
		que.pop();
		done[v] = true;

		if (c > d[v])
			continue;

		for (P p : g[v])
			if (!done[p.second] && chmin(d[p.second], c + p.first))
				que.push(P(d[p.second], p.second));
	}
}



int main()
{
	init();

	Dijkstra(0, g, d);

	REP(i, n)
	{
		cout << ((ll)1 & d[i]) << endl;
	}
}


Measured memory_bytes: 8704
//
// Created by yamunaku on 2019/10/22.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    int s = 0;
    rep(i, n) cin >> a[i], s += a[i];
    sort(all(a), greater<int>());
    vi r(k), b(k);
    int rs = 0, bs = 0;
    rep(i, k) cin >> r[i], rs += r[i];
    sort(all(r), greater<int>());
    rep(i, k) cin >> b[i], bs += b[i];
    sort(all(b), greater<int>());
    vector<mti> dp(k + 1, mti(rs + 1, vi(2, 10000)));
    dp[0][0][0] = 0;
    rep(i, n){
        perl(j, 1, k + 1){
            per(x, rs + 1){
                int tmp = dp[j][x][0];
                if(x >= a[i]){
                    dp[j][x][0] = min(dp[j - 1][x - a[i]][0], dp[j - 1][x - a[i]][1]) + max(0, a[i] - r[j - 1]);
                    dp[j][x][0] = min(10000, dp[j][x][0]);
                }else{
                    dp[j][x][0] = 10000;
                }
                if(0 <= i-j && i-j < k){
                    dp[j][x][1] = min(tmp, dp[j][x][1]) + max(0, a[i] - b[i - j]);
                    dp[j][x][1] = min(10000, dp[j][x][1]);
                }else{
                    dp[j][x][1] = 10000;
                }
            }
        }
        if(i < k){
            per(x, rs + 1){
                dp[0][x][1] = min(dp[0][x][0], dp[0][x][1]) + max(0, a[i] - b[i]);
                dp[0][x][1] = min(10000, dp[0][x][1]);
            }
        }else{
            per(x, rs + 1){
                dp[0][x][1] = 10000;
            }
        }
        dp[0][0][0] = 10000;
    }
    int ans = 10000;
    rep(j, k + 1){
        rep(x, rs + 1){
            if(x <= rs && s - x <= bs){
                ans = min(ans, min(dp[j][x][0], dp[j][x][1]));
            }
        }
    }
    if(ans == 10000) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 12104
#include <stdio.h>

int main(void) {
	int N, a[100];
	scanf("%d", &N);
	for (int i = 0;i < N;i++) {
		scanf("%d", &a[i]);
	}

	int A = 0, B = 0, n = 1;
	while (n <= N + 1) {
		int max = 0;
		for (int i = 0;i < N;i++) {
			if (max < a[i]) {
				max = a[i];
			}
		}

		if (n % 2 != 0) {
			A += max;
		} else {
			B += max;
		}

		for (int i = 0;i < N;i++) {
			if (max == a[i]) {
				a[i] = 0;
				break;
			}
		}

		n++;
	}

	printf("%d\n", A - B);

	return 0;
}

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

int main() {
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    vector<string> U(N);
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (i < K)
        {
            if (T[i] == 'r') {
                U[i] = "p";
                ans += P;
            } else if (T[i] == 's') {
                U[i] = "r";
                ans += R;
            } else
            {
                U[i] = "s";
                ans += S;
            }
            continue;
        }
        if (T[i] == 'r')
        {
            if (U[i - K] == "p")
            {
                U[i] = "rs";
            } else
            {
                U[i] = "p";
                ans += P;                
            }
        } else if (T[i] == 's') {
            if (U[i - K] == "r"){
                U[i] = "sp";
            } else
            {
                U[i] = "r";
                ans += R;
            }
        } else
        {
            if (U[i - K] == "s") {
                U[i] = "pr";
            } else
            {
                U[i] = "s";
                ans += S;                
            }   
        }      
    }
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;

int dp[N][3];

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

int main(){
    int T,i,j;
    int n;

    cin>>n;
    int a[n+1];
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    dp[2][0]=a[1];

    for(i=3;i<=n;i++){
        dp[i][0]=gcd(dp[i-1][0],a[i-1]);
    }

    dp[n-1][1]=a[n];

    for(i=n-2;i>=1;i--){
        dp[i][1]=gcd(dp[i+1][1],a[i+1]);
    }
    int g=max(dp[1][1],dp[n][0]);

    for(i=2;i<n;i++){
        int g_=gcd(dp[i][0],dp[i][1]);
        if(g_>g) g=g_;
    }

    printf("%d\n",g);




return 0;
}


Measured memory_bytes: 5356
m='+=+j[0]*Math.',n='(s*Math.PI/180)',x=y=s=0;require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n').some(function(i){j=i.split(','),eval('x'+m+'sin'+n+',y'+m+'cos'+n),s+=+j[1]});console.log(~~x),console.log(~~y)

Measured memory_bytes: 7640
a = int(input().split()[0])
alle = []
counter = 0
output = []
for i in range(a):
	p = input().split()
	p = [int(j)%2 for j in p]
	for j in range(len(p) - 1):
		if p[j] % 2 == 1:
			output.append([i + 1, j + 1, i + 1, j + 2])
			counter += 1
			p[j + 1] += 1
	alle.append(p[-1])
	
for i in range(a - 1):
	if alle[i] % 2 == 1:
		output.append([i + 1, len(p),  i + 2, len(p)])
		counter += 1
		alle[i + 1]  += 1
		
print (counter)
for i in output:
	print (i[0],i[1],i[2],i[3])

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  int h1, h2, k1, k2, a, b, c, d;
  cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
  int h = (h1 * a) + (h1 / 10 * c) + (h2 * b) + (h2 / 20 * d);
  int k = (k1 * a) + (k1 / 10 * c) + (k2 * b) + (k2 / 20 * d);

  cout << (h == k ? "even" : h > k ? "hiroshi" : "kenjiro") << endl;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
#define X first
#define Y second
#define int long long int
const int N = (int)1e6 + 10;
const int MOD = (int) 1e9 + 7;

int fastpower(int a, int b){
    int res = 1;
    a %= MOD;
    while(b){
        if(b&1) res = (res * a) % MOD;
        a *= a; a %= MOD;
        b >>= 1;
    }
    return res;
}


void solve(){
    //THink in reverse..
    // we want to find contribution of each gcd to happen
    // consider we have k places _ , _ , _ , _ , __ ,n.
    // gcd = 1 -> k^n ways;
    // gcd = 2 -> total multiples of 2 are k/2 -> (k/2)^n ways
    // so on until gcd = n;
    // but we need to take care of overcounting
    int n, k;
    cin >> n >> k;
    vector<int> dp(k + 1, 0);
    for(int gd = k; gd >= 1; --gd){
        int total_multiples = k/gd;
        int temp = fastpower(total_multiples, n);
        temp %= MOD;
        temp %= MOD;
        int extra = 0;
        for(int j = gd * 2; j <= k; j += gd){
            extra = (extra + dp[j]) % MOD;
        }
        dp[gd] = (temp - extra + MOD) % MOD;
    }

    int ans = 0;
    for(int i = 1; i <= k; ++i){
        int add = ( dp[i] % MOD * i % MOD ) % MOD;
        ans += add, ans %= MOD;
    }

    cout << ans << '\n';


}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}
/*
Sample inp
*/


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

int main(){

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

    int n, k; cin >> n >> k;

    vector< int > a(n);
    for(int &u:a) cin>>u;

    vector<int> dp(k+1,0);
    for(int i=1; i<=k; i++)
        for(int j=0; j<n; j++)
            if(i>=a[j] && dp[i-a[j]]==0)
                {dp[i] = 1; break;}

    cout << (dp[k] ? "First" : "Second") << "\n";

    return 0;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int K;
    cin >> K;
    for (int i = 0; i < K; i++) {
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;
typedef long long unsigned ull;

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

ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

int main() {
    int n, m, a[100000];
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    ll r = 0, l = 1;
    for (int i = 0; i < n; i++) {
        l = lcm(l, a[i] / 2);
    }
    bool f = true;
    for (int i = 0; i < n; i++) {
        if ((l / (a[i] / 2)) % 2 != 1) {
            f = false;
            break;
        }
    }
    if (!f || m < l) {
        cout << 0 << endl;
        return 0;
    }
    ll w = m - l;
    cout << (w / (2 * l)) + 1 << endl;
}

Measured memory_bytes: 640
import math
from functools import reduce


def prime_factorize(n):
    """素因数分解する。"""
    def facs(n):
        """試し割り法における割る数を生成する。"""
        yield 2
        max_prime = int(pow(n, 0.5)) + 2
        for x in range(3, max_prime, 2):
            yield x

    ans = set()
    for fac in facs(n):
        while n % fac == 0:
            ans.add(fac)
            n //= fac
    if n != 1:
        ans.add(n)
    return ans


def gcd_list(numbers):
    # これじゃすべての最大公約数を出しているだけ。
    # すべての組み合わせにおいて最大公約数が1でなくてはいけない。
    return reduce(math.gcd, numbers)


def main():
    a, b = [int(x) for x in input().split()]
    gcd_ = math.gcd(a, b)
    primes = prime_factorize(gcd_)
    print(len(primes) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9824
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    double max = 1;
    
    if(N == 1){
      max = 2;
    }else{
      for (int i = 0; i < N; i++){
        max = Math.pow(2, i);
        if (max > N){
          break;
        }
      }
    }
    max = max / 2;
    int answer = (int)max;
    
    System.out.println(answer);
  }
}

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

int main(){
    int N, a, b, c;
    string ans;
    cin >> N;
    a = N / 100;
    b = (N - a*100) / 10;
    c = N - a*100 - b*10;
    if((a == 7) || (b == 7) || (c == 7)){
        ans = "Yes";
    }else{
        ans = "No";
    }

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

Measured memory_bytes: 3628
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 1000;
    boolean f = false;
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) != s.charAt(0)) f = true;
    }
    if(f) {
    for(int i = 0; i < s.length(); i++) {
      char cha = s.charAt(i);
      boolean flg = true;
      String test = s;
      int count = 0;
      while(flg) {
        count++;
        String temp = "";
        for(int j = 0; j < test.length() - 1; j++) {
          if(test.charAt(j) == cha || test.charAt(j + 1) == cha) {
            temp += String.valueOf(cha);
          } else {
            temp += String.valueOf(test.charAt(j));
          }
        }
        test = temp;
        int c = 0;
        for(int j = 0; j < temp.length(); j++) {
          if(temp.charAt(j) != cha) c++;
        }
        if(c == 0) flg = false;
      }
      ans = Math.min(ans, count);
    }
    } else {
      ans = 0;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 88264
def resolve():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    dp = [0] * (s + 1)
    dp[0] = 1
    for i in a:
        for j in range(s - i, -1, -1):
            dp[j + i] = dp[j + i] * 2 + dp[j]
            dp[j + i] %= mod
        for j in range(min(i, s + 1)):
            dp[j] *= 2
            dp[j] %= mod
    print(dp[-1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 68316