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

int main()
{
  	int n, sum = 0;
  	cin >> n;
  
  	int a[n+5], c[n+5];
  	for(int i = 0; i < n; i++) cin >> a[i];
  	for(int i = 0; i < n; i++){
     	cin >> c[i];
      
      	if(c[i] < a[i]) sum += a[i]-c[i];
    }
  
  	cout << sum << endl;
 	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  vector<int> C(3);
  C.at(0) = a+b;
  C.at(1) = a-b;
  C.at(2) = a*b;
  sort(C.begin(),C.end());
  
  cout << C.at(2) << endl;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

ll d;
vector<ll> cnt;
vector<ll> c(26);
ll s[366][26];

void culc_socre(){
  ll res = 0;
  vector<ll> last(26, 0);
  rep(i, 0, d){
    ll day = i+1;
    res += s[i][cnt[i]-1];
    last[cnt[i]-1] = day;
 
    rep(j, 0, 26){
      if(cnt[i]-1 == j) continue;
      res -= c[j] * (day - last[j]);
    }
    cout << res << endl;
  }
}

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

  cin >> d;
  rep(i, 0, 26) cin >> c[i];
  rep(i, 0, d) rep(j, 0, 26) cin >> s[i][j];

  vector<ll> last(26, 0);
  rep(i, 0, d){
    ll day = i+1;
    ll ans = -1;
    ll manum = -INF;
    rep(j, 0, 26){
      ll res = 0;
      res += s[i][j];
      rep(k, 0, 26){
        if(j == k) continue;
        res -= c[k] * (day - last[k]);
      }
      if(manum < res){
        manum = res;
        ans = j+1;
      }
    }
    cnt.pb(ans);
    last[ans-1] = day;
  }

  rep(i, 0, d) cout << cnt[i] << endl;

  //culc_socre();
  return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    System.out.println(a/3);
  }
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> m >> n;
  vector<vector<LD>> p(m,vector<LD>(n));
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++) cin >> p[i][j];
  }
  vector<vector<LD>> dp(n,vector<LD>(1<<m,0));
  LD tmp,pp;
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<(1<<m);j++){
      dp[i][j]=0;
      for(int k=0;k<m;k++){
        if(j&(1<<k)){
          tmp=0,pp=1;
          for(int l=i;l<n;l++){
            tmp+=pp*(1-p[k][l])*dp[l][j-(1<<k)];
            pp*=p[k][l];
          }
          tmp+=pp;
          dp[i][j]=max(dp[i][j],tmp);
        }
      }
    }
  }
  cout << fixed << setprecision(12) << dp[0][(1<<m)-1] << endl;
  return 0;
}



Measured memory_bytes: 20372
x, y = map(int, input().split())

if x > y:
    larger = x
    smaller = y
else:
    larger = y
    smaller = x

while True:
    quot, rem = divmod(larger, smaller)  # a > b ?????????
    larger = smaller
    smaller = rem
    if rem == 0:
        gcd = larger
        break

print(gcd)

pass

Measured memory_bytes: 7624
fun main(args :Array<String>) {
    val n = readInteger()
    val (s, t) = readStringList()

    for (i in 0 until n) {
        print(s[i])
        print(t[i])
    }
    println()
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 37924
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;


int32_t main(){

    ll n,m,x,y;
    cin >> n >> m >> x >> y;
   cout << (ld)n*ld(m)/2 << " " ;
    if (n%2==0 && m%2==0 && x==n/2 && y==m/2){
        cout << 1;
    }
    else{
        cout << 0;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int read(){
    int k=0,f=1; char c=getchar();
    for(;c<'0'||c>'9';c=getchar())
      if(c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar())
      k=(k<<3)+(k<<1)+c-48;
    return k*f;
}
int sum[201][201],ans;
int main(){
	int n; cin>>n;
	for(int i=1;i<=n;i++){
		ans^=(read()&1);
	}
	if(ans) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n, m, q;
		
		n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		
		q = scan.nextInt();
		for (int i = 0; i < q; i++) {
			m = scan.nextInt();
			if (dfs(a, m, 0)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}
	
	static boolean dfs(int[] a, int m, int current) {
		if (m == 0) {
			return true;
		}
		if (m < 0 || current == a.length) {
			return false;
		}
		
		if (dfs(a, m, current+1) || dfs(a, m - a[current], current+1)) {
			return true;
		}
		return false;
	}
}

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

using namespace std;

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

  int x = 0;
  int y = 0;
  int z = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a % 4 == 0) {
      x++;
    } else if (a % 2 == 0) {
      y++;
    } else {
      z++;
    }
  }

  if (y == 0) {
    puts(z - 1 <= x ? "Yes" : "No");
  } else {
    puts(z <= x ? "Yes" : "No");
  }
}


Measured memory_bytes: 256
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#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;

// 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();
}

