akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	cin >> n >> k;
	int nums[n];
	for(int i = 0;i < n;++i)
		cin >> nums[i];
	int dp[k+1];
	dp[0] = 0;
	for(int i = 1;i <= k;++i)
	{
		dp[i] = 0;
		for(int j = 0;j < n;++j)
		{
			if(i - nums[j] >= 0 && dp[i-nums[j]] == 0)
				dp[i] = 1;
		}
	}
	cout << (dp[k] ? "First":"Second") << endl;
	return 0;
}

Measured memory_bytes: 640
from collections import *

# def solve():


# for _ in range(int(input())):
#     solve()
n = int(input())
l = []
for i in range(n):
    l.append(input())

print("AC x",l.count("AC"))
print("WA x",l.count("WA"))
print("TLE x",l.count("TLE"))
print("RE x",l.count("RE"))


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

int main(){
  
  int X,Y,counter;

  while(1){

  cin >>X>>Y;

  if(X == 0 && Y == 0)break;

  counter=0;

  if(X < Y)swap(X,Y);

  while(Y != 0){
    X=X%Y;
    swap(X,Y);
    counter++;
  }
  
  cout <<X<<" "<<counter<<endl;
  
  } 

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, ans;
  cin >> a >> b >> c >> d;
  ans = a * c;
  if(b * d > ans) ans = b * d;
  if(a * d> ans) ans = a * d;
  if(b * c > ans) ans = b * c;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3516
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, h[N], dp[N];

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> h[i];
  dp[2] = abs(h[2]-h[1]);
  for (int i = 3; i <= n; ++i)
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  cout<<dp[n]<<"\n";
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#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>
#include <fstream>
#include <complex>
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<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//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 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())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const double INF = 1e12;

int N;
int a[10003];
int pari(int pos){
	int l=pos-1,r=pos+1;
	int sum1=0,sum2=0,temp=1;
	int nowc=(a[l]!=0)?a[l]:a[r];
	
	while(1){
		if(a[l]!=nowc&&a[r]!=nowc||a[l]==0&&a[r]==0){
			if(temp>=4){
				sum1+=temp;
				temp=0;
				nowc=max(a[l],a[r]);
				if(nowc==0)break;
			}else{
				break;
			}
		}
		if(a[l]==nowc){
			temp++;
			l--;
		}
		if(a[r]==nowc){
			temp++;
			r++;
		}
	}
	temp=1;l=pos-1,r=pos+1;
	nowc=(a[r]!=0)?a[r]:a[l];
	while(1){
		//cout<<temp<<" "<<nowc<<endl;
		if(a[l]!=nowc&&a[r]!=nowc||a[l]==0&&a[r]==0){
			if(temp>=4){
				sum2+=temp;
				temp=0;
				nowc=max(a[l],a[r]);
				if(nowc==0)break;
			}else{
				break;
			}
		}
		if(a[l]==nowc){
			temp++;
			l--;
		}
		if(a[r]==nowc){
			temp++;
			r++;
		}
	}
	return max(sum1,sum2);
}

int main(){
	
	while(cin>>N){
		if(N==0)break;
		CLR(a);
		REP(i,N)cin>>a[i+1];
		int maxi=0;
		FOR(i,1,N+1){
			maxi=max(pari(i),maxi);
		}
		cout<<N-maxi<<endl;
	}
	return 0;
}

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

using namespace std;

int gcd(int p, int q) {
    if (p % q == 0)return q;
    return gcd(q, p % q);
}

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

    long long min = n;
    long long ab1=n,ab2=n;

    long long amari;
    amari = n % k;

    if (amari * 2 <= k) {
        cout << amari;
    }
    else {
        cout << llabs(amari - k);
    }

    
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  string s,t;
  cin >> s >>t;
  int sn=s.length(),tn=t.length();
  vi sl,tl;
  REP(i,sn) {
    sl.push_back(s[i]);
  }
  REP(i,tn) {
    tl.push_back(t[i]);
  }
  sort(ALL(sl));
  sort(ALL(tl),greater<int>());
  if(sl<tl) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main() {
  int N , count , ans;
  cin >> N;
  vector<int>vec(101);
  for(int i = 0;i<N;i++){
    int d;
    cin >> d;
    vec.at(d) = 1;
  }
  
  for(int i = 0 ; i<101;i++){
    ans += vec.at(i);
  }
      
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define CHAL_BC_APNE_BAAP_KO_MAT_SIKHA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define fr first
#define se second
#define MAX 10000003
int prime[MAX]; 
#define mod 1000000007
unordered_map<int, int> max_map; 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
int power(int n,int r){
	int res=1;
	while(r>0){
		if(r%2!=0)
			res=(res*n)%mod;
		n=(n*n)%mod;
		r=r/2;
	}
	return res;
}	
int lcmModuloM(vector<int> ar, int n) 
{ 
  
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            int factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    int ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.fr, it.se)) % mod; 
    } 
  
    return ans; 
} 
signed main()
{
	CHAL_BC_APNE_BAAP_KO_MAT_SIKHA;		
	int n;
	cin>>n;
	int a[n+1];
	int f=1;
	vector<int> v;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		v.pb(a[i]);
	}
	sieve();
	int ans=lcmModuloM(v,n);
	int sum=0;
	for(int i=1;i<=n;i++){
		sum=(sum+(ans*power(a[i],mod-2))%mod)%mod;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  vi l(n);
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int ans = 0;
  for(int i = 0; i < n; i++){
    int j = i+1;
    while(l[i] == l[j]) j++;
    for(; j < n; j++){
      int k = j+1;
      while(l[j] == l[k]) k++;
      for(; k < n; k++){
        if(l[i] + l[j] > l[k]) ans++;
      }
    }
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3656
#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 int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
void solve()
{
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    map<int,int> mp;
    for (int i = 0; i < n;i++){
        cin >> a[i];
        sum += a[i];
        mp[a[i]]++;
    }
    int q;
    cin >> q;
    while(q--){
        int b, c;
        cin >> b >> c;
        sum -= mp[b] * b;
        sum += mp[b] * c;
       
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << endl;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 10348
#include<stdio.h>
#define TRUE 1
#define FALSE 0
int n,a[50];
int solve(int,int);
int main()
{
  int q,m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&m);
      if(solve(0,m))printf("yes\n");
      else printf("no\n");
    }
  return 0;	
}
int solve(int i,int m)
{
  if(m==0)return TRUE;
  if(i>=n) return FALSE;
  int res = solve(i+1,m)||solve(i+1,m-a[i]);
  return res;
}


Measured memory_bytes: 2108
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	ll n, p; cin >> n >> p;
	vector<pair<ll,ll>> prime;
	for (ll i = 2; i*i <= p; ++i)
	{
		if (p%i != 0)continue;
		ll cnt = 0;
		while (p%i == 0)
		{
			++cnt;
			p /= i;
		}
		prime.push_back({ i,cnt });
	}
	if (p != 1)prime.push_back({ p,1 });
	ll res = 1;
	for (auto q : prime)
	{
		while (q.second >= n)
		{
			res *= q.first;
			q.second -= n;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3556
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long double, long double>;

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

  ll n,m;
  std::cin>>n>>m;

  std::vector<ll> a(n*m+1,0),b(n*m+1,0);

  rep(i,0,n){
    ll temp;
    std::cin>>temp;
    a[temp]++;
  }
  rep(i,0,m){
    ll temp;
    std::cin>>temp;
    b[temp]++;
  }

  rep(i,1,n*m+1){
    if(a[i]>1||b[i]>1){
      std::cout<<0<<"\n";
      return 0;
    }
    a[i]+=a[i-1];
    b[i]+=b[i-1];
  }

  ll ans=1;

  for(ll i=n*m;i>0;i--){
    bool isa=(a[i]!=a[i-1]);
    bool isb=(b[i]!=b[i-1]);
    if(isa){
      if(!isb){
        ans=(ans*(m-b[i]))%MOD;
      }
    }else{
      if(isb){
        ans=(ans*(n-a[i]))%MOD;
      }else{
        ll num=(n-a[i])*(m-b[i]);
        if(num<=n*m-i){
          ans=0;
        }
        ans=(ans*(num+i-n*m))%MOD;
      }
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}




Measured memory_bytes: 15872
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String s  = sc.next();

      System.out.print(s.charAt(0));
      System.out.print(s.length()-2);
      System.out.print(s.charAt(s.length()-1));
      System.out.println();



}
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, s;
    bool truth = false;
    cin >> n >> s;
    s /= 1000;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n - i; j++)
        {
            if (i * 9 + j * 4 + n == s)
            {
                cout << i << ' ' << j << ' ' << n - i - j;
                truth = true;
                break;
            }
        }
        if (truth == true) break;
    }
    if (truth == false) cout << "-1 -1 -1";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
	double A, B, X; 
	cin >> A >> B >> X; 
	X /= A; double ans; 
	double pi = acos(-1); 
	if(X >= A * B * 0.5){
		ans = atan(2.0 * (A * B - X) / (A * A)); 
		ans *= 180.0 / pi; 
	}
	else{
		ans = atan((2.0 * X) / (B * B)); 
		ans *= 180.0 / pi; 
		ans = 90 - ans; 
	}
	cout.precision(12); 
	cout << ans << endl; 
}

Measured memory_bytes: 512
Antennas = []
for i in range(5):
    Antennas.append(input())
    
Antennas_int = [int(n) for n in Antennas]

K = int(input())

Yay_juge = 1
for j in range(5) :
    for m in range(5) :
        Antennas_juge = abs(Antennas_int[j] - Antennas_int[m])
        if Antennas_juge > K:
            Yay_juge = 0
            break

if Yay_juge == 1 :
    print('Yay!')
else:
    print(':(')

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

int main() {
  int N, A = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
  int l, r;
  cin >> l >> r;
  A += (r - l + 1);
  }
  cout << A;
}


