akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct {
  int id;
  char city[11];
  int point;
} set;


int main(){
  int i,j,k,N;
  char tmp[11];
  scanf("%d",&N);
  set hyouka[N];
  for(i=0;i<N;i++){
    scanf("%s %d",hyouka[i].city,&hyouka[i].point);
    hyouka[i].id = i;
  }
  int tmpp;
  for(i=1;i<N;i++){
    for(j=1;j<N;j++){
      if(strcmp(hyouka[j-1].city, hyouka[j].city)>0){
        strcpy(tmp, hyouka[j-1].city);
        strcpy(hyouka[j-1].city, hyouka[j].city);
        strcpy(hyouka[j].city, tmp);
        tmpp=hyouka[j-1].id;
        hyouka[j-1].id = hyouka[j].id;
        hyouka[j].id = tmpp;
        tmpp=hyouka[j-1].point;
        hyouka[j-1].point = hyouka[j].point;
        hyouka[j].point = tmpp;
      }
    }
  } 
  
  for (i=0; i<N; ++i) {
    for (j=i+1; j<N; ++j) {
      if (hyouka[i].point < hyouka[j].point  && strcmp(hyouka[i].city,hyouka[j].city)==0) {
        tmpp =  hyouka[i].point;
        hyouka[i].point = hyouka[j].point;
        hyouka[j].point = tmpp;
        tmpp =  hyouka[i].id;
        hyouka[i].id = hyouka[j].id;
        hyouka[j].id = tmpp;
      }
    }
  }
  
  for(i=0;i<N;i++)
    printf("%d\n",hyouka[i].id + 1);
  return 0;
}

          
  
  




Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>                                       
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long

int h, w, n;
vector<string> s,tmp;


bool solve()
{
	auto copy = tmp;
	bool update;
	do{
		update = false;
		bool update_ = true;
		while (update_)
		{
			update_ = false;
			for (int i = h - 2; i >= 0; i--)REP(j, w)
			{
				if (tmp[i][j] != '.'&&tmp[i + 1][j] == '.')
				{
					update_ = true;
					swap(tmp[i][j], tmp[i + 1][j]);
				}
			}
		}
		copy = tmp;
		REP(i, h)REP(j, w - n + 1)
		{
			if (copy[i][j] == '.') continue;
			char c = copy[i][j];
			bool f = true;
			REP(k, n) if (copy[i][j + k] != c) f = false;
			if (f) REP(k, n) tmp[i][j + k] = '.';
			if (f)
			{
				update = true;
			}
		}
		REP(i, h - n + 1)REP(j, w)
		{
			if (copy[i][j] == '.') continue;
			char c = copy[i][j];
			bool f = true;
			REP(k, n) if (copy[i + k][j] != c) f = false;
			if (f) REP(k, n) tmp[i + k][j] = '.';
			if (f) update = true;
		}

	} while (update);
	bool f = true;
	REP(i, h)REP(j, w) 
	{
		if (tmp[i][j] != '.') f = false;
	}
	return f;
}

int main()
{
	cin >> h >> w >> n;
	s.resize(h);
	REP(i, h) cin >> s[i];
	bool f = false;
	REP(i, h)REP(j, w - 1)
	{
		tmp = s;
		swap(tmp[i][j], tmp[i][j + 1]);
		if (solve()) f = true;
	}
	if (f) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>

main(){
  char data[21][21][21][21];
  int in, a, b, c, d, i, j, k, l, ans[4], n, flag=0, temp, s[4], sum, f[4];

  while(1){
    scanf("%d", &in);
    if(in==0) break;
    if(flag==1) printf("\n");
    scanf("%d %d %d %d", &a, &b, &c, &d);

    sum=100;
    for(i=0;i<=a;i++){
      for(j=0;j<=b;j++){
	for(k=0;k<=c;k++){
	  for(l=0;l<=d;l++){
	    temp=(10*i+50*j+100*k+500*l)-in;
	    f[0]=f[1]=f[2]=f[3]=0;
	    s[0]=a-i;
	    s[1]=b-j;
	    s[2]=c-k;
	    s[3]=d-l;
	    if(i==0) f[0]=1;
	    if(j==0) f[1]=1;
	    if(k==0) f[2]=1;
	    if(l==0) f[3]=1;
	    if(temp>=500 && f[3]==1){
	      s[3]+=temp/500;
	      temp-=(temp/500)*500;
	    }
	    if(temp>=100 && f[2]==1){
	      s[2]+=temp/100;
	      temp-=(temp/100)*100;
	    }
	    if(temp>=50 && f[1]==1){
	      s[1]+=temp/50;
	      temp-=(temp/50)*50;
	    }
	    if(temp>=10 && f[0]==1){
	      s[0]+=temp/10;
		temp-=(temp/10)*10;
	    }
	    if(temp!=0) continue;
	    if((s[0]+s[1]+s[2]+s[3])<sum){
	      ans[0]=i;
	      ans[1]=j;
	      ans[2]=k;
	      ans[3]=l;
	      sum=s[0]+s[1]+s[2]+s[3];
	    }
	  }
	}
      }
    }

    if(ans[0]!=0) printf("10 %d\n", ans[0]);
    if(ans[1]!=0) printf("50 %d\n", ans[1]);
    if(ans[2]!=0) printf("100 %d\n", ans[2]);
    if(ans[3]!=0) printf("500 %d\n", ans[3]);
    flag=1;
  }
  return 0;
}

Measured memory_bytes: 416
c,d[4010]={1};main(t,j){for(;t+=(j=getchar())>10?c+=j%3,1:-1;d[j]=0)for(j=c;j>c-t&&~j;d[j--]%=998244353)d[j]+=d[j-1];printf("%d",d[c]);}

Measured memory_bytes: 128
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

int main()
{
    string s,o;
    
    cin >> s;



    for (int i = 0; i < s.size(); i++) {
        char c;
        c=s[i];
        switch (c)
        {
        case '0':
            o.push_back('0');
            break;
        case '1':
            o.push_back('1');
            break;

        case 'B':
            if (o.size() > 0) {
                o.erase(o.size() - 1);
            }
            break;
        default:
            break;
        }
    }

        cout << o;

    return 0;
}




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

long long int n,i,ans;
string s[200010];

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	for (i=1;i<n+1;i++) cin>>s[i];
	sort(s+1,s+n+1);
	ans=1;
	for (i=2;i<n+1;i++) if (s[i]!=s[i-1]) ans++;
	cout<<ans;
}


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

