akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn=2009;
const int inf=1000000000;

int a[4]={0,0,1,-1};
int b[4]={1,-1,0,0};

int n,m;
int cx,cy;
int dx,dy;

char s[maxn][maxn];
int d[maxn][maxn];

int l,r;
int q[maxn*maxn*2][2];
void bfs(){
	l=r=maxn*maxn;
	q[l][0]=cx;q[l][1]=cy;
	d[cx][cy]=0;
	while(l<=r){
		int x=q[l][0],y=q[l][1];++l;
		for(int k=0;k<4;++k){
			int xx=x+a[k];
			int yy=y+b[k];
			if(xx<=0||yy<=0||xx>n||yy>m)continue;
			if(s[xx][yy]=='#')continue;
			if(d[x][y]>=d[xx][yy])continue;
			d[xx][yy]=d[x][y];
			--l;q[l][0]=xx;q[l][1]=yy;
		}
		for(int i=x-2;i<=x+2;++i){
			for(int j=y-2;j<=y+2;++j){
				int xx=i,yy=j;
				if(xx<=0||yy<=0||xx>n||yy>m)continue;
				if(s[xx][yy]=='#')continue;
				if(d[x][y]+1>=d[xx][yy])continue;
				d[xx][yy]=d[x][y]+1;
				++r;q[r][0]=xx;q[r][1]=yy;
			}
		}
	}
}

int main(){
	scanf("%d%d",&n,&m);
	scanf("%d%d",&cx,&cy);
	scanf("%d%d",&dx,&dy);
	for(int i=1;i<=n;++i)scanf("%s",s[i]+1);
	
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			d[i][j]=inf;
		}
	}
	
	bfs();
	if(d[dx][dy]==inf)printf("-1\n");
	else printf("%d\n",d[dx][dy]);
	
	return 0;
}

Measured memory_bytes: 17340
#include<stdio.h>
int getarea(int, int);
int getlength(int, int);

int main(void)
{
        int width, height;
        scanf("%d %d", &width, &height);
        if(height < 1 || width > 100) return -1;
        printf("%d %d\n", getarea(height, width), getlength(height, width));
        return 0;
}

int getarea(int height, int width)
{
        return height * width;
}

int getlength(int height, int width)
{
        return height*2 + width*2;
}

Measured memory_bytes: 596
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_1.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int

    # write code
    P += 3 * A
    print(P//2)


Measured memory_bytes: 5332
#include<bits/stdc++.h>
const int maxn = 100100;
int dep[maxn], h[maxn], nxt[maxn];
int n, k, a[maxn];
int ans;
inline void link(int f,int x) { nxt[x] = h[f], h[f] = x; }
inline void dfs(int x) {
	for(int i = h[x];i;i = nxt[i])
		dfs(i), dep[x] = std::max(dep[x], dep[i] + 1);
	if(x != 1 && dep[x] >= k - (a[x] != 1)) ++ ans, dep[x] = -1;
}
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> k;
	for(int i = 1;i <= n;++i) std::cin >> a[i];
	for(int i = 2;i <= n;++i) link(a[i], i);
	dfs(1);
	std::cout << ans + (a[1] != 1) << '\n';
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, m;
  cin >> n >> m;
  vector<ll> ans(n,0);
  REP(i, m) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    ans[a]++, ans[b]++;
  }
  REP(i, n) { cout << ans[i] << "\n"; }
  return 0;
}


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

int main(){
	int h[10];
	for(int i=0; i<10; i++){
		cin >> h[i];
	}
	sort(h, h+10);
	for(int i=9; i>=7; i--){
		cout << h[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
# -*- coding:utf-8 -*-
from collections import Counter

def check(n, a):
    count = Counter(a)
    if n % 2 == 1 and (0 not in count or count[0] != 1):
        return False
    for i in range(1 + (n % 2), n+1, 2):
        if i not in count or count[i] !=2:
            return False
    return True

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))

    m = N // 2
    if not check(N,A):
        print(0)
    else:
        print((2 ** m) % (10**9+7))


Measured memory_bytes: 14820
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	ll mid = abs(b-a);
	ll ts = abs(w-v);
	if(w-v >= 0){
		puts("NO");
		return 0;
	}
	if(ts*t >= mid) puts("YES");
	else puts("NO");
 	return 0;
}

Measured memory_bytes: 3624
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
n1 = 0
n2 = 0
n3 = 0
for i in P:
  if i <= A:
    n1 += 1
  elif i <= B:
    n2 += 1
  else:
    n3 += 1
