akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define Rep(i,s,f) for(int i=(int)s;i<(int)f;i++)
using ll=long long;
using namespace std;


int main()
{
	int N;
	cin>>N;
	map<ll,ll> kind;
	rep(i,N)
	{
		ll a;
		cin>>a;
		kind[a]++;
	}
	vector<ll> stick;
	for(auto p : kind)
	{
		if(p.second>=2)
		{
			stick.push_back(p.first);
			if(p.second>=4)
				stick.push_back(p.first);
		}
	}
	if(stick.size()<=1)
	{
		cout<<0<<endl;
		return 0;
	}
	sort(stick.begin(),stick.end(),greater<ll>());
	cout<<stick[0]*stick[1]<<endl;
	return 0;
}


Measured memory_bytes: 6656
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n, k, c = nm()
s = ns()
g = [0]*n
f = [0]*n
_h = 0
for i in reversed(range(n)):
    if i + c + 1 < n:
        if _h < g[i+c+1]:
            _h = g[i+c+1]
    if s[i] == 'o':
        g[i] = _h + 1
if max(g) == k:
    _h = 0
    for i in range(n):
        if i > c:
            if _h < f[i-c-1]: _h = f[i-c-1]
        if s[i] == 'o':
            f[i] = _h + 1
    # print(g)
    # print(f)
    a = [0]*(k+2)
    b = [0]*(k+2)
    for i in range(n):
        a[g[i]] = i
    for i in reversed(range(n)):
        b[k+1-f[i]] = i
    # print(a)
    # print(b)
    for i in range(k, 0, -1):
        if a[i] == b[i]:
            print(a[i] + 1)

Measured memory_bytes: 36368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    long long c0=n/k;
    long long ans=0;
    ans+=c0+c0*3*(c0-1)+(c0-1)*(c0-2)*c0;
    if(k%2==0&&n>=k/2){
        c0=(n-k/2)/k+1;
        ans+=c0+c0*3*(c0-1)+(c0-1)*(c0-2)*c0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll k,a,b;
    cin >> k >> a >> b;
    if(b - a <= 2)cout << k + 1 << endl;
    else{
        ll x = max(0LL,(k - a + 1)/2);
        if(x == 0)cout << k + 1 << endl;
        else cout << (x - 1) * (b - a) + b + (k - a + 1)%2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)
int main() {
	int A,B;
	cin>>A>>B;
	cout<<max(max(A+B,A-B),A*B)<<endl;
	return 0;
}

Measured memory_bytes: 256
main = do
  nIn <- getLine
  hlsIn <- getLine
  let
    n = read $ head $ words nIn :: Int
    hls = map read $ words hlsIn :: [Int]
    func ls m ret
      | ls == []     = ret
      | head ls >= m = func (tail ls) (head ls) (ret+1)
      | otherwise    = func (tail ls) m ret
    in
      putStrLn $ show $ func hls 0 0


Measured memory_bytes: 508
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int n,a;cin>>n>>a;
  cout<<n*n-a;
}
  

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