//change
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

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

template <class T>
inline T nCr(T n, T r)
{
    T num = 1;
    for (int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1) / i;
    }
    return num;
}
template <class T>
inline T nPr(T n, T r)
{
    r = n - r;
    T sum = 1;
    int i;
    for (i = n; i >= r + 1; --i)
        sum *= i;
    return sum;
}

template <class T>
inline T facctorial(T k)
{
    T sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//numeric
template <class T>
inline T gcd(T a, T b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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())

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

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

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

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

int main()
{
    int N, D;
    cin >> N >> D;
    int cnt = 0;
    while (N > 0)
    {
        N -= (2 * D + 1);
        ++cnt;
    }
    cout << cnt << endl;
}

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

int main()
{
    int i;

    int n;
    scanf("%d", &n);
    char taro[101], hanako[101];
    int score_taro = 0, score_hanako = 0, judge;
    for( i = 0; i < n; ++i ){
        scanf("%s%s", taro, hanako);
        judge = strcmp(taro, hanako);
        if( judge > 0 ) score_taro += 3;
        else if( judge < 0 ) score_hanako += 3;
        else ++score_taro, ++score_hanako;
    }

    printf("%d %d\n", score_taro, score_hanako);

    return 0;
}

Measured memory_bytes: 604
n, m = map(int, input().split())
jud = [True] + [False]*(n - 1)
l = [1]*n

for i in range(m):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    l[x] -= 1
    l[y] += 1
    if jud[x]:
        jud[y] = True
    if l[x] == 0:
        jud[x] = False

ans = 0
for i in jud:
    if i:
        ans += 1
print(ans)

Measured memory_bytes: 10360
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(int i=a;i<b;i++)
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  vec b(a);
  For(i,0,a)
    ci(b[i]);
  ll an=0;
  For(i,0,a)
    while(b[i]>0){
      if(b[i]%2!=0)
        break;
      an++;
      b[i]/=2;
  }
  co(an);
}

