akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, t;
  cin >> n >> t;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll ans = t;
  rep2(i, 1, n) ans += min(t, a[i] - a[i - 1]);
  cout << ans << endl;
}

Measured memory_bytes: 1792
N,K,C = map(int,input().split())
S = list(str(input()))

L = []###i+1回目に働くのはL[i]日目以降
R = []###i+1回目に働くのはL[i]日目以前

for i in range(N):
    if len(L) >= K:
        break
    if S[i] =="o" and (L==[] or (i+1) - L[-1] > C):
        L.append(i+1)

for i in range(N-1,-1,-1):
    if len(R) >= K:
        break
    if S[i] == "o" and (R==[] or R[-1] - (i+1) > C):
        R.append(i+1)

R.reverse()###Rは逆順にappendしたのでreverse
ans = []

for i in range(K):
    if L[i] == R[i]:
        ans.append(L[i])


###
#print(L)
#print(R)
###
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 23576
import collections
H,W=map(int,input().split())
S=[input() for i in [0]*H]
M=[[-1]*W for _ in [0]*H]
k=0
for y in range(H):
    for x in range(W):
        if M[y][x]!=-1:continue #visited
        M[y][x]=k
        Q=collections.deque()
        Q.append((y,x))
        while len(Q)>0:
            i,j=Q.popleft()
            s=S[i][j]
            if i+1<H and M[i+1][j]==-1 and s!=S[i+1][j]:
                M[i+1][j]=k
                Q.append((i+1,j))
            if i-1>=0 and M[i-1][j]==-1 and s!=S[i-1][j]:
                M[i-1][j]=k
                Q.append((i-1,j))
            if j+1<W and M[i][j+1]==-1 and s!=S[i][j+1]:
                M[i][j+1]=k
                Q.append((i,j+1))
            if j-1>=0 and M[i][j-1]==-1 and s!=S[i][j-1]:
                M[i][j-1]=k
                Q.append((i,j-1))
            #print(k,M,Q)
        k+=1
ds={}
dd={}
for i in range(H):
    for j in range(W):
        m=M[i][j]
        if S[i][j]=='#':ds[m]=ds.get(m,0)+1
        else:dd[m]=dd.get(m,0)+1
r=0
for i in range(k):
    r += ds.get(i,0)*dd.get(i,0)
print(r)

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