int main() {
	string a;
	while(cin >> a){
		if(a[0] == a[1] && a[0] == a[2] && a[0] != 's'){
			if(a[0] == 'o')
				cout << 'o' << endl;
			if(a[0] == 'x')
				cout << "x" << endl;
		}else if(a[3] == a[4] && a[3] == a[5] && a[3] != 's'){
			if(a[3] == 'o')
				cout << "o" << endl;
			if(a[3] == 'x')
				cout << "x" << endl;
		}else if(a[6] == a[7] && a[8] == a[7] && a[8] != 's'){
			if(a[6] == 'o')
				cout << "o" << endl;
			if(a[6] == 'x')
				cout << "x" << endl;
		}else if(a[0] == a[3] && a[0] == a[6] && a[0] != 's'){
			if(a[0] == 'o')
				cout << "o" << endl;
			if(a[0] == 'x')
				cout << "x" << endl;
		}else if(a[1] == a[4] && a[7] == a[4] && a[4] != 's'){
			if(a[4] == 'o')
				cout << "o" << endl;
			if(a[4] == 'x')
				cout << "x" << endl;
		}else if(a[2] == a[5] && a[8] == a[5] && a[5] != 's'){
			if(a[2] == 'o')
				cout << "o" << endl;
			if(a[2] == 'x')
				cout << "x" << endl;
		}else if(a[0] == a[4] && a[8] == a[4] && a[0] != 's'){
			if(a[0] == 'o')
				cout << 'o' << endl;
			if(a[0] == 'x')
				cout << "x" << endl;
		}else if(a[2] == a[4] && a[6] == a[4] && a[4] != 's'){
			if(a[4] == 'o')
				cout << 'o' << endl;
			if(a[4] == 'x')
				cout << "x" << endl;
		}else{
			cout << "d" << endl;
		}

		
	}
	

	return 0;
}




Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int e,ans;
  while(1){
    cin>>e;
    if(!e)break;
    ans=(1e9);
    for(int z=0;z*z*z<=e;z++){
      int Z=z*z*z;
      for(int y=0;y*y<=e-Z;y++){
    int Y=y*y;
    int X=e-Y-Z;
    if(X+Y+Z!=e)continue;
    ans=min(ans,X+y+z);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
/* 拡張ダイクストラ */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

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

    vector<ll> c(n);
    vector<ll> waza[n];

    REP(i, n) {
        cin >> c[i];
        REP(j, m) {
            ll me;
            cin >> me;
            waza[i].push_back(me);
        }
    }

    ll ans = INF_LL;

    REP(i, 1 << n) {
        vector<ll> rikai(m, 0);
        ll money = 0;
        REP(j, n) {
            if((i >> j) & 1) {
                money += c[j];
                REP(k, m) {
                    rikai[k] += waza[j][k];
                }
            }
        }
        //cout << rikai[0] << rikai[1] << rikai[2] << endl;
        bool flag = true;
        REP(j, m) {
            if((rikai[j] < x)) flag = false;
        }
        if(flag){
            ans = min(ans, money);
        }         
    }

    if(ans == INF_LL) {
        cout << "-1" << endl;
        return 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
using namespace std;
int n;

struct Point 
{
    double x, y;
};

void KorchCurve(int d, Point p1, Point p2) {
    if (d == 0) return;

    // 与えられたp1, p2から三等分する
    Point s, u, t;
    double theta = M_PI * 60.0 / 180.0;
    s.x = (p1.x*2 + p2.x)/3;
    s.y = (p1.y*2 + p2.y)/3;
    t.x = (p1.x + p2.x*2)/3;
    t.y = (p1.y + p2.y*2)/3;
    u.x = (t.x-s.x)*cos(theta) - (t.y-s.y)*sin(theta) + s.x;
    u.y = (t.x-s.x)*sin(theta) + (t.y-s.y)*cos(theta) + s.y;

    KorchCurve(d-1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y);
    KorchCurve(d-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    KorchCurve(d-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    KorchCurve(d-1, t, p2);
}


int main() {
    scanf("%d", &n);
    Point a, b;
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    KorchCurve(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d) cout<<"Yes";
    else if(abs(a-b)<=d&&abs(b-c)<=d) cout<<"Yes";
    else cout<<"No";
}

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


  long long  a[200000+1];
int main()
{
   long long  h,n,nr,s=0,k;
   unsigned long long atack=0;
    cin>>n>>k;

    for(int i=1; i<=n; ++i)
    {
        cin>>nr;
        a[i]=nr;
    }
    sort (a+1,a+n+1);


    for(int i=n-k; i>=1; --i)
    {
        atack+=a[i];
    }
    cout<<atack;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
   int n,a,b;
   cin>>n;
   cin>>a>>b;
   if((b-a)%2==0)
   cout<<"Alice"<<endl;
   else cout<<"Borys"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1919];
int b[1919];
int main(){
	int n,p=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	for(int i=0;i<n;i++){
		p+=b[i]-a[i]+1;
	}
	cout<<p<<endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 3) {
        if (s[i] == t[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,m;
  std::cin>>n>>m;
  int h[n+1];
  h[0]={0};
  for(int i=1; i<=n; ++i)
    std::cin>>h[i];

  int a,b;
  std::vector<int> vec[n+1];
  while(m--){
    std::cin>>a>>b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }

  // for(int i=1; i<=n; ++i){
  //   std::cout<<i<<" : ";
  //   for(auto j=vec[i].begin(); j<vec[i].end(); ++j){
  //     std::cout<<*j<<" ";
  //     }
  //     std::cout<<std::endl;
  //   }

  bool flag=true;
  int count = 0;
  for(int i=1; i<=n; ++i){
    flag = false;
    if(vec[i].begin() == vec[i].end()){
      ++count;
      // std::cout<<i<<" increased the count\n";
      flag=true;
    }
    for(auto j=vec[i].begin(); j<vec[i].end(); ++j){
      if(h[i] <= h[*j]){
        flag = true;
      }
    }
    if(!flag){
      // std::cout<<i<<" increased the count2\n";
      ++count;
    }
  }
  std::cout<<count<<std::endl;

  // std::sort(h, h+n+1);
  // for(int i=1; i<=n; ++i)
  //   std::cout<<h[i]<<" ";
  // std::cout<<std::endl;
}


Measured memory_bytes: 9160
def solve():
  x, y, a, b, c = list(map(int, input().split()))
  p = list(map(int, input().split()))
  q = list(map(int, input().split()))
  r = list(map(int, input().split()))

  p = list(sorted(p))
  p = p[-x:]
  q = list(sorted(q))
  q = q[-y:]

  _r = r + p + q
  
  _r = list(sorted(_r))
  
  s = 0
  for _s in _r[-(x + y):]:
    s += _s
  
  print(s)

  return

if __name__ == "__main__":
  solve()

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int n;
    cin >> n;
    int ary[n] = {};

    int maxV = 0;
    int sum  = 0;
    rep(i, n) {
        cin >> ary[i];
        maxV = max(maxV, ary[i]);
        sum += ary[i];
    }

    // 処理
    // 出力
    cout << sum - maxV / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int n;
    scanf("%d",&n);
    int x[n],y[n];
    for(int i=0;i<n;i++){
        scanf("%d%d",&x[i],&y[i]);
    }
    double len=0.0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            len+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    len*=2.0/n;
    printf("%f\n",len);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(void){
	int E,Y;
	cin>>E>>Y;
	switch(E){
		case 0:
			if(1868<=Y&&Y<=1911){
				cout<<"M"<<Y-1867<<endl;
			}
			else if(1912<=Y&&Y<=1925){
				cout<<"T"<<Y-1911<<endl;
			}
			else if(1926<=Y&&Y<=1988){
				cout<<"S"<<Y-1925<<endl;
			}
			else if(1989<=Y&&Y<=2016){
				cout<<"H"<<Y-1988<<endl;
			}
			break;
		case 1:
			cout<<1867+Y<<endl;
			break;
		case 2:
			cout<<1911+Y<<endl;
			break;
		case 3:
			cout<<1925+Y<<endl;
			break;
		case 4:
			cout<<1988+Y<<endl;
			break;
	}
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s;
	cin>>s;
	switch(s)
	{
		case 'A':cout<<'T';break;
		case 'T':cout<<'A';break;
		case 'G':cout<<'C';break;
		case 'C':cout<<'G';break;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}
    vector<ll> sum(n+1);
    sum[0] = 0;
    rep(i, n) { sum[i+1] += sum[i] + a[i];}

    ll ans = 0;
    
    // multiset<ll> sp;
    // rep(i, n+1){
    //     ans += sp.count(sum[i]);
    //     sp.insert(sum[i]);
    // }
    map<ll, int> mp;
    rep(i, n+1){
        if (mp.find(sum[i]) != mp.end()){
            ans += mp[sum[i]];
            mp[sum[i]]++;
        } else {
            mp.insert({sum[i], 1});
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 15092
#include <stdio.h>
int main ()
{
	int H,A,J,result;
	scanf("%d", &H);
	scanf("%d", &A);
	if(H%A==0){
		J=H/A;
		printf("%d",J);
	}
	else{
		result=(H/A)+1;
		printf("%d",result);
	}
return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;
bool prime[100001];
bool is_2017[100001];
int sum[100001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    for(int i=0;i<100001;i++){
        prime[i]=1;
    }
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<100001;i++){
        if(prime[i]){
            int now=i*2;
            while(now<100001){
                prime[now]=0;
                now+=i;
            }
        }
    }
    for(int i=0;i<100001;i++){
        if(prime[i] && prime[(i+1)/2])is_2017[i]=1;
        else is_2017[i]=0;
    }
    sum[0]=0;
    for(int i=1;i<100001;i++){
        sum[i]=sum[i-1]+(int)is_2017[i];
    }
    cin>>n;
    for(int i=0;i<n;i++){
        int l,r;cin>>l>>r;
        cout<<sum[r]-sum[l-1]<<endl;
    }
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		for (int i = 0; i < 3; i++) {
			System.out.print(str[i]);
		}
		System.out.println();
	}
}


Measured memory_bytes: 32888
#include <bits/stdc++.h>
using namespace std;
int x[4],y[4];

int main(){
    cin>>x[0]>>y[0]>>x[1]>>y[1];
    int dx = x[1] - x[0], dy = y[1] - y[0];
    x[2] = x[1] - dy; y[2] = y[1] + dx;
    swap(dx,dy);    dx = -dx;
    x[3] = x[2] - dy; y[3] = y[2] + dx;
    cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = (ll) 1e9+7;
ll n,m,x[100005],y[100005];
int main(){
   iostream::sync_with_stdio(0);
   cin >> n >> m;
   for(int i=1;i<=n;i++) cin >> x[i];
   for(int j=1;j<=m;j++) cin >> y[j];
   ll totalx = 0, totaly=0;
   for(int i=2;i<=n;i++){
      totalx = (totalx + (x[i] - x[i-1]) * (i-1) * (n-i+1)) % mod;
   }
   for(int i=2;i<=m;i++){
      totaly = (totaly + (y[i] - y[i-1]) * (i-1) * (m-i+1)) % mod;
   }
   cout << totalx * totaly % mod;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key)
    cur = cur->next;
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L') deleteLast();
      } else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Measured memory_bytes: 33940
#include <stdio.h>
int main(){

	int x,y,dx[3000],dy[3000],i,j;
	i=0;
	do{
		scanf("%d %d",&dx[i],&dy[i]);
		i++;
	}
	while(dx[i-1]!=0 || dy[i-1]!=0);
	j=i;
	
	for(i=1;i<j;i++){
		
		if(dx[i-1]<dy[i-1]){
		printf("%d %d\n",dx[i-1],dy[i-1]);}
		else{printf("%d %d\n",dy[i-1],dx[i-1]);}
	
	}
	
return 0;
}

Measured memory_bytes: 620
#!/usr/bin/env pypy3


def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def main():
    H, W = get_ints()
    a = []
    for _ in range(H):
        a.append(get_ints())

    order = []
    for h in range(H):
        s, e, d = (0, W, +1) if h % 2 == 0 else (W - 1, -1, -1)
        w = s
        while w != e:
            order.append((h, w))
            w += d

    seq = []
    for (h, w), (nh, nw) in zip(order[:-1], order[1:]):
        if a[h][w] % 2 == 1:
            a[h][w] -= 1
            a[nh][nw] += 1
            seq.append((h + 1, w + 1, nh + 1, nw + 1))

    print(len(seq))
    for vs in seq:
        print(*vs)


if __name__ == '__main__':
    main()

Measured memory_bytes: 86556
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

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

  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  rep(i, H) cin >> S[i];

  int ans = 1e9;
  rep(bit, 1 << (H - 1)) {
    vector<int> count(__builtin_popcount(bit) + 1);
    int tmp = __builtin_popcount(bit);
    bool backed = false;
    rep(j, W) {
      int curb = 0;
      rep(i, H) {
        if(S[i][j] == '1') count[curb]++;
        if((bit >> i) & 1) curb++;
      }
      if(*max_element(count.begin(), count.end()) > K) {
        if(backed) {
          tmp = 1e9;
          break;
        }
        ++tmp;
        --j;
        for(auto &x : count) x = 0;
        backed = true;
        continue;
      } else {
        backed = false;
      }
    }
    chmin(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhas Jain
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.ni();
            int[] ar = new int[n];
            for (int i = 0; i < n; ++i) {
                ar[i] = in.ni();
            }
            int[] dp = new int[n];
            dp[1] = Math.abs(ar[0] - ar[1]);
            for (int i = 2; i < n; ++i) {
                dp[i] = Math.min(dp[i - 1] + Math.abs(ar[i] - ar[i - 1]), dp[i - 2] + Math.abs(ar[i] - ar[i - 2]));
            }
            out.print(dp[n - 1]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

    }
}



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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 1e6 + 10;
int n, A[maxn];

void solve() {
  int x = 0;
  cin >> n;
  rep(i,1,n)A[i]=read(),x^=A[i];
  rep(i,1,n)printf("%d ",x^A[i]);
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 4452
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;


int main()
{
    int X;
    int uresisa;

    cin >> X;

    uresisa = 1000 * floor(X / 500);
    uresisa += floor((X - floor(X / 500) * 500) / 5) * 5;

    cout << uresisa;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int N, K, ans = 0;
    cin >> N >> K;
    for (int i = 0, x; i < N; i++) {
        cin >> x;
        ans += 2 * min(x, K - x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(W, H, x, y, r) {
    var result = x - r >= 0 ? (y - r >= 0 ? (x + r <= W ? (y + r <= H ? 'Yes' : 'No') : 'No') : 'No') : 'No';
    // ????????????????????????
    console.log(result);
  }(params[0], params[1], params[2], params[3], params[4]));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15580
n = int(input())
w = list(map(int, input().split()))
s1 = 0
s2 = 0
ans = 0
for t in range(n):
    s1 = sum(w[:t + 1])
    s2 = sum(w[t + 1:])
    d = abs(s1-s2)
    if t==0:
        ans = d
    else:
        if ans > d:
            ans = d
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
using ll = long long;

string str;
int id;
int expr();
int number(){
  int res = 0;
  for (; isdigit(str[id]); id++) {
    res *= 10;
    res += str[id] - '0';
  }
  return res;
}
int factor(){
  int res = 0;
  if(str[id] == '('){
    id++;
    res = expr();
    if(str[id] == ')') ++id;
    return res;
  }else {
  return number();
}

}
int term(){
  int res = factor();
  while(str[id] == '*' || str[id] == '/') {
    if (str[id] =='*') {
      ++id;
      res *= factor();
    } else {
      ++id;
      res /= factor();
    }
  } 
  return res;
}
int expr(){
  int res = term();
  while (str[id] == '+' || str[id] == '-') {
    if(str[id] == '+'){
      ++id;
      res += term();
    } else{
      ++id;
      res -= term();
    }
  }
  return res;
}
int main(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    id = 0;
    cin >> str;
    int ans = expr();
    cout << ans << endl;
  }
}


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

int N;

int main() {
  cin>>N;
  int a=0,b=0,c=0,d=0;
  vector<string> S(100000);
  for(int i=0;i<N;i++) cin>>S.at(i);
  for(int i=0;i<N;i++) {
    if (S.at(i) == "AC") a++;
    else if (S.at(i) == "WA") b++;
    else if (S.at(i) == "TLE") c++;
    else d++;
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
}


Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

bool vfind(vector<ll> v, ll num) {
    auto itr = find(v.begin(), v.end(), num);
    size_t index = distance( v.begin(), itr );
    if (index != v.size()) { // 発見できたとき
        return true;
    }
    else { // 発見できなかったとき
        return false;
    }
}

int main(){
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
    ll x=a[0]*100+a[1]*10+a[2];
    if (x%4==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

int main(void){
  double N;
  int M;
  cin >> N >> M;
  vector<int> A(M);
  for(int i = 0; i < M; i++){
    cin >> A[i];
    N -= A[i];
  }
  if(N >= 0) cout << N;
  else cout << "-1";
  return 0;
}

Measured memory_bytes: 3796
import sys, math
from functools import lru_cache
import numpy as np
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def sieve(n):
    res = [i for i in range(n)]

    i = 2
    while i*i < n:
        if res[i] < i:
            i += 1
            continue
        j = i*i
        while j < n:
            if res[j] == j:
                res[j] = i
            j += i
        i += 1

    return res

def factor(n, min_factor):
    res = set()
    while n > 1:
        res.add(min_factor[n])
        n //= min_factor[n]

    return res

def main():
    N = ii()
    A = np.array(list(mi()))

    m = max(A)
    s = sieve(m+1)
    d = defaultdict(bool)
    
    g = np.gcd.reduce(A)
    if g > 1:
        print('not coprime')
        return

    for a in A:
        f = factor(a, s)
        for v in f:
            if d[v]:
                print('setwise coprime')
                return
            d[v] = True

    print('pairwise coprime')



if __name__ == '__main__':
    main()


Measured memory_bytes: 145312
#include<cstdio>

int pa[10000];

int find(int x){

    if(pa[x]!=x) pa[x] = find(pa[x]);
    return pa[x];
}

void Init(int n){

    for(int i=0;i<n;i++) pa[i] = i;
    return ;
}

int Query(int a,int b){

    if(find(a)!=find(b)) return 0;
    return 1;
}

void Union(int a,int b){

    int x = find(a);
    int y = find(b);

    if(x!=y) pa[x] = y;
}

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m)){

        Init(n);

        while(m--){

            int op;
            int x,y;

            scanf("%d%d%d",&op,&x,&y);

            if(op==1) printf("%d\n",Query(x,y));
            else Union(x,y);
        }
    }
    return 0;
}

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

int main()
{
	int n,k,l[50];
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>l[i];
	
	sort(l,l+n);
	int sum=0;
	for(int i=n-1;i>=n-k;i--) sum+=l[i];
	
	cout<<sum<<endl;
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
l_rng = []
for i in range(n):
  x,l = map(int,input().split() )
  l_rng.append([x-l,x+l])
l_rng.sort(key=lambda x: x[1] )

#右端の値を初期化
migigawa = l_rng[0][1]
cnt = 1
for i in l_rng:
  if migigawa <= i[0]:
    migigawa = i[1]
    cnt = cnt +1
print(cnt)

Measured memory_bytes: 62808
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

int main()
{
	int32_t H, W;
	cin >> H >> W;

	vector<string> pic(H);
	for (int32_t i = 0; i < H; i++) {
		cin >> pic[i];
	}

	for (int32_t i = 0; i < W + 2; i++) {
		cout << "#";
	}
	cout << endl;

	for (int32_t i = 0; i < H; i++) {
		cout << "#" << pic[i] << "#" << endl;
	}

	for (int32_t i = 0; i < W + 2; i++) {
		cout << "#";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    if(s[0]==s[s.size()-1] ^ s.size()%2==0) cout<<"Second";
    else cout<<"First";
    cout<<endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
  ll n;cin>>n;
  ll odd=0;
    for (int i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        if (a % 2 == 1)odd++;
    }
    if(odd%2==0)puts("YES");
    else puts("NO");
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int k,x;
    cin>>k>>x;
    if(k*500>=x){
        cout << "Yes"<<endl;
    }
    else{
        cout<< "No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	
	int a, b, i, j, count;

	int yaku, bai;
	
	while( scanf("%d",&a) != EOF ) {
			int boya[1000] = {0}, boyb[1000] = {0};
		scanf("%d",&b);
		yaku = 1;
		bai = 1;
		count = 0;
		while(a != 1) {
			for(i = 2; i <= a; i++ ) {
				if( a % i == 0 ) {
					boya[count] = i;
					count++;
					a /= i;
					break;
				}
			}
		}
		count = 0;
		while( b != 1 ) {
			for(i = 2; i <= b; i++ ) {
				if( b % i == 0 ) {
					boyb[count] = i;
					count++;
					b /= i;
					break;
				}
			}
		}
		
		for(i = 0; i >= 0; i++ ) {
			if(boya[i] == 0 ) break;
			for(j = 0; j >= 0; j++ ) {
				if( boyb[j] == 0 ) break;
				if( boya[i] == boyb[j] ) {
					yaku *= boya[i];
					boyb[j] = 1;
					boya[i] = 1;
					break;
				}
			}    
		}
		bai *= yaku;
		for(i = 0; i >= 0; i++ ) {
			if( boya[i] == 0 ) break;
			bai *= boya[i];
		}
		for(i = 0; i >= 0; i++ ) {
			if( boyb[i] == 0 ) break;
			bai *= boyb[i];
		}
		printf("%d %d\n",yaku,bai);
	}
	return(0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}


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

    int sum=0;

    rep(i,m){
        int a;
        cin>>a;

        sum+=a;
    }

    if(sum>n)cout<<-1<<endl;
    else cout<<n-sum<<endl;

}



Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
const int maxn = 200;
string s[maxn];
string temp[maxn];
int h,w,k;
int row[maxn], col[maxn];
int check(int x, int y)
{
    int i = 0, j = 0;
    // cout << x << " " << y << endl;
    for (int i = 0; i < h; ++i)
        temp[i] = s[i];
    memset(row, 0, sizeof(row));
    memset(col, 0, sizeof(col));
    while (x)
    {
        row[i] = (x % 2 == 0 ?0:1);
        x=x/2;
        i++;
    }
    while (y)
    {
        col[j] = (y % 2 == 0 ?0:1);
        y = y /2;
        j++;
    }
    for (int i = 0; i < h; ++i)
    {
        if (row[i])
        for (int j = 0; j < s[i].size(); ++j){
            temp[i][j] = 'r';
        }
    }
    for (int i = 0; i < w; ++i)
    {
        if (col[i])
        for (int j = 0; j < h; ++j){
            temp[j][i] = 'r';
        }
    }
    // for (int i = 0; i < w; ++i)
    // {
    //     cout << temp[i] << endl;
    // }
    int res = 0;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
        if (temp[i][j] == '#') res++;
    //cout << res << endl;
    if (res == k) return 1;
    else return 0;
}

int main()
{
    int ans = 0;
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i)
        cin >> s[i];
    for (int i = 0; i < (1<<h); ++i)
        for (int j = 0; j < (1<<w); ++j)
        if (check(i,j))
            ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n, w, v, maxw;
int weight[101];
int val[101];
ll dp[101][100001];

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n >> maxw;
  rep(i, 1, n){
  	cin >> weight[i] >> val[i];
  }
  rep(i, 1, n){
  	rep(j, 1, maxw){
  		dp[i][j]=max(dp[i-1][j], (j-weight[i]>=0?val[i]+dp[i-1][j-weight[i]]:0));
  	}
  }
  cout << dp[n][maxw];
}

Measured memory_bytes: 81744
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

class Status{
  public:
    string S;
    int P;
    int index;
};

int main(void){
  int N;
  cin >> N;
  vector<Status> I(N);
  for(int cnt = 0; cnt < N; ++cnt){
    Status* tmp = new Status();
    cin >> tmp->S >> tmp->P;
    tmp->index = cnt + 1;
    I[cnt] = *tmp;
  }
  for(int cnt = 0; cnt < N - 1; ++cnt){
    for(int index = 0; index < N - 1- cnt; ++index){
      if(I[index].P < I[index+1].P){
        Status tmp = I[index];
        I[index] = I[index+1];
        I[index+1] = tmp;
      }
    }
  }
  for(int cnt = 0; cnt < N - 1; ++cnt){
    for(int index = 0; index < N - 1 - cnt; ++index){
      if(I[index].S > I[index+1].S){
        Status tmp = I[index];
        I[index] = I[index+1];
        I[index+1] = tmp;
      }
    }
  }
  for(int cnt = 0; cnt < N; ++cnt){
    cout << I[cnt].index << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
    
    long long int N;
    long long int total;
    long long int odd_pattern = 1;
    
    cin >> N;
    long long int x;
    for (int i = 0; i < N; i++) {
        cin >> x;
        if (x % 2 == 0)
            odd_pattern *= 2;
    }
    total = pow(3,N);
    
    cout << total - odd_pattern << endl;
    
    return 0;
}

Measured memory_bytes: 256
dct = []
N, M = map(int, input().split())
data = {k+1: [] for k in range(N)}

for i in range(M):
    P, Y = list(map(int, input().split()))
    data[P].append([i, Y])

for v in data.values():
  v.sort(key=lambda x:x[1])

ans = {}
for k, v in data.items():
  for i, j in enumerate(v):
    ans[j[0]] = "{0:06d}".format(k) + "{0:06d}".format(i+1)

for i in ans.values():
  print(i)

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

int main(){
  int a;
  map<int,int> m;
  REP(i,3){
    cin>>a;
    m[a]++;
  }
  cout<<m.size();
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int c[8], p[] = {4, 1, 4, 1, 2, 1, 2, 1};

	while(scanf("%d", &c[0]) != EOF) {
		int max = 0, max_p_index = 0;
		int i, j;

		for(i = 1; i < 8; i++)
			scanf("%d", &c[i]);

		for(i = 0; i < 8; i++) {
			int tmp = 0;
			for(j = 0; j < 8; j++) {
				if(c[j] < p[(i + j) % 8]) {
					tmp += c[j];
				}
				else {
					tmp += p[(i + j) % 8];
				}
			}

			if(max < tmp) {
				max = tmp;
				max_p_index = i;
			}

			else if(max == tmp) {
				int tmp_ = 0, tmp__ = 0;

				for(j = 0; j < 8; j++) {
					tmp_ *= 10;
					tmp_ += p[(max_p_index + j) % 8];
					tmp__ *= 10;
					tmp__ += p[(i + j) % 8];
				}

				if(tmp_ > tmp__)
					max_p_index = i;
			}
		}

		printf("%d", p[max_p_index]);
		for(i = 1; i < 8; i++)
			printf(" %d", p[(max_p_index + i) % 8]);
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 604
import numpy as np
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [ ]
for i in range(N):
  AA = list(map(int, input().split()))
  A.append(AA)
Bnp = np.array(B)
Anp = np.array(A)
C = np.dot(Anp, Bnp) + C
D = 0
for i in range(N):
  if C[i] > 0:
    D += 1
print(D)

Measured memory_bytes: 12508
# Nまでの素数を全て出す
# 素数をすべて出す
# 小さい順から
import math
N = int(input())
s = {}

for i in range(2, math.ceil(math.sqrt(N))):
    mod = N % i
    while mod == 0:
        s[i] = s.get(i, 0) + 1
        N = N // i

        if N == 0:
            break

        mod = N % i
if not N == 1:
    s[N] = s.get(N, 0) + 1

count = 0

for prime in s:
    pow = s[prime]

    if pow == 1:
        count += 1
        continue

    for i in range(1, pow+1):
        pow -= i
        if pow < 0:
            count += i - 1
            break

        if pow == 0:
            count += i
            break

print(count)


Measured memory_bytes: 9228
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int X = Integer.parseInt(str[2]);
    int Y = Integer.parseInt(str[3]);
    if(X>=Y) {
      System.out.println("War");
      return;
    }
    
    str = in.readLine().split(" ");
    int[] x = new int[n+1];
    x[0] = X;
    for(int i=1; i<=n; i++) {
      x[i] = Integer.parseInt(str[i-1]);
    }
    Arrays.parallelSort(x);
    
    str = in.readLine().split(" ");
    int[] y = new int[m+1];
    y[0] = Y;
    for(int i=1; i<=m; i++) {
      y[i] = Integer.parseInt(str[i-1]);
    }
    Arrays.parallelSort(y);
    
    if(x[n]>=y[0]) {
      System.out.println("War");
      return;
    }
    
    System.out.println("No War");
  }
}

Measured memory_bytes: 32464
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int a, b;
    cin >> a >> b;
    a--; b--;
    cout << a*b << endl;
}


Measured memory_bytes: 896
N, W = map(int, input().split())

MAX_V = N * (10 ** 3)
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [10**9+7 for _ in range(MAX_V + 1)]
dp[0] = 0

for w, v in wv:
    for j in range(MAX_V, -1, -1):
        if j - v >= 0:
            dp[j] = min(dp[j],dp[j - v] + w)

mv = 0
for i in range(MAX_V + 1):
    if dp[i] <= W:
        mv = i

print(mv)


Measured memory_bytes: 45040
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
#define OFF 200000
typedef pair<int,int> P;
typedef long long ll;
ll d[20];
ll c[20];
ll dist[400010];
ll n,x;
void dijkstra() {
	priority_queue<P, vector<P>, greater<P> >que;
	fill(dist, dist + 400010, (ll)INF);
	dist[0+OFF] = 0;
	que.push(P(0, 0+OFF));
	while (!que.empty()) {
		P p = que.top();que.pop();
		ll v = p.second;
		if (dist[v] < p.first)continue;
		for (ll i = 0;i < n;i++) {
			int x=v+d[i];
            int y=v-d[i];
            if(x>400000)continue;
            if(y<0)continue;
			if (dist[x] > dist[v] + c[i]) {
				dist[x] = dist[v] + c[i];
				que.push(P(dist[x], x));
			}
            if (dist[y] > dist[v] + c[i]) {
				dist[y] = dist[v] + c[i];
				que.push(P(dist[y], y));
			}
		}
	}
}

int main(void){
    cin>>n>>x;
    for(int i=0;i<n;i++)cin>>d[i]>>c[i];
    dijkstra();
    if(dist[x+OFF]==INF)cout<<-1<<endl;
    else cout<<dist[x+OFF]<<endl;
    return 0;
}


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

const int N=1e2+4;
int a[N];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<2*n;++i) cin>>a[i];
	sort(a,a+2*n);
	int ans=0;
	for(int i=0;i<2*n;i+=2){
		ans+=a[i];
	}
	cout<<ans<<endl;
}

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

#define INF 1000000000
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

long map[500][500];
long red[500][500];
long blue[500][500];

int main() {
	long N;
	long H, W;
	char buf[512];
	long i, j;
	long ans = 0;
	long bottom[500] = {0};
	
	scanf("%ld %ld", &H, &W);
	for(i=0;i<H;i++) {
		scanf("%s", buf);
		for(j=0;j<W;j++) {
			map[i][j] = buf[j] == '#' ? 1 : 0;
		}
	}
	
	for(i=0;i<H;i++) {
		for(j=0;j<W;j++) {
			red[i][j] = j == 0 ? 1 : map[i][j];
			blue[i][j] = j == W-1 ? 1 : map[i][j];
		}
	}
	
	for(i=1;i<H-1;i++) {
		for(j=1;j<W-1;j++) {
			if(i % 2) {
				red[i][j] = 1;
			} else {
				blue[i][j] = 1;
			}
		}
	}
	
	for(i=0;i<H;i++) {
		for(j=0;j<W;j++) {
			if(red[i][j]) printf("#");
			else printf(".");
		}
		printf("\n");
	}
	printf("\n");
	for(i=0;i<H;i++) {
		for(j=0;j<W;j++) {
			if(blue[i][j]) printf("#");
			else printf(".");
		}
		printf("\n");
	}
	
	/*
	printf("*** check ***\n");
	for(i=0;i<H;i++) {
		for(j=0;j<W;j++) {
			if(red[i][j] && blue[i][j]) printf("#");
			else printf(".");
		}
		printf("\n");
	}
	*/
	
	return 0;
	
}

Measured memory_bytes: 6528
import java.util.Scanner;

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

	void solve(Scanner sc) {
		int N = sc.nextInt();
		System.out.println("ABC" + N);
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define INFLL (long long)1e14
#define Loops(i, n) for(int i = 0; i < (int)n; i++)
#define Loops1(i, n) for(int i = 1; i <= (int)n; i++)
int main(void){
	long long int x;
	long long int ans=0;
	std::cin>>x;
	ans+=(long long int)(x/11)*2;
	if(x%11==0){

	}else if(x%11<=6){
		ans++;
	}else {
		ans+=2;
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;

bool is_prime(ll n){
  for(ll i = 2; i * i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

int main(){
  ll n,p;
  cin >> n >> p;
  if(n==1){
    cout << p << endl;
    return 0;
  }
  ll ans = 1;
  for(ll i = 2; i*i<=p; i++){
    if(!is_prime(i)) continue;
    ll cnt = 0;
    while(p%i==0){
      p = p/i;
      cnt++;
      if(cnt%n==0) ans *= i;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " <<  a << " " << b;
}









Measured memory_bytes: 3656