using namespace std;

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int solve(int N, int K) {
  int A[N];
  for (int& a : A) {
    cin >> a;
  }
  int DP[N];
  for (int& dp : DP) {
    dp = numeric_limits<int>::max() - 2;
  }
  DP[0] = 0;
  for (int i {1}; i < N; ++i) {
    for (int k {0}; k <= K; ++k) {
      if (i - k < 0) {
        break;
      }
      DP[i] = min(DP[i], DP[i - k] + abs(A[i - k] - A[i]));
    }
  }
  return DP[N - 1];
}

int main(int argc, char* argv[]) {
  int N, K;
  cin >> N >> K;
  cout << solve(N, K) << '\n';
  return 0;
}

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

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

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

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        res++;  // 操作回数をインクリメント
    }

    cout << res << endl;
}

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

vector<list<int> >adjList(MAX);
int dp[MAX];

void addEdge(int u, int v){
	adjList[u].push_back(v);
}

int solve(int src){
	// If it is not solved for the src node
	if(dp[src]==-1){
		bool leaf = true;
		int bestChild = 0;
		
		for(int child : adjList[src]){
			leaf = false;
			bestChild = max(bestChild, solve(child));
		}
		if(leaf){
			dp[src] = 0;
		}
		else{
			dp[src] = 1 + bestChild;
		}
	}

	return dp[src];
}

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

	// Clearing graph and dp
	memset(dp, -1, sizeof dp);

	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		addEdge(u,v);
	}

	int ans = 0;
	for(int i=1;i<=n;i++){
		ans = max(ans, solve(i));
	}
	cout<<ans<<"\n";

}

Measured memory_bytes: 7424
#include<iostream>
#include<vector>
#include<queue>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100
#define INF (1 << 21)
using namespace std;

int n;
int a[N+5][N+5];

vector<int> d;
vector<int> color;

void dfs(int s){
  queue<int> Q;
  
  for(int i = 0; i < n; i++) color[i] = WHITE;
  for(int i = 0; i < n; i++) d[i] = INF;

  color[s] = GRAY;
  d[s] = 0;

  Q.push(s);

  while(!Q.empty()){
    int u = Q.front();
    Q.pop();

    for(int i = 0; i < n; i++){
      if(a[u][i] && color[i] == WHITE){
	color[i] = GRAY;
	d[i] = d[u] + 1;
	Q.push(i);
      }
    }

    color[u] = BLACK;
    
  }
}

int main()
{
  int u, k, v;
  
  cin >> n;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      a[i][j] = 0;
    }
  }

  d.resize(n+5);
  color.resize(n+5);

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    u--;

    for(int j = 0; j < k; j++){
      cin >> v;
      v--;
      a[u][v] = 1;
    } 
  }

  dfs(0);

  for(int i = 0; i < n; i++){
    cout << i+1 << " " << ((d[i] == INF) ? (-1):d[i]) << endl;
  }

  return 0;

}



Measured memory_bytes: 3124
s = int(input())


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return n * 3 + 1