Measured memory_bytes: 256
n = int(input())
day, x = map(int, input().split())
a = [int(input()) for _ in range(n)]


def choco(cday):
    sum = 0
    for i in range(day):
        if cday * i + 1 <= day:
           sum += 1
    return sum


csum = sum(list(map(choco, a))) + x
print(csum)


Measured memory_bytes: 2940
import java.util.Scanner;

class Solver {
    void solve(Scanner in) {
        final int N = in.nextInt();
        final int T = in.nextInt();
        int time = -T;
        int sum = 0;
        for (int i = 0; i < N; i++) {
            int timing = in.nextInt();
            sum += T - Math.max((time + T) - timing, 0);
            time = timing;
        }
        System.out.println(sum);
    }
}

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

        new Solver().solve(in);

        in.close();
    }
}

Measured memory_bytes: 64564
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, K;
ll a[1123], sum[1123];

int main() {
	cin >> N >> K;
	REP(i, N) scanf("%lld", a + i);
	
	sum[0] = 0;
	REP(i, N) sum[i + 1] = sum[i] + a[i];
	
	vector<ll> v;
	REP(i, N) {
		FOR(j, i, N) {
			// [i,j]
			v.push_back(sum[j + 1] - sum[i]);
		}
	}
	
	ll ans = 0;
	for (int k = 60; k >= 0; k--) {
		if (v.size() < K) break;
		sort(ALL(v), greater<ll>());
		
		if (v[K - 1] >> k & 1) {
			ans |= 1ll<<k;
			vector<ll> nextv;
			REP(i, v.size()) if (v[i] >= 1ll<<k) nextv.push_back(v[i] - (1ll<<k));
			v = nextv;
		}
		else {
			REP(i, v.size()) if (v[i] >= 1ll<<k) v[i] -= 1ll<<k;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s;
  cin >> s;
  if(s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,i;
  double sum;
  sum=0;
  cin>>N;
  string S[N];
  double x[N];
  for(i=0;i<N;i++){
  cin>>x[i]>>S[i];
    if(S[i]=="JPY"){
    sum=sum+x[i];
    }else{
    sum=sum+x[i]*380000;
    }
  }
 cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val first = sc.nextLine
    val second = sc.nextLine
    if (first(0) == second(2) & first(1) == second(1) & first(2) == second(0)) println("YES")
    else println("NO")
  }
}


Measured memory_bytes: 25648
w, h, n = map(int, input().split())
max_x = w
min_x = 0
max_y = h
min_y = 0

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        min_x = max(x, min_x)
    elif a == 2:
        max_x = min(x, max_x)
    elif a == 3:
        min_y = max(y, min_y)
    elif a == 4:
        max_y = min(y, max_y)
print(max(max(0, (max_y - min_y)) * max(0, max_x - min_x), 0))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
int n, a[N], dep[N];
int head[N], nex[N], to[N], size;
vector<int> ord[N];
void add(int x, int y){
    to[++size] = y;
    nex[size] = head[x];
    head[x] = size;
}
void dfs(int u){
    int res = 0;
    for(int i = head[u];i;i = nex[i]){
        int v = to[i];
        dfs(v);
        ord[u].push_back(dep[v]);
    }
    sort(ord[u].begin(), ord[u].end(), greater<int>());
    int sz = ord[u].size();
    for(int i = 0;i < sz; i++){
        dep[u] = max(dep[u], i + 1 + ord[u][i]);
    }
}
int main(){
    cin>>n;
    for(int i = 2;i <= n; i++){
        scanf("%d", &a[i]);
        dep[a[i]]++;
        add(a[i], i);
    }
    dfs(1);
    cout<<dep[1]<<endl;
    return 0;
}


Measured memory_bytes: 12288
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
int A,B,C;
cin >> A >> B;
cout << (A*B)/2 << endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int x, a, b;
  cin >> x >> a >> b;
  cout << (abs(x-a) > abs(x-b) ? "B" : "A") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	lint n;
	in(n);
	lint ans=n-1;
	for(lint i=1;i*i<=n;i++)if(n%i==0)chmin(ans,i-2+(n/i));
	

	out(ans);
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
   int x[110],y[110],n,m,X,Y;
   cin>>n>>m>>X>>Y;
   bool flag=false;
   int min_y=1000,large_x=-1000;
   for(int i=1;i<=n;i++){
        cin>>x[i];
        if(x[i]>large_x)large_x=x[i];
   }
   for(int i=1;i<=m;i++){
        cin>>y[i];
        if(y[i]<min_y)min_y=y[i];
   }
  
   if(!flag){
       for(int i=X+1;i<=Y;i++){
            if(!(large_x<i&&min_y>=i))continue;
            flag=true;
            break;
        }
   }
    if(flag)cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL rou(LL a,LL d){if((a*10/d)%10<5)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}

int main(){
  LL H,W,N,i,ans=0;
  scanf("%lld%lld%lld",&H,&W,&N);

  printf("%lld\n",dup(N,MAX(H,W)));
	return 0;
}


Measured memory_bytes: 128
// https://atcoder.jp/contests/abc098/tasks/abc098_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int ma(int p, string &s)
{
  string x = s.substr(0, p),
         y = s.substr(p);
  set<char> m;

  REP(i, p)
  {
    if (y.find(x[i]) != string::npos)
      m.insert(x[i]);
  }

  return m.size();
}

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n;
  string s;

  cin >> n >> s;

  int p = 0, m = 0;

  while (++p < s.length())
  {
    m = max(m, ma(p, s));
  }

  cout << m << '\n';

  return 0;
}


Measured memory_bytes: 256
import collections


def main():
    n = int(input())
    c = list(input())
    wcnt = c.count("W")
    rcnt = c.count("R")
    if wcnt == 0 or rcnt == 0:
        print(0)
        return
    ans = c[0:rcnt].count("W")
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12068
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c;
    cin >> a>> b >>c;
    cout << c <<" "<< a <<" "<< b <<"\n";
    return 0;
}

