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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef pair<ll,ll> pll;
#define MP make_pair<ll>

int main(){
  ll n,r,l;
  cin >> n >> r >> l;
  ll nowtime = 0;
  ll times[n]; REP(i,n)times[i]=0;
  ll score[n]; REP(i,n)score[i]=0;
  set<pll> ranking; REP(i,n)ranking.insert(MP(score[i],i));
  set<pll>::iterator iter;
  REP(i,r){
    ll d,t,x;
    cin >> d >> t >> x;
    times[ranking.rbegin()->second] += (t-nowtime);
    nowtime = t;
    d = n-d;

    pll nw = MP(score[d],d);
    iter = ranking.find(nw);
    ranking.erase(iter);
    score[d] += x;
    nw = MP(score[d],d);
    ranking.insert(nw);
  }
  times[ranking.rbegin()->second] += (l-nowtime);
  ll id = 0;
  ll mx = times[0];
  REPR(i,n){
    if(times[i]>mx){
      mx = times[i];
      id = i;
    }
  }
  cout << (n-id) << endl;
  return 0;
}

Measured memory_bytes: 9004
from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x = ni()

print(0 if x==1 else 1)

Measured memory_bytes: 68128
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,aa[110000],cnt=0;
double d;
string s,ss;
signed main()
{
	cin>>a;
	cout<<a*(a-1)/2;
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  if ((b-a)%2==0) printf("Alice\n");
  else printf("Borys\n");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define see(x) cerr<<#x<<"="<<x<<endl;
using namespace std;
typedef long long ll;
const ll mod= 998244353;
ll fast(ll x,ll n) {ll ans=1;for(;n;n>>=1,x=x*x%mod) if(n&1) ans=ans*x%mod; return ans;}
const int N=1e6+100;

ll n,k,ans;
struct node {
    int len;char s[200];
};
int main() {
    queue<node>q;
    for(int i=1;i<=9;i++) {
        node x;
        x.len=1;
        x.s[1]=i+'0';
        q.push(x);
    }
    ll k;cin>>k;
    k--;
    node x;
    while(k--) {
        //see(k);
        node u=q.front();q.pop();
        for(int i=-1;i<=1;i++) if(!(u.s[u.len]=='9'&&i==1)&&!(u.s[u.len]=='0'&&i==-1) ) {
           x=u;
           x.s[++x.len]=u.s[u.len]+i;
           q.push(x);
        }
    }
    x=q.front();
    for(int i=1;i<=x.len;i++) printf("%c",x.s[i]);
}


Measured memory_bytes: 41052
def gausu(x):
    if x%2==0:
        return int(x/2)
    if x%2==1:
        return int((x-1)/2)
h=int(input())
i=0
while h!=1:
    h=gausu(h)
    i=i+1
#print(i)
answer=2**(i+1)-1
print(answer)

Measured memory_bytes: 3060
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
unique_a = {a[0] % m: 1}
for i in range(1, n):
    a[i] += a[i - 1]
    a[i] %= m
    if a[i] in unique_a:
        unique_a[a[i]] += 1
    else:
        unique_a[a[i]] = 1
count = 0
if 0 in unique_a:
    count += unique_a[0]
for k in unique_a:
    count += unique_a[k] * (unique_a[k] - 1) // 2
print(count)

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  
  if(abs(x-a) < abs(x-b)) cout << 'A' << endl;
  else cout << 'B' << endl;
  
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(R: int):
    if R < 1200:
        return 'ABC'
    elif R < 2800:
        return 'ARC'
    return 'AGC'


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    result = solve(R)
    print(result)

if __name__ == '__main__':
    main()


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

int main() {
  string S;
    cin>> S;
  if(S.at(5)=='1'){
    cout<<"TBD"<<endl;
  }
  else if(S.at(6)=='1'||S.at(6)=='2'||S.at(6)=='3'||S.at(6)=='4'){
    cout<<"Heisei"<<endl;
  }
  else{
    cout<<"TBD"<<endl;
  }
}


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

int main()
{
  string s;
  cin >> s;
  if(stoi(s.substr(0,1))+stoi(s.substr(1,1))+stoi(s.substr(2,1))+stoi(s.substr(3,1))==7)
    cout << s.substr(0,1) << '+' << s.substr(1,1) << '+' << s.substr(2,1) << '+' << s.substr(3,1) << "=7" << endl;
  else if(stoi(s.substr(0,1))+stoi(s.substr(1,1))+stoi(s.substr(2,1))-stoi(s.substr(3,1))==7)
    cout << s.substr(0,1) << '+' << s.substr(1,1) << '+' << s.substr(2,1) << '-' << s.substr(3,1) << "=7" << endl;
  else if(stoi(s.substr(0,1))+stoi(s.substr(1,1))-stoi(s.substr(2,1))+stoi(s.substr(3,1))==7)
    cout << s.substr(0,1) << '+' << s.substr(1,1) << '-' << s.substr(2,1) << '+' << s.substr(3,1) << "=7" << endl;
  else if(stoi(s.substr(0,1))+stoi(s.substr(1,1))-stoi(s.substr(2,1))-stoi(s.substr(3,1))==7)
    cout << s.substr(0,1) << '+' << s.substr(1,1) << '-' << s.substr(2,1) << '-' << s.substr(3,1) << "=7" << endl;
  else if(stoi(s.substr(0,1))-stoi(s.substr(1,1))+stoi(s.substr(2,1))+stoi(s.substr(3,1))==7)
    cout << s.substr(0,1) << '-' << s.substr(1,1) << '+' << s.substr(2,1) << '+' << s.substr(3,1) << "=7" << endl;
  else if(stoi(s.substr(0,1))-stoi(s.substr(1,1))+stoi(s.substr(2,1))-stoi(s.substr(3,1))==7)
    cout << s.substr(0,1) << '-' << s.substr(1,1) << '+' << s.substr(2,1) << '-' << s.substr(3,1) << "=7" << endl;
  else if(stoi(s.substr(0,1))-stoi(s.substr(1,1))-stoi(s.substr(2,1))+stoi(s.substr(3,1))==7)
    cout << s.substr(0,1) << '-' << s.substr(1,1) << '-' << s.substr(2,1) << '+' << s.substr(3,1) << "=7" << endl;
  else if(stoi(s.substr(0,1))-stoi(s.substr(1,1))-stoi(s.substr(2,1))-stoi(s.substr(3,1))==7)
    cout << s.substr(0,1) << '-' << s.substr(1,1) << '-' << s.substr(2,1) << '-' << s.substr(3,1) << "=7" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define li long int
#define ull unsigned long long int
#define pb(k) push_back(k)
#define rep(i,n) for(int i =0;i<n;i++)
#define repk(i,k,n) for(int i =k; i<n; i++)
#define rrep(i,n) for(int i = n-1;i>=0;i--)
#define rrepk(i,n,k) for(int i = n-1; i>=k; i--)
#define f first
#define s second
#define vi vector<int>
#define vvi vector<vector<int>>
#define tc int t;cin>>t;while(t--)
using namespace std;

void optimize()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(k,n) for(auto i =k; i<n; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();

int main(){
    IOS
    ll x; 
    cin>>x;
    if(x<5) cout<<"0";
    else if(x<500){
        ll y = x/5;
        cout<<y*5;
    }
    else{
        ll k = x , c1 =0, c2 = 0;
        k = x/500;
        c1 = x%500;
        c2 = c1/5;
        cout<<(k*1000)+(c2*5);
    }
    
    return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        //strline
        String strline = sc.nextLine();
        //str[]
        String[] str = strline.split("");
        //n
        String line = sc.nextLine();
        int n = Integer.parseInt(line);
        //n回繰り返し
        for(int i = 0; i < n; i++) {
            String line1 = sc.nextLine();
            String[] line1sp = line1.split(" ");
            String order = line1sp[0];
            int a = Integer.parseInt(line1sp[1]);
            int b = Integer.parseInt(line1sp[2]);
            String p;
            
            if(order.equals("print")) {
                for(int j = a; j <= b; j++) {
                    System.out.print(str[j]);
                    if(j == b) {
                        System.out.println("");
                    }
                }
            }
        
            if(order.equals("reverse")) {
                String[] dainyu = new String[b-a+1];
                for(int j = 0; j <= b-a; j++) {
                    dainyu[j] = str[b-j];
                }
                for(int j = 0; j <= b-a; j++) {
                    str[a+j] = dainyu[j];
                }
            }
            
            if(order.equals("replace")) {
                p = line1sp[3];
                String[] psp = p.split("");
                for(int j = a; j <= b; j++) {
                    str[j] = psp[j-a];
                }
            }
        }
    }
}



Measured memory_bytes: 32532
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int d, n;
    cin >> d >> n;
    int m = (n==100?101:n);
    cout << (int)pow(100, d)*m << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = [list(map(int, input().split())) for i in range(2)]

dp = [[0]*(n+1) for _ in range(3)]

for i in range(1, 3):
    for j in range(1, n+1):
        now = a[i-1][j-1]
        dp[i][j] = max(dp[i-1][j], dp[i][j-1])+now

# print(dp)
print(dp[-1][-1])


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int x, long long int y){
 long long int tmp;
 long long int r;
 if(x > y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = y % x;
  while(r!=0){
    y = x;
    x = r;
    r = y % x;
  }
  return x;
}
int main(){
    long long int a,b,k;
    cin >> a >> b >> k;
    long long int ans;
    ans=gcd(a,b);
    int count=0;
    for(long long int i=ans;i>0;i--){
        if(ans%i==0)count++;
        if(count==k){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static decimal result;
static Hashtable ht=new Hashtable();
static StringBuilder sb = new StringBuilder();
static int N,M,K;
static long[,] table;
    static void Main()
    {
Read4();
for(int i=0;i<N;i++){
result+=K+i;
}
      if(K>0){result-=K;}
      if(K+N<1){result-=K+N-1;}
      Console.WriteLine(result.ToString());

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {

 
    }


}

Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S,T;

signed main(){
	int A,B;
	cin>>A>>B;
	S=to_string(A);
	T=to_string(B);
	string C,D;
	REP(i,B){
		C+=S;
	}
	REP(i,A){
		D+=T;
	}
	if(C<D){
		cout<<C<<endl;
	}
	else{
		cout<<D<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import math

S = list(input())
RL = []
c = 1
for i in range(len(S)-1):
    if S[i+1] == S[i]:
        c += 1
        if i == len(S)-2:
            RL.append(c)
    else:
        RL.append(c)
        c = 1
        if i == len(S)-2:
            RL.append(1)

#print(RL)

RLs =[]

som = 0
for i in range(len(RL)):
    som += RL[i]
    RLs.append(som)

#print(RLs)

p = [0]*len(S)

for i in range(len(RL)):
    fo = math.ceil(RL[i]/2)
    la = RL[i]//2
    if RL[i]%2 == 1:
        if i%2 == 0:
            p[RLs[i//2*2]-1] += fo
            p[RLs[i//2*2]] += la
        else:
            p[RLs[i//2*2]-1] += la
            p[RLs[i//2*2]] += fo
    else:
        if i%2 == 0:
            p[RLs[i//2*2]-1] += la
            p[RLs[i//2*2]] += fo
        else:
            p[RLs[i//2*2]-1] += fo
            p[RLs[i//2*2]] += la

#print(p)

ans = " ".join(map(str,p))
print(ans)

Measured memory_bytes: 61836
S = list(input())
T = list(input())

i = len(S) - 1
ti = len(T) - 1
match = 0
ms = len(S) - 1
flag = False
while 0 <= i:
    if S[i] == T[ti] or S[i] == '?':
        if ms == -1:
            ms = i
        match += 1
        ti -= 1
        i -= 1
    else:
        if match > 0:
            match = 0
            ti = len(T) - 1
            i = ms - 1
            ms = -1
        else:
            ms = -1
            match = 0
            ti = len(T) - 1
            i -= 1
    if match == len(T):
        k = 0
        i += 1
        for j in range(i, i + len(T)):
            S[j] = T[k]
            k += 1
        flag = True
        break

# print(S)
# print(T)

if flag == True:
    for i in range(len(S)):
        if S[i] == '?':
            S[i] = 'a'
    print(''.join(S))
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define _GLIBCXX_DEBUG
const int MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  bool can = true;
  for (int i=0; i<N-1; i++) {
    if (A[i]==0&&A[i]==A[i+1]&&N%2!=0) {
      can = false;
      break;
    }
    else if (i<N-2&&A[i]==A[i+1]&&A[i+1]==A[i+2]) {
      can = false;
      break;
    }
  }
  if (can) {
    ll ans=1LL, num_same=0LL; // 同じ要素(2つ1組)の数
    for (int i=0; i<N-1; i++) {
      if (A[i]==A[i+1]) num_same++;
    }
    for (int i=0; i<num_same; i++) {
      ans *= 2LL;
      ans %= MOD;
    }
    cout << ans << endl;
  }
  else cout << 0 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b==c)
	{
		cout<<"Yes";
	}
	else
	{
		if(a+c==b)
		{
			cout<<"Yes";
		}
		else
		{
			if(b+c==a)
			{
				cout<<"Yes";
			}
			else
			{
				cout<<"No";
			}
		}
	}
	cout<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    std::string s; std::cin >> s;
    if (s == "ABC") std::cout << "ARC" << "\n";
    else std::cout << "ABC" << "\n";
    return 0;
}


Measured memory_bytes: 3624
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    
    ans = 0
    for k in range(10**6):
        k += 1
        if N%k==0:
            i = N//k-1
            if k < i:
                ans += i
                
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
import java.io.IOException;
	import java.util.ArrayList;
	import java.util.HashMap;
	import java.util.Scanner;
	import java.util.Stack;
	
	public class Main {
		public static class pair implements Comparable<pair> {
			int id;
			int ans;
	
			pair(int x, int y) {
	
				id = x;
				ans = y;
	
			}
	
			public pair() {
	
			}
	
			public int compareTo(pair o) {
				// TODO Auto-generated method stub
	
				return this.id - o.id;
			}
		}
	
	//	static int mod = (int) 998244353.;
		static int mod = (int) 1e9 + 7;
		static ArrayList<Integer> gr[];
		static int[][] ar;
		static Scanner sc = new Scanner(System.in);
		static int pri[] = new int[(int) 1e6 + 5];
		static StringBuilder out = new StringBuilder();
	
		 static int dp[];
	
		 static int []c;
		public static void main(String[] args) throws IOException {
			int t = 1;// sc.nextInt();
	
			while (t-- > 0) {
			int n=sc.nextInt();
			int m=sc.nextInt();
			int k=sc.nextInt();
			c=new int[n];
			ar=new int [n][m];
			dp=new int [m];
			
			
			for(int i=0;i<n;i++) {
				c[i]=sc.nextInt();
				
				for(int j=0;j<m;j++) {
					ar[i][j]=sc.nextInt();
					dp[j]=k;
				}
			}
			solve(n-1,0);
			if(ans!=Integer.MAX_VALUE)
			System.out.println(ans);
			else System.out.println(-1);
			
			}
	
			
			
			System.out.println(out);
		}
		static int ans=Integer.MAX_VALUE;
		static void solve(int id,int sum) {
			if(id<0) {
				boolean f=true;;
				for(int i=0;i<ar[0].length;i++) {
				    if(dp[i]>0)return;
				}
				ans=Math.min(ans, sum);
				return;
				
			}
			for(int i=0;i<ar[0].length;i++) {
				dp[i]-=ar[id][i];
			}
			
			  solve(id-1,sum+c[id]);
			  for(int i=0;i<ar[0].length;i++) {
					dp[i]+=ar[id][i];
				}
			  solve(id-1,sum);
			
		}
	}

Measured memory_bytes: 43560
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	int flag=0;
	cin >> a >>b >>c;
	int t1,t2,t3;
	while(a%2==0&&b%2==0&&c%2==0) {
		if(a==b&&b==c) {
			cout <<"-1" ;
			return 0;
		}
		t1=a/2;t2=b/2;t3=c/2;
		a=t2+t3;
		b=t1+t3;
		c=t1+t2;
		flag++;
		//cout <<flag<<" "<<a<<" "<<b<<" "<<c<<" "<<endl;
	}
	cout <<flag;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<vector<double> > x(n, vector<double>(n));
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                cin >> x[i][j];
            }
        }

        vector<double> y(n, 1.0);
        while(--m > 0){
            vector<double> z(n, 0.0);
            for(int i=0; i<n; ++i){
                for(int j=0; j<n; ++j){
                    z[i] = max(z[i], y[j] * x[j][i]);
                }
            }
            y = z;
        }

        double ret = *max_element(y.begin(), y.end());
        printf("%.2f\n", ret);
    }
}

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

import sys
from collections import deque

sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

N=INT()
nodes=[[] for i in range(N)]
for i in range(N):
    l=LIST()
    u=l[0]
    l=l[2:]
    for v in l:
        nodes[u-1].append(v-1)
    nodes[u-1].sort()

que=deque()
que.append((0, 0))
costs=[-1]*N
while len(que):
    cost,node=que.popleft()
    if costs[node]==-1:
        costs[node]=cost
        for v in nodes[node]:
            que.append((cost+1, v))

for i in range(N):
    print(i+1, costs[i])



Measured memory_bytes: 6056
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main() {
  

  string s;
  cin >> s;

  if(s == "ABC")
  cout << "ARC" << endl;
  else
  {
    cout << "ABC" << endl;
  }
  

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repx(i,x,n) for(int i=x; i<(int)(n);i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";

int main() {
    int n;
    cin>>n;
    vin a(n),b(n),c(n);
    rep(i,n) cin>>a[i]>>b[i]>>c[i];
    vector<vector<int>> dp(n, vector<int>(3,1001001001));
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    rep(i,n-1){
        dp[i+1][0]=max(dp[i][1]+a[i+1],dp[i][2]+a[i+1]);
        dp[i+1][1]=max(dp[i][0]+b[i+1],dp[i][2]+b[i+1]);
        dp[i+1][2]=max(dp[i][1]+c[i+1],dp[i][0]+c[i+1]);
    }
    //cout<<dp[n-1][0]<<" "<<dp[n-1][1]<<" "<<dp[n-1][2]<<endl;
    sort(dp[n-1]);
    cout<<dp[n-1][2]<<endl;
}


Measured memory_bytes: 9772
#if 1

#include <bits/stdc++.h>
using namespace std;
int l,r;
int n,m;
pair <int,int> a[100005];

int main()
{
    scanf("%d %d", &n, &m);
    r = n+1;
    for(int i = 1;i <= m;i++)
    {
        scanf("%d %d", &a[i].first, &a[i].second);
        l = max(l,a[i].first);
        r = min(r,a[i].second);
    }
    printf("%d",max(r-l+1,0));
}

#endif // 1++

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

int n,k;
vector<int> ng;
vector<int> ps;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		int a; scanf("%d",&a);
		if(a==0){
			k--;
			continue;
		}
		if(a<0) ng.push_back(a*-1);
		else ps.push_back(a);
	}
	if(k==0){
		printf("%d\n", 0);
		return 0;
	}
	n=(int)ng.size()+(int)ps.size();
	sort(ng.begin(),ng.end());
	int us=0;
	int rs=1e9;
	for(int i=0;i<(int)ng.size();i++){
		us++;
		if(us>k) break;
		if(us==k){
			rs=min(rs,ng[i]);
		}
		else{
			int nd=k-us;
			if((int)ps.size()>=nd) rs=min(rs,ng[i]*2+ps[nd-1]);
		}
	}
	us=0;
	for(int i=0;i<(int)ps.size();i++){
		us++;
		if(us>k) break;
		if(us==k){
			rs=min(rs,ps[i]);
		}
		else{
			int nd=k-us;
			if((int)ng.size()>=nd) rs=min(rs,ps[i]*2+ng[nd-1]);
		}
	}
	printf("%d\n", rs);
}


Measured memory_bytes: 1020
r,c = gets.split.map(&:to_i)
row_array =[[]]
sum_column = Array.new(c,0)
sum_all = 0
r.times do |i|
  sum_row = 0 
  row_array[i] = gets.split.map(&:to_i)
  count = 0
  row_array[i].each{|a| sum_row += a; print("#{a} "); sum_column[count] += a; count += 1 }
  puts sum_row
  sum_all += sum_row
end
sum_column.each{|a| print("#{a} ")}
puts sum_all



Measured memory_bytes: 6864
package main

import (
    "fmt"
    "math"
)

func main(){
    var a, b int
    fmt.Scan(&a, &b)

    var A, B int
    
    for i:=0; i<b; i++ {
        A += a * int(math.Pow10(i))
    }
    for i:=0; i<a; i++ {
        B += b * int(math.Pow10(i))
    }

    if A>=B {
        fmt.Println(A)
    } else {
        fmt.Println(B)
    }
    
}


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

struct edge{
    int u, v, c;
    bool operator<(const edge &e)const{
        return c < e.c;
    }
};

struct UnionFind{
    vector<int> par, sz;
    UnionFind(int n){
        par.resize(n);
        sz.resize(n, 1);
        for(int i = 0; i < n; i++) par[i] = i;
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int n, m;
vector<edge> es; 

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    es.resize(m);
    rep(i, 0, m){
        cin >> es[i].u >> es[i].v >> es[i].c;
        es[i].u--; es[i].v--;
    }
    vector<bool> use(m);
    UnionFind uf(n);
    sort(es.begin(), es.end());
    int sum = 0;
    rep(i, 0, m){
        if(!uf.same(es[i].u, es[i].v)){
            uf.unite(es[i].u, es[i].v);
            sum += es[i].c;
            use[i] = true;
        }
    }
    rep(i, 0, m){
        if(use[i] == false) continue;
        UnionFind uf2(n);
        int tmpSum = 0;
        rep(j, 0, m){
            if(j == i) continue;
            if(!uf2.same(es[j].u, es[j].v)){
                uf2.unite(es[j].u, es[j].v);
                tmpSum += es[j].c;
            }
        }
        if(sum == tmpSum){
            use[i] = false;
        }
    }
    int ans = 0, cost = 0;
    rep(i, 0, m){
        if(use[i]){
            ans++;
            cost += es[i].c;
        }
    }
    cout << ans << ' ' << cost << endl;
}


Measured memory_bytes: 3704
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String S = scan.next();

		switch(S) {
		case "SUN":
			System.out.println(7);
			break;
		case "MON":
			System.out.println(6);
			break;
		case "TUE":
			System.out.println(5);
			break;
		case "WED":
			System.out.println(4);
			break;
		case "THU":
			System.out.println(3);
			break;
		case "FRI":
			System.out.println(2);
			break;
		case "SAT":
			System.out.println(1);
			break;
		}

		scan.close();

	}

}


Measured memory_bytes: 21204
n = int(input())
r = []

for i in range(n):
    r.append(int(input()))
#
# max = r[1]-r[0]
#
# for j in range(n):
#     for k in range(j+1,n):
#         if k > j and r[k]-r[j] > max:
#             max = r[k]-r[j]
#
# print(max)

minv = r[0]
maxv = r[1]-r[0]
for j in range(1,n):
    maxv = max(maxv,r[j]-minv)
    minv = min(minv,r[j])
print(maxv)


Measured memory_bytes: 13588
# coding: utf-8
# Your code here!

H,W=map(int, input().split())
S=["."+input()+"." for i in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
flag = 0
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            if S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                flag = 1
print("Yes" if flag==0 else "No")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.time.chrono.MinguoChronology;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      int swap = 0;
      while (true) {        
        int x = in.nextInt();
        int y = in.nextInt();
        if (x == 0 && y == 0) break; 
        if (x > y) {
          swap = x;
          x = y;
          y = swap;
        }
        out.println(x+" "+y);        
      }
    }
  }

  public static void main(String[] args) throws IOException {
//    ??????
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

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

int main() {
	int n;
	unsigned long long int k;
	cin >> n;
	cin >> k;

	vector<int> a(n);
	vector<bool> visited(n, false);

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

	int destination = 1;
	vector<int> history;

	while (true) {
		if (visited[destination - 1]) {
			break;
		}
		history.push_back(destination);
		visited[destination - 1] = true;
		destination = a[destination - 1];
	}

	int pos;
	for (int i = 0; i < history.size(); i++) {
		if (history[i] == destination) {
			pos = i;
			break;
		}
	}
	int length = history.size() - pos;

	if (k >= pos + 1) {
		k -= pos;
		k = k % length;
		cout << history[k + pos] << endl;
	} else {
		cout << history[k] << endl;
	}

	return 0;
}


Measured memory_bytes: 5032
#include<stdio.h>
int main()
{
	int a,b,max;
	scanf("%d%d",&a,&b);
	max=a+b;
	if(a-b>max)
	    max=a-b;
	if((a*b)>max)
	    max=a*b;
	printf("%d",max);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[] x= new int[3];
		int temp =0;
		Scanner scanner = new Scanner(System.in);
		for(int i=0; i<10; i++){
		     temp =scanner.nextInt();
		    if(temp>x[0]){
		    	 x[2]=x[1];
		    	 x[1]=x[0];
		    	 x[0]=temp;
		     }else if(temp>x[1]){
		    	 x[2]=x[1];
		    	 x[1]=temp;
		     }else if(temp>x[2]){
		    	 x[2]=temp;
		     }
		}
		scanner.close();
		for(int i =0; i<3; i++){
        System.out.println(x[i]);
		}
	}

}

Measured memory_bytes: 17332
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    cout << ceil(N/2) << endl;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in [0]*n]
d = {}
for i in s:
    if i not in d: d[i] = 1
    else: d[i] += 1
num = max(d.values())
ans = [i for i in d if d[i]==num]
print('\n'.join(sorted(ans)))

Measured memory_bytes: 35716
#include <stdio.h>
#define INRANGE(a,b,c) ((a<=b)&&(b<=c)?(1):(0))
int h,w;
int map[100][100];
int count;
void walk(int x,int y){
	map[x][y]=2;
	if(INRANGE(0,x-1,h-1)&&map[x-1][y]==1) walk(x-1,y);
	if(INRANGE(0,x+1,h-1)<h&&map[x+1][y]==1) walk(x+1,y);
	if(INRANGE(0,y-1,w-1)&&map[x][y-1]==1) walk(x,y-1);
	if(INRANGE(0,y+1,w-1)&&map[x][y+1]==1) walk(x,y+1);
	if(INRANGE(0,x-1,h-1)&&INRANGE(0,y-1,w-1)&&map[x-1][y-1]==1) walk(x-1,y-1);
	if(INRANGE(0,x+1,h-1)&&INRANGE(0,y-1,w-1)&&map[x+1][y-1]==1) walk(x+1,y-1);
	if(INRANGE(0,x+1,h-1)&&INRANGE(0,y+1,w-1)&&map[x+1][y+1]==1) walk(x+1,y+1);
	if(INRANGE(0,x-1,h-1)&&INRANGE(0,y+1,w-1)&&map[x-1][y+1]==1) walk(x-1,y+1);

}
int main(void){
	int i,j;

	while(scanf("%d%d",&w,&h),w||h){
		count=0;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				scanf("%d",&map[i][j]);
			}
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(map[i][j]==1){
					walk(i,j);
					count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF ((ll)1<<31)-1
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int gcd(int a,int b){
	if(!a)return b;
	return gcd(b%a,a);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int n,h,w,a,b;
signed main(){
	cin>>n>>h>>w;
	int ans=0;
	rep(i,n){
		cin>>a>>b;
		if(h<=a&&w<=b)ans++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

// ref: https://codeforces.com/blog/entry/77148?#comment-619728
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ld pi = acos(-1);
const ll inf = 1e18, M = 1e9 + 7;
const int N = 1;

void solve()
{
	int n;
	cin >> n;
	vector<pair<int,int>> pve, nve;

	string s;
	int cnt, len;
	pair<int, int> p;
	for (int i = 0; i<n; ++i)
	{
		cin >> s;
		len = s.size();

		cnt = 0;
		for (int j = 0; j<len; ++j)
		{
			if (s[j] == '(')
				++cnt;
			else if (cnt)
				--cnt;
		}
		p.second = cnt;        // unbalanced "("

		cnt = 0;
		for (int j = len - 1; j >= 0; --j)
		{
			if (s[j] == ')')
				++cnt;
			else if (cnt)
				--cnt;
		}
		p.first = cnt;        // unbalanced ")"

		if (p.second - p.first >= 0)
			pve.push_back(p);
		else
			nve.push_back(p);
	}

	sort(pve.begin(),pve.end(), [](pair<int,int> a, pair<int,int> b){return a.first<b.first; });
	sort(nve.begin(),nve.end(), [](pair<int,int> a, pair<int,int> b){return a.second>b.second; });

	vector<pair<int,int>> a;
	a.reserve(n);
	a.insert(end(a), pve.begin(),pve.end());
	a.insert(end(a), nve.begin(),nve.end());

	int sum = 0;
	for (auto c : a)
	{
		sum -= c.first;

		if (sum<0)
		{
			cout << "No";
			return;
		}
		sum += c.second;
	}

	if (sum)
		cout << "No";
	else
		cout << "Yes";
}

int main()
{
	fast();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t = 1;
	//cin>>t;
	for (int z = 1; z <= t; ++z)
	{
		solve();
		//cout<<"\n";
	}

	return 0;
}



Measured memory_bytes: 18820
import java.util.Scanner;

public class Main {

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

			int count = 0;
			for (char c : s.toCharArray()) {
				if (count % 2 == 0) {
					if (c == 'L') {
						System.out.println("No");
						return;
					}
				} else {
					if (c == 'R') {
						System.out.println("No");
						return;
					}

				}

				count++;
			}
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
using Graph=vector<vector<int>>;
ll INF=1000000000000000001;
ll mod=1000000007;

int i,j,k;

int main(){
    int n,x,y;cin>>n>>x>>y;
    vector<int> ans(n,0);
    x--;y--;

    Graph G(n);

    G[x].push_back(y);
    G[y].push_back(x);

    for(i=0;i<n-1;i++){//Graph作成
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    


    queue<int> que;
    for(i=0;i<n;i++){
        que.push(i);//iからの距離を見る
        
        vector<bool> visit(n,false);
        vector<int> parent(n,0);
        vector<int> distance(n,0);//iからどれだけ離れているのか

        visit[i]=true;

        while(que.size()!=0){
            int now=que.front();//今見ている頂点
            que.pop();
            
            for(auto next:G[now]){//今見ている頂点回りの点
                if(!visit[next]){
                    que.push(next);
                    //まだ訪れていない点ならそこをqueにいれる
                    parent[next]=now;//nextの親
                    visit[next]=true;
                    
                    distance[next]=distance[now]+1;//子のiからの距離=親の距離+1
                    ans[distance[next]]++;
                }
            }
            
        }    
    }

    for(i=1;i<n;i++){//重複して数えているので2で割る
        cout<<ans[i]/2<<endl;
    }

    return 0;
}

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

vector<set<int> > edges;

int dp(int v, int p){
	int sum = 0;
	bool seen = false;
	for(int w : edges[v]){
		if(w == p) continue;
		int x = dp(w, v);
		if(x == 0){
			if(seen){
				x++;
			} else {
				seen = true;
			}
		}
		sum += x;
	}
	return sum;
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	edges.resize(n);
	for(int i = 0; i < n-1; i++){
		int u, v;
		cin >> u >> v;
		edges[u].insert(v);
		edges[v].insert(u);
	}
	int nl = 0;
	for(int i = 0; i < n; i++){
		if(edges[i].size() == 1) nl++;
	}
	vector<bool> done(n, false);
	for(int i = 0; i < n; i++){
		int v = i;
		if(edges[v].size() != 1) continue;
		while(true){
			int w = *edges[v].begin();
			if(done[w]) break;
			if(edges[w].size() == 2){
				edges[v].erase(w);
				edges[w].erase(v);
				v = w;				
			} else {
				done[w] = true;
				nl--;
			}
		}
	}
	nl = max(nl, 1);
	cout << nl << '\n';
}

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

using namespace std;

int main(int argc, char ** argv){
	int a,b;
	cin>>a>>b;
	if( a == 1 && b == 1 ){
		cout<<"Draw\n";
		return 0;
	}else if( a == 1 && b != 1){
		cout<<"Alice\n";
		return 0;
	}else if( a != 1 && b == 1 ){
		cout<<"Bob\n";
		return 0;
	}
	if(a > b) cout<<"Alice\n";
	else if(b > a) cout<<"Bob\n";
	else cout<<"Draw\n";
	return 0;
}

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

struct LowestCommonAncestor {
    size_t n;
    size_t size() const { return n; }
    enum { B = 1000 };
    vector<int> color, parent, depth, topDepth, goUp, visited;
    vector<vector<int>> g;
    LowestCommonAncestor(size_t n_) : n(n_), g(n) {}
    void addEdge(int u, int v){
        g[u].push_back(v); g[v].push_back(u);
    }
    void decomp(int root){
        parent.assign(n, -1); depth.assign(n, 0);
        topDepth.assign(n, 0); goUp.assign(n, -1); visited.assign(n, false);
        vector<int> tord;
        vector<int> q(n+1); int l = 0, r = 0;
        q[r++] = root;
        while(l != r){
            int v = q[l++]; visited[v] = true;
            tord.push_back(v);
            for(int c : g[v]){
                if(visited[c]) continue;
                parent[c] = v; depth[c] = depth[v] + 1; q[r++] = c;
            }
        }
        swap(color, visited); // ?????¢????????±??????
        color.assign(n, 0);
        int c = 0;
        for(int u : tord){
            if(color[u]) continue;
            c++;
            l = 0, r = 0;
            q[r++] = u;
            for(int i = 0; i < B && l != r; i++){
                int v = q[l++];
                color[v] = c; goUp[v] = parent[u]; topDepth[v] = depth[u];
                for(int c : g[v]) if(!color[c]) q[r++] = c;
            }
        }
    }
    int solve(int u, int v){
        while(color[u] != color[v]){
            if(topDepth[u] > topDepth[v]) u = goUp[u];
            else v = goUp[v];
        }
        while(u != v){
            if(depth[u] > depth[v]) u = parent[u];
            else v = parent[v];
        }
        return u;
    }
};

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

int main(){
    int n;
    cin >> n;
    LowestCommonAncestor g(n);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int c;
            cin >> c;
            g.addEdge(i,c);
        }
    }
    g.decomp(0);
    int q;
    cin >> q;
    rep(i,q){
        int u,v;
        cin >> u >> v;
        cout << g.solve(u,v) << endl;
    }
}

Measured memory_bytes: 10028
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, k = list(map(int, readline().split()))
    am = min(a, k)
    a -= am
    k -= am
    bm = min(b, k)
    b -= bm
    print(a, b)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include<stdio.h>

int GCD(int x,int y)
{
	if(y==0)
		return x;
	return GCD(y,x%y);
}

int LCM(int x,int y)
{
	for(int i=1;i<=y;i++)
	{
		if((x*i)%y==0)
			return x*i;
	}
	return x*y;
}

int main()
{
	int x,y;
	while(scanf("%d%d",&x,&y)!=EOF)
	{
		if(x>y)
		{
			int temp=y;
			y=x;
			x=temp;
		}
		printf("%d %d\n",GCD(x,y),LCM(x,y));
	}
}

Measured memory_bytes: 0
N, M = map(int, input().split())
A = list(map(int, input().split()))

from fractions import gcd
def two(n):
    ans = 0
    while n%2==0:
        n //= 2
        ans += 1
    return ans

def multi_lcm(A):
    ans = A[0]
    for a in A:
        ans *= a//gcd(ans,a)
    return ans

def solve(N,M,A):
    ans = 0
    num_two = len(set(map(two,A)))
    if num_two != 1:
        return 0
    l = multi_lcm(A)
    ans = (M+l//2)//l
    return ans
print(solve(N,M,A))

Measured memory_bytes: 14356
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n,k; cin >> n >> k;
  vector<bool> snk(n, false);
  rep(i, k) {
    int d; cin >> d;
    rep(j, d) {
      int tmp; cin >> tmp;
      --tmp;
      snk[tmp] = true;
    }
  }
  int cnt = 0;
  rep(i, n) {
    if(!snk[i]) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    int c[4]={};
    cin>>a>>b;
    c[a]=1;
    c[b]=1;
    for(int i=1;i<=3;i++){
	if(c[i]==0) cout<<i<<"\n";
    }
}


Measured memory_bytes: 256