int main(){
    int H[1000],W[1000];
    int tmph,tmpw;
    int i=0;
    cin>>tmph>>tmpw;
    while(tmph!=0 || tmpw!=0){
        H[i]=tmph;
        W[i]=tmpw;
        cin>>tmph>>tmpw;
        i++;
    }
    for(int j=0;j<i;++j){
        for(int h=0;h<H[j];++h){
            for(int w=0;w<W[j];++w){
                if(w==0||w==W[j]-1||h==0||h==H[j]-1)cout<<'#';
                else cout<<'.';
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3100
#include<stdio.h>
int gcd(int a, int b)
{
    if(a%b == 0)
    {
        return b;
    }else
    {
        return gcd(b, a%b);
    }
}



int main(void)
{
    
    int a,b,c,p,q;
    
    
    
    int k;
    long int sum = 0;
    scanf("%d",&k);
    for(a = 1 ; a <= k ; a++)
    {
        for(b = 1 ; b <= k ; b++)
        {
            for( c = 1 ; c <= k ; c++)
            {
                p = gcd(a,b);
                q = gcd(c,p);
                sum += q;
            }
        }
    }
    printf("%ld\n",sum);

}

Measured memory_bytes: 1712
N, M = map(int, input().split())

lst = []
for i in range(M):
    a = list(map(int, input().split()))
    lst += [a]
p = list(map(int, input().split()))

# print ('lst', lst)
ans = 0
for i in range(2 ** N): #1をon, 0をoffとする2bit
    a = format(i, '012b')
    lst2 = list(a[2:])
    # print ('lst2', lst2)
    flag = True
    l = 0
    for j in lst:
        # print ('j[1:]', j[1:])
        count = 0
        for k in j[1:]:
            # print ('k', k)
            if lst2[9-k+1] == '1': #ONの時、カウントを増やす
                count += 1
                # print ('B')
        # print ('count', count)
        # print ('p[l]', p[l])
        if count%2 != p[l]:
            flag = False
            # print ('C')
        l += 1
    if flag:
        ans += 1
        # print ('A')
    

print (ans)

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

d = []
s = 0
for i in range(1, N+2):
    diff = A[i] - A[i-1]
    d.append(diff)
    s += abs(diff)


for i in range(N):
    ss = s
    ss -= abs(d[i]) + abs(d[i+1]) - abs(d[i] + d[i+1])
    print(ss)


Measured memory_bytes: 13920
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>

using namespace std;

int X; //Aの枚数
int Y; //B
int Z1,Z2 = 0; //AB

int get_max(int *X, int *Y) {
	int max = 0;
	if (*X > *Y) {
		max = *X;
	}
	else {
		max = *Y;
	}
	return max;
}

int max_num_cost(int *X, int *Y, int *a, int *b) {
	int max = 0;
	if (*X > *Y) {
		max = *a;
	}
	else {
		max = *b;
	}
	return max;
}

int get_min(int *X, int *Y) {
	int min = 0;
	if (*X < *Y) {
		min = *X;
	}
	else {
		min = *Y;
	}
	return min;
}

int main() {
	int a, b, c = 0; //ピッツァの価格
	int ans = 0;

	cin >> a >> b >> c >> X >> Y;
	//ハーフを入れて買うのがお得な時(ABの値段の2倍がA,Bの和を超えないとき)
	if ((a + b) > c * 2) {
		
		int ans1, ans2 = 0;
		//全ての種類で組み合わせる場合
		int max_num,max_val=0; //A.Bで大きい方の枚数と価格
		max_num = get_max(&X, &Y); //大きい方の枚数
		max_val = max_num_cost(&X, &Y, &a, &b); //枚数が大きい方の値段

		Z1 = get_min(&X, &Y) * 2; //A,Bの少ない方の枚数をABで実現する⇒ABの枚数
		int zan = max_num - get_min(&X, &Y); //大きい方の残枚数
		ans1 = max_val * zan + c * Z1;

		//ABセットのみで完結する場合
		int Z2 = get_max(&X, &Y) * 2;//大きい方の枚数をABだけで完成させる⇒ABの枚数
		ans2 = Z2 * c;

		ans = get_min(&ans1,&ans2);
	}
	//ハーフを入れて買わない時
	else {
		ans = a * X + b * Y;
	}

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

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c;
  char sa[110],sb[110],sc[110],p='a';
  scanf("%s",sa);
  scanf("%s",sb);
  scanf("%s",sc);
  a=b=c=0;
  while(1){
    if(p=='a'){
      if(a==strlen(sa)){
        printf("A\n");
        break;
      }
      p=sa[a];
      a++;
    }
    else if(p=='b'){
      if(b==strlen(sb)){
        printf("B\n");
        break;
      }
      p=sb[b];
      b++;
    }
    else if(p=='c'){
      if(c==strlen(sc)){
        printf("C\n");
        break;
      }
      p=sc[c];
      c++;
    }
  }
  
}

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

int main() {
  int n,t,ans=1e9;
  cin>>n>>t;
  for(int i=0; i<n; i++){
    int c,x;
    cin>>c>>x;
    if(x<=t) ans=min(ans,c);
  }
  if(ans==1e9) cout<<"TLE";
  else cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)

mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

//int dp[333][2];

void solve(){
	int n, m;
	cin>>n>>m;
	n==m?(cout<<"Yes"):(cout<<"No");
}	

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

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

int main() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    vector<int> d;
    rep(i,x) d.push_back(p[i]);
    rep(i,y) d.push_back(q[i]);
    rep(i,c) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    rep(i,x+y) ans += d[i];
    cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp44 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(s);


            if (s[0] + s[1] == s[2]) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
const int tot=26+26+10;
char enc(int t){
	if(t<10)return '0'+t;
	t-=10;
	if(t<26)return 'a'+t;
	t-=26;
	return 'A'+t;
}
 
string s[tot];
int sum=tot;
 
// string Ans="Atcod3rIsGreat";
int ttm=0;
int query(string s){
	if(s.length()>128)return 0x3f3f3f3f;
	++ttm;
	if(ttm>=850)while(1);
	cout << "?" << " " << s << endl;
	fflush(stdout);
	int ans=0;
	// int t=0;
	// for(size_t q=0;q<Ans.length();q++){
	// 	if(t<s.length()&&s[t]==Ans[q]){
	// 		++t;
	// 	}
	// }
	// return t==s.size()?Ans.length()-t:Ans.length()-t+1;
	cin >> ans;
	return ans;
}
 
 
int len=0x3f3f3f3f;
int q[tot];
 
string merge(string a,string b){
	int i=0,j=0;
	int la=a.length(),lb=b.length();
	string fir=string();
	// int qTime=query(b+a);
	while(i<la&&j<lb){
		string qr=fir;
		qr+=a[i];
		for(int k=j;k<lb;k++){
			qr+=b[k];
		}
		if(query(qr)+qr.length()==len){
			fir+=a[i++];
		}else {
			fir+=b[j++];
		}
	}
	while(i<la)fir+=a[i++];
	while(j<lb)fir+=b[j++];
	// assert(query(fir)+fir.length()==len);
	return fir;
}
 
int main()
{
	for(int i=0;i<tot;i++){
		s[i]+=enc(i);
		q[i]=query(s[i])+1;
		len=min(len,q[i]);
	}
	for(int i=0;i<tot;i++){
		if(q[i]==len){
			while(query(s[i]+enc(i))+s[i].length()+1==len)s[i]+=enc(i);
		}else s[i]=string();
	}
	while(1){
		for(int i=0;i<tot;i++)for(int j=i+1;j<tot;j++)if(s[i].length()>s[j].length())swap(s[i],s[j]);
		int t=0;
		while(!s[t].length())++t;
		if(t+1==tot){
			break ;
		}
		string nw=merge(s[t],s[t+1]);
		s[t+1]=nw;
		s[t]=string();
		// cout << s[t+1] << "!" << endl;
	}
	assert(query(s[tot-1])==0);
	cout << "! "<< s[tot-1] << endl;
	fflush(stdout);
	// cerr << ttm << endl;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>

int main() {

    ll N;
    cin >> N;

    ll tmp;
    vl A;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A.push_back(tmp);
    }

    if (A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }

    ll count = 0;
    for (int i = 1; i < N; i++) {
        if (A[i] == A[i-1] + 1) {
            count += 1;
        }
        else if(A[i] <= A[i-1]) {
            count += A[i];
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << count << endl;

    return 0;
}


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

    #define ll long long
    int main() {

      ll n;
      cin>>n;
      ll dp[3][n],arr[3][n],i,j;
      for(i=0;i<n;i++)
        cin>>arr[0][i]>>arr[1][i]>>arr[2][i];

      memset(dp,0,sizeof dp);
      dp[0][0]=arr[0][0];
      dp[1][0]=arr[1][0];
      dp[2][0]=arr[2][0];

      for(i=1;i<n;i++)
      {
        dp[0][i]= max(dp[1][i-1],dp[2][i-1]) + arr[0][i];
        dp[1][i]=max(dp[0][i-1],dp[2][i-1])+arr[1][i];
        dp[2][i]=max(dp[0][i-1],dp[1][i-1])+arr[2][i];
      }
      cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));

      return 0;
    } 

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

using namespace std;


int main()
{
  int H, W, N, A[100000];

  cin >> H >> W;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int tail = 0;

  for(int i = 0; i < H; i++) {
    vector< int > curr(W, 0);
    for(int j = 0; j < W; j++) {
      curr[j] = tail + 1;
      A[tail]--;
      if(A[tail] == 0) ++tail;
    }
    if(i % 2) reverse(begin(curr), end(curr));
    for(int j = 0; j < W; j++) {
      if(j > 0) cout << " ";
      cout << curr[j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	rep(i, 0, 3){
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n, cnt, a[100005];
ll ac[100005], t = 1, ans;
int main(){
	scanf("%d", &n);
	rep(i,n+1) scanf("%d", a+i);
	for(int i=n; i>=0; i--) ac[i] = ac[i+1] + a[i];
	rep(i,n+1){
		ans += t;
		t -= a[i];
		if(t < 0) return puts("-1") * 0;
		t = min(t*2, ac[i+1]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4992
x,k,d = map(int,input().split())

if x < 0:
    flag = -1
else:
    flag = 1
x = abs(x)

tmp = x//d

if k < tmp:
    print(abs(x-d*k))
else:
    x=x-d*tmp
    k = k-tmp
    if k%2==0:
        print(abs(x))
    else:
        print(abs(x-d))


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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

ll ceil(ll a, ll b)
{
	return (a + b - 1) / b;
}

ll H[100005];
ll N, A, B;

bool check(ll n)
{
	ll sum = n;
	REP(i, N)
	{
		sum -= ceil(H[i] - n*B, A - B);
		if (sum < 0)break;
	}
	return sum >= 0;
}

int main()
{
	cin >> N >> A >> B;
	ll max = 0;
	REP(i, N)
	{
		cin >> H[i];
		max += ceil(H[i], A);
	}
	sort(H, H + N, [](ll a, ll b) {return a > b; });
	ll ng = 0, ok = max;
	while (abs(ok - ng) > 1)
	{
		ll mid = (ok + ng) / 2;
		if (check(mid))
		{
			ok = mid;
		}
		else
		{
			ng = mid;
		}
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define NN 100000
#define NQ 50000

int linearSearch(int *,int ,int);

int main(){

  int n, S[NN], q, T[NQ];
  int i=0,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d", &S[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++)scanf("%d", &T[i]); 

  for(i=0;i<q;i++) if(linearSearch(S, T[i], n)) count++;

  printf("%d\n",count);
  return 0;
}

int linearSearch(int *A, int key, int n)
{

  int mid, left = 0, right = n;

  while(left<right){

    mid = (left + right)/2;

    if(A[mid] == key)    return 1;
    else if(key<A[mid])  right = mid;
    else                 left = mid +1;
  }
    return 0;
}

Measured memory_bytes: 1184
n=int(input())
l=[0]*(10**5)
for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            a=x**2+y**2+z**2+x*y+y*z+z*x
            l[a]+=1
for j in range(1,n+1):
    print(l[j])

Measured memory_bytes: 69352
((input) => {
  const data = input.split('\n');
  const N = +data[0];
  const tasks = data.slice(1, N + 1).map((line) => {
    const d = line.split(' ');
    return [+d[0], +d[1]];
  });

  tasks.sort((a, b) => a[1] - b[1]);

  var count = 0;
  for (var task of tasks) {
    count += task[0];
    if (count > task[1]) {
      console.log('No');
      return;
    }
  }

  console.log('Yes');
})(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 69892
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

typedef long long ll;


using namespace std;


int main(){
    int x;
    cin>>x;
    
    cout<<x*x*x<<endl;


    return 0;
};

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

//cmdで g++ test.cpp とするとコンパイルできる

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=(i%2)?-a.at(i):a.at(i);
  }
  cout<<ans<<endl;
}


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

int a, b;
char s[20], c='0', d='9';

int main(){
    scanf("%d %d", &a, &b);
    scanf("%s", s);

    int n=strlen(s);

    //printf("%d %d", c, d);
    bool flag = true;

    if(n != (a+b+1)){
        flag = false;
    } else {
        for(int i=0; i<n; i++){
            if( i == a){
                if(s[i] != '-')
                    flag = false;
            } else if(s[i] > 57 || s[i] <48){
                flag = false;
            }
        }
    }

    if(flag)
        printf("Yes\n");
    else
        printf("No\n");



}


Measured memory_bytes: 128
import java.util.Scanner;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in).useDelimiter("[,\\s]+");
        int as = 0, bs = 0, abs = 0, os = 0;

        while (scanner.hasNext()) {
            scanner.nextInt();
            String bloodType = scanner.next();
            if (bloodType.equals("A")) {
                as++;
            } else if (bloodType.equals("B")) {
                bs++;
            } else if (bloodType.equals("AB")) {
                abs++;
            } else {
                os++;
            }
        }
        System.out.println(as);
        System.out.println(bs);
        System.out.println(abs);
        System.out.println(os);
    }

    public static void main(String... args) {
        solve();
    }
}

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

namespace AGC001_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = 0;
            int N = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(L);
            for(int i = 0; i < N; i++)
            {
                num += L[i * 2];
            }
            Console.WriteLine(num);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

const int MOD = 1000000007;

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  vector<int> imos(n+1, 0);
  for(int i = 0; i < n; i++){
    imos[i+1] = imos[i] + a[i];
    imos[i+1] %= MOD;
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    ans = (ans + a[i] * (imos[n] - imos[i+1] + MOD) % MOD )% MOD;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<int> v;
    rep(i,N){
        if(S[i] == 'o')v.emplace_back(i);
    }
    //前から見たときのやつ
    //map<int, int> mae;
    vector<int> mae(K+1);
    int sz = v.size();
    int pre = v[0];
    int cnt = 1;
    mae[cnt] = pre;
    while(cnt < K){
        int next = *lower_bound(all(v), pre + C+1);
        cnt++;
        mae[cnt] = next;
        pre = next;
    }

    //逆から
    //map<int, int> usi;
    vector<int> usi(K+1);
    pre = v[sz-1];
    cnt = K;
    usi[cnt] = pre;
    while(cnt > 1){
        int idx = upper_bound(all(v), pre - C - 1) - v.begin();
        int next = v[idx-1];
        cnt--;
        usi[cnt] = next;
        pre = next;
    }
    rep1(i,K+1){
        if(mae[i] == usi[i]){
            cout << mae[i]+1 << endl;
        }
    }
}

Measured memory_bytes: 4236
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

bool a[2005][2005];
int down[2005][2005],l[2005],r[2005];

char str[2005];
int st[2005];

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++) {
  	scanf("%s",str+1);
  	for(int j=1;j<=m;j++) a[i][j]=(str[j]=='#');
  }
  for(int i=n;i>1;i--)
    for(int j=m;j>1;j--) a[i][j]=!(a[i-1][j-1]^a[i-1][j]^a[i][j-1]^a[i][j]);
  for(int i=n;i>1;i--)
    for(int j=m;j>1;j--) down[i][j]=(a[i][j])?down[i+1][j]+1:0;
  int ans=max(n,m);
  for(int i=2;i<=n;i++) {
  	int top=0;
  	st[top]=1;
  	for(int j=2;j<=m;j++) {
  		while (top&&down[i][j]<=down[i][st[top]]) top--;
  		l[j]=st[top]+1;
  		st[++top]=j;
	  }
	top=0;
	st[top]=m+1;
	for(int j=m;j>1;j--) {
		while (top&&down[i][j]<=down[i][st[top]]) top--;
		r[j]=st[top]-1;
		st[++top]=j;
	}
	for(int j=2;j<=m;j++) ans=max(ans,(r[j]-l[j]+2)*(down[i][j]+1));
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 19840
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.io.Serializable;

public class Main {
	public static void main(final String[] args){
    
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> list1 = new ArrayList<>();
        List<Integer> list2 = new ArrayList<>();
        List<Integer> list3 = new ArrayList<>();
        int count = 0;

        for(int i = 0; i < n ; i++){
            list1.add(sc.nextInt());
        }

        List<Integer> list4 = new ArrayList<>(list1);
        for(int i = 0; i < m ; i++){
            list2.add(sc.nextInt());
            list3.add(sc.nextInt());
        }

    
        for(int j = 0; j < m ; j++){
            if(list1.get(list2.get(j) - 1) < list1.get(list3.get(j) - 1)){
                list4.set(list2.get(j) - 1 , 0); 
            }else if(list1.get(list2.get(j) - 1).equals(list1.get(list3.get(j) - 1))){
                list4.set(list3.get(j) - 1 , 0); 
                list4.set(list2.get(j) - 1 , 0); 
            }else{
                list4.set(list3.get(j) - 1 , 0); 
            }
        }
        //System.out.println(list4);

        for(int i = 0; i < n ; i++){
            if(list4.get(i).equals(0)){
                count++;
            }
        }

        System.out.println(list1.size()-count);

        


    }
}

Measured memory_bytes: 67556
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			//long A = scan.nextLong();
			//double B = scan.nextDouble();
			BigDecimal s = scan.nextBigDecimal();//new BigDecimal(A);
			BigDecimal k = scan.nextBigDecimal();//new BigDecimal(B);
			BigDecimal C= s.multiply(k);
			
			
		
			
			
			/*
			long goukei = 0;
			int k = (int)(100.0*B);
			int a = k%10;//1
			k/=10;
			int b = k%10;//10
			k/=10;
			int c = k%10;//100
			
			
			
			goukei+=(long)c*A;
			long x = A*(long)b/10;
			long y = A*(long)a/100;
			
			goukei+=x+y;
			*/
			
	
			System.out.println(C.longValue());
			//System.out.println();
			
			
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 37492
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL count(LL x){
   LL c=0;
   while(x!=0){
      c++;
      x/=10;
   }
   return c;
}
int main(){
	LL N;
	cin>>N;
	LL ans=1000000000;
	for(LL i=1;i*i<=N;i++){
	    if(N%i!=0)continue;
	    LL A=i;
	    LL B=N/i;
	    ans=min(ans,max(count(A),count(B)));
	}
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void draw(int h,int w)
{
	rep(i, h)rep(j, w)
	{
		if((i+j)%2==0)cout<<'#';
		else cout<<'.';
		if(j == w-1)cout<<endl;
	}
}

void solve()
{
	vector<int> hs,ws;
	while (true)
	{
		int h, w; cin >> h >> w;
		if(!h && !w)break;
		hs.push_back(h);
		ws.push_back(w);
	}
	rep(i,sz(hs))
	{
		draw(hs[i],ws[i]);
		cout << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3108
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, x: "List[int]", y: "List[int]"):
    par = [-1] * N

    def getroot(a: int):
        if par[a] != -1:
            par[a] = getroot(par[a])
            return par[a]
        else:
            return a

    def union(a: int, b: int):
        par[getroot(b)] = getroot(a)

    xpts = sorted((xi, i) for i, xi in enumerate(x))
    ypts = sorted((yi, i) for i, yi in enumerate(y))
    edges = [
        (xj - xi, i, j) for (xi, i), (xj, j) in zip(xpts, xpts[1:])
    ] + [
        (yj - yi, i, j) for (yi, i), (yj, j) in zip(ypts, ypts[1:])
    ]
    edges.sort()
    ans = 0
    for cost, i, j in edges:
        if getroot(i) == getroot(j):
            continue
        union(i, j)
        ans += cost
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 57292
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,C,c,s,si,t,imos[100010],ret;
vector<map<int,int>> channel;
vector<pair<int,pi>> q;
int main(){
    I(n); I(C);
    channel.resize(C+1);
    q.resize(n);
    REP(i,n){
        I(s); I(t); I(c);
        q[i] = mp(s, mp(t,c));
    }
    sort(q.begin(),q.end());
    for (auto pg: q){
        s = pg.first;
        t = pg.second.first;
        c = pg.second.second;
        //cerr << s << " " << t << " " << c << endl;
        if (channel[c][s] != 0){
            channel[c][t] = channel[c][s];
            channel[c].erase(channel[c].lower_bound(s));
            //cerr << s << " " << t << " " << c << endl;
        } else {
            channel[c][t] = s;
        }
    }
    REP(i,C+1){
        for (auto pg : channel[i]){
            t = pg.first;
            s = pg.second;
            //cerr <<i << " "<< s << " " << t << endl;
            if (s) {
                imos[s-1]++;
                imos[t]--;
            }
        }
    }
    REP(i,100003){
        imos[i+1] += imos[i];
        ret = max(ret,imos[i]);
    }
    cout << ret << endl;
}


Measured memory_bytes: 11136
#include <stdio.h>
int main(void)
{
  int b1,b2,b3;

  scanf("%d %d %d",&b1,&b2,&b3);

  if(b1==1){
    if(b2==1)
      puts("Open");
    else
      puts("Close");
  }

  else{
    if(b3==1)
      puts("Open");
    else
      puts("Close");
  }

  return 0;
}

Measured memory_bytes: 584
n=int(input())
sp=[]
for i in range(n):
    s,p=input().split()
    sp.append([s,int(p),i+1])
sp.sort(key=lambda x:x[1],reverse=True)
sp.sort(key=lambda x:x[0])

for i in range(n):
    print(sp[i][2])

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

		    int a = sc.nextInt();
		    if(a % 2 == 0) {
		    	System.out.println(a * a / 4);
		    }
		    else {
		    	System.out.println((a+1)/2*(a/2));
		    }
		    sc.close(); }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

#define MOD 1000000007

ll modinv(ll a, ll m)
{
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
    ll N, K;
    cin >> N >> K;
    ll A[N];
    REP(i, N) cin >> A[i];

    ll ret0 = 0;
    ll ret1 = 0;

    REP(i, N-1) FOR(j, i+1, N) if (A[i] > A[j]) ++ret0;
    REP(i, N) REP(j, N) if (i != j && A[i] > A[j]) ++ret1;

    ll ret = K*ret0 % MOD;
    ret += K*(K-1)/2 % MOD * ret1 % MOD;
    ret %= MOD;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int abs(int s,int t){
	if(s>=t){
		return s-t;
	}
	else{
		return t-s;
	}
}
int main(){
	int x,a,b;
	cin >> x >> a >> b;
	if(abs(x,a)>abs(x,b)){
		cout << "B" << endl;
	}
	else if(abs(x,a)<abs(x,b)){
		cout << "A" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;


 
long long gcd( long long a, long long b ) {
    
    long long c = a%b;
    
    if ( !c ) { return b; }
    
    return gcd(b,c);
    
}
 
int main() {
    
    long long ans = 1;
    int N;
    cin >> N;
    vector<long long> T(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> T[i];
    }
    
    ans = T[0];
    for ( int i = 1; i < N; i++ ) {
        // cout << ans << endl;
        ans = ans * ( T[i] / gcd( ans, T[i] ) );
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

long long GCD(long long a, long long b)
{
	return a == 0 ? b : GCD(b % a, a);
}

void ABC118C()
{
	int N;
	cin >> N;
	vector<long long int> vals(N);
	for (auto& x : vals)
		cin >> x;

	long long int gcd = vals[0];
	for (int i = 1; i < N; ++i)
	{
		gcd = GCD(gcd, vals[i]);
	}
	cout << gcd << endl;
}

int main()
{
	ABC118C();
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int js(int a, int b)
{
	return b*2-a;
}
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<js(a,b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    for(int i=0; i<S.size(); i++){
        int a = S[i] - 'A';
        a = (a+N) % 26;
        S[i] = 'A' + a;
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
a = [int(i) for i in input().split()]
if sum(a)<x:
    ans = n-1
elif min(a)>x:
    ans = 0
else:
    a_new = sorted(a)
    i = 0
    while i < n:
        if x >= a_new[i]:
            x -= a_new[i]
        else:
            break
        i += 1
    ans = i
print(ans)

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::string s;
	std::cin >> s;
	s.erase(std::unique(s.begin(), s.end()), s.end());
	std::cout << s.size() << std::endl;
	return 0;
}



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

int main() {
    std::string S;
    std::cin >> S;

    int ans = 700;
    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] == 'o') {
            ans += 100;
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int a, b, c, k, ans = 0;
  cin >> a >> b >> c >> k;
  if (k <= a) {
    cout << k;
    return 0;
  } else {
    ans = a;
    k -= a;
  }
  if (k <= b) {
    cout << ans;
    return 0;
  } else {
    k -= b;
  }
  cout << ans - k;
  return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	char o;
	cin >> o;
	cout << (o=='a' || o=='i' || o=='u' || o=='e' || o=='o' ? "vowel" : "consonant") << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <iostream>

auto main () -> int
{
    constexpr auto n = 10;
    int highest [3] = {};
    
    for (int i = 0; i < n; ++ i)
    {
        int h;
        std::cin >> h;
        if (highest [0] < h)
        {
            highest [2] = highest [1];
            highest [1] = highest [0];
            highest [0] = h;
        }
        else if (highest [1] < h)
        {
            highest [2] = highest [1];
            highest [1] = h;
        }
        else if (highest [2] < h)
        {
            highest [2] = h;
        }
    }

    for (auto && elem : highest)
    {
        std::cout << elem << std::endl;
    }
}

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

vector<vector<int>> g(100010);
vector<vector<ll>> dp(2, vector<ll>(100010, 0));
ll mod = 1e9 + 7;

void dfs(int v, int p) {
    if (dp[0][v] != 0)
        return;
    dp[0][v] = dp[1][v] = 1;
    for (auto w : g[v])
        if (w != p) {
            dfs(w, v);
            dp[0][v] = dp[0][v] * (dp[0][w] + dp[1][w]) % mod;
            dp[1][v] = dp[1][v] * dp[0][w] % mod;
        }
}

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

    int n;
    cin >> n;

    rep(i, 1, n) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    dfs(0, -1);
    cout << (dp[0][0] + dp[1][0]) % mod << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

int main(){
    ll h,w,n;
    cin >> h >> w >> n;
    cout << ceil((double)n/max(h,w)) << endl;
    return 0;
}


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

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

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

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main() {
  double xa, ya, xb, yb, xc, yc, xd, yd;

  while(cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {  
    double x1 = xb-xa, y1 = yb-ya;
    double x2 = xd-xc, y2 = yd-yc;

    if(abs(x1*x2 + y1*y2) < EPS) cout << "YES" << endl;
    else cout << "NO" << endl;
  }  
}

Measured memory_bytes: 1216
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll a,b,aa,k,z=0;
    cin>>a>>b>>k;
    aa=a;
    a=max(z,a-k);
    k-=aa;
    if(k>0){
        b=max(z,b-k);
    }


    cout<<a<<" "<<b<<endl;
    return 0;
}





Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

    if (n == 0 && m == 0) { break; }

    vector<int> r;
    vector<int> c;

    for (int i = 0; i < n; i++) {
      int input;
      cin >> input;
      r.push_back(input);
    }

    for (int i = 0; i < m; i++) {
      int input;
      cin >> input;
      c.push_back(input);
    }

    vector<int> r_w(1500 * 1000, 0);
    vector<int> c_w(1500 * 1000, 0);

    for (int i = 0; i < n; i++) {
      int w = 0;
      for (int j = i; j < n; j++) {
        w += r[j];
        r_w[w] += 1;
      }
    }

    for (int i = 0; i < m; i++) {
      int w = 0;
      for (int j = i; j < m; j++) {
        w += c[j];
        c_w[w] += 1;
      }
    }

    /*
       cout << "__________" << endl;
       for (int i = 0; i < n; i++) {
       if (r_w[i] > 0) { cout << i << ": " << r_w[i] << endl; }
       }

       cout << "__________" << endl;
       for (int i = 0; i < m; i++) {
       if (c_w[i] > 0) { cout << i << ": " << c_w[i] << endl; }
       }
       */

    int result = 0;
    for (int i = 0; i < (1500 * 1000); i++) {
      // if (r_w[i] * c_w[i] > 0) cout << i << ": " << r_w[i] << " / " <<  c_w[i] << endl;
      result += r_w[i] * c_w[i];
    }

    cout << result << endl;
  }

  return 0;
}

Measured memory_bytes: 12812
N = gets.to_i
As = gets.split.map(&:to_i)

l,r = 0,0
xor,sum =As[0],As[0]
ans = 0
flag = false

loop do
    break if (r == N)
    if (r != 0)
        if flag
            xor ^= As[r]
            sum += As[r]
        else
            xor ^= As[l-1]
            sum -= As[l-1]
        end
    end

    if xor == sum
        if !flag
            flag = true
        end
        ans += r - l + 1
        r = r + 1
    else
        flag = false
        l = l + 1
    end
end

puts ans


Measured memory_bytes: 15372
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(123456789)
//#define LINF (long long int)(123456789012345678)
#define LINF (long long int)(((ll)1<<31)-1)
#define MAX_V 1000

const int MAX_N = 1 << 20;

//葉の数
int N;
//扱うデータ型をllとしている.適宜修正.
ll dat[2 * MAX_N - 1];

void init(int n_){
	//簡単のため, 要素数を2のべき乗に
	N = 1;
	while(N < n_) N *= 2;

	//初期化処理をここに書く
	rep(i,2 * N - 1){
		dat[i] = LINF;
	}
}

//k番目の値について, 処理を行う
//例として, aに変更している
void update(int k, int a){
	//葉のノード番号
	k += N-1;

	//葉の更新処理をここに書く.
	dat[k] = a;

	//登りながら更新.
	while(k > 0){
		k = (k-1) / 2;
		//中間ノードの更新処理をここに書く.
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}

	return;
}

//[a,b)における評価値を得る. ここでは最小値としている.
//nowが現在の接点番号, nowは[l, r)に対応している.
//呼ぶ時は query(a,b,0,0,N)
ll query(int a, int b, int now, int l, int r){
	//[a,b)と[l,r)が交差しなければ, 無を返す.
	//評価値が最小値ならばINT_MAX. 修正すること.
	if(r <= a || b <= l) return LINF;

	// [a, b)が[l, r)を完全に含んでいれば, このノードの値
	if(a <= l && r <= b){
		return dat[now];
	}else{
		//そうでなければ, 2つの個の複合値
		//ここでは, 2つの子の最小値. 修正すること.
		ll vl = query(a, b, now*2+1, l, (l+r)/2);
		ll vr = query(a, b, now*2+2, (l+r)/2, r);
		return min(vl, vr);
	}
}

int main(void){
	int n,q;cin>>n>>q;
	init(n);
	rep(i,q){
		ll com,x,y;
		cin>>com>>x>>y;
		if(com == 0){
			update(x, y);
		}else{
			cout<<query(x, y+1, 0, 0, N)<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5144
mod = 10**9 + 7

r1, c1, r2, c2 = map(int, input().split())

fact = [1] * (r2 + c2 + 3)
inv = [1] * (r2 + c2 + 3)
inv_fact = [1] * (r2 + c2 + 3)
for i in range(2, r2 + c2 + 3):
  fact[i] = fact[i-1] * i % mod
  inv[i] = -inv[mod % i] * (mod // i) % mod
  inv_fact[i] = inv_fact[i-1] * inv[i] % mod

total = fact[r2 + c2 + 2] * inv_fact[r2 + 1] * inv_fact[c2 + 1] % mod
total -= fact[r1 + c2 + 1] * inv_fact[r1] * inv_fact[c2 + 1] % mod
total -= fact[r2 + c1 + 1] * inv_fact[c1] * inv_fact[r2 + 1] % mod
total += fact[r1 + c1] * inv_fact[r1] * inv_fact[c1] % mod

print(total % mod)

Measured memory_bytes: 87148
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int a , b ;
	double x , y ;
	cin >> a >> b ;
	x = a ;
	y = b ;
	cout << a / b <<" "<< a % b <<" ";
	printf("%.8lf\n", x / y );
}

Measured memory_bytes: 1240
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[310000];
int q[310000];
vector<int>v[310000];
int bit[110000];
int sum(int a,int b){
	if(a)return sum(0,b)-sum(0,a-1);
	int ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
	return ret;
}
void add(int a,int b){
	for(;a<110000;a|=a+1)bit[a]+=b;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d",p+i,q+i);
		int len=q[i]-p[i]+1;
		v[len].push_back(i);
	}
	int rem=a;
	for(int i=1;i<=b;i++){
		rem-=v[i].size();
		for(int j=0;j<v[i].size();j++){
			add(p[v[i][j]],1);
			add(q[v[i][j]]+1,-1);
		}
		int ret=rem;
		for(int j=0;j<=b;j+=i){
			ret+=sum(0,j);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 14080
#include<iostream>
using namespace std;
int main(){
  int n,a,min=10000000000,max=-1000000000;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a<min)min=a;
    if(a>max)max=a;
  }
  cout<<max-min;
  return 0;
}

Measured memory_bytes: 256
# coding:utf-8
r,c = map(int, raw_input().split())
array = [[0 for i in range(c)] for j in range(r)]
for i in range(r):
    array[i] = map(int, raw_input().split())
for i in range(r):
    for j in range(c):
        print array[i][j],
    else:
        print sum(array[i])
total = 0
total2 = 0
for i in range(c):
    for j in range(r):
        total += array[j][i]
    else:
        print total,
        total2 += total
        total = 0
else:
    print total2



Measured memory_bytes: 4712
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
const int N=1e6+10;
using namespace std;
int a,b;

int main() {
  cin>>a>>b;
  if(a-2*b<=0){
      cout<<0<<endl;
      return 0;
  }
  else
      cout<<a-2*b<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int D = int.Parse(Console.ReadLine());
            int train = Math.Min(A, B);
            int bus = Math.Min(C, D);
            Console.WriteLine(bus + train);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define ll long long 
#define N 100005
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define piii pair<int, pii>
#define print(x) cout << #x << "=" << x << "\t";
#define endl "\n"
#define newline cout << endl;

int n;
vector<int> v[N];
ll dp[N][2];

void dfs(int id, int par) {
    dp[id][0] = dp[id][1] = 1;
    for(auto u : v[id]) {
        if (u == par)
            continue;
        dfs(u, id);
        dp[id][0] *= (dp[u][0] + dp[u][1]) % mod;
        dp[id][0] %= mod;
        dp[id][1] *= dp[u][0];
        dp[id][1] %= mod;
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); 
    cin >> n;
    for(int i=1;i<n;i++) {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1, 0);
    cout << (dp[1][0] + dp[1][1]) % mod;
    return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=10000;

int main(){
	int K;
	cin>>K;
	
	if(K%2)cout<<(K+1)*(K-1)/4;
	else cout<<K*K/4;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
  string str;
  cin >> str;
  int x=810;
  
  for(int i=0;i<str.size()-2;i++){
     x=min(x,abs(ctoi(str.at(i))*100+ctoi(str.at(i+1))*10+ctoi(str.at(i+2))-753));
  }

  cout << x <<endl;

}
      

Measured memory_bytes: 256