akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

long long mypow(long long k, long long n) {
	long long temp = 1;

	k = k % DIV;
	while (n) {
		if (n % 2) temp = temp * k % DIV;
		k = k * k % DIV;
		n = n / 2;
	}
	return temp % DIV;
}

ll mul(ll a, ll b) {
	return ((a % DIV) * (b % DIV)) % DIV;
}

int main() {
	ll N, A, B, K; cin >> N >> A >> B >> K;
	int M = 3e5;
	vector<ll> f(M + 1), invf(M + 1);
	f[0] = 1, invf[0] = 1;
	for (int i = 1; i <= M; i++) {
		f[i] = f[i - 1] * i;
		f[i] %= DIV;
		invf[i] = mypow(f[i], DIV - 2);
		//if(i<=10)
		//cout << "i=" << i << " f[i]=" << f[i] << endl;
	}

	ll ans = 0;
	for (ll i = 0; i <= N; i++) {
		if (K - i * A >= (ll)0 && (K - i * A) % B == (ll)0) {
			ll j = (K - i * A) / B;
			if (j > N)continue;
			ll temp = mul(f[N], invf[i]);
			temp = mul(temp, invf[N - i]);
			temp = mul(temp, f[N]);
			temp = mul(temp, invf[j]);
			temp = mul(temp, invf[N - j]);
			//ans += (((f[N] * invf[i]) % DIV * ((invf[N - i] * f[N])) % DIV) % DIV * (f[j] * f[N - j]) % DIV) % DIV;
			ans += temp;
			ans %= DIV;
			//cout << "i=" << i <<" j="<<j<<" ans="<<ans<< endl;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 7984
n = input()
A = map(int, raw_input().split())

def func(plus):
    res = su = 0
    for i in xrange(n):
        su += A[i]
        if plus:
            if su <= 0:
                res += (1-su)
                su = 1
        else:
            if su >= 0:
                res += (su+1)
                su = -1
        plus ^= 1
    return res
print min(func(0), func(1))


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

int main() {
  string a,b;
  cin>>a>>b;
  if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
x, y = map(int, input().split())
mod = 10 ** 9 +7
f = [1]

for i in range(10**6):
  f.append(f[-1] * (i+1) % mod)
  
def nCr(n, r):
  return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

if (x+y) % 3 != 0 or (x+y) // 3 < abs(x-y):
  print(0)
  exit()
  
n = (x+y)//3
r = n // 2 - abs(x-y) // 2
print(nCr(n, r))

Measured memory_bytes: 42668
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
#define G(A,B) G[A][B]
#define Fp(A,B,C,D) for(A=B;A<=C;A+=D)
#define Fm(A,B,C,D) for(A=B;A>=C;A-=D)
#define Clear(A) memset(A,0,sizeof(A))
using namespace std;
const LL Max=1e3+5;
const LL Mod=1e9+7;
const LL Inf=1e18;
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
int main(){
	LL I,J,K;
	LL A=Read(),B=Read(),C=Read();
	if(C>=A&&C<=A+B-1){
		puts("YES");
	} else {
		puts("NO");
	}
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
const int dir[4][2]={{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
const int INF=1e9;
int n,m,k,x1,y1,x2,y2;
int main() {
	cin>>n>>m>>k>>x1>>y1>>x2>>y2;
	x1--;
	x2--;
	y1--;
	y2--;
	char mp[n][m]={};
	int dis[n][m]={};
	int i,j,ans=0;
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            cin>>mp[i][j],dis[i][j]=INF;
    queue<pair<int,int> >que;
    dis[x1][y1]=0;
    que.push(make_pair(x1,y1));
    while (!que.empty())
	{
        int x=que.front().first;
        int y=que.front().second;
        que.pop();
        for(i=0;i<4;i++)
		{
            int nx=x, ny=y;
            int nd=dis[x][y]+1;
            for(j=1; j<=k; j++)
			{
                nx+=dir[i][0];
                ny+=dir[i][1];
                if (nx<0||ny<0||nx>=n||ny>=m||mp[nx][ny]=='@'||dis[nx][ny]<nd)
                    break;
                if(dis[nx][ny]>nd)
				{
                    dis[nx][ny]=nd;
                    que.push(make_pair(nx, ny));
                }
            }
        }
    }
    ans=dis[x2][y2];
    cout<<(ans == INF ? -1 : ans);
    return 0;
}



Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<string> ret(h, string(w, '0'));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if ((i < b) ^ (j < a))
                ret[i][j] = '1';
        }
    }
    for (auto &r : ret) {
        cout << r << "\n";
    }
    return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = Long.parseLong(sc.next());
		long Y = Long.parseLong(sc.next());

		int cnt = 0;
		while(X<=Y) {
			cnt++;
			X=X*2;
		}
		System.out.println(cnt);
	}

}

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

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

using namespace std;

int main(void){
  int h, a;
  cin >> h >> a;
 
  int ans = 0;
  while(h > 0){
    h -= a;
    ans ++;
  }

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

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

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;
const int INF = 1 << 28;

int main()
{
	int dist[101][101], mincost[101];
	bool used[101];

	int n, m;
	int a, b, c;

	while(cin >> n ,n)
	{
		int total = 0;
		cin >> m;

		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < n; j++)
			{
				dist[i][j] = INF;

				if(i == j)
				{
					dist[i][j] = 0;
				}
			}
			used[i] = false;
			mincost[i] = INF;
		}
		for(int i = 0; i < m; i++)
		{
			scanf("%d%*c%d%*c%d", &a, &b, &c);
			c /= 100; c -= 1;
			dist[a][b] = c; dist[b][a] = c;
		}

		mincost[0] = 0;

		while(1)
		{
			int v = -1;
			for(int i = 0; i < n; i++)
			{
				if(!used[i] && (v == -1 || mincost[i] < mincost[v])) v = i;
			}
			if(v == -1)
			{
				break;
			}

			used[v] = true;
			total += mincost[v];

			for(int i = 0; i < n; i++)
			{
				mincost[i] = min(mincost[i], dist[v][i]);
			}
		}
	
		cout << total << endl;
	}
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

ll poll(pair<ll,ll> s,pair<ll,ll> g){
    return abs(s.first-g.first)+abs(s.second-g.second);
}

int main(){
    ll h,w,d;
    cin >> h >> w >> d;
    map<ll,pair<ll,ll>> mp;
    map<pair<int,int>,int> dp;
    map<pair<int,int>,bool> flag;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            ll a;
            cin >> a;
            mp[a] = {i,j};
        }
    }

    for(int i = d+1; i <= w*h; i++){
        dp[mp[i]] = dp[mp[i-d]]+poll(mp[i],mp[i-d]);
    }
    int q;
    cin >> q;
    vector<int> ans;
    for(int i = 0; i < q; i++){
        int l,r;
        cin >> l >> r;
        ans.push_back(dp[mp[r]]-dp[mp[l]]);
    }
    for(auto p:ans){
        cout << p << endl;
    }
}

Measured memory_bytes: 12924
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n],b[m];
  priority_queue<P,vector<P>,greater<P> > que;
  int x=0,y=0;
  rep(i,n) {
    R a[i];
    que.push(P(a[i],0));
  }
  rep(i,m){
    R b[i];
    que.push(P(b[i],1));
  }
  ll ans=0;
  while(!que.empty()) {
    P p=que.top();que.pop();
    if(p.S==0) {
      ans+=(m-y+1)*p.F;
      x++;
    } else {
      ans+=(n-x+1)*p.F;
      y++;
    }
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 5488
#include<bits/stdc++.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a*b==15)
	{
		printf("*");
	}
	else if(a+b==15)
	{
		printf("+");
	}
	else
	{
		printf("x");
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define lli unsigned long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define pint pair<int,int>
#define setit set<int>::iterator seti
#define mapit map<int,int> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)
{   int res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {   if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

int main()
{
  /*
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
*/
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t, n, g, b, i, x, j;
//   cin >> t;
    t = 1;
    lli s, w;
    for (i = 0; i < t; i++) {
        cin >> s >> w;

        cout << ceil(((w - 1) * 1.0) / (s - 1));
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int ans=1;
	for(int i=1;i<=sqrt(M);i++){
		if(M%i==0){
			if(M/i>=N)ans=max(ans,i);
			if(i>=N)ans=max(ans,M/i);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main() {
    ll n;    
    cin >> n;
    ll a[n][3];
    rep(i, n) {
        rep(j, 3) {
            cin >> a[i][j];
        }
    }

    ll dp[n+2][3];
    memset(dp, 0, sizeof(dp));
    rep(i, n) {
        rep(j, 3) {
            rep(k, 3) {
                if(j==k) continue;
                chmax(dp[i+1][j], dp[i][k] + a[i][j]);
            }
        }
    }

    ll ans = 0;
    rep(i, 3) {
        chmax(ans, dp[n][i]);
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 4992
loop do
  n, m = gets.split.map(&:to_i)
  
  break if n == 0
  
  h, ans = {}, []
  
  n.times do
    arr = gets.split.map(&:to_i)
    
    m.times do |i|
      h[i] = 0 unless h[i]
      h[i] += arr[i]
    end
  end
  
  h.sort{ |(k1, v1), (k2, v2)| v2 <=> v1 }.each do |arr|
    ans << arr[0] + 1
  end
  
  puts ans.join(" ")
end

Measured memory_bytes: 9100
using System;
         
        class Program{
        	static void Main(string[] args){
            	string[] input = Console.ReadLine().Split(' ');
              	int[] count = new int[10];
              	for(int i = 0;i < input.Length;i ++){
                	int check = int.Parse(input[i]);
                  	count[check - 1] ++;
                }
              
              	if(count[4] == 2 && count[6] == 1){
                	Console.WriteLine("YES");
                }else Console.WriteLine("NO");
            }
        }

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    vector<string> x;
    string y,z;
    int a,b;
    cin>>a>>b;
    for(int i=0;i!=a;++i){
        cin>>y;
        x.push_back(y);
    }
    sort(x.begin(),x.end());
    for(auto i:x)
        z+=i;
    cout<<z<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <stdlib.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;



int main()
{
	int N, Y;
	cin >> N >> Y;

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

			if (flag!=1) {
				if ((10000 * i + 5000 * j + 1000 * (N-i-j)) == Y) {
					cout << i << " " << j << " " << N - i - j;
					flag = 1;
				}
				
				
			}
		}

	}

	if (flag!=1) {
		cout << -1 << " " << -1 << " " << -1;
	}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		char[]s = stdIn.next().toCharArray();
		char[]t = stdIn.next().toCharArray();
		int cnt = 0;
		for(int i = 0; i < 3; i++) {
			if(s[i]==t[i]) {
				cnt++;
			}
		}
		
		System.out.println(cnt);
		
		
		
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  int P=700;
  for(int i=0;i<S.size();i++){
  	if(S.at(i)=='o'){
      P +=100;
    }
  }

  cout << P << endl;
}

Measured memory_bytes: 256
class perm():
  F = [1, 1]
  Fi = [1, 1]
  I = [0, 1]
  def __init__(self, num, mod):
    self.MOD = mod
    for i in range(2, num + 1):
      self.F.append((self.F[-1] * i) % mod)
      self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
      self.Fi.append(self.Fi[-1] * self.I[i] % mod)
  def per(self, n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return self.F[n] * (self.Fi[n - k] % self.MOD) % self.MOD

class Tree:
  C, RL = {}, {}
  R, T, N, D = None, None, None, None
  def __init__(s, num):
    s.N = num
  def setC(s, a, b):
    if a in s.C: s.C[a].append(b)
    else: s.C[a] = [b]
    if b in s.C: s.C[b].append(a)
    else: s.C[b] = [a]
  def makeRank(s, root):
    s.R = [0] * s.N
    s.R[root] = 1
    s.RL[1] = [root]
    F = [root]
    s.D = 2
    while F != []:
      Ft = []
      s.RL[s.D] = []
      for i in F:
        for j in s.C[i]:
          if s.R[j] == 0:
            s.R[j] = s.D
            Ft.append(j)
            s.RL[s.D].append(j)
      s.D += 1
      F = Ft
  def dfs(s, x):
    S = [x]
    ans = K
    while S != []:
      k = S.pop()
      n = 0
      for i in s.C[k]:
        if s.R[i] > s.R[k]:
          n += 1
          S.append(i)
      if n != 0:
        if k == x:
          if n > K - 1:
            return 0
          ans = ans * P.per(K - 1, n) % MOD
        else:
          if n > K - 2:
            return 0
          ans = ans * P.per(K - 2, n) % MOD
    return ans

N, K = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(N - 1)]
MOD = 1000000007

if N == 1:
  print(K)
  exit()
  
P = perm(K, MOD)

T = Tree(N)
for a, b in ab:
  T.setC(a - 1, b - 1)

T.makeRank(0)

print(T.dfs(0))

Measured memory_bytes: 96856
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;


ll power(int a){
    ll power_a = 1;
    for(int i=0; i<a; i++) power_a *= 10;
    return power_a;
}

int main(){
    int a, b; cin >> a >> b;
    int A, B;
    for(int i=0; i<b; i++) A += a*power(i);
    for(int i=0; i<a; i++) B += b*power(i);
    if(a<b) cout << A << endl;
    else cout << B << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
using namespace std;


//pair型のソート用：昇順
bool pairCompare(const pair<ll,ll>& firstElof, const pair<ll,ll>& secondElof)
{
	return firstElof.first < secondElof.first;
}

int main(){
	ll n, m; cin >> n >> m;
	vector<pair<ll, ll> > p(n);
	for (int i = 0; i < n; ++i) cin >> p[i].first >> p[i].second;
	sort(p.begin(), p.end(), pairCompare);
	ll now = 0;
	ll ans = 0;
	for (int i = 0; i < n; ++i){
		now+=p[i].second;
		ans += p[i].second * p[i].first;
		if (m <= now){
			ans -= (now - m)*p[i].first;
			break;
		}
	}cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
 
int main() {
  ll m,d;
  ci(m>>d);
  ll c=0;
  if(m<4||d<22)
    c=-1;
  for(i,1,m+1){
    if(c==-1)
      break;
    for(j,22,d+1){
      ll a=j/10,b=j%10;
      if(b==0||b==1)
        continue;
      if(i==a*b)
        c++;
    }
  }
    if(c==-1)
      c=0;
    co(c);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#define ll long long 
#define pb push_back
#define INF (ll)1e18
#define IINF (int)1e9 
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);   
#define MOD 1000000000 + 7
#define F first 
#define S second
#define sp << " " << 
/*rrrohan*/ 
using namespace std; 
 
/*less than or equal to -> l + r + 1*/
 
/*class dsu{
private: 
	vector <int> r,p; 
public: 
	dsu(int n){
		p.resize(n+1);
		r.resize(n+1);  
		for(int i = 0; i < n+1; i++){
			p[i] = i; 
			r[i] = 0; 
		}
	}
	int findset(int i){
		return (p[i] == i) ? i : (p[i] = findset(p[i])); 
	}
	bool issameset(int a, int b){
		return findset(a) == findset(b); 
	}
	void unionset(int i, int j){
		if(!issameset(i,j)){
			int x = findset(i), y = findset(j); 
			if(r[x] > r[y]){
				p[y]  = x; 
			}else{
				p[x] = y; 
				if(r[x] == r[y]){
					r[y]++; 
				}
			}
		}
	}
};
*/ 


int main(){
	int n; 
	cin >> n; 
	int arr[n];  
	for(int i = 0; i < n; i++){
		cin >> arr[i]; 
	}
	ll dp[n-1][2];
	for(int i = 0; i < n-1; i++){
		dp[i][0] = -INF, dp[i][1] = -INF; 
	} 
	dp[0][0] = arr[0] + arr[1], dp[0][1] = -(arr[0] + arr[1]);  
	for(int i = 1; i < n-1; i++){
		 dp[i-1][0] = dp[i-1][0] - arr[i];
		 dp[i-1][1] = dp[i-1][1] + arr[i]; 
		 ll sum = arr[i] + arr[i+1], sum2 = -arr[i] + arr[i+1]; 
		 dp[i][0] = max(dp[i][0], dp[i-1][0] + sum); 
		 dp[i][0] = max(dp[i][0], dp[i-1][1] + sum2);
		 dp[i][1] = max(dp[i][1], dp[i-1][0] - sum); 
		 dp[i][1] = max(dp[i][1], dp[i-1][1] - sum2);    
	}
	cout << max(dp[n-2][0], dp[n-2][1]); 
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
typedef pair<ll,ll> 	pll;
#define br "\n"
#define ff first
#define ss second
#define MAXIM 1000003

ll mod = 1e9 + 7;
set<pll> sx,sy;

ll checkdist(vector<pll> &temp){
    ll ans=0;
    ll xi=temp[0].ff;
    ll yi = temp[0].ss;
    rep(i,1,temp.size()){
        ans = max(ans,abs(xi-temp[i].ff) + abs(yi-temp[i].ss));
    }
    return ans;
}



void solve(){
    ll n;
    cin >> n;
    ll min1=1e9,max1=0,min2=1e9,max2=0;
    ll x,y;
    cin >> x >> y;
    min1 = x + y;
    max1 = x + y;
    min2 = x - y;
    max2 = x - y;
    rep(i,1,n){
        cin >> x >> y;
        min1 = min(x + y,min1);
        min2 = min(x - y,min2);
        max1 = max(x + y,max1);
        max2 = max(x - y,max2);

    }
    cout << max(max1 - min1,max2-min2);

}
	

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}	

Measured memory_bytes: 3612
// 2008ツアツジツアツ地ツ凝ヲツ予ツ選J : Zigzag

#include <iostream>
#include <fstream>
#include <vector>
#include <complex>
#include <queue>
#include <cstring>

using namespace std;

const double EPS = 1e-8;

typedef complex<double> P;
struct L { P p, q; L(P p, P q) : p(p), q(q) {} };

class Node{
public:
	int b, p, q, num; double len;
	Node(int b, int p, int q, int num, double len) : b(b), p(p), q(q), num(num), len(len) {}
	bool operator < (const Node &nd) const {
		return make_pair(num, len) > make_pair(nd.num, nd.len);
	}
};

double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }

P ssCrosspoint(L a, L b){
	double A = cross(a.q-a.p, b.q-b.p);
	double B = cross(a.q-a.p, a.q-b.p);
	return b.p + B/A * (b.q-b.p);
}

int main(){
	int n;
	int bit[10][10];
	int num[1024][10][10];
	double len[1024][10][10];
	while(cin >> n, n){
		memset(num, -1, sizeof(num));
		priority_queue<Node> qu;
		vector<P> vp(n);
		for(int i=0;i<n;i++){
			double x, y; cin >> x >> y;
			vp[i] = P(x, y);
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				int b = (1<<i)|(1<<j);
				for(int k=0;k<n;k++)
					if(abs(abs(vp[i]-vp[k])+abs(vp[k]-vp[j])-abs(vp[i]-vp[j])) < EPS) b |= (1<<k);
				bit[i][j] = bit[j][i] = b;
				qu.push(Node(b, i, j, 0, abs(vp[i]-vp[j])));
				qu.push(Node(b, j, i, 0, abs(vp[i]-vp[j])));
			}
		}
		pair<int, double> res;
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			if(nd.b == (1<<n)-1){
				res = make_pair(nd.num, nd.len); break;
			} 
			if(num[nd.b][nd.p][nd.q]!=-1) continue;
			num[nd.b][nd.p][nd.q] = nd.num;
			len[nd.b][nd.p][nd.q] = nd.len;
			L l = L(vp[nd.p], vp[nd.q]);
			for(int i=0;i<n;i++){
				if(nd.b&(1<<i)) continue;
				for(int j=0;j<n;j++){
					if(i==j) continue;
					if(abs(imag((l.q-l.p)/(vp[i]-vp[j]))) < EPS) continue;
					P p = ssCrosspoint(l, L(vp[i], vp[j]));
					if(dot(l.q-p, l.p-p) < -EPS || dot(vp[i]-p, vp[j]-p) < -EPS) continue;
					if(abs(p-l.q)>abs(p-l.p)||abs(p-vp[j])>abs(p-vp[i])) continue;
					qu.push(Node(nd.b|bit[i][j], j, i, nd.num+1, nd.len+abs(p-l.q)+abs(p-vp[i])));
				}
			}
		}
		printf("%d %.8lf\n", res.first, res.second);
	}
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x;
int main(){
    cin>>x;
    for(ll a=-1000;a<=1000;a++){
        for(ll b=-1000;b<=1000;b++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm> 
#include <map> 
#include <math.h>
using namespace std;



int main(){
	int e;
	
	cin >> e;
	while(e != 0){
		int minimum = 10000000;
		for(int z = 0; z * z * z <= e; z++){
			for(int y = 0; y * y <= e; y++){
				if(ceil(e - y * y - z * z * z) == floor(e - y * y - z * z * z) && e - y * y - z * z * z >= 0){
					minimum = min(minimum, e - y * y - z * z * z + y + z);
				}
			}
		}
		cout << minimum << endl;
		cin >> e;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <queue>
using namespace std;
int main()
{
    int n, que, q, t, x;
    cin >> n >> q;
    vector<queue<int>> queu(n);
    while (q--)
    {
        cin >> que;
        if (que == 0) {
            cin >> t >> x;
            queu[t].push(x);
        }
        else if (que == 1) {
            cin >> t;
            if (!queu[t].empty())
                cout << queu[t].front() << endl;
        }
        else if (que == 2) {
            cin >> t;
            if (!queu[t].empty())
                queu[t].pop();
        }
    }
}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int fun(string &s,int i,string &t)
{
	int j,f=0;
	for(j=0;j<t.size();j++)
	{
		if(t[j]!=s[j+i])
			f++;

	}
	return f;
}
/*********************************************************************/
void test(int r)
{
	string s,t;
	cin>>s>>t;
	int i,j;
	int ans=t.size();
	for(i=0;i+t.size()<=s.size();i++)
	{
		ans=min(ans,fun(s,i,t));
	}
	cout<<ans<<endl;

}
/***********************************************************************/
int main()
{
	fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
int n,m,x,y,a[101],b[101];
int main()
{
	cin>>n>>m>>x>>y;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<m;i++) cin>>b[i];
	sort(a,a+n);
	sort(b,b+m);
	int z=b[0];
	if (z>a[n-1] && z>x && z<=y) cout<<"No War";
	else cout<<"War";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println((a * 100 +b *10 +c) % 4 == 0 ? "YES" : "NO");
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map> 
using namespace std;

#define LL long long
#define MOD (1000000007)


//B
int main() {
	LL N, K;
	scanf("%lld %lld", &N, &K);

	LL result = 0;

	for (LL i = 0; i < N; i++) {
		LL h;
		scanf("%lld", &h);

		if (h >= K) {
			result++;
		}
	}

	printf("%lld\n", result);

	return 0;
}

//A
/*
int main() {
	LL N;

	scanf("%lld", &N);

	double result = (double)((N + 1) / 2) / (double)N;

	printf("%0.9f\n", result);

	return 0;
}
*/

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int ax[100];

int main()
{
    int N,M,i,a,b;
    scanf("%d%d",&N,&M);
    for(i=0;i<M;i++){
        scanf("%d%d",&a,&b);
        ax[a]++;
        ax[b]++;
    }
    for(i=1;i<=N;i++){
        printf("%d\n",ax[i]);
    }
    return 0;
}


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

int main(){
    int x,y;
    cin >> x >> y;
    if (x>y) {
        cout << "a > b" << endl;
    } else if (x<y) {
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
#import bisect
#from collections import deque
import math

sys.setrecursionlimit(10**5)

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
peers = [[] for _ in range(N)]
colors = [{} for _ in range(N)]
pairs = []
for _ in range(N-1):
    a,b = list(map(int, input().split()))
    a -= 1
    b -= 1
    pairs.append([a,b])
    peers[a].append(b)
    colors[a][b] = 0


def draw(node, parent_edge_color):
    _peers = peers[node]
    if len(_peers) == 0:
        return 0
    color = 1
    max_nrof_color = 1
    for peer in _peers:
        #print(node,peer,color)
        if color == parent_edge_color:
            color +=1
        colors[node][peer] = color
        max_nrof_color = max(max_nrof_color, color, draw(peer, color))
        color += 1

    return max_nrof_color


print(draw(0,0))
for a,b in pairs:
    print(colors[a][b])


Measured memory_bytes: 95164
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int a, b;
    cin >> a >> b;
    if(b < a) {
        int tmp = b;
        b = a;
        a = tmp;
    }

    REP(i, b) cout << a;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

C = Counter(A)
even = len([c for c in C.values() if c % 2 == 0])

ans = len(set(A))
if even % 2 == 0:
    print(ans)
else:
    print(ans - 1)


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

int main() {
  string str;
  cin >> str;
  bool flg = false;
  for(int i=0; i< str.size(); i++) {
    if (str[i] == '7') {
      flg = true;
    }
  }
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }











}


Measured memory_bytes: 3620
#include<iostream>

int32_t get_num_32(void){                                                                                                 
    int32_t x;                                                                                                            
    scanf("%d",&x);                                                                                                       
    return x;                                                                                                             
}

int main(void){
    int32_t a =get_num_32();
    int32_t b =get_num_32();
    int32_t h =get_num_32();
    std::cout << (a + b) * h /2 << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;
typedef unsigned long long ull;



int main(){
    int n;
    cin >> n;
    map<int,int> m;
    rep(i,n){
        int a;
        cin >> a;
        m[a]++;
    }
    vector<ll> d(n+1,0);
    for (auto it=m.begin();it!=m.end();++it){
        d[it->second]++;
    }
    ll u=0,o=0;
    vector<ll> f(n);
    rep(i,n) o+=d[i+1];
    rep(i,n){
        u+=(i+1)*d[i+1];
        o-=d[i+1];
        f[i]=(u+o*(i+1))/(i+1);
        // cout << f[i] << endl;
    }
    int ans=n;
    rep(i,n){
        while(true){
            if (ans==0) break;
            if (i+1<=f[ans-1]) break;
            ans--;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 18944
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
cnt = 0
for a in C:
    if C[a] >=2:
        if C[a]%2==0:
            C[a] = 2
            cnt += 1
        else:
            C[a] = 1
if cnt%2==0:
    card = len(C)
else:
    card = len(C)-1
print(card)

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

int main()
{
  int n,d,x,ans=0;
  cin>>n>>d>>x;
  int a[n];
  for(int i=1;i<=n;i++)
  {
      cin>>a[i];
  }

  for(int i=1;i<=n;i++)
  {
      ans++;
      for(int j=1; ;j++)
      {
          if((a[i]*j)+1<=d) ans++;
          //cout<<a[i]<<" "<<j<<" "<<ans<<" a\n";
          if(d<(a[i]*j+1)) break;
      }
  }
  cout<<ans+x;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[1000005];
ll n,k;
ll sol(ll x){
	ll len=0;
	for(ll i=1;i<=n;i++){
		if(len%2==0 && a[i]<=x)len++;
		else if(len%2)len++;
	}
	if(len>=k)return 1;
	len=0;
	for(ll i=1;i<=n;i++){
		if(len%2 && a[i]<=x)len++;
		else if(len%2==0) len++;
	}
	return(len>=k);
}
int main(){
	
    ll n,k;
    cin>>n>>k;
    for(ll i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    ll ans=0;
    for(ll i=1;i<=k;i++)ans+=a[i];
    cout<<ans;
    
}
    


	
	
    



Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var cin = GetIntArray();
            var ans = YESNO(cin[1] -cin[0] == cin[2]-cin[1]);
            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  vector<int> ans(n);
  int ans_sum = 0;
  rep(i, k){
    int m;
    cin >> m;
    rep(j, m){
      int a;
      cin >> a;
      ans[a-1] = 1;
    }
  }
  rep(i, n){
    if(ans[i] == 0) ans_sum++;
  }
  cout << ans_sum << endl;
}


Measured memory_bytes: 3588
from itertools import combinations
N = int(input())
L = sorted(map(int, input().split()))
c = 0
for a in combinations(L, 3):
  if a[0]==a[1] or a[0]==a[2] or a[1]==a[2]:
    continue
  if a[0]+a[1]>a[2]:
    c += 1
print(c)

Measured memory_bytes: 9168
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 3*max_- sum(ls)
    print(int(cnt/2))


else:
    ls.remove(max_)
    if ls[0]%2 == ls[1]%2:
        cnt = 2*max_- sum(ls) -2
        print(int(cnt/2 +1))    
    else:
        cnt = 2*max_- sum(ls) + 1
        print(int(cnt/2 +1))

    

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

void end(int n = -1)
{
	cout << n << "\n";
	exit(0);
}
int n, m;
vector<int> G[N];
int dp[N];
bool vis[N];

void dfs(int node)
{
	vis[node] = 1;
	for (int i : G[node])
	{
		if (!vis[i])
		{
			dfs(i);
		}
		dp[node] = max(dp[node], dp[i] + 1);
	}
}

int32_t main()
{
	AB_BHI_NI_DEGI
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		G[u].pb(v);
	}
	for (int i = 1; i <= n; i++)
	{
		if (!vis[i])
			dfs(i);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = max(ans, dp[i]);
	cout << ans << "\n";
	return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  
  vector<string> vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  string S;
  for(int i = 0; i < N; i++) {
    S += vec.at(i);
  }
  cout << S << endl;
    
}
    

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var t string
	var s = bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	if s.Scan() {
		t = s.Text()
	}

	a, err := strconv.Atoi(t)
	if err != nil {
		return
	}

	if s.Scan() {
		t = s.Text()
	}

	b, err := strconv.Atoi(t)
	if err != nil {
		return
	}

	fmt.Println(a * b)
}


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

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

    int sum = 0;    
    for (int i = 0; i < (1 << 3); i++) {
        for (int j = 0; j < 3; j++) {
            if (i & (1 << j)) sum += s.at(3 - j) - '0';
            else sum -= s.at(3 - j) - '0';
        }
        sum += s.at(0) - '0';
        if (sum == 7) {
            string ans = "";
            ans += s.at(0);
            for (int j = 2; j >= 0; j--) {
                if (i & (1 << j)) ans += '+';
                else ans += '-';
                ans += s.at(3 - j);
            }
            ans += "=7";
            cout << ans << endl;
            break;
        }
        sum = 0;
    }
}


Measured memory_bytes: 3632
slp = [map(int,raw_input().split()) for _ in range(int(raw_input()))]
maxp = [0]*400

for s,l,p in slp:
    for i in range(s,l+1): maxp[i] = max(maxp[i],p)

dp = maxp[:]
for i in range(399):
    for l in range(1,400-i):
        dp[i+l] = max(dp[i+l],dp[i]+maxp[l])

ans = []
for roop in range(int(raw_input())):
    w = int(raw_input())
    if dp[w] == 0:
        print -1
        break
    ans.append(dp[w])
else:
    for a in ans: print a

Measured memory_bytes: 4280
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(void){
    // Your code here!
    long long int a,b,x;
    cin >> x >> a >> b;
    if(abs(x-a) > abs(x-b)) cout << 'B' << endl;
    else cout << 'A' << endl;
    
    
    
    
    
    return 0;
}


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

int main() {

	int N, K;
	int ans = 0;
	std::cin >> N >> K;

	std::vector<int> L(N);
	   
	for (int i = 0; i < N; i++)std::cin >> L[i];

	std::sort(L.begin(), L.end(),std::greater<int>());

	for (int i = 0; i < K; i++)ans += L[i];

	std::cout << ans << std::endl;

}

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

int main() {
  
  int n, x, t;
  cin >> n >> x >> t;
  int p = 0;
  
  for (int i = 1; i < 2000; i++){
  	int y = x * i;
    if(n <= y){
      p = i;
      break;
    }
  }
  
  int ans = p * t;
  cout << ans << endl;
  
}




Measured memory_bytes: 3636
#include <cstdio>
#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;

const double EPS = 1.0e-10;
const int MOD = 100000007;

void combination(int n, vector<vector<int> >& comb)
{
    comb.assign(n+1, vector<int>(n+1, 0));
    for(int i=0; i<=n; ++i){
        comb[i][0] = 1;
        for(int j=1; j<=i; ++j){
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
            comb[i][j] %= MOD;
        }
    }
}

vector<double> destroy(1001, 0.0); // 破壊されるまでの時間の期待値

double solve(vector<double>& p, vector<double>& q, int& pattern)
{
    int n = p.size();

    double t = 0.0;
    for(int i=0; i<n; ++i)
        t += destroy[q[i]*1000+EPS];

    double ret = DBL_MAX;
    pattern = 0;
    for(int i=0; i<n; ++i){
        double t2 = t - destroy[q[i]*1000+EPS] + destroy[p[i]*1000+EPS];
        if(t2 < ret - EPS){
            ret = t2;
            pattern = 1;
        }else if(t2 < ret + EPS){
            ++ pattern;
        }
    }

    return ret;
}

int main()
{
    for(int i=1; i<=1000; ++i){
        double p = i / 1000.0;
        double a = 1.0;
        for(int j=1; ; ++j){
            if(a * p * j < EPS / 1000)
                break;
            destroy[i] += a * p * j;
            a *= 1.0 - p;
        }
    }

    vector<vector<int> > comb;
    combination(100, comb);

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

        vector<double> p(n), q(n);
        vector<int> id(n);
        for(int i=0; i<n; ++i)
            cin >> p[i] >> id[i] >> q[i];

        vector<bool> check(n, false);
        double ret = 0.0;
        long long pattern = 1;
        int tmp = n;
        for(int i=0; i<n; ++i){
            if(check[i])
                continue;

            int j = i;
            vector<double> p2, q2;
            while(!check[j]){
                p2.push_back(p[j]);
                q2.push_back(q[j]);
                check[j] = true;
                j = id[j];
            }

            int pattern2;
            ret += solve(p2, q2, pattern2);
            pattern *= pattern2;
            pattern %= MOD;

            pattern *= comb[tmp][p2.size()];
            pattern %= MOD;
            tmp -= p2.size();
        }

        printf("%.10f %d\n", ret, (int)pattern);
    }
}

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

vector<vector<int>> G;
vector<int> counter;
vector<int> res;
vector<bool> visited;

void dfs(const vector<vector<int>> &G, int v, int p){
    visited[v] = true;
    res[v] = res[p] + counter[v];
    for(auto& nv : G[v]){
        if(visited[nv]) continue;
        dfs(G, nv, v);
    }
}

int main() {
    int N, Q; cin >> N >> Q;
    G.resize(N);
    counter.resize(N);
    res.resize(N);
    visited.resize(N);

    
    for(int i=0; i<N-1; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for(int i=0; i<Q; i++){
        int p, x; cin >> p >> x;
        p--;
        counter[p] += x;
    }

    dfs(G, 0, 0);
    for(auto& v : res) cout << v << ' ';
    cout << endl;
}


Measured memory_bytes: 24320
n = int(input())
A = [0] + list(map(int,input().split()))
B = [0]*(n+1)
m = 0
for i in range(n,0,-1):
    cnt = 0
    for j in range(i,n+1,i):
        cnt += B[j]
    if cnt%2==A[i]:
        continue
    else:
        B[i] =1
        m += 1
print(m)
for i in range(len(B)):
    if B[i]==1:
        print(i)


Measured memory_bytes: 90884