def insert(sslist, x):
    if not sslist:
        sslist.append(x)
        return False

    start = 0
    end = len(sslist)

    while start < end - 1:
        y = sslist[(start + end) // 2]
        if x == y:
            return True
        if x < y:
            end = (start + end) // 2
        if x > y:
            start = (start + end) // 2

    if sslist[start] == x:
        return True
    if sslist[start] < x:
        sslist.insert(start + 1, x)
        return False
    if sslist[start] > x:
        sslist.insert(start, x)
        return False


slist = []
ss = s
for i in range(1, 2**32):
    ret = insert(slist, ss)
    ss = f(ss)
    if ret:
        print(i)
        break


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

ll memo[1000];
ll fib(ll n) {
  if(n == 0) return 2;
  else if(n == 1) return 1;
  else if(memo[n]) return memo[n];
  else return memo[n] = fib(n-1) + fib(n-2);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll a, b, k; cin >> a >> b >> k;
  set<int> st;
  for(int i=a;i<min(b, a+k);++i) {
    st.insert(i);
  }
  for(int i=max(a, b-k+1);i<=b;++i) {
    st.insert(i);
  }
  for(auto &e: st) {
    cout << e << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll q;
    string s;
    cin>>q>>s;
    ll n = s.size();
    
    for (ll i = 0; i < n; i++){
        s[i] = (s[i] - 'A' + q)%26 +'A';
    }
    cout << s << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<25);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string g[225];
int n,c[225],d[225][225];

bool dfs(int v, int color){
	int u;
	if(c[v] && color!=c[v]){
		return false;
	}else if(c[v]){
		return true;
	}
	c[v] = color;
	for(u=0; u<n; ++u){
		if(!g[v][u]){
			continue;
		}
		if(!dfs(u,-color)){
			return false;
		}
	}
	return true;
}

int main(void){
	int i,j,k,ans=-INF;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> g[i];
		for(j=0; j<n; ++j){
			g[i][j] -= '0';
		}
	}
	if(!dfs(0,1)){
		cout << "-1" << endl;
		return 0;
	}
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			d[i][j] = INF;
			if(g[i][j]){
				d[i][j] = 1;
			}
			if(i==j){
				d[i][j] = 0;
			}
		}
	}
	for(k=0; k<n; ++k){
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){	
			ans = max(ans,d[i][j]);
		}
	}
	cout << (ans+1) << endl;
	return 0;
}


Measured memory_bytes: 512
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s1,s2,s3;cin>>s1>>s2>>s3;
    char a=toupper(s1[0]);
    char b=toupper(s2[0]);char c=toupper(s3[0]);
    cout<<a<<b<<c<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

using namespace std; 

int n, a[20]; 

map < pair <pair <int, int>, pair <long long, long long> > , long long> f, vis; 

long long dp(int l, int r, long long x, long long y) {
  if (vis[{{l, r}, {x, y}}] != 0) return f[{{l, r}, {x, y}}];
  long long ret = 1e18; 
  vis[{{l, r}, {x, y}}] = 1; 
  if (r == l + 1) {
    ret = a[l] * x + a[r] * y; 
  }
  else {
    for (int m = l + 1; m <= r - 1; m++) {
      ret = min(ret, dp(l, m, x, x + y) + dp(m, r, x + y, y) - 1ll * a[m] * (x + y)); 
    }
  }
  return f[{{l, r}, {x, y}}] = ret; 
}

int main() {
  cin >> n; 
  for (int i = 1; i <= n; i++) {
    cin >> a[i]; 
  }  
  cout << dp(1, n, 1, 1) << endl; 
  return 0; 
}
 

Measured memory_bytes: 82428
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A<=8 && B<= 8) {
            System.out.println("Yay!");
        }else {
            System.out.println(":(");
        }

    }
}

Measured memory_bytes: 23508
n = int(input())
h = list(map(int, input().split()))
l = []
cnt = 0
ans = 0
for i in reversed(range(1, n)):
  if h[i]<=h[i-1]:
    cnt += 1
  else:
    l.append(cnt)
    cnt = 0
  if i==1:
    l.append(cnt)

if len(l)!=0: ans = max(l)
print(ans)

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

using namespace std;

#define inf (int)1e9
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;

const int N = 123456;
const int M = 1234567;

ll c[N];

int main(int argc, char const *argv[])
{
	
	#ifdef Cyborg1o1
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	

	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n, k;

	cin >> n >> k;

	while(n--){
		int a, b;
		cin >> a >> b;
		c[a] += b;
	}


	ll cur = 0;
	for(int i = 1; i <= N; ++i){
		cur += c[i];

		if(cur >= k){
			cout << i << endl;
			break;
		}

	}	

	return 0;				
	
	
	
}