Measured memory_bytes: 384
/*
Problem : AtCoder Grand Contest 030 - C
Algorithm : math
Status : AC
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;

int k;

int main(){
    cin >> k;
    if (k == 1) {
        printf("1\n1\n");
        return 0;
    }
    int n = (k + 3) / 4;
    n *= 2;
    int a = 2 * n - k;
    printf("%d\n", n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int k = (i + j) % n;
            printf("%d ", (i % 2 && k >= a) * (n - a) + k + 1);
        }
        printf("\n");
    }
	return 0;
}


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

int main()
{
	int size;
	
	cin >> size;
	
	int *d = new int[size];
	
	for (int i = 0; i < size; i++)
		cin >> d[i];
	
	for (int i = size - 1; i > 0; i--)
		cout << d[i] << ' ';
	cout << d[0] << endl;
	
	delete [] d;

	return 0;
}

Measured memory_bytes: 3048
#
# abc048 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3
2 2 2"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """6 1
1 6 1 2 0 4"""
        output = """11"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 9
3 1 4 1 5"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2 0
5 5"""
        output = """10"""
        self.assertIO(input, output)


def resolve():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        if a[i] > x:
            ans += (a[i] - x)
            a[i] = x

    for i in range(1, N):
        if a[i-1] + a[i] > x:
            ans += (a[i] + a[i-1] - x)
            a[i] = x - a[i-1]

    print(ans)


if __name__ == "__main__":
     # unittest.main()
     resolve()


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

int main(){
    string S;
    int N;
    cin >> N >> S;

    int ans = 0, x = 0;
    rep(i, N){
        if(S[i] == 'I') x++;
        else x--;
        ans = max(ans, x);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,int> PL;

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

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  int sx,sy,gx,gy;
  cin >> sx >> sy >> gx >> gy;
  sx--,sy--,gx--,gy--;
  vector<string> g(h);
  rep(i,h)cin >> g[i];
  priority_queue<PL,vector<PL>,greater<PL>> pq;
  vector<ll> dist(h*w*4,LINF);
  auto toID = [&](int i,int j,int v){
    return (i*w+j)*4+v;
  };
  auto modCeilK = [&](ll x) {
    return (x+k-1)/k*k;
  };
  auto push = [&](int i,int j,int v,ll x){
    int id = toID(i,j,v);
    if(dist[id]<=x)return;
    pq.emplace(x,id);
    dist[id]=x;
  };
  rep(v,4)push(sx,sy,v,0);
  while(!pq.empty()){
    int id = pq.top().second;
    ll x = pq.top().first;
    pq.pop();
    if(dist[id]!=x)continue;
    int i = id/w/4;
    int j = id/4%w;
    int v = id%4;
    rep(nv,4)push(i,j,nv,modCeilK(x));
    int ni = i+dx[v],nj = j+dy[v];
    if(0<=ni&&ni<h&&0<=nj&&nj<w){
      if(g[ni][nj]=='.')push(ni,nj,v,x+1);
    }
  }
  ll ans = LINF;
  rep(v,4)chmin(ans,dist[toID(gx,gy,v)]);
  if(ans == LINF)cout << -1 << endl;
  else cout << modCeilK(ans)/k << endl;
}

Measured memory_bytes: 43556
#include<bits/stdc++.h>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
const int inf=0x3f3f3f3f,maxn=200010;

int n,A[maxn],B[maxn],cx[40][maxn],dx[maxn],ans=0;

int main(){
    n=read();
    for(int i=1;i<=n;i++)A[i]=read();
    for(int i=1;i<=n;i++)B[i]=read();
    for(int k=0;k<28;k++){
        if(!k)for(int i=1;i<=n;i++)cx[k][i]=((1<<k)&B[i]);else
        for(int i=1;i<=n;i++)cx[k][i]=cx[k-1][i]^((1<<k)&B[i]);
    }
    for(int k=0;k<28;k++)sort(cx[k]+1,cx[k]+n+1);
    for(int k=1;k<=28;k++){
        for(int i=1;i<=n;i++){
            dx[i]^=(1<<(k-1))&A[i];
            int x=lower_bound(cx[k-1]+1,cx[k-1]+n+1,((1<<k)-dx[i]))-cx[k-1];
            ans^=(((n-x+1)%2)<<k);
        }
    }
    int a,b,c,d;
    for(int k=0;k<=28;k++){
        a=b=c=d=0;
        for(int i=1;i<=n;i++)if((1<<k)&A[i])b++;else a++;
        for(int i=1;i<=n;i++)if((1<<k)&B[i])d++;else c++;
        ans^=(((1ll*a*d%2+1ll*b*c%2)%2)<<k);
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 27944
#if defined(LOCAL)
#define PROBLEM_NAME "a"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

bool bipartite_matching_connect(const l u, vvb& m, vl& to, vb& used) {
  for (size_t v = 0; v < to.size(); v++) {
    if (!m[u][v] || used[v]) continue;
    used[v] = true;
    if (to[v] == -1 || bipartite_matching_connect(to[v], m, to, used)) {
      to[v] = u;
      return true;
    }
  }
  return false; // return to; to get actual connections
}

// {A} => {B}, m[i][j] if A[i] -> B[j]
l bipartite_matching(vvb& m) {
  if (m.empty()) return 0;
  vl to(m[0].size(), -1);
  int result = 0;
  for (size_t u = 0; u < m.size(); u++) {
    vb used(to.size());
    if (bipartite_matching_connect(u, m, to, used)) result++;
  }
  return result;
}


void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  vll a(n), b(n);
  F(i, 0, n) cin >> a[i].first >> a[i].second;
  F(i, 0, n) cin >> b[i].first >> b[i].second;
  vvb m(n, vb(n));
  F(i, 0, n) F(j, 0, n) m[i][j] = a[i].first < b[j].first and a[i].second < b[j].second;
  cout << bipartite_matching(m) << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


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

using namespace std;

int main() {
	int n, *nums,tmp,counter = 0;
	cin >> n;

	nums = (int *)malloc(sizeof(int) * n);
	for (int i = 0; i < n; i++)
	{
		cin >> nums[i];
	}

	for (int i = 0; i < n - 1; i++)
	{
		for (int j = n - 1; j >= 1 ; j--)
		{
			
			if (nums[j] < nums[j-1]) {
				tmp = nums[j];
				nums[j] = nums[j-1];
				nums[j-1] = tmp;
				counter++;
			}
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		cout << nums[i];
		if (i == n - 1) cout << endl;
		else cout << " ";
	}

	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	ini(n1);
	out((n+n1 * 2 )/(n1*2+1));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String args[]){
		    Scanner sc = new Scanner(System.in);	
			
			int n = sc.nextInt();
			if (n == 22) {
				System.out.println("Christmas Eve Eve Eve");
			}else if (n == 23) {
				System.out.println("Christmas Eve Eve");
			}else if (n == 24) {
				System.out.println("Christmas Eve");
			}else{
				System.out.println("Christmas");
			}
    }

}


Measured memory_bytes: 21204
import copy
import sys
sys.setrecursionlimit(10**7)

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())

meiro = [ ['#'] * (w+4)]
meiro += [ ['#'] * (w+4)]
meiro += [['#'] * 2 + list(input()) + ['#'] * 2 for _ in range(h)]
meiro += [ ['#'] * (w+4)]
meiro += [ ['#'] * (w+4)]

moved = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def label(row, column):
    meiro[row][column] = num
    for i,j in moved:
        if meiro[row+i][column+j] == '.':
            check.append([row+i, column+j])
            label(row+i, column+j)

row = ch + 1
column = cw + 1

num = 0
check = [[row, column]]
label(row, column)

while True:
    num += 1
    check_copy = copy.deepcopy(check)
    check = []
    for i,j in check_copy:
        for s in range(-2, 3):
            for t in range(-2, 3):
                if meiro[i+s][j+t] == '.':
                    check.append([i+s, j+t])
                    label (i+s,j+t)

    if len(check) == 0:
        break

if meiro[dh+1][dw+1] == '.':
    print(-1)
else:
    print(meiro[dh+1][dw+1])


Measured memory_bytes: 194572
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
      int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();int d=sc.nextInt();
      int max=Math.max(Math.max(a,b),c);
      int sum=a+b+c-max;
      for(int i=0;i<d;i++)max*=2;
      System.out.println(sum+max);
    }
}


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

int main() 
{
	int n,total;
	int* d;
	cin >> n;
	total = 0;
	if( n >= 2 && n <= 50 )
	{
		d = new int[n];
		for( int i=0 ; i<n ; i++ )
		{
			cin >> d[i];
			if( d[i] < 0 && d[i] > 100 )
				return 0 ;
		}

		for( int j=0 ; j<n-1 ; j++ )
		{
			for( int k=1 ; k<n-j ; k++)
				total += d[j]*d[j+k];
		}
		delete[] d;
		cout << total << endl;
	}
	else
		return 0;
}

Measured memory_bytes: 256
<?php 
  fscanf(STDIN, "%d %d", $n, $k);
  $p = explode(' ', trim(fgets(STDIN)));
  $price = 0;
  sort($p);

  for ($i=0; $i < $k; $i++) {
    // code...
    $price += $p[$i];
  }

  echo $price;

Measured memory_bytes: 16276
#include <iostream>
#define MOD 10000
using namespace std;

int main(){
	int n,k,p[100],dp[100][4][4] = {};
	cin >> n >> k;
	for(int i = 0;i < n;i++) p[i] = -1;
	for(int i = 0;i < k;i++){
		int a,b;
		cin >> a >> b;
		p[a - 1] = b;
	}
	for(int i = 0;i < n;i++){
		if(i == 0){
			if(p[0] != -1) dp[i][p[0]][0] = 1;
			else{
				dp[i][1][0] = 1;
				dp[i][2][0] = 1;
				dp[i][3][0] = 1;
			}
		}
		else if(i == 1){
			if(p[1] != -1){
				for(int j = 1;j <= 3;j++){
					dp[i][p[1]][j] += dp[i - 1][j][0];
				}
			}else{
				for(int j = 1;j <= 3;j++){
					for(int k = 1;k <= 3;k++) dp[i][j][k] += dp[i - 1][k][0];
				}
			}
		}
		else{
			if(p[i] != -1){
				for(int j = 1;j <= 3;j++){
					for(int k = 1;k <= 3;k++){
						if(p[i] == j && j == k) continue;
						dp[i][p[i]][j] = (dp[i][p[i]][j] + dp[i - 1][j][k]) % MOD;
					}
				}
			}else{
				for(int j = 1;j <= 3;j++){
					for(int k = 1;k <= 3;k++){
						for(int l = 1;l <= 3;l++){
							if(j == k && k == l) continue;
							dp[i][j][k] = (dp[i][j][k] + dp[i - 1][k][l]) % MOD;
						}
					}
				}
			}
		}
	}
	int res = 0;
	for(int i = 1;i <= 3;i++){
		for(int j = 1;j <= 3;j++){
			res = (res + dp[n - 1][i][j]) % MOD;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  map<int,int> mp;
  for (int i = 0; i < 3; ++i) {
    int a,b;
    cin >> a >> b;
    mp[a] += 1;
    mp[b] += 1;
  }

  for (auto itr : mp) {
    if (itr.second == 0 or itr.second > 2) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}


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

const int N = 300 + 5, INF = 1e9;
int h,w,d,q, a[N][N], dp[N*N];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>h>>w>>d;
    
    map<int, pair<int, int> > v_p;
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            cin>>a[i][j];
            v_p[a[i][j]] = {i, j};
        }
    }
    
    fill_n(&dp[0], N*N, INF);
    
    int total = h*w;
    for (int i = total; i >=1; i--){
        if(i + d>total)dp[i] = 0;
        else{
            dp[i] = dp[i+d] + abs(v_p[i].first - v_p[i+d].first) + abs(v_p[i].second - v_p[i+d].second);
        }
    }
    
    
    cin>>q;
    int l,r;
    for (int i = 1; i <= q; i++){
        cin>>l>>r;
        cout<<dp[l] - dp[r]<<endl;
    }
 
    
    return 0;
}



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

const int DIM = 1e2 + 5;

vector<int> lst[4];
pair<int, int> arr[DIM];

int main( void ) {
    
    int n, w;
    cin >> n >> w;
    
    fill( lst, lst + 4, vector<int>(1, 0) );
    
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i].first >> arr[i].second;
        lst[arr[i].first - arr[1].first].push_back( arr[i].second );
    }
    
    for( int i = 0; i <= 3; i ++ ) {
        sort( lst[i].begin() + 1, lst[i].end(), greater<int>() );
        
        for( int j = 1; j < lst[i].size(); j ++ )
            lst[i][j] += lst[i][j - 1];
    }
    
    int ans = 0;
    for( int i = 0; i < lst[0].size(); i ++ ) {
    for( int j = 0; j < lst[1].size(); j ++ ) {
    for( int k = 0; k < lst[2].size(); k ++ ) {
        int p = min( (long long)( lst[3].size() ) - 1, ( 1LL * w - 1LL * i * ( arr[1].first + 0 )
                                                                 - 1LL * j * ( arr[1].first + 1 )
                                                                 - 1LL * k * ( arr[1].first + 2 ) ) / ( arr[1].first + 3 ) );
        
        if( 1LL * i * ( arr[1].first + 0 ) + 1LL * j * ( arr[1].first + 1 ) + 1LL * k * ( arr[1].first + 2 ) <= 1LL * w )
            ans = max( ans, lst[0][i] + lst[1][j] + lst[2][k] + lst[3][p] );
    } } }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            pass System Test!
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
  if (!v.empty()) {
    out << '[';
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}
template <class T, class U>
void chmin(T& t, U f) {
  if (t > f) t = f;
}
template <class T, class U>
void chmax(T& t, U f) {
  if (t < f) t = f;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  const int B = 350;

  int N, x, y;
  cin >> N >> x >> y;
  vector<int> a(N), b(N), c(N), d(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  vector<vector<vector<int>>> dp(
      N + 1, vector<vector<int>>(305, vector<int>(B + 605, -1)));
  dp[0][x][y + B] = 0;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < dp[i].size(); ++j) {
      for (int k = 0; k < dp[i][j].size(); ++k) {
        if (dp[i][j][k] < 0) continue;
        chmax(dp[i + 1][j][k], dp[i][j][k]);
        if (j >= a[i]) chmax(dp[i + 1][j - a[i]][k + b[i]], dp[i][j][k]);
        if (k >= c[i]) chmax(dp[i + 1][j][k - c[i]], dp[i][j][k] + d[i]);
      }
    }
  }

  int ma = 0;
  for (int j = 0; j < dp[N].size(); ++j) {
    for (int k = B; k < dp[N][j].size(); ++k) {
      chmax(ma, dp[N][j][k]);
    }
  }
  cout << ma << endl;
}

Measured memory_bytes: 120096
# 2019/08/05

input=open(0).readline

n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    edge[a].append(b)
    edge[b].append(a)


for e in edge[-1]:
    if 0 in edge[e]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Measured memory_bytes: 38320
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

const int MOD = 1000000007;

map<vector<int>, int> p2id;
vector<int> id2p[40320+2];
vector<int> g[40320+2];

int w, k;

int memo[40320+2][100+2][8+2];
int solve(int id, int h, int pos) {
  int& res = memo[id][h][pos];
  if(res < 0) {
    if(h == 0) {
      const vector<int> p = id2p[id];
      if(p[k-1] == 0) {
        res = 1;
      } else {
        res = 0;
      }
    } else if(pos >= w-1) {
      res = solve(id, h-1, 0);
    } else {
      res = solve(id, h, pos+1);
      if(pos+1 < w) {
        res = (res + solve(g[id][pos], h, pos+2)) % MOD;
      }
    }
  }
  return res;
}

int main(void) {
  int h;
  cin >> h >> w >> k;

  vector<int> perm(w);
  REP(i, w) {
    perm[i] = i;
  }
  do {
    int id = p2id.size();
    p2id[perm] = id;
    id2p[id] = perm;
  } while(next_permutation(perm.begin(), perm.end()));
  REP(i, p2id.size()) {
    vector<int> p = id2p[i];
    REP(j, w-1) {
      swap(p[j], p[j+1]);
      int i2 = p2id[p];
      g[i].push_back(i2);
      swap(p[j], p[j+1]);
    }
  }
  
  memset(memo, -1, sizeof memo);
  int res = solve(0, h, 0);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 171648
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ds = readStrings().map(String::toInt)
    var ans = 0
    for (i in 0 until n) {
        for (j in (i + 1) until n) {
            ans += ds[i] * ds[j]
        }
    }

    println(ans)
}

fun readStrings() = readLine()!!.split(" ")


Measured memory_bytes: 37964
N = int(input())
As = list(map(int, input().split()))
mod = 10**9 + 7

dp0 = [0]*61
dp1 = [0]*61
for a in As:
    bins = format(a,"061b")[::-1]
    for i,b in enumerate(bins):
        if b == "0":
            dp0[i] += 1
        else:
            dp1[i] += 1
ans = 0
for i,(zero,one) in enumerate(zip(dp0,dp1)):
    ans += (zero*one*2**i)%mod
print(ans%mod)

Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long A, long long B)
{
  cout << A * B << endl;
}

int main()
{
  cout << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;



int main(){
    int N;cin >> N;
    LL ma = 0,sum = 0;
    for(int a = 0;a < N;a++){
        LL b;cin >> b;
        ma = max(b,ma);
        sum += b;
    }
    sum -= ma;
    if(sum > ma){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<double,int>pii;
int main(){
    vector<pii>rize;
    vector<vector<pii>>gotiusa(3,vector<pii>());
    for(int i=1; i<=24;i++){
        pii tiya; cin>>tiya.second>>tiya.first;
        if(i<=8){gotiusa[0].push_back(pii(tiya));}
        else if(i<=16){gotiusa[1].push_back(tiya);}
        else gotiusa[2].push_back(tiya);
    }
    for(int i=0; i<3;i++)sort(gotiusa[i].begin(),gotiusa[i].end());
    for (int i=0;i<3;i++) {
        for(int j=0; j<2;j++)cout<<gotiusa[i][j].second<<" "<<gotiusa[i][j].first<<endl;
        for(int j=2; j<gotiusa[i].size();j++)rize.push_back(gotiusa[i][j]);
    }
    sort(rize.begin(),rize.end());
    for(int i=0;i<2;i++)cout<<rize[i].second<<" "<<rize[i].first<<endl;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
#define F first
#define S second
P dp[33][33][33][33];
int h,w,s,sum[33][33],a[33][33],SUM;
int get(int ly,int lx,int ry,int rx){
  return sum[ry+1][rx+1]-sum[ry+1][lx]-sum[ly][rx+1]+sum[ly][lx];
}
P dfs(int ly,int lx,int ry,int rx){
  if(dp[ly][lx][ry][rx]!=P(0,1e9))return dp[ly][lx][ry][rx];
  P res=P(1,s-(SUM-get(ly,lx,ry,rx)));//cout<<get(ly,lx,ry,rx)<<endl;
  for(int i=lx;i<rx;i++){
    if(s-(SUM-get(ly,lx,ry,i))<0)continue;
    if(s-(SUM-get(ly,i+1,ry,rx))<0)continue;
    P res1=dfs(ly,lx,ry,i),res2=dfs(ly,i+1,ry,rx);
    res=max(res,P(res1.F+res2.F,min(res1.S,res2.S)));
  }
  for(int i=ly;i<ry;i++){
    if(s-(SUM-get(ly,lx,i,rx))<0)continue;
    if(s-(SUM-get(i+1,lx,ry,rx))<0)continue;
    P res1=dfs(ly,lx,i,rx),res2=dfs(i+1,lx,ry,rx);
    res=max(res,P(res1.F+res2.F,min(res1.S,res2.S)));
  }
  return dp[ly][lx][ry][rx]=res;
}

int main(){
  while(cin>>h>>w>>s,s){
    SUM=0;
    r(i,h)r(j,w)cin>>a[i][j],SUM+=a[i][j];
    r(i,33)r(j,33)r(k,33)r(l,33)dp[i][j][k][l]=P(0,1e9);
    memset(sum,0,sizeof(sum));
    r(i,h)r(j,w)sum[i+1][j+1]=a[i][j];
    r(i,h+1)r(j,w)sum[i][j+1]+=sum[i][j];
    r(j,w+1)r(i,h)sum[i+1][j]+=sum[i][j];

    P p=dfs(0,0,h-1,w-1);
    cout<<p.F<<' '<<p.S<<endl;
  }
}

Measured memory_bytes: 12396
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    ll L,R;
    cin >> L >> R;

    if(R - L >= 2019 || L == 0){
        cout << 0 << endl;
        return 0;
    }

    ll minval = INF;
    for(ll i = L; i < R; ++i){
        for(ll j = i+1; j <= R; ++j){
            minval = min(minval, i*j%2019);
        }
    }
    cout << minval << endl;

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c=='A'){
    cout << 'T' << endl;
  }
  if(c=='T'){
    cout << 'A' << endl;
  }
  if(c=='G'){
    cout << 'C' << endl;
  }
  if(c=='C'){
    cout << 'G' << endl;
  }
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

vector<ll> X(212345, 0), S(212345, 0);

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

  rep1(i, N) {
    ll a;
    cin >> a;
    X[i] = X[i - 1] ^ a;
    S[i] = S[i - 1] + a;
  }

  ll ans = 0;
  rep1(i, N) {
    ll l = i, r = N + 1;
    while (r - l > 1) {
      ll m = (l + r) / 2;
      ll s = S[m] - S[i - 1];
      ll x = X[m] ^ X[i - 1];
      if (s == x) {
        l = m;
      } else {
        r = m;
      }
    }
    ans += (r - i);
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 3584
import java.util.Arrays;
import java.util.Scanner;

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

		while(sc.hasNext())
		{
			int n = sc.nextInt();
			if(n==0)
				return;
			boolean a[] = new boolean[n+1];
			Arrays.fill(a, true);
			a[0]=a[1]=false;

			for(int i=2;i*i<=n; i++)
			{
				if(!a[i]) //falseだったら
					continue;
				for(int j=i+i; j<=n; j+=i)
				{
					a[j] = false;
				}

			}
			int x=0;
			int y=0;
			boolean flag=false;
			for(int i =n; i>=0; i--)
			{
				if(a[i])
					x =i;
				else
					continue;
				for(int j=i-2; j>=0; j--)
				{
					if(a[j])
					{
						y=j;
						if(x-y==2)
						{
							System.out.println(y+" "+x);
							flag = true;
							break;
						}
					}
					else
						break;
				}
				if(flag)
					break;
			}
		}
	}

}

Measured memory_bytes: 12000
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    for {
        a := nextInt()
        op := nextString()
        b := nextInt()
        if op == "+" {
            fmt.Printf("%v\n", a+b);
        } else if op == "-" {
            fmt.Printf("%v\n", a-b);
        } else if op == "*" {
            fmt.Printf("%v\n", a*b);
        } else if op == "/" {
            fmt.Printf("%v\n", a/b);
        } else {
            break;
        }
    }
}
 
/* templates */
 