print(min(min(n1,n2),n3))

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,m,k,val[10],ans=hell;
vi v[10];
string s[10];
void solve(){
    cin>>n>>m>>k;
    rep(i,0,n) cin>>s[i];
    rep(i,0,1<<(n-1)){
        rep(j,0,n) v[j].clear(),val[j]=0; 
        int last=-1,q=0,g=0;
        rep(j,0,n){
            if(j==n-1 or (i>>j)&1){
                rep(l,0,m){
                    int cur=0;
                    rep(w,last+1,j+1){
                        cur+=s[w][l]-'0';
                    }
                    if(cur>k) g=1;
                    v[q].pb(cur);
                }
                last=j;
                q++;
            }
        }
        if(g==1) continue;
        int cnt=__builtin_popcount(i);
        rep(l,0,m){
            int f=0;
            rep(j,0,q){
                val[j]+=v[j][l];
                if(val[j]>k) f=1;
            }
            if(f){
                l--;
                cnt++;
                rep(j,0,q) val[j]=0;
            }
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 384
N,A,B=map(int,input().split())
P=10**9+7

Q=pow(2,N,P)

def fac(n,k,p):
    ans=1
    for i in range(n-k+1,n+1):
        ans=(ans*i)%p
    return ans

def makeinv(length,p):
    L=[0,1]
    for i in range(2,length+1):
        x=p-((L[p%i]*(p//i))%p)
        L.append(x)
    return L

def comb(n,k,p):
    if k==0:
        return 1
    else:
        ans=fac(n,k,p)
        inv=makeinv(k,p)
        for i in range(1,k+1):
            ans=(ans*inv[i])%p
        return ans

R=comb(N,A,P)
S=comb(N,B,P)

print((Q-1-R-S)%P)


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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>

ll arr[110][2];
ll W,N;
ll dp[110][100010];
ll solve(ll i,ll weight){
	if(weight<0){
		return INT_MIN;
	}
	if(i>=N){
		return 0;
	}
	if(weight==0){
		return 0;
	}
	if(dp[i][weight]!=-1){
		return dp[i][weight];
	}
	ll ans=INT_MIN;
	ans=max(ans,arr[i][1]+solve(i+1,weight-arr[i][0]));
	ans=max(ans,solve(i+1,weight));
	dp[i][weight]=ans;
	return dp[i][weight];
}
int main(){
	fast;
	cin>>N>>W;
	for(ll i=0;i<N;i++){
		cin>>arr[i][0]>>arr[i][1];
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,W)<<endl;
}

Measured memory_bytes: 86272
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
a.unshift(nil)
ans = Array.new(n+1, 0)

n.downto(1) do |i|
  sum = a[i]
  cur = i * 2
  while cur <= n
    sum += ans[cur]
    cur += i
  end
  ans[i] = sum % 2
end

# p ans
ans.shift
puts ans.count{|num| num == 1}
puts (1..n).to_a.zip(ans).select{|x,y| y==1}.map{|x,y|x}.join(' ')



Measured memory_bytes: 35316
# E - Colorful Blocks
import sys
sys.setrecursionlimit(10**8)

MOD = 998244353
N,M,K = map(int,input().split())
inv_M = pow(M-1,-1,MOD) if M>1 else 0
ans = 0
tmp = pow(M-1,N-1,MOD) if M>1 else 0
comb = 1
for i in range(K+1):
    ans = (ans+M*comb*tmp)%MOD
    if i==K:
        break
    tmp = (tmp*inv_M)%MOD
    comb = (comb*(N-1-i)*pow(i+1,-1,MOD))%MOD
if M==1 and K==N-1:
    ans += 1
print(ans)

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

#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
const int maxn = 2e5+15;
int n,Q,a,b,c,d,cnt,head[maxn],ans[maxn];
struct edge{
    int to,nxt,col,len;
}e[maxn<<1];
struct query{
    int l,r,x,y,id;
}q[maxn<<1];
pii p[maxn];
inline void add(int u,int v,int c,int d){
    e[++cnt] = (edge){v,head[u],c,d};
    head[u] = cnt;
}
int dp[maxn][20],deep[maxn],st[maxn],ed[maxn],tot,A[maxn<<1];
void dfs(int x,int fa,int depth){
    A[++tot] = x; st[x] = tot; deep[x] = depth;
    for(int i = head[x];i > 0;i = e[i].nxt){
        int v = e[i].to;
        if(v == fa) continue;
        p[v] = pii(e[i].col,e[i].len);
        dp[v][0] = x; dfs(v,x,depth+1);
    }
    A[++tot] = x; ed[x] = tot;
}
void init(){
    for(int i = 1;(1<<i)<=n; ++i)
    for(int j = 1;j <= n; ++j)
    dp[j][i] = dp[dp[j][i-1]][i-1];
}
int LCA(int u,int v){
    if(deep[u] < deep[v]) swap(u,v);
    int h = deep[u] - deep[v];
    for(int i = 0;i < 20; ++i){
        if(h&(1<<i)) u = dp[u][i];
    }
    if(u == v) return u;
    for(int i = 19; ~i; --i){
        if(dp[u][i] != dp[v][i]){
            u = dp[u][i];
            v = dp[v][i];
        }
    }
    return dp[u][0];
}
int block,num[maxn],sum[maxn],vis[maxn],res;
bool cmp(query a,query b){
    return (a.l/block)^(b.l/block)?a.l<b.l:(((a.l/block)&1)?a.r<b.r:a.r>b.r);
}
void add(int v){
    if(vis[v]) {num[p[v].fi]--;sum[p[v].fi]-=p[v].se;res-=p[v].se;}
    else {num[p[v].fi]++;sum[p[v].fi]+=p[v].se;res+=p[v].se;}
    vis[v] ^= 1;
}
void del(int v){
    if(vis[v]) {num[p[v].fi]--;sum[p[v].fi]-=p[v].se;res-=p[v].se;}
    else {num[p[v].fi]++;sum[p[v].fi]+=p[v].se;res+=p[v].se;}
    vis[v] ^= 1;
}
int main(){
    scanf("%d %d",&n,&Q); block = sqrt(n*1.0);
    for(int i = 1;i < n; ++i){
        scanf("%d %d %d %d",&a,&b,&c,&d);
        add(a,b,c,d); add(b,a,c,d);
    }
    dfs(1,0,1); init();
    for(int i = 0;i < Q; ++i){
        scanf("%d %d %d %d",&a,&b,&c,&d);
        if(st[c] > st[d]) swap(c,d);
        if(LCA(c,d) == c) q[i] = (query){st[c]+1,st[d],a,b,i};
        else q[i] = (query){ed[c],st[d],a,b,i}; 
    }
    sort(q,q+Q,cmp);
    int L = 2,R = 1; res = 0;
    for(int i = 0;i < Q; ++i){
        while(R > q[i].r) del(A[R]),--R;
        while(R < q[i].r) ++R,add(A[R]);
        while(L < q[i].l) del(A[L]),++L;
        while(L > q[i].l) --L,add(A[L]);
        ans[q[i].id] = res-sum[q[i].x]+num[q[i].x]*q[i].y;
    }
    for(int i = 0;i < Q; ++i) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 30208
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import os

sys.setrecursionlimit(500*500)

runc=0

def tonari(n,x,keta,k):
    #print(n,end="")
    #print(" ",end="")
    #print(x,end="")
    #print(" ",end="")
    #print(keta)
    global runc
    if keta==1:
        runc+=1
        if runc==k:
            print(n)
            sys.exit()
        return 0

    if x==0:
        yy=[0,1]
    elif x==9:
        yy=[8,9]
    else:
        yy=[x-1,x,x+1]
    for y in yy:
        #rint(y)
        tonari(n+y*(10**(keta-2)),y,keta-1,k)
        #if res!=0:
        #    return res

    

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    k=int(readline())

    for keta in range(1,100):
        for i in range(1,10):
            tonari(i*(10**(keta-1)),i,keta,k)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,m;
ll a[e5];
ll dp[e5];

int main(){
  cin >> n >> m;
  for(ll i = 0;i < m;i++){
    ll x;
    cin >> x;
    a[x] = 1;
  }
  dp[0] = 1;
  for(ll i = 0;i < n;i++){
    dp[i] %= mod;
    if(a[i+1] == 0) dp[i+1] += dp[i];
    if(a[i+2] == 0) dp[i+2] += dp[i];

  }
  cout << dp[n]%mod << endl;

}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    vector<pair<int, int>> pos, neg;
    REP(i, 0, N) {
        string s; cin >> s;
        int lowest = 0, inc = 0;
        for (auto c : s) {
            if (c == '(') {
                inc++;
            } else {
                inc--;
                lowest = min(lowest, inc);
            }
        }
        if (inc > 0) pos.push_back({lowest, inc});
        else neg.push_back({lowest - inc, -inc});
    }

    sort(ALL(pos), greater<pair<int, int>>());
    sort(ALL(neg), greater<pair<int, int>>());

    int curp = 0, curn = 0;
    for (auto p : pos) {
        if (curp + p.first < 0) {
            cout << "No" << endl;
            return 0;
        }
        curp += p.second;
    }
    for (auto n : neg) {
        if (curn + n.first < 0) {
            cout << "No" << endl;
            return 0;
        }
        curn += n.second;
    }

    if (curp == curn) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 11320
K = int(input())
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += (gcd(i,j,k))
print(ans)

Measured memory_bytes: 75000
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=20+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
char arr[MAXN][MAXN];
int h,w;
int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
bool jude(int x,int y)
{
    if(x>=1&&x<=h&&y>=1&&y<=w)return true;
    return false;
}
int vis[MAXN][MAXN];
struct node
{
    int x,y,tep;
    node(){}
    node(int x,int y,int tep):x(x),y(y),tep(tep){}
};
int bfs(int sx,int sy,int ex,int ey)
{
    memset(vis,0,sizeof(vis));
    vis[sx][sy]=1;
    queue<node>que;
    que.push(node(sx,sy,0));
    while(!que.empty())
    {
        node curr=que.front();que.pop();
        if(curr.x==ex&&curr.y==ey)
        {
            return curr.tep;
        }
        for(int k=0;k<4;k++)
        {
            int nx=curr.x+dir[k][0];
            int ny=curr.y+dir[k][1];
            if(jude(nx,ny)&&vis[nx][ny]==0&&arr[nx][ny]=='.')
            {
                vis[nx][ny]=1;
                que.push(node(nx,ny,curr.tep+1));
            }
        }
    }
    return -1;
}
int main()
{
    while(cin>>h>>w)
    {
        for(int i=1;i<=h;i++)
        {
            cin>>(arr[i]+1);
        }
        int ans=0;
        for(int si=1;si<=h;si++)
        {
            for(int sj=1;sj<=w;sj++)
            {
                if(arr[si][sj]=='#')continue;
                for(int ei=1;ei<=h;ei++)
                {
                    for(int ej=1;ej<=w;ej++)
                    {
                        if(arr[ei][ej]=='#')continue;
                        int res=bfs(si,sj,ei,ej);
                        ans=max(ans,res);
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[N];
    for(int i=0;i<N;++i) A[i] = sc.nextInt();
    
    System.out.println(getWinner(A, N, K));
  }
  
  private static String getWinner(int[] nums, int n, int k) {
    boolean[] dp = new boolean[k+1];
    
    // base case
    dp[0] = false;
    for(int i=1;i<=k;++i) {
      for(int j=0;j<n;++j) {
        if (i-nums[j] >= 0 && !dp[i-nums[j]]) {
          dp[i] = true;
          break;
        }
      }
    }
    
    return dp[k] ? "First" : "Second";
  }
}

Measured memory_bytes: 27588
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i=n;i<=999;i++){
        if(i%10 == i/100 && i/100 == (i%100)/10){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    int a, b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0) out("Possible");
    else out("Impossible");
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var h, w, n int
	fmt.Scan(&h, &w, &n)
	b := make([]int, 0)
	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		for j := 0; j < a; j++ {
			b = append(b, i+1)
		}
	}

	idx := 0
	c := make([][]int, h)
	for i := 0; i < h; i++ {
		c[i] = make([]int, w)
		for j := 0; j < w; j++ {
			x := j
			if i%2 == 1 {
				x = w - j - 1
			}
			c[i][x] = b[idx]
			idx++
		}
	}

	for _, r := range c {
		fmt.Println(strings.Trim(fmt.Sprint(r), "[]"))
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
typedef long long ll;
typedef pair <int,ll> pii;


int main(void)
{
  int a,b;
  cin >> a >> b;
  if((a*b) % 2 ==0)
    {
      cout << "Even" << endl;
      return 0;
    }
  else
    {
      cout << "Odd" << endl;
      return 0;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif




int main()
{
    fastio;
    
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b;
    return 0;
}


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

int main(){
	int x;
	cin>>x;
	bool t;
	vector <int> pri;
	for(int i=2;i<x;i++){
		t=true;
		for(int j=0;j<pri.size();j++){
			if(i%pri[j]==0){
				t=false;
				break;
			}
		}
		if(t){
			pri.push_back(i);
		}
	}
	for(int i=x;i<x*2;i++){
		t=true;
		for(int j=0;j<pri.size();j++){
			if(i%pri[j]==0){
				t=false;
				break;
			}
		}
		if(t){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int d; cin>>d;
	string ans="Christmas"s;
	for(int i=d;i<25;++i){
		ans+=" Eve"s;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

const int N = 110;
const int MOD = 1e9+7;

inline int add(int a, int b) { return (a+b)%MOD; }
inline int mul(int a, int b) { return (a*1ll*b)%MOD; }
inline int subt(int a, int b) { a = (a-b)%MOD; return a < 0 ? a+MOD : a; }

int n, H[N];

int pw(int b)
{
    int a = 2, ans = 1;
    while (b) {
        if (b&1) ans = mul(ans, a);
        a = mul(a, a);
        b >>= 1;
    }
    return ans;
}

pii solve(int l, int r, int dh)
{
    int mn = MOD;
    for (int i = l; i <= r; ++i)
        mn = min(mn, H[i]);
    int all = 1, sw = 2;
    for (int i = l; i <= r; ) {
        if (H[i] == mn) {
            all = mul(all, 2);
            ++i;
        } else {
            int j = i;
            while (j <= r && H[j] > mn) ++j;
            pii ret = solve(i, j-1, mn);
            all = mul(all, add( mul(2, ret.second), ret.first ));
            sw = mul(sw, ret.second);
            i = j;
        }
    }
    int nsw = subt(all, sw);
    sw = mul(sw, pw(mn-dh-1));
    return pii(nsw, sw);
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &H[i]);
    pii ans = solve(0, n-1, 0);
    printf("%d\n", add(ans.first, ans.second));

    return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, k = LI()
    N = 10**9+7
    ans = 0
    start = sum([i for i in range(0,k-1)])
    goal = sum([i for i in range(n,n-k+1,-1)])

    for i, j in zip(range(k-1,n+1), range(n-k+1,-1,-1)):
        start += i
        goal  += j
        cnt = (goal-start+1)%N
        ans += cnt
        ans %= N

    print(ans)
main()

Measured memory_bytes: 17604
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000007;
ll INF=1e18;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}



void solve()
{
     ll n,m,k;
     cin>>n>>m>>k;
     vector<ll> a(n+1),b(m+1);
     set<pll> st;
     ll i,j;
     for(i=1;i<=k;i++)
     {
          ll x,y;
          cin>>x>>y;
          a[x]+=1;
          b[y]+=1;
          st.insert({x,y});
     }
     ll ans =0;
     ll mc=0;
     vector<ll> midx;
     for(i=1;i<=m;i++)
     {
          if(b[i]>mc)
          {
               mc=b[i];
               midx.clear();
               midx.pb(i);
          }
          else if(b[i]==mc)
          {
               midx.pb(i);
          }
     }
     for(i=1;i<=n;i++)
     {
          ll cnt = a[i]+mc;
          bool  f=false;
          for(auto it:midx)
          {
               if(st.find({i,it})==st.end())
               {
                    f=true;
                    break;
               }
          }
          if(!f)
               cnt-=1;
          ans=max(ans,cnt);
     }
     cout<<ans;
}

     
     


int main()
{
    ios;
    ll t;
//    cin>>t;
   t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 30820
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <stdio.h>
#define ll              long long
#define fr(i,j,p)       for(ll i=j; i<p ;i++)
#define frr(i,j,p)      for(int i=j; i>=p ;i--)
#define PI              3.14159265358979323846
#define print(m)        std::cout << std::fixed << std::setprecision(11) << m <<endl;
#define mkp             make_pair
#define pb              push_back
#define M1              32
#define lbindex(a,x)    (int)(lower_bound(a.begin(), a.end(),x)-a.begin());
#define upindex(a,x)    (int)(upper_bound(a.begin(), a.end(),x)-a.begin());
#define all(a)          (a).begin(),(a).end()
#define mem(b,a,n)      memset(b,a,sizeof(b[0])*n);
#define meme(b,a,n,m)   memset(b,a,sizeof(b[0][0])*n*m);
#define ff              first
#define ss              second
#define endl            '\n'

using namespace std;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;

ll mdd=998244353;
ll md=1000000007;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a;  cin>>a;
    cout<<(int)(a+a*a+a*a*a)<<endl;
    return 0;
}


Measured memory_bytes: 3608
#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 INF 1145141919
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#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> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<edge> edges;
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int a[10];
bool ans;
void solve(int i, int l, int r)
{
	if (i == 10) ans = true;
	if (l < a[i]) return solve(i + 1, a[i], r);
	if (r < a[i]) return solve(i + 1, l, a[i]);
}

int main()
{
	int n;
	cin >> n;
	REP(x, n)
	{
		ans = false;
		REP(i, 10) cin >> a[i];
		solve(0, 0, 0);
		cout << (ans ? "YES" : "NO") << endl;
	}
	return 0;
}

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

const int INF = 1e9;

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

  long long t_ans, a_ans;
  t_ans = t[0];
  a_ans = a[0];
  for (int i=1; i<n; i++) {
    if (t_ans * a[i] == a_ans * t[i]) {
      continue;
    }
    long long x = (t_ans - 1)/ t[i] + 1;
    long long y = (a_ans - 1)/ a[i] + 1;

    t_ans += max(x, y) * t[i] - t_ans;
    a_ans += max(x, y) * a[i] - a_ans;
  }
  cout<<t_ans + a_ans<<endl;
}

Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

string s ;
int n ;

pair < int , int > get ( char c ) {
	int mn = 2e9 , ind = 0 , ps = 0 ;
	pair < int , int > ret ( -1 , -1 ) ; 
	for ( int i = 0 ; i < n ; i++ ) {
		ps += ( s [ i ] == c ? 1 : -1 ) ;
		if ( ps > 0 && i >= 1 ) {
			ret . first = 0 ;
			ret . second = i ;
			return ret ;
		}
		if ( mn != 2e9 && mn < ps && i - ind >= 2 ) {
			ret . first = ind + 1 ; 
			ret . second = i ; 
			return ret ; 
		}
		if ( smin ( mn , ps ) )
			ind = i ; 
	}
	return ret ; 
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s ;
	n = ( int ) s . size ( ) ;
	for ( char c = 'a' ; c <= 'z' ; c++ ) {
		pair < int , int > ans = get ( c ) ;
		if ( ans . first != -1 ) { 
			cout << ++ans . first << ' ' << ++ans . second << '\n' ;
			return 0 ; 
		}
	}
	cout << -1 << ' ' << -1 << '\n' ; 
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> ii;
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    int cnt=0;
    f(i,n)
    {
        cin>>v[i];
    }
    int k,x;
    cin>>k>>x;
    vector<int> a;
    f(i,n)
    {
        a.pb((v[i]^x)-v[i]);
        if(a.back()>=0)
        {
            cnt++;
        }
    }
    sort(all(a),greater<int>());
    if(cnt>=k)
    {
        int i=0;
        ll sum=0;
        while(i<n&&a[i]>=0)
        {
            sum=sum+a[i];
            i++;
        }
        if(cnt%k&&cnt%2)
        {
            if(i>=0)
            {
                if(abs(v[i+1])<abs(v[i]))
                {
                    sum=sum-a[i+1];
                }
                else
                {
                    sum=sum+a[i];
                }
                sum=accumulate(all(v),sum);
                cout<<sum<<endl;
            }
            else
            {
                sum=sum-a[i+1];
                sum=accumulate(all(v),sum);
                cout<<sum<<endl;
            }
        }
        else
        {
            sum=accumulate(all(v),sum);
            cout<<sum<<endl;
        }
    }
    else
    {
        
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    //let's fuck dp
    ll n,x;
    cin>>n>>x;
    vector<ll> v(n);
    int cnt=1;
    ll sum=0;
    f(i,n)
    {
        cin>>v[i];
        sum=sum+v[i];
        if(sum<=x)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

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

    for(int i = k; i < n; i++){
        if(a[i] > a[i-k]){
            cout << "Yes"<< endl;
        } else{
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int H,W,A,B;cin>>H>>W>>A>>B;
	rep(i,0,H){
        rep(j,0,W){
		    if(i<B){
			    if(j<A) cout<<0;
			    else cout<<1;
		    }else{
			    if(j<A) cout<<1;
			    else cout<<0;
		    }
        }cout<<endl;
	}
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int ans;
string s,cmp="CODEFESTIVAL2016";
int main(){
	cin>>s;
	int l=s.size();
	for(int i=0;i<l;i++)
		if(s[i]!=cmp[i])ans++;
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
  int n, i, j;
  string s;
  int p;
  pair<pair<string, int>, int> a[100];

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s >> p;
    p *= -1;
    a[i] = make_pair(make_pair(s, p), i+1);
  }
  sort(a, a+n);
  for (i = 0; i < n; i++)
    cout << a[i].second<< endl;
}


Measured memory_bytes: 256
import bisect
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
timea=[0]
timeb=[0]
time=0
ans=0
for i in range(N):
    time+=A[i]
    if time>K:
        break
    timea.append(time)
time=0
for i in range(M):
    time+=B[i]
    if time>K:
        break
    timeb.append(time)
for i in range(len(timea)):
    b=K-timea[i]
    if b<0:
        break
    num=bisect.bisect_right(timeb,b)
    num+=i-1
    ans=max(ans,num)
if ans==10**10:
    print(0)
else:
    print(ans)

Measured memory_bytes: 40548
# -*- coding: utf-8 -*-


def main():
    """Function."""
    s = str(input())

    max_len = 0
    for i in range((len(s)-1)//2):
        if s[:i+1] * 2 == s[:(i+1)*2]:
            max_len = (i + 1) * 2

    print(max_len)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define int long long 

using namespace std;
const int MAXN = 100005;
typedef long long LL;

inline int rd(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)) {f=ch=='-'?-1:1;ch=getchar();}
	while(isdigit(ch))  {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}

struct Data{
	int diff,id;
}data[MAXN];

int n,m,a[MAXN];
int fa[MAXN],ans[MAXN];
int now[MAXN<<1],num,sum[MAXN];
bool vis[MAXN];
LL k; 

int get(int x){
	if(vis[x]) return 0;
	now[++num]=x;
	vis[x]=1;
	return get(fa[x])+1;
}

signed main(){
//	freopen("data.txt","r",stdin);
//	freopen("wrong.txt","w",stdout);
	n=rd();
	for(register int i=1;i<=n;i++) a[i]=rd();
	for(register int i=1;i<=n;i++)
		data[i].diff=a[i]-a[i-1],data[i].id=i;
	m=rd();scanf("%lld",&k);
	for(register int i=1;i<=m;i++){
		int x=rd();
		swap(data[x],data[x+1]);
	}
	for(register int i=1;i<=n;i++)	{
		if(data[i].id==i) continue;
		fa[i]=data[i].id;
	}
	for(register int i=1;i<=n;i++){
		if(data[i].id==i) {
			ans[i]=data[i].diff;
			continue;
		}
		if(vis[i]) continue;
		int siz=get(i);
		for(register int j=1;j<=siz;j++) now[j+siz]=now[j];
		LL to=(k-1ll)%(LL)siz;
		for(register int j=1;j<=siz;j++) 
			ans[now[j]]=data[now[j+to]].diff;
		num=0;
	}
//	for(register int i=1;i<=n;i++) cout<<ans[i]<<" ";cout<<endl;
	for(register int i=1;i<=n;i++)
		sum[i]=ans[i]+sum[i-1],printf("%lld.0\n",sum[i]);
	return 0; 
}

Measured memory_bytes: 7808
# coding: utf-8

H, N = (int(x) for x in input().split())

a = [0 for x in range(N)]
b = [0 for x in range(N)]
for i in range(N):
	a[i], b[i] = (int(x) for x in input().split())

inf = 10000000000
max_d = H + max(a)
dp = [[inf for x in range(max_d)] for x in range(N)]

dp[0][0] = 0

for i in range(N):
	for j in range(max_d):
		if i >= 1:
			dp[i][j] = min(dp[i][j], dp[i-1][j])
		if j - a[i] >= 0:
			dp[i][j] = min(dp[i][j], dp[i][j-a[i]] + b[i])

# for i in range(N):
# 	for j in range(max_d):
# 		if dp[i][j] == inf:
# 			print(" inf", end="")
# 		else:
# 			print("{0:>4}".format(str(dp[i][j])), end="")
# 	print("")

min_m = inf
for i in range(N):
	for j in range(max_d):
		if j >= H:
			min_m = min(min_m, dp[i][j])

print(min_m)

Measured memory_bytes: 134280
#include<stdio.h>
int main(){
	int a,b,c,i;
	while(scanf("%d %d",&a,&b)!=EOF){
		if(a==0&&b==0){break;}
	c=a+b;
	for(i=0;c>0;i++){
		c=c/10;
	}
	printf("%d\n",i);
	}
	
	
    return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define read(n) scanf("%d",&n);
#define readll(n) scanf("%lld",&n);
#define readdb(n) scanf("%lf",&n);
#define readch(n) scanf("%c",&n);
#define readstr(n) scanf("%s",n);
#define test printf("test\n");
#define init(n , i) memset(n,i,sizeof(n));

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
bool cmp (int a , int b){
	return a>b;
}

int main(){
	char c[3];
	readstr(c);
	for(int i = 0 ; i<strlen(c) ; i ++){
		if(c[i] == '1') putchar('9');
		else if(c[i] == '9') putchar('1');
		else putchar(c[i]); 
	}
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 return 0; 
}












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

int main(){
    int h,w;
    for (;;) {
        scanf("%d %d",&h,&w);
        if (h==0) break;
        for (int i=0;i<h;i++) {
            for (int j=0;j<w;j++) printf("%c",((i%2+j%2)%2==1)?'.':'#');
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

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

    vector<ll> c(n);
    vector<vector<ll>> a(n, vector<ll>(m));
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }

    bool success = false;
    ll min_cost = 1e15;
    for (int buy_flag = 1; buy_flag <= (1 << n)- 1; buy_flag++)
    {
        vector<ll> u(n);
        ll cost = 0;
        for (int i = 0; i < n; i++)
        {
            if (buy_flag & (1 << i))
            {
                cost += c[i];
                for (int j = 0; j < m; j++)
                {
                    u[j] += a[i][j];
                }
            }
        }

        bool all_u = true;
        for (int j = 0; j < m; j++)
        {
            if (u[j] < x)
            {
                all_u = false;
                break;
            }
        }
        if (all_u)
        {
            success=true;
            min_cost = min(cost, min_cost);
        }
    }

    if(success)
    {
        cout << min_cost<<endl;
    }else
    {
        cout << -1<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 3080
main = do
  li <- getLine
  let [a,b,c] = map read $ words li
  print $ compute a b c

-- 偶数があれば0
-- 全て奇数なら、小さい方ふたつの積
-- 手抜きするとオーバーフロー

compute :: Int -> Int -> Int -> Int
compute a b c
  | even a || even b || even c = 0
  | True = x * y
  where
    x = minimum [a,b,c]
    z = maximum [a,b,c]
    y = sum [a,b,c] - z - x


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

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

int X[3];
int K;
int A[3][1111];

signed main(){
	rep(i,3)cin>>X[i];
	cin>>K;
	rep(i,3){
		rep(j,X[i])cin>>A[i][j];
		sort(A[i],A[i]+X[i]);
		reverse(A[i],A[i]+X[i]);
	}

	set<vint>mem;
	mem.emplace(3);
	priority_queue<pair<int,vint>>que;
	que.emplace(A[0][0]+A[1][0]+A[2][0],vint(3));
	rep(i,K){
		int sum;
		vint idx;
		tie(sum,idx)=que.top();
		que.pop();
		cout<<sum<<endl;
		rep(j,3){
			if(idx[j]+1==X[j])continue;
			vint u=idx;
			u[j]++;
			if(mem.find(u)!=mem.end())continue;
			int nex=0;
			rep(k,3)nex+=A[k][u[k]];
			mem.insert(u);
			que.emplace(nex,u);
		}
	}
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        long D = sc.nextLong();
        long[] X = new long[N];
        long[] Y = new long[N];
        for(int i=0; i<N; i++){
            X[i] = sc.nextLong();
            Y[i] = sc.nextLong();
        }
        int res=0;
        for(int j=0; j<N; j++){
            if(Math.pow(X[j],2)+Math.pow(Y[j],2)<=Math.pow(D,2)){
                res++;
            }
        }
		System.out.println(res);
	}
}

Measured memory_bytes: 64100
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100005;
const int INF = (LL)1e9 + 5;
const LL MOD = 998244353;

vector<int> G[MAXN];
int N, M, deg[MAXN], dp[MAXN], dq[MAXN], s, t;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		deg[b]++;
	}
	
	for (int i = 1; i <= N; i++) {
		if (deg[i] == 0) {
			dq[t++] = i;
		}
	}
	
	int ans = 0;
	while (s != t) {
		int v = dq[s++];
		for (int to : G[v]) {
			dp[to] = max(dp[to], dp[v] + 1);
			deg[to]--;
			if (deg[to] == 0) {
				dq[t++] = to;
			}
		}
		ans = max(ans, dp[v]);
	}
	
	cout << ans << "\n";
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll t,n,m,ans=0;
    char str[200005];
    cin>>str;
    n = strlen(str);
    bool flag = false;
    for(int i=0;i<n;i++){
        if(str[i]=='P')
            flag=true;
        else if(str[i]=='D'){
            if(flag)
                ans++;
            flag=false;
            ans++;
        }
        else if(flag){
            flag=false;
            ans+=2;
            str[i]='D';
        }
        else
            str[i]='D';
    }
    cout<<str<<'\n';
    return 0;
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define CL(a,b) memset(a,b,sizeof a)
#define pb push_back
#define fi first
#define sc second
#define pi pair<int,int>
#define pii pair<int,pair<int,int>>
int a[10],b[10],c[10];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)
        c[i]=i;
    int x=0,y=0,t=0;
    do
    {
        t++;
        int  f1=0,f2=0;
        for(int i=1;i<=n;i++)
            if(c[i]!=a[i])
            f1=1;
        for(int i=1;i<=n;i++)
            if(c[i]!=b[i])
            f2=1;
        if(!f1) x=t;
        if(!f2) y=t;
    }while(next_permutation(c+1,c+n+1));
    printf("%d",abs(x-y));
    return 0;
}


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

int main () {
  int A, B, C;
  cin >> A >> B >> C;
  int count = 0;
  while (A%2 == 0 && B%2 == 0 && C%2 == 0) {
    count++;
    int a = A, b = B, c = C;
    A = b/2+c/2;
    B = a/2+c/2;
    C = a/2+b/2;
    if (A == B && B == C) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int H, W;
    while (true) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
 
#define N 200003
 
long  divisors(long x) {
    long limit = x;
    long numberOfDivisors = 0;
 
    if (x == 1) return 1;
 
    for (long i = 1; i < limit; ++i) {
        if (x % i == 0) {
            limit = x / i;
            if (limit != i) {
                numberOfDivisors++;
            }
            numberOfDivisors++;
        }
        if(numberOfDivisors>=4)
        {
            break;
        }
    }
 
    return numberOfDivisors;
}
 bool isPrime(long n)
{
   
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (long i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
#define max_a 100001
bool visit[max_a]={false};
vector<long> a[max_a];
long sum=0;
long cost[max_a];
void dfs(long node)
{
    visit[node]=true;
    
    for(int i=0;i<(int)a[node].size();i++)
    {
        if(visit[a[node][i]]==false)
        {
            sum+=cost[a[node][i]];
            dfs(a[node][i]);
            
        }
    }
    
}
void SieveOfEratosthenes(int n)
{
   
    bool prime[n+1];
    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])
          cout << p << " ";
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    lli a,b,c;
    cin>>a>>b>>c;
    if(a==b)
    {
      cout<<c;
    }
    else if(a==c)
    {
      cout<<b;
    }
    else {
      cout<<a;
    }
    return 0;
}
 

Measured memory_bytes: 2560