Measured memory_bytes: 1024
main()
{
  int a,b,i,c,k[3100];
    scanf("%d %d",&a,&b);
  while(1)
    {
      c=0;
      for(i=a;i<=b;i++)
	  if(i%400==0 || (i%100!=0 && i%4==0))
	    k[c++]=i;
      if(c==0)
	puts("NA");
      else
	{
	  for(i=0;i<c;i++)
	    printf("%d\n",k[i]);
	}
      scanf("%d %d",&a,&b);
      if(a==0)
	exit(0);

      puts("");      
    }
}

Measured memory_bytes: 0
/*
 author : nit1n
 created : 14/09/2020 22:55:08
*/
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int mod = 1e9 + 7 ; 
int power(int a , int b)
{
	int ans = 1 ;
	while(b)
	{
		if(b&1)
		{
			ans *= a ;
			ans %= mod ;
		}
		a *=a ; 
		a %= mod ;
		b >>=1 ; 
	}
	return ans ; 
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int n ; 
	cin >> n ; 
	int ans = (power(10 , n) - 2*power(9,n)%mod + power(8 , n) + mod)%mod ; 
	cout << ans ;
}



Measured memory_bytes: 3636
h,w,a,b = map(int, input().split())

ansl = [[-1]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if i < b and j < a:
            ansl[i][j] = '0'
        elif i >= b and j >= a:
            ansl[i][j] = '0'
        else:
            ansl[i][j] = '1'

for a in ansl:
    print(''.join(a))



Measured memory_bytes: 89700
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
int x=0,y=0;
rep(i,0,n-1)
{
	int a;
	cin>>a;
	if(a%2==1)x++;
	if(a%4==0)y++;
}
if(y>=x)
{
	ol("Yes");
	return 0;
}

if(n%2==1&&x==n/2+1&&x+y==n)
{
	ol("Yes");
	return 0;
}
ol("No");
return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

void print_time(int sec);
void print_num(int n);

int main(void)
{
	int h, m, s;
	int i;
	int left;
	
	while (scanf("%d %d %d", &h, &m, &s)){
		if (h == -1 && m == -1 && s == -1) break;
		
		left = 7200 - (h * 3600 + m * 60 + s);
		
		print_time(left);
		print_time(left * 3);
	}
	
	return (0);
}

void print_time(int sec)
{
	print_num(sec / 3600);
	sec %= 3600;
	printf(":");
	
	print_num(sec / 60);
	printf(":");
	
	print_num(sec % 60);
	puts("");
}

void print_num(int n)
{
	if (n < 10){
		printf("0%d", n);
	} else {
		printf("%d", n);
	}
}

Measured memory_bytes: 616
#include <iostream>
using namespace std;
int main(void){
    int r,c;
    cin>>r>>c;
    int vec[r+1][c+1];
    for(int i=0;i<=r-1;i++){
        for(int j=0;j<=c-1;j++){
            cin>>vec[i][j];
        }
    }
    for(int i=0;i<=r-1;i++){
        vec[i][c]=0;
    }
    for(int j=0;j<=c-1;j++){
        vec[r][j]=0;
    }
    vec[r][c]=0;
    for(int i=0;i<=r-1;i++){
        for(int j=0;j<=c-1;j++){
            vec[i][c]+=vec[i][j];
            vec[r][j]+=vec[i][j];
        }
        vec[r][c]+=vec[i][c];
    }
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c-1;j++){
            cout<<vec[i][j]<<" ";
        }
        cout<<vec[i][c]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    set<int> cnt[n];
    rep(i, 0, n) {
        int k;
        cin >> k;
        rep(j, 0, k) {
            int a;
            cin >> a;
            cnt[i].insert(a);
        }
    }

    int ans = 0;
    rep(i, 1, m + 1) {
        bool found = true;
        rep(j, 0, n) {
            if (!cnt[j].count(i)) found = false;
        }
        if(found) ans++;
    }

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


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

int main() {
  int A,B;
  cin >> A>> B;
  int ans = A;
  int c = 1;
  
  if(B == 1) cout << 0 << endl;
  else{
  while(true){
    if(ans >= B) break;
    ans += A-1;
    c++;
  }
  cout << c << endl;
  }
}

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

const long long MOD = 1e9+7;
int main(){
   int N, M;
   std::cin >> N >> M;
   int a;
   std::vector<bool> status(N+1,true);
   for(int i=0; i<M; ++i){
      std::cin >> a;
      status[a] = false;
   }

   std::vector<long long> dp(N+1,0);
   dp[0] = 1;
   for(int i=0; i<N; ++i){
      for(int j=i+1; j<=std::min(N,i+2); ++j){
	 if(status[j]){
	    dp[j] += dp[i];
	    dp[j] %= MOD;
	 }
      }
   }
   std::cout << dp[N] << std::endl;
   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n;
bool isPallindrome(string s){
	for(int i = 0 ;i  < n/2; i++){
		if(s[i] != s[s.length()-1-i])return false;
	}
	
	return true;
}
int main(){

      string s;
      cin >> s;
      n = s.length();
      if(isPallindrome(s) && n%2 == 1){
          string str = "";
          for(int i =1; i <= (n-1)/2;i++){
          	str+=s[i-1];
          }
          string str1 ="";
          for(int i = (n+3)/2; i<=n ;i++){
          	str1 += s[i-1];
          }
          if(isPallindrome(str) && isPallindrome(str1))cout<<"Yes\n";
          else cout<<"No\n";
      }
      else cout<<"No\n";
      
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

ll dp[3000][3000][4];
int v[3000][3000];

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

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

    for (int l = 0; l < k; l++) {
        int i, j;
        cin >> i >> j;
        i--; j--;

        cin >> v[i][j];
    }

    for (int l = 0; l < 3; l++) {
        dp[0][0][l + 1] = v[0][0];
    }
    for (int j = 1; j < m; j++) {
        for (int l = 0; l < 3; l++) {
            dp[0][j][l + 1] = max(dp[0][j - 1][l] + v[0][j], dp[0][j - 1][l + 1]);
            //cout << dp[0][j][l + 1] << ' ';
        }
        //cout << '\n';
    }
    for (int i = 1; i < n; i++) {
        dp[i][0][0] = dp[i - 1][0][3];
        for (int l = 0; l < 3; l++) {
            dp[i][0][l + 1] = dp[i - 1][0][3] + v[i][0];
        }
        for (int j = 1; j < m; j++) {
            dp[i][j][0] = max(dp[i - 1][j][3], dp[i][j - 1][0]);
            //cout << dp[i][j][0] << ' ';
            for (int l = 0; l < 3; l++) {
                dp[i][j][l + 1] = max(max(max(dp[i][j - 1][l] + v[i][j], dp[i][j - 1][l + 1]), dp[i][j][0] + v[i][j]), dp[i][j][0]);
            }
        }
    }

    cout << dp[n - 1][m - 1][3] << endl;

    return 0;
}

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

int main() {
  int x;
  cin >> x;
  string ans = "No";
  if (x >= 30) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int a,b;
	cin>>a>>b;
	if(a%2==1&&b%2==1) cout<<"Odd"<<endl;
	else cout<<"Even"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP (i, N) cin >> A[i];
    N--; K--;
    cout << (N + K - 1) / K << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  for (int i = 1; i <= 5; i++) {
    int a;
    cin >> a;
    if (a == 0) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;

}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, d[50];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> d[i];
	int sum = 0;
	for(int i = 0; i < n - 1; i++)
		for(int j = i + 1; j < n; j++) sum += d[i] * d[j];
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  n--;
  COUT((n+1)*n/2);
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[510][10010];
int main()
{
    int M,N,P[10010],C[510],E[510],ans = 0;
    scanf("%d%d",&M,&N);
    for(int i = 0; i < M; i++)scanf("%d",&P[i]);
    sort(P,P + M);
    for(int i = M - 2; i >= 0; i--)P[i] = P[i] + P[i + 1];
    //for(int i = M - 1; i >= 0; i--)printf("%4d",P[i]);printf("\n");
    for(int i = 0; i < N; i++)scanf("%d%d",&C[i],&E[i]);
    for(int i = 0; i < N + 1; i++)
    {
        for(int j = 0; j < M + 1; j++)
        {
            if(j == 0)dp[i][j] = 0;
            else dp[i][j] = 1000000000;
            if(i != 0)
            {
                dp[i][j] = dp[i - 1][j];
                if(j >= C[i - 1])dp[i][j] = min(dp[i][j],dp[i - 1][j - C[i - 1]] + E[i - 1]);
            }
        }
        if(i != 0 && C[i - 1] > M)dp[i][M] = min(dp[i][M],E[i - 1]);
        for(int j = M - 1; j >= 0; j--)dp[i][j] = min(dp[i][j],dp[i][j + 1]);
    }
    /*for(int i = 0; i < N + 1; i++)
    {
        for(int j = 0; j < M + 1; j++)
        {
            printf("%9d",dp[i][j]);
        }
        printf("\n");
    }*/
    for(int i = 0; i < M; i++)ans = max(ans,P[M - 1 - i] - dp[N][i + 1]);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 22396
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
vector<ll> hieghts ;
#define INF 1000000007
const int N = 1e7;
vector<ll> dp(N);
ll total_size;
int min_cost(int curr_position)
{  
   
    dp[0] = 0;
    dp[1]  = abs(hieghts[1] - hieghts[0]);
    for(ll i=2;i<total_size;i++)
    {
    	dp[i] = min((dp[i-1]+abs(hieghts[i]-hieghts[i-1])),(dp[i-2]+abs(hieghts[i]-hieghts[i-2])));
    }
cout<<dp[total_size-1]<<"\n";
}

int main()
{
//#ifndef ONLINE_JUDGE
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
//#endif
cin>>total_size;
for(ll i=0;i<total_size;i++)
{
   ll temp;cin>>temp;
   hieghts.pb(temp);
}
min_cost(0);
}


Measured memory_bytes: 79480
n, k, s = map(int, input().split())

ans = []
for i in range(k):
    ans.append(s)

if s == 10 ** 9:
    for i in range(n - k):
        ans.append(1)
else:
    for i in range(n - k):
        ans.append(s + 1)

print(*ans)

Measured memory_bytes: 9584
//Utkarsh.25dec
#include <bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    ll dp[n+1][3];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        ll x,y,z;
        cin>>x>>y>>z;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+x;
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+y;
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+z;
    }
    cout<<max3(dp[n][0],dp[n][1],dp[n][2]);
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
}

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


using namespace std;
 
int main(){
   int N,M;
   cin >> N;

   vector<string> blue(N);

   
  


    map<string,int> s;
    for(int i = 0; i < N; i++){ cin >> blue[i]; s[blue[i]]++; }
   
   cin >> M;
   vector<string> red(M);
   
    for(int i = 0; i < M; i++){
         cin >> red[i]; 
         s[red[i]]--; 
         }

   

    

    int max = 0; 
    for(int i = 0; i < N; i++){
        if(max < s[blue[i]]) max = s[blue[i]];
    }
    cout << max;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  ll sum = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        sum += gcd((i + 1), gcd((j + 1), (k + 1)));
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3672
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define m 1000000007
#define MAXN 1000001
#define satya ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cil(a,b) (((a-1)/b)+1)
//#define init int t;cin>>t;while(t--)
#define in(a) ll a;scanf("%lld",&a)
#define ine(a,b) ll a,b;scanf("%lld lld",&a,&b)



ll spf[MAXN]; 

void sieve1() 
{ 
	spf[1] = 1; 
	for (int i=2; i<MAXN; i++) 

		spf[i] = i; 

	for (int i=4; i<MAXN; i+=2) 
		spf[i] = 2; 

	for (int i=3; i*i<MAXN; i++) 
	{ 
		if (spf[i] == i) 
		{ 
			for (int j=i*i; j<MAXN; j+=i) 

				if (spf[j]==j) 
					spf[j] = i; 
		} 
	} 
} 

ll  getFactorization(int x) 
{ 
	vector<int> ret; 
	long long int p=0;
	while (x != 1) 
	{ 
		ret.push_back(spf[x]); 
		x = x / spf[x]; 
	} 
	sort(ret.begin(),ret.end());
	for(int i=0;i<ret.size()-1;i++) 
	{
	    if(ret[i]!=ret[i+1])
	    p=p+ret[i];
	}
	p=p+ret[ret.size()-1];
	return p;
} 

ll d[1000055],u=0;
void Sieve(int n) 
{ 
	bool prime[n+1]; 
//	ll u=0;
	memset(prime, true, sizeof(prime)); 

	for (int p=2; p*p<=n; p++) 
	{ 
		if (prime[p] == true) 
		{ 
			for (int i=p*2; i<=n; i += p) 
				prime[i] = false; 
		} 
	} 

	for (int p=2; p<=n; p++) 
	if (prime[p]) 
	{
	    d[u]=p;
	    u++;
	}
} 

ll minverse(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return minverse((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*minverse((x*x)%M,(n-1)/2,M))%M;

}
ll prime(ll n){
    ll i;
    if(n==1||n==0)
    return 0;
    for(i=2;i<sqrt(n);i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
int main() {
       satya;
     //sieve1(); 
     //Sieve(100);
  ll n,k;
  cin>>n>>k;
  ll a[n],i,b[n],j,c=0,d[n];
  for(i=0;i<n;i++)
  cin>>a[i];
  for(i=0;i<n;i++)
  {
      c=0;
     for(j=i+1;j<n;j++)
     {
        if(a[i]>a[j])
        c++;
     }
     b[i]=c;
    //  cout<<c<<" ";
  }
//   cout<<endl;
    for(i=0;i<n;i++)
  {
      c=0;
     for(j=0;j<n;j++)
     {
        if(a[i]>a[j])
        c++;
     }
     d[i]=c;
    //  cout<<c<<" ";
  }
//   cout<<endl;

  ll sum=0,y=0;
//   k--;
  for(i=0;i<n;i++)
  {
      if(d[i]>0)
      {
             ll  p=k-1;
        ll u1=(d[i]*p);
        u1+=b[i];
        u1%=m;
        // cout<<u1<<endl;
        u1=(u1+b[i]);
                // cout<<u1<<endl;

        u1%=m;
        u1*=k;
        u1%=m;
        y=u1;
        // cout<<u1<<endl;
          u=(minverse(2,m-2,m));
        //   cout<<(u*y)%m<<endl;
        y=(y*u)%m;
          y+=m;
          y%=m;
        //  cout<<y<<" ";
          sum+=y;
        //   sum=sum+b[i]+b[i];
          sum%=m;
          
        //   cout<<sum<<endl;
      }
  }
  
  cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;


#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.

LL n;
int main() {
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	cin>>n;
	LL ans = 0;
	for(LL i = 1;i<=n;i++){
		ans += i*(((n/i) * (n/i + 1))/2);
	}
	cout<<ans;
  	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define N 1000000007;
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int ns=s.length();
    int nt=t.length();
    int dp[ns+1][nt+1]={};
    for(int i=1;i<ns+1;i++)
        {
        for(int j=1;j<nt+1;j++)
            {
            if (s[i-1]!=t[j-1])
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            else
                dp[i][j]=1+dp[i-1][j-1];

            }
        }
    string ch="";
    int i=ns;
    int j=nt;
    while((i>0)and(j>0))
    {
        if (dp[i][j]>max(dp[i][j-1],dp[i-1][j]))
        {
            ch=s[i-1]+ch;
            i--;
            j--;
        }
        else if (dp[i][j-1]>dp[i-1][j])
            j--;
        else
            i--;
    }
    cout<<ch;

    return(0);
}


Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define REP0(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REP1(i,n) for((i)=1;(i)<=(int)(n);(i)++)
#define ll long long
using namespace std;

int i,j,k;
int i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11;
const ll MOD = 1000000000 + 7;

int main(){
    int n,m,x,ans;
    ans=INT32_MAX;
    cin>>n>>m>>x;
    int c[n],memo[m];
    REP0(i,m)memo[i]=0;
    int a[n][m];
    REP0(i,n){
        cin>>c[i];
        REP0(j,m){
            cin>>a[i][j];
            memo[j]+=a[i][j];
        }
        
    }
    REP0(i,m){
        if(memo[i]<x){
            ans=-1;
            break;
        }
    }
    

    if(ans!=0){
        for(int bit=0;bit<(1<<n);++bit){
            vector<int> S;
            int mini=0;
            REP0(i,m)memo[i]=0;
            for (i = 0; i < n; ++i) {
                if (bit & (1<<i)) { // 列挙に i が含まれるか
                    S.push_back(i);
                }
            }
            for(i = 0; i < (int)S.size(); ++i){
                mini+=c[S[i]];
                REP0(j,m){
                    memo[j]+=a[S[i]][j];
                }
            }
            bool flg=true;
            REP0(i,m){
                if(memo[i]<x){
                    flg=false;
                    break;
                }
            }
            if(flg){
                ans=min(ans,mini);
            }
        }

    }

    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int a[3];
  for(int i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  int sum;
  sum=a[0]+a[2]+a[1];
  if(sum>=22)
    printf("bust");
  else
    printf("win");
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MOD 1000000007
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll n, m;
ll dp[2005][2005][3];
ll s[2005], t[2005];
ll compute(ll i, ll j, ll k)
{
    if(i < 0 || j < 0)
    {
        if(k == 1) return 0;
        return 1;
    }
    if(dp[i][j][k] != -1) return dp[i][j][k];
    ll ans = 0, num = 0;
    if(s[i] == t[j])
    {
        ans += compute(i-1, j-1, 0);
        ans %= MOD;
    } 
    ans += compute(i-1, j, k);
    ans %= MOD;
    ans += compute(i, j-1, k);
    ans %= MOD;
    ans -= compute(i-1, j-1, k);
    ans += MOD;
    ans += MOD;
    ans %= MOD;
    return dp[i][j][k] = ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>n>>m;
    ll i, j, k;
    FOR0(i, n) cin>>s[i];
    FOR0(i, m) cin>>t[i];
    FOR0(i, n+4)FOR0(j, m+4)FOR0(k, 3){ dp[i][j][k] = -1;}
    ll ans = compute(n-1, m-1, 1) + 1;
    ans %= MOD;
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 94720
#import <Foundation/Foundation.h>
#import <stdarg.h>

@interface StdIO : NSObject
+(NSMutableString*)stringFromStdIn; // 標準入力から NSString を得る
+(void)printf:(NSString*)format, ...; // 標準出力へ出力
@end

@implementation StdIO
+(NSMutableString*)stringFromStdIn
{
    NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
    NSMutableString *result = [NSMutableString string];
    NSData *data = [handle availableData];
    while ([data length] > 0) {
        [result appendString:[[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]];
        data = [handle availableData];
    }
    NSUInteger length = [result length];
    if (length >= 1 && [result characterAtIndex:length-1] == '\n') { // 入力末尾に改行文字があれば削除
        [result deleteCharactersInRange:NSMakeRange(length-1,1)];
    }
    return result;
}
+(void)printf:(NSString*)format, ...
{
    va_list arguments;
    va_start(arguments, format);
    NSString *string = [[[NSString alloc] initWithFormat:format arguments:arguments] autorelease];
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
    [fileHandle writeData:[string dataUsingEncoding:NSUTF8StringEncoding]];
    va_end(arguments);
}
@end

@interface NSMutableArray (Extension)
-(id)shift;
@end

@implementation NSMutableArray (Extension)
-(id)shift
{
    if ([self count] > 0) {
        id first = [self objectAtIndex: 0];
        [self removeObjectAtIndex: 0];
        return first;
    } else {
        return nil;
    }
}
@end

int main() {
    @autoreleasepool {
        NSString *S = [StdIO stringFromStdIn];
        NSUInteger length = [S length];
        NSArray *words = @[@"dream", @"erase", @"eraser", @"dreamer"];
        NSMutableArray *candidates = [NSMutableArray arrayWithObject:@0]; // 切断に成功している位置の候補を格納するキュー
        NSNumber *candidate;
        while ((candidate = [candidates shift])) {
            NSUInteger currentIndex = [candidate unsignedIntegerValue]; // 先頭候補を取り出し
            for (NSString *word in words) {
                NSUInteger size = [word length];
                if (currentIndex + size <= length) {
                    NSString *prefix = [S substringWithRange:NSMakeRange(currentIndex, size)];
                    if ([prefix isEqualToString: word]) {
                        if (currentIndex + size == length) { // ちょうど末尾にたどり着いたら終了
                            [StdIO printf:@"YES"];
                            return 0;
                        } else {
                            [candidates addObject:@(currentIndex + size)];
                        }
                    }
                }
            }
        }
        [StdIO printf:@"NO"];
    }
    return 0;
}


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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    faster
	llu n,i,j,r,x;
	string s="abcdefghijklmnopqrstuvwxyz";
	string ans="";
	cin>>n;
	while(n)
	{
	    n--;
		ans=s[n%26]+ans;
		n/=26;
	}
	//reverse(ans.begin(),s.end());
	cout<<ans<<nl;
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int k;cin >> k;
  LL ans = 0;
  for(int i=1;i<=k;i++) for(int j=1;j<=k;j++) for(int l=1;l<=k;l++){
    ans += __gcd(i,__gcd(j,l));
  }
  cout << ans << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
#endif
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int x, n;
   cin >> x >> n;
   if (n == 0)
   {
      cout << x;
      return 0;
   }
   vector<int> a(n);
   for (int i = 0; i < n; i++)
      cin >> a[i];
   sort(a.begin(), a.end());
   int ans = INT_MAX;
   int i = x - 1, j = x + 1;
   if (find(a.begin(), a.end(), x) == a.end())
   {
      ans=x;
      cout<<ans;
      return 0;
   }
   while (1)
   {
      if (abs(x - i) < abs(x - ans))
      {
         if (find(a.begin(), a.end(), i) == a.end())
         {
            ans = i;
            break;
         }
      }
      if (abs(x - j) < abs(x - ans))
      {
         if (find(a.begin(), a.end(), j) == a.end())
         {
            ans = j;
            break;
         }
      }
      i--;
      j++;
   }
   cout << ans;
   return 0;
}

Measured memory_bytes: 3604
fun main(args:Array<String>) {
  val (n, q) = readLine()!!.split(" ").map {it.toInt()}
  val s = readLine()!!
  val l = (1..q).map { readLine()!!.split(" ").map {it.toInt()}.toTypedArray()}.toTypedArray()
  solve(s, l)
}

fun solve(s:String, l:Array<Array<Int>>) {
  val r = create(s)

  for (ll in l) {
    println(r[ll[1] - 1] - r[ll[0] -1])
  }
}

fun create(s:String) : Array<Int> {
  var result = Array(s.length,  { 0 })
  var count = 0
  for (i in 1..s.length - 1) {
    if (s.substring(i - 1,  i + 1) == "AC") {
      ++count
    }
    result[i] =  count
  }
  return result
}


Measured memory_bytes: 69300
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

string s, t;
ll dp[3001][3001];
string ans;

int main() {
    cin >> s >> t;
    dp[0][0] = 0;
    rep(i,s.size()) {
        rep(j,t.size()) {
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            if (s[i] == t[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1);
        }
    }
    ll p = s.size(), q = t.size();
    while (true) {
        if (dp[p][q] == 0) break;
        if (dp[p-1][q] == dp[p][q]) {
            p--;
        } else if (dp[p][q-1] == dp[p][q]) {
            q--;
        } else {
            p--; q--;
            ans.push_back(s[p]);
        }
    }
    rep(i,ans.size()) {
        cout << ans[ans.size()-1-i];
    }
    cout << endl;
}



Measured memory_bytes: 70656