func Max(a ...int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a ...int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}
 
func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}
 
func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


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


}



Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(){
    long long n;
    int a, b, result;
    cin >> n;

    for(int a = 1; a <= sqrt(n + 1); a++){
        if(n % a == 0) b = n / a;
        result = to_string(b).length();
    }

    cout << result << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  priority_queue<long> right;
  priority_queue<long,vector<long>,greater<long>> left;
  vector<long> suml(n+1),sumr(n+1);
  long a[3*n];
  for(int i = 0;i < 3*n;i++){
    cin >> a[i];
    if(i < n){ 
      left.push(a[i]);
      suml.at(0) += a[i];
    }
    else if(i >= 2*n){
      right.push(a[i]);
      sumr.at(0) += a[i];
    }
  }
  for(int i = 0;i < n;i++){
    left.push(a[i+n]);
    suml.at(i+1) = suml.at(i) + a[i+n] - left.top();
    left.pop();
  }
  for(int i = 0;i < n;i++){
    right.push(a[2*n-i-1]);
    sumr.at(i+1) = sumr.at(i) + a[2*n-i-1] - right.top();
    right.pop();
  }
  long ans = suml.at(0) - sumr.at(n);
  //cout << suml.at(0) << ' ' << sumr.at(0) << endl;
  for(int i = 1;i <= n;i++){
    ans = max(ans,suml.at(i) - sumr.at(n-i));
    //cout << suml.at(i) << ' ' << sumr.at(i) << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6260
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N;
    cin >> N;
    int tmp;
    bool ans = true;
    rep(i, N) {
        cin >> tmp;
        if (tmp % 2 == 0) {
            if (tmp % 3 != 0 && tmp % 5 != 0) ans = false;
        }
    }
    cout << (ans ? "APPROVED": "DENIED") << endl;


	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

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

using namespace std;
typedef long long ll;
const int INF = INT_MAX / 4;

const int max_n = 1e3;

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

  int N;
  cin >> N;

  int a = ceil((sqrt(1 + 8 * N) - 1) / 2);
  int s = a * (a + 1) / 2;
  int d = s - N;
  for(int i = 1;i <= a;i++){
    if (i != d) cout << i << "\n";
  }

  return 0;
}


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

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

  int ans;
  if (N % 1000 == 0) {
    ans = 0;
  }
  else {
    ans = 1000 - (N % 1000);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int N, T; cin >> N >> T;
	long X=0;
	int tmae=0, tato;
	for(int i=0; i<N; ++i){
	    cin >> tato;
	    X += min(tato-tmae, T);
	    tmae=tato;
	}
	X += T;
	cout << X << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int a,b;
    cin>>a>>b;
    cout<<(a*b%2?"Odd":"Even")<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll x,n;
ll len[100],gs[100];
ll dfs(ll l,ll r,int x,ll sum,ll pos){
    if(sum==0)return 0;
    if(x==1){
        return max(0ll,min(3ll,sum+pos-1-l));
    }
    ll ans=0;
    ll mid=(l+r)/2;
    if(sum+pos-1<mid)ans+=dfs(l+1,mid-1,x-1,sum-1,l+1);
    else if(sum+pos-1==mid)ans+=gs[x-1]+1;
    else{
        ans+=gs[x-1]+1+dfs(mid+1,r-1,x-1,sum-len[x]/2-1,mid+1);
    }
    return ans;
}
int main()
{
    cin>>n>>x;
    gs[1]=3,len[1]=5;
    for(int i=2;i<=n;i++)gs[i]=gs[i-1]*2+1,len[i]=len[i-1]*2+3;
    printf("%lld\n",dfs(1,len[n],n,x,1));
}


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

int main() {
    int n;
    cin>>n;
    if(n==1)
    {
    	cout<<"Hello World";
    	return 0;
    }
    int a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

#define N 1000010

int ans=1;
int num;

int gcd(int a,int b){
  if(a%b==0) return b;
  else return gcd(b,a%b);
}

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  num=gcd(a,b);
  //cout<<num<<endl;
  int nex=2;
  repi(i,nex,1000001){
    if(num%i==0){
      ans++;
      while(num%i==0) num/=i;
    }
  }
  if(num>1000001) ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384