Measured memory_bytes: 256
lines = $stdin.read
array = lines.split("\n")
S = array[0].split("")

def is_lower?(c)
  c >= 'a' && c <= 'z'
end

str = S.dup
low = str.reject{|s| s=='A' or s=='C'}.all?{|c| is_lower?(c)}

if S.first=='A' and S[2...S.length-1].count{|s| s=='C'}==1 and low
  puts "AC"
else
  puts "WA"
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	string s, t;
	cin >> s;
	cin >> t;
	int sl = s.size();
	int tl = t.size();
	int sum = 0, ans = 0;

	for (int i = 0; i < sl - tl + 1; i++) {
		sum = 0;
		for (int j = 0; j < tl; j++) {
			//printf("[%c,%c]\n", s[i + j], t[j]);
			if (s[i + j] == t[j]) {
				sum++;
			}
		}
		if (ans < sum)ans = sum;
	}

	printf("%d", tl - ans);

	return 0;
}


Measured memory_bytes: 3720
import numpy as np
H, W = map(int, input().split())
x = [list(map(str, list(input()))) for l in range(H)]

y = []
for i in range(H):
    if set(x[i]) != {"."}:
        y.append(x[i])

z = np.array(y)
zz = np.rot90(z)
zzz = zz.tolist()

ans = []
for i in range(W):
    if set(zzz[i]) != {"."}:
        ans.append(zzz[i])

a = np.array(ans)
b = np.rot90(a, -1)
c = b.tolist()

for i in range(len(c)):
    print(*c[i], sep='')

Measured memory_bytes: 27576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
#define F first
#define S second
typedef double D;
typedef complex<D> P;
typedef pair<double,int>P1;
typedef pair<int,int>P2;
typedef pair<P1,P2>P3;
int n,ans;
P p[21];
D r,qu,dp[10001][21][21],t[21][21];
int main(){
  cin>>n>>r>>qu;
  rep(i,10001)rep(j,21)rep(k,21)dp[i][j][k]=1e15;
  rep(i,n){
    D x,y;
    cin>>x>>y;
    p[i]=P(x,y);
  }
  priority_queue<P3,vector<P3>,greater<P3> >q;
  for(int i=1;i<n;i++){
    if(abs(p[0]-p[i])>r)continue;
    dp[1][0][i]=abs(p[0]-p[i]);
    q.push(P3(P1(dp[1][0][i],1),P2(0,i)));
  }
  rep(i,n)rep(j,n)t[i][j]=abs(p[i]-p[j]);
  while(!q.empty()){
    P3 ppp=q.top();q.pop();
    int pre=ppp.S.F;
    int now=ppp.S.S;
    int num=ppp.F.S;
    double cost=ppp.F.F;
    if(dp[num][pre][now]<cost)continue;
    rep(i,n)if(now!=i){
      D a=t[pre][now];
      D b=t[now][i];
      D c=t[pre][i];
      D radi=acos((a*a+b*b-c*c)/(2*a*b));
      radi=radi/M_PI*180;
      if(180.0-radi > qu)continue;
      if(cost+abs(p[now]-p[i])>r)continue;
      if(dp[num+1][now][i]<=cost+t[i][now])continue;
      dp[num+1][now][i]=cost+t[i][now];
      q.push(P3(P1(dp[num+1][now][i],num+1),P2(now,i)));
    }
  }
  dp[0][0][0]=1;
  for(int i=10000;i>=0;i--){
    rep(j,21)rep(k,21)if(dp[i][j][k]!=1e15){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 38068
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// 約数を列挙
func divisor(n int) []int {
	ret := []int{}
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			if i*i != n {
				ret = append(ret, n/i)
			}
		}
	}
	return ret
}

func a(M, N int, ch chan int) {
	ans := 1
	for i := N; i < M; i++ {
		if M%i == 0 {
			ans = M / i
			break
		}
	}
	ch <- ans
	//	close(ch)
}

func b(M, N int, ch chan int) {
	ans := 1
	m := M/N + 1
	for i := 1; i < m; i++ {
		if M%i == 0 && ans < i {
			ans = i
		}
	}
	ch <- ans
	//	close(ch)
}

func solve(M, N int) int {
	m := M / N
	d := divisor(M)
	max := -1
	for _, v := range d {
		if max < v && v <= m {
			max = v
		}
	}
	return max
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()

	/*	c := make(chan int)
		go a(M, N, c)
		go b(M, N, c)

		res := <-c
	*/
	out(solve(M, N))
}


Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

string str;
string temp;
int m;//シャッフル回数
int h;
int main()
{
  while(cin>>str){
    if(str =="-")
      break;
    cin >>m;
    for(int i = 0;i <m;i++){
      temp =str;
      cin >>h;
      for(int j = h;j <str.size();j++){
	str[j-h] = temp[j];
      }
      for(int j = 0;j <h;j++){
	str[j+str.size()-h] = temp[j];
      }
    }
      for(int j = 0;j < str.size();j ++){
	cout <<str[j];
      }
      cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define rg register
#define ll long long 
#define inf 0x3f3f3f3f
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
struct A
{
    ll t,d;
}stk[100005],a[100005];
ll ans,n,m,k,top,cnt,tmp,p;
int vis[100005];
inline bool cmp(A a,A b){return a.d>b.d;}
int main(){

    n=read();k=read();
    for(int i=1;i<=n;i++)
        a[i].t=read(),a[i].d=read();
    sort(a+1,a+1+n,cmp);

    for(int i=1;i<=n;i++)
    {
        if(p<k)
        {
            if(vis[a[i].t]==0)
            {
                vis[a[i].t]=1;
                cnt++;
            }
            else
                stk[++top]=a[i];
            tmp+=a[i].d;
            p++;
            ans=max(ans,tmp+cnt*cnt);
        }
        else
        {
            if(top==0)break;
            if(vis[a[i].t]) continue;
            vis[a[i].t]=1;
            cnt++;
            tmp+=a[i].d;
            tmp-=stk[top--].d;
            ans=max(ans,tmp+cnt*cnt);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2688
import random

mod=998244353
N,X=input().split()
N=int(N)
A=[]
for i in range(N):
    A.append(int(input(),2))
A.sort()

a=A[-1]
M=max(len(X)-1,a.bit_length()-1)
data=[0]*(M+1)
n=a.bit_length()-1
for i in range(M-n,-1,-1):
    data[i+n]=a<<i

low=n
for i in range(0,N-1):
    a=A[i]
    flag=True
    while flag:
        n=a.bit_length()
        for j in range(n-1,low-1,-1):
            a=min(a,a^data[j])
        if a!=0:
            data[a.bit_length()-1]=a
            id=a.bit_length()-1
            low=id
            while data[id+1]==0:
                data[id+1]=min((data[id]<<1)^a,(data[id]<<1))
                id+=1
            else:
                a=data[id]<<1
        else:
            break

data2=[0]*(M+1)
for i in range(M+1):
    data2[i]=(data[i]!=0)

for i in range(1,M+1):
    data2[i]+=data2[i-1]

data2=[0]+data2

#print(data)
#print(data2)

x=0
ans=0
n=len(X)-1
for i in range(len(X)):
    if X[i]=="1":
        if x>>(n-i)&1==1:
            if data[n-i]:
                ans+=pow(2,data2[n-i],mod)
                ans%=mod
        else:
            ans+=pow(2,data2[n-i],mod)
            ans%=mod
            if data[n-i]:
                x=x^data[n-i]
            else:
                break
    else:
        if x>>(n-i)&1==1:
            if data[n-i]:
                x=x^data[n-i]
            else:
                break
        else:
            continue
else:
    ans+=1
    ans%=mod
print(ans)


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

int a, b;
int main() {
	scanf("%d %d", &a, &b);
	if (a <= 0 && b >= 0) puts("Zero");
	else if (b < 0 && (b-a+1)%2) puts("Negative");
	else puts("Positive");



	return 0;
}


Measured memory_bytes: 256
function main(input) {
  var N = input[0].split(" ")[0]-0;
  var s = 0;
  var n = 0;
  var dp = [0];
  for(var i=1;i<=N;i++){
    var ans = dp[i-1]+1;
    for(var s=1;Math.pow(6,s)<=i;s++){
      ans = Math.min(ans, dp[i-Math.pow(6,s)]+1);
    }
    for(var s=1;Math.pow(9,s)<=i;s++){
      ans = Math.min(ans, dp[i-Math.pow(9,s)]+1);
    }
    dp[i] = ans;
  }
  console.log(dp[N]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

using namespace std;

int main(void) {
	int N, M;
	cin >> N >> M;
	vector<char> v(N, -1);
	for(int i = 0; i < M; ++i) {
		int s, c;
		cin >> s >> c;
		--s;
		if(v[s] != -1 && v[s] != c) {
			cout << "-1\n";
			return 0;
		}
		v[s] = c;
	}
	string ans;
	for(int i = 0; i < N; ++i) {
		if(v[i] == -1) {
			if(i == 0 && N > 1) {
				ans.push_back('1');
			} else {
				ans.push_back('0');
			}
		} else {
			if(N > 1 && i == 0 && v[i] == 0) {
				cout << "-1\n";
				return 0;
			}
			ans.push_back('0' + v[i]);
		}
	}
	cout << ans << '\n';
	return 0;
}



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

int calc()
{	
	double ax,ay,ar,bx,by,br,d,r1,r2;
	scanf("%lf%lf%lf%lf%lf%lf",&ax,&ay,&ar,&bx,&by,&br);
	d=((ax-bx)*(ax-bx))+((ay-by)*(ay-by));
	r1=(ar+br)*(ar+br);
	r2=(ar-br)*(ar-br);
	if(d<=r1 && d>=r2)
		return 1;
	else if(d<r2 && ar>=br)
		return 2;
	else if(d<r2 && ar<=br)
		return -2;
	else
		return 0;
}

int main()
{
	int n;
	scanf("%d",&n);
	while((n--) > 0)
		printf("%d\n",calc());
	return 0;
}

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

int A,B;

int main(){
	cin>>A>>B;
	if(A<=0&&B>=0){
		cout<<"Zero"<<'\n';
	}else if(A>0&&B>0){
		cout<<"Positive"<<'\n';
	}else{
		if((B-A)%2==0){
			cout<<"Negative"<<'\n';
		}else{
			cout<<"Positive"<<'\n';
		}
	}
}

Measured memory_bytes: 3568
import math
import time
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

n = iin()
a =  [int(x) for x in input().split()]
while all(x%2!=1 for x in a):
    a = [int(i/2) for i in a]
    neko+=1

print(neko)

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

using namespace std;

const int N = 1e5 + 1;
int a[N], b[N], c[N];
int dp[N][3];

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


Measured memory_bytes: 2560
c500 = gets.to_i
c100 = gets.to_i
c50 = gets.to_i
x = gets.to_i
ans = 0
(0..c500).each do |i|
  (0..c100).each do |j|
    (0..c50).each do |k|
      ans += 1 if i*500 + j*100 + k*50 == x
    end
  end
end
puts ans


Measured memory_bytes: 14296
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
#define rep_one(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;

int h, w, k, ans=0, all=0, tmp;
int cell[6][6];

int main(){
    string inp;
    cin >> h >> w >> k;
    rep(i, h){
        cin >> inp;
        rep(j, w){
            if(inp[j] == '.') cell[i][j] = 0;
            else{
                cell[i][j] = 1;
                all++;
            }
        }
    }
    rep(i, (1<<h)){
        rep(j ,(1<<w)){
            // cout << "(i, j) = " <<i << " , "<< j <<endl;
            tmp = 0;
            rep(k, h){
                rep(l, w){
                    if((i&(1<<k)) || (j&(1<<l))){
                        tmp += cell[k][l];
                        // cout << "(k, h) = " << k << " , "<< l << ":" << tmp << endl;                        
                    }
                }
            }
            // cout << all-tmp << endl;
            if(all-tmp == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int c,i, j, k,l, n, x,count,counta[100];
	l = 0;
	while (1) {
		scanf("%d %d", &n, &x);
		if (n==0&&x==0){
			break;
		}
		count = 0;
		for ( i = 1; i <= n; i++){
			for (j = 2; j <n; j++){
				for (k = 3; k <=n; k++){
					if ((i + j + k == x)&&(i<j&&j<k)) {
						count++;
					}
				}
			}

		}
		counta[l] = count;
		l++;
	}
	c = l;
	for ( i = 0; i < c; i++){
		printf("%d\n", counta[i]);
	}
}

Measured memory_bytes: 1744
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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



int main(){

	char x,y,A=10,B=11,C=12,D=13,E=14,F=15;
	cin>>x>>y;


	if(x==A){
	x=A;
	}
	if(y==A){
	y=A;
	}
	if(x==B){
	x=B;
	}
	if(y==B){
	y=B;
	}
	if(x==C){
	x=C;
	}
	if(y==C){
	y=C;
	}
	if(x==D){
	x=D;
	}
	if(y==D){
	y=D;
	}
	if(x==E){
	x=E;
	}
	if(y==E){
	y=E;
	}
	if(x==F){
	x=F;
	}
	if(y==F){
	y=F;
	}
	if( x < y ){
		cout<<"<"<<endl;
	}else
	if( x > y ){
		cout<<">"<<endl;
	}else
	if( x = y ){
				cout<<"="<<endl;
			}




}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = 998244353;
const ll MAX_N = 100010;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>M>>K;
    typedef tuple<ll,ll,ll> T;
    vector<T> G(M);
    for(int i = 0; i < M; i++) {
        // sからtへの辺を張る
        int s,t,u;
        cin>>s>>t>>u;
        get<0>(G[i]) = s;
        get<1>(G[i]) = t;
        get<2>(G[i]) = u-K;
    }
    ll INF;
    INF = -(1e+9);
    vec memo(N+1,INF);
    memo[1] = 0;
    bool f = false;
    rep(i,N*4+10){
        bool update = false;
        rep(j,M){
            T tt = G[j];
            ll s = get<0>(tt),t = get<1>(tt),cost = get<2>(tt);
            if(memo[s] != INF){
                if(memo[t] < memo[s] + cost){
                    memo[t] = memo[s] + cost;
                    if(t == N) update = true;
                    //if(i < 15)cout<<s<<' '<<t<<' '<<memo[t]<<endl;
                }
            }
        }
        if(i > N*2+10) f = f || update;
        if(i == N*4+9) {
            if (f) {
                cout << -1 << endl;
            } else {
                cout << max(0LL,memo[N]) << endl;
            }
        }
    }
}


Measured memory_bytes: 384
str= gets
q = gets
while order = gets
    orders = order.split
    if orders[0] == "print"
        puts str[orders[1].to_i..orders[2].to_i]
    elsif orders[0] == "replace"
        str[orders[1].to_i..orders[2].to_i] = orders[3]
    else
        str[orders[1].to_i..orders[2].to_i] = str[orders[1].to_i..orders[2].to_i].reverse
    end
end


Measured memory_bytes: 8908
import java.util.Scanner;

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

        if (scanner.hasNextLine()) {
            String line = scanner.nextLine();

            int price = 700;
            for (int i = 0; i < 3; ++i) {
                if (line.charAt(i) == 'o') {
                    price += 100;
                }
            }
            System.out.println(price);
        }
    }
}

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

const int N = 1005; 
const int X = 5005; 

using namespace std;

int n; 
bool f[X], Kill; 
int s1[N], s2[N]; 

vector< int > son[N]; 

void dfs(int u) {
	int weight = 0; 
	int size = son[u].size();
	for(int i=0; i<size; ++i) {
		int v=son[u][i]; 
		dfs(v);
		if(Kill) return ; 
		weight += s1[v] + s2[v]; 
	}
	for(int i=0; i<=s1[u]; ++i) f[i] = 0; 
	f[0] = 1; 
	for(int i=0; i<size; ++i) {
		int v=son[u][i]; 
		for(int j=s1[u]; j>=0; j--)
			f[j] = (j>=s1[v] && f[j-s1[v]]) || (j>=s2[v] && f[j-s2[v]]);
	}
	bool tmpKill = 1; 
	for(int j=s1[u]; j>=0; j--)
		if(f[j]) {
			weight += s1[u] - j; 
			tmpKill = 0; 
			break; 
		}		 
	if(tmpKill) Kill=1; 
	s2[u] = weight - s1[u]; 
}

int main() {
	
	int p; 
	
	cin >> n;
	for(int i=2; i<=n; ++i) cin >> p, son[p].push_back(i);
	for(int i=1; i<=n; ++i) cin >> s1[i];
	
	dfs(1); 
	
	if(Kill) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n"); 
	
	return 0; 
	
}

Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  string s[10];
  s[1] = ".,!? ";
  s[2] = "abc";
  s[3] = "def";
  s[4] = "ghi";
  s[5] = "jkl";
  s[6] = "mno";
  s[7] = "pqrs";
  s[8] = "tuv";
  s[9] = "wxyz";
  int T; cin >>T;
  REP(t, T){
    string str; cin >>str;
    int num = -1, cnt = -1;
    REP(i, str.length()){
      int n = str[i] - '0';
      if(n == 0){
        if(cnt != -1){
          cout <<s[num][cnt % (int)s[num].length()];
          cnt = -1;
          num = -1;
        }
      } else{
        if(num == -1) num = n;
        ++cnt;
      }
    }
    cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1208