akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

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

    long long a[n];
    for(long long i=0;i<n;i++) cin >> a[i];

    long long cnt = 0;
    long long current_div0PlusSum = 0;
    long long current_div0MinusSum = 0;
    long long cnt_div0Plus = 0;
    long long cnt_div0Minus = 0;

    for(long long i=0;i<n;i++){
        current_div0PlusSum += a[i];

        if(i%2 ==0){
            if(current_div0PlusSum>0) continue;
            else{
                while(current_div0PlusSum <= 0){
                    current_div0PlusSum++;
                    cnt_div0Plus++;
                }
            }
        }else{
            if(current_div0PlusSum<0) continue;
            else{
                while(current_div0PlusSum >=0){
                    current_div0PlusSum--;
                    cnt_div0Plus++;
                }
            }
        }
    }

    for(long long i=0;i<n;i++){
        current_div0MinusSum += a[i];
        if(i%2 ==0){
            if(current_div0MinusSum<0) continue;
            else{
                while(current_div0MinusSum >=0){
                    current_div0MinusSum--;
                    cnt_div0Minus++;
                }
            }
        }else{
            if(current_div0MinusSum>0) continue;
            else{
                while(current_div0MinusSum <= 0){
                    current_div0MinusSum++;
                    cnt_div0Minus++;
                }
            }
        }
    }

    cout << min(cnt_div0Plus,cnt_div0Minus) << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, x;
    cin >> n >> x;
    long long ans = n;
    long long y = n - x;
    while(1){
        long long t = y/x;
        ans += t*x*2;
        long long newx = y % x;
        if(newx == 0){
            break;
        }
        y = x;
        x = newx;
    }
    ans -= x;
    cout << ans << endl;
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>

using namespace std;

long long mod = 1000000007;

long long binpow(long long x, long long k)
{
    if (k == 0)
    {
        return 1LL;
    }
    long long temp = binpow(x, k / 2);
    if (k % 2 == 1)
    {
        return (((temp * temp) % mod) * x) % mod;
    }
    else
    {
        return (temp * temp) % mod;
    }
}

long long modular_inverse(long long x)
{
    return binpow(x, mod - 2);
}

long long binomial(long long n, long long k)
{
    long long rez = 1;
    for (long long i = n - k + 1; i <= n; i++)
    {
        rez *= i;
        rez %= mod;
    }
    long long temp = 1;
    for (long long i = 1; i <= k; i++)
    {
        temp *= i;
        temp %= mod;
    }
    rez *= modular_inverse(temp);
    rez %= mod;
    return rez;
}

int main()
{
    int n;
    cin >> n;
    cout << (n + 1) / 2 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    // youtube解説
    
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    
    vector<int> dp(n + 1, inf);
    // goalから最短何手でいけるか
    
    queue<int> q;
    q.push(0); // goalからの最短手数
    dp[n] = 0;
    
    for (int i = n - 1; i >= 0; --i) {
        // goalからの最短手数を試す
        // ある頂点でその数字が使えなくなったら
        // 自分よりstartに近い頂点でその数字が使えることはないので捨てる
        
        while (1) {
            if (sz(q) == 0) { cout << -1 << endl; return 0; }
            if (q.front() != inf && sz(q) <= m) break; // 採用, popせずbreak
            // sample1 queue 0, 0 1, 0 1 inf, 0 1 inf 1,
            // 1 inf 1(goalから距離mより大きいから先頭捨てる)
            q.pop();
        }
        if (s[i] == '0') chmin(dp[i], q.front() + 1);
        q.push(dp[i]);
    }
    // rep(i, n + 1) cout << dp[i] << " "; cout << endl;
    int x = 0; // 現在地
    vector<int> ans;
    int rest = dp[0];
    while (x < n) { // x = nで終わり
        int i = 1; // 何個先に行くか
        --rest; // 1減った次の値
        // restになるまで
        while (dp[x + i] != rest) ++i;
        x += i;
        ans.eb(i);
    }
    rep(i, sz(ans)) cout << ans[i] << " "; cout << endl;
    
    
}



Measured memory_bytes: 1484
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX


void solve()
{
    int n;
    cin >> n;
    int k;
    cin >> k;
    set<int> q;
    rep(i,0,n-1)
        q.insert(i+1);
    rep(i,0,k-1)
    {
        int x;
        cin >> x;
        while(x--)
        {
            int u;
            cin >> u;
            q.erase(u);
        }
    }

    cout << q.size() << endl;
}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main(){
int N;
cin >> N;
int M;
cin >>M;

int safe[N+1]={};
int bstair;
for(int i=1;i<=M;i++){
cin >>bstair;
safe[bstair]=-1;
}
long long stair[N+2]={};
stair[0]=1;

for(int i=0;i<N;i++){
if(safe[i+2]!=-1 && i<N-1){
stair[i+2]+=stair[i]%1000000007;
}
if(safe[i+1]!=-1){
stair[i+1]+=stair[i]%1000000007;
}

}

stair[N]%=1000000007;



cout <<stair[N] <<endl;
 return 0;
}

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

namespace Atcoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static void print(object obj) { Console.WriteLine(obj); }

        static void Main(string[] args)
        {
            string a = Read();
            string b = Read();
            var c = a.ToList();
            var d = b.ToList();



            for (int j = 0; j < c.Count; j++)
            {
                var aa = c.Last();
                c.RemoveAt(c.Count-1);
                c.Insert(0,aa);
                bool cc = true;
                for (int i = 0; i < c.Count; i++)
                {
                    cc = (c[i] == d[i]) && cc;
                    if (!cc)
                        continue;
                }
                if (cc)
                {
                    print("Yes");
                    return;
                }
                  
            }

            print("No");
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
using namespace std;

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

	vector<int> ans(n, 0);
	
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			ans.at(a - 1)++;

		}
	}

	int res = 0;
	for (int i = 0; i < n; i++) {
		if (ans.at(i) == 0) res++;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3604
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
from collections import defaultdict
#すべてのkeyが用意されてる defaultdict(int)で初期化
from collections import OrderedDict
#順序を保ったdict
from math import ceil
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import Decimal #floatの高精度ver, 渡すのはstr型で
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
k=int(input())
print(50);n=50
if k==0:
    print(" ".join(["0"]*50));exit()
    
a=k//n
b=k%n
A=[a+i for i in range(50)]
for  i in range(b):
    A=[A[j]-1 if i!=j else A[j]+n for j in range(50)]
print(*A)

Measured memory_bytes: 9980
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<Integer> set = new HashSet<>();
		int n=sc.nextInt();
		for(int i=0; i<n; i++) {
			set.add(sc.nextInt());
		}
		System.out.println(set.size());
	}
}


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

using namespace std;

string toString(int a)
{
    ostringstream temp;
    temp << a;
    return temp.str();
}

int main()
{
	int a,b,c,cont=0;
	cin>>a>>b>>c;
	for(int i=a; i<=b; i++){
		if(c%i==0){
			cont++;
		}
	}
	cout<<cont<<endl;
}



Measured memory_bytes: 3116
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int n,a[200000],i,ans=0,k;

	cin>>n;
	
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	
	for(i=1;i<=n;i++){
		k=a[i];
		if(a[k]==i){
			ans=ans+1;
		}
	}
	ans=ans/2;
	
	cout<<ans<<"\n";
	
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
  int n,i,j,max=0;
  scanf("%d",&n);
  int num[n];
  for(i=1;i<n+1;i++)
  {
    scanf("%d",&num[i]);
    if(max<num[i]) max=num[i];
  }
  for(i=1;i<=max;i++)
  {
    int flag=1;
    for(j=1;j<n+1;j++)
    {
      if(num[j]%i!=0) flag=0;
    }
    if(flag==1) printf("%d\n",i);
  }
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int v[n][3],p=0;
for(int i=0;i<n;i++)
{
    for(int j=0;j<3;j++)
        cin>>v[i][j];
}
int f[n][3];
f[0][0]=v[0][0],f[0][1]=v[0][1],f[0][2]=v[0][2];
for(int j=1;j<n;j++)
{
    for(int k=0;k<3;k++)
        f[j][k]=0;
}
if(n==1)
{
    int d=max(v[0][0],v[0][1]);
    int e=max(d,v[0][2]);
    cout<<e;
}
else
{
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(k==j)
                    continue;
                if(f[i-1][j]+v[i][k]>=f[i][k])
                f[i][k]=f[i-1][j]+v[i][k];
            }
        }
    }
    for(int j=0;j<3;j++)
    {
        if(f[n-1][j]>p)
            p=f[n-1][j];
    }
    cout<<p;
}
}

Measured memory_bytes: 2560
from collections import deque
x,y,a,b,c = map(int,input().split())
ls = []
la = list(map(int,input().split()))
lb = list(map(int,input().split()))
lc = list(map(int,input().split()))
la.sort(reverse=True)
lb.sort(reverse=True)
lc.sort(reverse=True)
for i in range(a):
    ls.append([la[i],1])
for j in range(b):
    ls.append([lb[j],2])
for l in range(c):
    ls.append([lc[l],3])
ls.sort(key=lambda x:x[0],reverse=True)
ls = deque(ls)
s,t,k = 0,0,0
cnt = 0
while True:
    now = ls.popleft()
    if now[1] == 1:
        if s < x:
            cnt += now[0]
            s += 1
    elif now[1] == 2:
        if t < y:
            cnt += now[0]
            t += 1
    else:
        cnt += now[0]
        k += 1
    if s + t + k == x + y:
        print(cnt)
        break

Measured memory_bytes: 53236
#include <iostream>

using namespace std;

int main(void){
  int n,m;cin>>n>>m;
  int s=m;
  int ans=s;
  bool f = false;
  for(int i=0;i<n;++i){
    int a,b;cin>>a>>b;
    s+=a-b;
    ans = max(ans,s);
    if(s<0) f=true;
  }
  cout<<(f?0:ans)<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
using namespace std;

const int INF = 1000000000;

int main(){

while(1){

int n,k;

int r[102][102] = {0};

scanf("%d%d",&n,&k);

if(n == 0) break;

for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
if(i == j){
r[i][j] = 0;
}else{
r[i][j] = INF;
}
}
}

for(int i = 0;i < k;i++){
	int f;
	scanf("%d",&f);
	if(f == 0){
	int a,b;
	scanf("%d%d",&a,&b);
	if(r[a][b] == INF){
	printf("-1\n");
	}else{
	printf("%d\n",r[a][b]);
	}
	}else{
	int c,d,e;
	scanf("%d%d%d",&c,&d,&e);
	if(r[c][d] == INF || r[c][d] > e){
	r[c][d] = e; r[d][c] = e;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if(i == j) continue;
			r[i][j] = min(r[i][j],r[i][c]+e+r[d][j]);
			r[i][j] = min(r[i][j],r[i][d]+e+r[c][j]);
		}
	}
	}
	}
}
}
return 0;


}
			


Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
int a,b,c,d;
a=0;
b=0;
c=0;
d=0;

for(int i=0;i<6;i++){
int l;
cin>>l;
if(l==1)a++;
else if(l==2)b++;
else if(l==3)c++;
else d++;
}
string ans="NO";
if(a==1 && b==2&&c==2&&d==1)ans="YES";
cout<<ans<<endl;

}

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

int main() {
  int n;
  cin >> n;
  
  if(n >=30){
    cout << "Yes";
  }else{
    cout << "No";
  }
  //for(int i = 1;i<n;i++){
  //}
  
}

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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

int N,X[300010];
int ans[300010] = {0};
vector<pair<int,int> > V;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",X + i);
    for(int i = 0; i < N; i++)ans[X[i] - 1] = 1 + i;
    for(int i = 0; i < N; i++)V.push_back(mk(X[i],i));
    sort(V.begin(),V.end());
    vector<int> mem,mem2;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < V[i].se; j++)mem.push_back(V[i].se + 1);
        for(int j = 0; j < N - V[i].se - 1; j++)mem2.push_back(V[i].se + 1);
    }
    reverse(mem2.begin(),mem2.end());

    int cnt = 0;
    for(int i = 0; i < N * N; i++)
    {
        if(cnt != mem.size() && ans[i] == 0)
        {
            ans[i] = mem[cnt];
            cnt++;
        }
    }
    cnt = 0;
    for(int i = N * N - 1; i >= 0; i--)
    {
        if(cnt != mem2.size() && ans[i] == 0)
        {
            ans[i] = mem2[cnt];
            cnt++;
        }
    }
    for(int i = 1; i <= N; i++)
    {
        cnt = 0;
        for(int j = 0; j < N * N; j++)
        {
            if(X[i - 1] == j + 1)
            {
                if(cnt != i - 1)
                {
                    printf("No\n");
                    return 0;
                }
            }
            if(ans[j] == i)cnt++;
        }
    }
    printf("Yes\n");
    for(int i = 0; i < N * N; i++)
    {
        printf("%d",ans[i]);
        if(i != N * N - 1)printf(" ");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      string s, t;
      cin >> s >> t;
      if (t.size()<s.size())
      {
            cout << "No" << endl;
            return 0;
      }
      int flag=1;
      for (int i=0; i<s.size(); i++)
      {
            if (s[i]!=t[i])
            {
                  flag=0;
                  break;
            }
      }
      if (flag==1)
      {
            cout << "Yes" << endl;
      }
      else cout<< "No" << endl;
      return 0;
}


Measured memory_bytes: 3652
package main

import (
	"bytes"
	"fmt"
)

var (
	s string
)

func main() {
	fmt.Scan(&s)
	buf := bytes.NewBufferString("")

	for i, v := range s {
		if (i+1)%2 == 1 {
			buf.WriteRune(v)
		}
	}

	fmt.Println(buf.String())
}


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

int b[2000000];

void countingSort(int a[], int n, int maxa);

int main() {
	int i, j, n, maxa, a[2000000];
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0)maxa = a[0];
		else maxa = max(maxa, a[i]);
	}
	countingSort(a, n, maxa);
	for (i = 0; i < n; i++) {
		cout << b[i];
		if (i != n - 1)cout << " ";
	}
	cout << endl;
	return 0;
}

void countingSort(int a[], int n, int maxa) {
	int i, c[10001] = {};
	for (i = 0; i < n; i++) c[a[i]]++;
	for (i = 1; i < 10001; i++)c[i] += c[i - 1];
	for (i = n - 1; i >= 0; i--) {
		b[c[a[i]] - 1] = a[i];
		c[a[i]]--;
	}
}

Measured memory_bytes: 18736
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return (halfpower*halfpower) % modd;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (((halfpower*halfpower)%modd)*a)%modd;
      }
  }
};
 
int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, 1000);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        vector<ll> x;
        forr(i,0,n) { readll(xx); x.push_back(xx); }

        multiset<int> last;
        ll ret = 1;
        forr(i,0,n) {
            if (x[i]==0) {
                ret *= (3-last.size());
                last.insert(0);
            } else {
                int ct = last.count(x[i]-1);
                ret *= ct; ret = ret % modd;
                if (ct==0) {break;}
                last.erase(last.find(x[i]-1));
                last.insert(x[i]);
            }
        }

        cout << ret << endl;


    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 8684
N = int(input())
d = input().split(' ') #d = [d1, d2, d3...dN]
pattern = N * (N - 1) / 2
ans = []
for i in range(N):
	x = int(d[i])
	for j in range(N):
		y = int(d[j])
		if i > j:
			ans.append(x*y)
		else:
			pass
print(sum(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define all(a) a.begin(),a.end()
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){x=x>y?y:x;}
template<class T> inline void gmax(T &x,const T &y){x=x<y?y:x;}
template<class T> inline bool Gmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T> inline bool Gmax(T &x,const T &y){return x<y?x=y,1:0;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=200005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,a[N];
map<ll,int> cnt;

int main(){
#ifdef rqgao2014
	assert(freopen("input.txt","r",stdin));
#endif
	scanf("%d",&n);
	cnt[0]=1;
	ll sum=0,ans=0;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		sum+=x;
		ans+=cnt[sum];cnt[sum]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main{

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

		while(sc.hasNextInt()){
			
			
			
			int n=sc.nextInt();
			if(n==0) break;
			int count=0;
			boolean judge=true;
			for(int i=0;i<n;i++){
				int singi=sc.nextInt();
				if(singi>0) count++;
				if(singi>1) judge=false;
			}
			if(judge) System.out.println("NA");
			else System.out.println(count+1);
		}
	}

}

Measured memory_bytes: 158576
while true
  w, h = gets.split.map(&:to_i)
  break if w == 0
  xa = []; ya = []
  xa << 0; xa << w
  ya << 0; ya << h
  points = []
  gets.to_i.times do
    point = gets.split.map(&:to_i)
    points << point
    xa << point[0]; xa << point[2]
    ya << point[1]; ya << point[3]
  end
  xa.sort!.uniq!; ya.sort!.uniq!
  xs = xa.size; ys = ya.size
  fld = Array.new(ys+1){ Array.new(xs+1, true) }
  fld[0].fill(false); fld[ys].fill(false)
  fld.map{ |arr| arr[0] = arr[xs] = false }
 
  for point in points
    x1, y1, x2, y2 = point
    for y in (ya.index(y1)+1...ya.index(y2)+1)
      for x in (xa.index(x1)+1...xa.index(x2)+1)
        fld[y][x] = false
      end
    end
  end
  ret = 0
  for y in (1...ys)
    for x in (1...xs)
      next unless fld[y][x]
      arr = []
      arr << [y, x]
      until arr.empty?
        ny, nx = arr.shift
        [[-1,0],[0,-1],[1,0],[0,1]].each do |dy, dx|
          px = nx+dx; py = ny+dy
          if fld[py][px]
            arr << [py, px] 
            fld[py][px] = false
          end
        end
      end
      ret += 1
    end
  end
  p ret
end

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0xfff;
const int maxn = 100005;
ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int main()
{
     ll a,b;
     ll v,w;
     ll t;
     cin>>a>>v;
     cin>>b>> w;
     cin >> t;
     if(v<=w) cout<<"NO"<<endl;
     else {
         ll cha=v-w;
        if(a>b)
        {
            ll c=a-b;
            if(cha*t<c) cout<<"NO"<<endl;
            else cout<<"YES"<<endl;
        }
        else if(a<b) {
            ll c=b-a;
            if(cha*t<c) cout<<"NO"<<endl;
            else cout<<"YES"<<endl;
        }
     }
     return 0;
}

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

int main() {
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    int ans = 0;
    bool up = false;
    bool leftup = false;
    bool rightup = false;
    for(int i = 0; i < N; ++i) {
      string s; cin >> s;
      if(s == "lu") leftup = true;
      if(s == "ru") rightup = true;
      if(s == "ld") leftup = false;
      if(s == "rd") rightup = false;
      if(up == false && leftup && rightup) {
        up = true;
        ans++;
      }
      else if(up && leftup == false && rightup == false) {
        up = false;
        ans++;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>


using namespace std;

int main(){

  int r,c;
  int n,gsum,rsum;
  //nで初期化
  //vector< vector<int> > v(10, vector<int>(20,n));

  cin >>r >>c;
  vector< vector<int> > v(r+1, vector<int>(c+1));

  for(int i=0; i<r; i++){
    gsum=0;
    
    for(int j=0; j<c; j++){
      cin >>n;
      v[i][j]=n;
      gsum+=n;
    }
    //v[i].push_back(gsum);
    v[i][c]=gsum;
  }
  //行の追加
  /*
  v[0].push_back(99);
  cout<<v[0][5]<<endl;
  */

  
  //列の追加
  //  v.resize(r+1);
  
   for(int i=0; i<=c; i++){
     rsum=0;
     for(int j=0; j<r; j++){
       rsum+=v[j][i];
     }
     //v[r][c]
     v[r][i]=rsum;   
   }
  
  for(int i=0; i<r+1; i++){
    for(int j=0; j<c+1; j++){

      if(j==c){
	cout<<v[i][j];
      }
      else{
      cout<<v[i][j]<<" ";
      }
    }
    cout<<endl;
  }




  return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <iterator>
#include <algorithm>

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

    int arr[3] { 0, 0, 0 };
    for (auto c : s) {
        switch(c) {
            case 'a':
            arr[0]++;
            break;

            case 'b':
            arr[1]++;
            break;

            case 'c':
            arr[2]++;
            break;
        }
    }

    std::cout << ((*std::max_element(std::begin(arr), std::end(arr)) - *std::min_element(std::begin(arr), std::end(arr)) <= 1)?"YES":"NO") << std::endl;
    return 0;
}

Measured memory_bytes: 512
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (n, m) = (it.next().unwrap(), it.next().unwrap());
    println!("{}", n * m);
}

Measured memory_bytes: 2140
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

typedef long long LL;

int main() {
	int x, y;
	cin >> x >> y;
	bool ans = false;
	for (int i = 0; i <= 100; ++i) {
		for (int j = 0; j <= 100; ++j) {
			if (i + j == x && i * 2 + j * 4 == y) {
				ans = true;
			}
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
 
int main()
{
    char s1[200000],s2[200000];
    int count=0,c=0;
    
    s1[0] = getchar();
    
    while ( s1[c] != '\n') {
        c++;
        s1[c] = getchar();
    }
    
    s1[c] = '\0';
    s2[0] = getchar();
    c=0;
    
    while ( s2[c] != '\n') {
        c++;
        s2[c] = getchar();
    }
    
    s2[c] = '\0';
    
    for (int i=(c-1) ; i>=0 ; i--) {
        if ( s1[i] != s2[i] )
        count++;
    }
    
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 1956
#include <iostream>
#include <memory>

#define NIL nullptr

struct Node {
  int key;
  Node *parent, *left, *right;

  Node(int key) : key(key) { parent = left = right = NIL; }
  ~Node() {
    if (right != NIL)
      delete right;
    if (left != NIL)
      delete left;
  }
};

Node *getRoot(Node *t) {
  Node *n = t;
  while (t->parent != NIL) {
    n = n->parent;
  }
  return n;
}

void insert(Node *t, Node *z) {
  Node *root = getRoot(t);
  Node *y = NIL;
  Node *x = root;
  while (x != NIL) {
    y = x;
    if (z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if (y == NIL)
    root = z;
  else if (z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void printInorder(Node *t) {
  if (t != NIL) {
    printInorder(t->left);
    std::cout << " " << t->key;
    printInorder(t->right);
  }
}

void printPreorder(Node *t) {
  if (t != NIL) {
    std::cout << " " << t->key;
    printPreorder(t->left);
    printPreorder(t->right);
  }
}

bool find(Node *t, int k, bool found = false) {
  if (found)
    return true;
  if (t != NIL) {
    if (t->key == k)
      return true;
    if (t->key > k)
      return find(t->left, k, found);
    else
      return find(t->right, k, found);
  }
  return false;
}

int main() {
  int n, k;
  std::cin >> n;
  std::string cmd;
  Node *t = NIL;

  for (int i = 0; i < n; ++i) {
    std::cin >> cmd;
    switch (cmd.at(0)) {

    case 'i':
      std::cin >> k;
      if (t == NIL)
        t = new Node(k);
      else
        insert(t, new Node(k));
      break;

    case 'f':
      std::cin >> k;
      std::cout << (find(t, k) ? "yes" : "no") << std::endl;
      break;

    case 'p':
      printInorder(getRoot(t));
      std::cout << std::endl;
      printPreorder(getRoot(t));
      std::cout << std::endl;
      break;
    }
  }
}



Measured memory_bytes: 21872
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <cmath>

using namespace std;

using lli = long long;

#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) ()
#define debug_array(a) ()
#endif

int main() {
  int x, y;
  cin >> x >> y;
  cout << (x + y/2) << endl;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <cstdlib>

using namespace std;

int dist(int x1, int y1, int x2, int y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}

void solve(int n, int prev_t, int prev_x, int prev_y) {
  for(int i=0;i<n;i++) {
    int t, x, y;
    cin >> t;
    cin >> x;
    cin >> y;
    int d = dist(x, y, prev_x, prev_y);
    if(d > t) {
      cout << "No" << endl;
      return;
    }
    if((t - prev_t)%2 != d%2) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main() {
  int prev_t = 0, prev_x = 0, prev_y = 0, n;
  cin >> n;
  solve(n, prev_t, prev_x, prev_y);
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
l.sort
ans = 0
for i in range(n):
  for j in range(n):
    if i ==	j:
      continue
    for k in range(n):
      if j == k:
        continue
      elif i == k:
        continue
      if l[i] < l[j] < l[k]:
        if l[i] + l[j] > l[k]:
          ans += 1
print(ans)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int n, x, y;
int dis[2010];

int get_dis(int p, int q)
{
    int ret = abs(p-q);
    ret = min(ret, abs(p-x) + 1 + abs(q-y));
    ret = min(ret, abs(p-y) + 1 + abs(q-x));
    return ret;
}

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n >> x >> y;
    Forn(i, n) for(int j=i+1; j<=n; j++)
    {
        dis[get_dis(i, j)]++;
    }
    Forn(i, n-1) cout << dis[i] << "\n";
}


Measured memory_bytes: 256
N,M=map(int, input().split())
H=list(map(int, input().split()))
G={}
for i in range(M):
  a,b=map(int,input().split())
  try:
    G[a].append(b)
  except:
    G[a] = [b]
  try:
    G[b].append(a)
  except:
    G[b] = [a]

count = 0
for i in range(N):
  h = H[i]
  if G.get(i+1):
  	g = G[i+1]
  else:
    continue
  for j in range(len(g)):
    if H[g[j]-1] >= h:
      count += 1
      break

print(N-count)

Measured memory_bytes: 31756
N,X=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=0
for i in range(0,N):
    if X>=a[i]:
        X=X-a[i]
        b+=1
        if i==len(a)-1 and (X+a[i])!=a[i]:
            b-=1
            break
    else:
        break
print(b)

Measured memory_bytes: 61964
n,t = map(int,input().split())
c = [list(map(int,input().split())) for i in range(n)]
p = []

for i in range(n):
    if c[i][1] <= t:
        p.append(c[i][0])

if len(p) == 0:
    print('TLE')
else:
    p.sort()
    print(p[0])

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

int main(int argc, char *argv[])
{
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0; i < a.size(); ++i) cin >> a[i];

    int min_cost = INT_MAX;
    for(int x = -100; x <= 100; ++x)
    {
        int cost = 0;
        for(int y : a) cost += (x - y)*(x - y);
        min_cost = min(cost, min_cost);
    }

    cout << min_cost << endl;
}


Measured memory_bytes: 256
H,W,D=map(int,input().split())
A=[]

for h in range(H):
    A.append(list(map(int,input().split())))

pos= {}
for h in range(H):
    for w in range(W):
        pos[A[h][w]]=[h,w]

S=[0]*(H*W)
for d in range(D):
    tmp=0
    now=d+1
    while now+D<=H*W:
        nowh,noww=pos[now]
        newh,neww=pos[now+D]
        tmp+=abs(nowh-newh)+abs(noww-neww)
        S[now+D-1]=tmp
        now+=D

Q=int(input())
for i in range(Q):
    L,R=map(int,input().split())
    ans=S[R-1]-S[L-1]
    print(ans)


Measured memory_bytes: 28772
arr = gets.chomp.split(" ")
i=0
arr.map!{|item| item.to_i}
if arr[0] == arr[1]+arr[2]
  puts "Yes"
elsif arr[1] == arr[2] + arr[0]
  puts "Yes"
elsif arr[2] == arr[0] + arr[1]
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll i,j,n,a1,a2,a3;
    string sa,sb,sc;
    while(cin>>sa>>sb>>sc)
    {
        a1=0,a2=0,a3=0;
        n=1;
        while(1)
        {
            if(n==1)
            {
                if(a1>=sa.size())
                {
                    cout<<"A"<<endl;
                    break;

                }
                if(sa[a1]=='a'){n=1;a1++;}
                else if(sa[a1]=='b'){n=2;a1++;}
                else if(sa[a1]=='c'){n=3;a1++;}
            }
            else if(n==2)
            {
                if(a2>=sb.size())
                {
                    cout<<"B"<<endl;
                    break;
                }
                if(sb[a2]=='a'){n=1;a2++;}
                else if(sb[a2]=='b'){n=2;a2++;}
                else if(sb[a2]=='c'){n=3;a2++;}

            }
            else if(n==3)
            {
                if(a3>=sc.size())
                {
                    cout<<"C"<<endl;
                    break;
                }
                if(sc[a3]=='a'){n=1;a3++;}
                else if(sc[a3]=='b'){n=2;a3++;}
                else if(sc[a3]=='c'){n=3;a3++;}

            }
        }

    }
    return 0;

}


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

public class Main {

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

        final int n = sc.nextInt();

        final int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);

        System.out.println(a[a.length-1] - a[0]);
    }
}


Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC157D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NMK = ReadInt();
            int N = NMK[0];
            int M = NMK[1];
            int K = NMK[2];

            par = new int[N + 1];
            rank = new int[N + 1];
            init(N + 1);

            int[] friendCount = new int[N + 1];
            int[] brockCount = new int[N + 1];

            for (int i = 0; i < M; i++)
            {
                var ab = ReadInt();
                unite(ab[0], ab[1]);

                friendCount[ab[0]]++;
                friendCount[ab[1]]++;
            }

            for (int i = 0; i < K; i++)
            {
                var cd = ReadInt();
                if (!same(cd[0], cd[1])) continue;

                brockCount[cd[0]]++;
                brockCount[cd[1]]++;
            }

            int[] groupCount = new int[N + 1];
            for (int i = 1; i < N + 1; i++)
            {
                groupCount[find(i)]++;
            }

            for (int i = 1; i < N + 1; i++)
            {
                var cand = groupCount[find(i)] - friendCount[i] - brockCount[i] - 1;
                Console.WriteLine(cand);
            }
            Console.ReadKey();
        }

        //Union-find

        static int[] par;
        static int[] rank;

        static void init(int n)
        {
            for (int i = 0; i < n; i++)
            {
                par[i] = i;
                rank[i] = 0;
            }
        }

        static int find(int x)
        {
            if (par[x] == x)
            {
                return x;
            }
            else
            {
                return par[x] = find(par[x]);
            }
        }

        static void unite(int x, int y)
        {
            x = find(x);
            y = find(y);
            if (x == y) return;

            if (rank[x] < rank[y])
            {
                par[x] = y;
            }
            else
            {
                par[y] = x;
                if (rank[x] == rank[y]) rank[x]++;
            }

        }
        static bool same(int x, int y)
        {
            return find(x) == find(y);
        }







        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 19732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
    string s;cin>>s;
    if(c<d){
        if(b!=d){
            rep(i,b-1,d-2){
                if(s[i]==s[i+1] && s[i]=='#'){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        if(a!=c){
            rep(i,a-1,c-2){
                if(s[i]==s[i+1] && s[i]=='#'){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        cout<<"Yes"<<endl;
    }else{
        if(b!=d){
            rep(i,b-1,d-2){
                if(s[i]==s[i+1] && s[i]=='#'){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        if(a!=c){
            rep(i,a-1,c-2){
                if(s[i]==s[i+1] && s[i]=='#'){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        bool bol=false;
        rep(i,b-1,d-1){
            if(s[i]==s[i+1] && s[i]==s[i-1] && s[i]=='.'){
                bol=true;
            }
        }
        if(!bol){
            cout<<"No"<<endl;
            return 0;
        }
        cout<<"Yes"<<endl;
        return 0;
    }
    
    return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  if((a + b) % 2 != 0) {
    cout << "IMPOSSIBLE" << endl;
  }else {
    cout << (a + b) / 2 << endl;
  }
}

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


int dsum(int n){
    int sm = 0;
    while (n > 0) {
        sm += n % 10;
        n /= 10;
    }
    return sm;
}
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int count = 0;
    int d = 0;
    for (int i = 1; i <= n; i++){
        d = dsum(i);
        if(a <= d && b >= d){
            count += i;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
N=int(input())

A=[[0]*2 for i in range(N)]

for i,x in enumerate(input()):
	A[i][0]=ord(x)
for i,x in enumerate(input()):
	A[i][1]=ord(x)

t=[]
f=True
for x,y in A:
	if f:
		if x==y:
			t.append(0)
		else:
			t.append(1)
			f=False
	else:
		f=True

ans=1
if t[0]==0:ans*=3
else:ans*=6


for i in range(1,len(t)):
	if t[i-1]==t[i]==0:
		ans=(ans*2)%(1000000007)
	elif t[i-1]==0 and t[i]==1:
		ans=(ans*2)%(1000000007)
	elif t[i-1]==1 and t[i]==1:
		ans=(ans*3)%(1000000007)

print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main() {
	int x1 = in(), y1 = in(), x2 = in(), y2 = in();
	cout << y1 - y2 + x2 << ' ' << x2 - x1 + y2 << ' ' << y1 - y2 + x1 << ' ' << x2 - x1 + y1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 609
using namespace std;
char s[maxn*2][maxn*2];
int f[maxn*2][maxn*2];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%s",s[i]+1);
    for(int j=n+1;j<2*n;j++)
      s[i][j]=s[i][j-n];
  }
  for(int i=n+1;i<2*n;i++)
    for(int j=1;j<2*n;j++)
      s[i][j]=s[i-n][j];
  for(int i=1;i<2*n;i++)
    for(int j=1;j<2*n;j++){
      bool bg=1;
      for(int k=0;k<n;k++){
	if(s[i+k][j]!=s[i][j+k]) bg=0;
	if(bg) f[i][j]=k;
      }
    }
  int ans=0;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++){
      bool bg=1;
      for(int k=0;k<n;k++)
	if(f[i+k][j+k]<n-k-1) bg=0;
      ans+=bg;
    }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 6784
loop do
  n = gets.strip.to_i
  break if n == 0

  d = [2, 5, 3, 4, 1, 6]
  sum = 1

  n.times do
    op = gets.strip

    case op
    when 'North'
      # 0->4->1->5->0
      t = d[0]; d[0] = d[5]; d[5] = d[1]; d[1] = d[4]; d[4] = t
    when 'South'
      # 0->5->1->4->0
      t = d[0]; d[0] = d[4]; d[4] = d[1]; d[1] = d[5]; d[5] = t
    when 'East'
      # 2->5->3->4->2
      t = d[2]; d[2] = d[4]; d[4] = d[3]; d[3] = d[5]; d[5] = t
    when 'West'
      # 2->4->3->5->2
      t = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = d[4]; d[4] = t
    when 'Right'
      # 0->3->1->2->0
      t = d[0]; d[0] = d[2]; d[2] = d[1]; d[1] = d[3]; d[3] = t
    when 'Left'
      # 0->2->1->3->0
      t = d[0]; d[0] = d[3]; d[3] = d[1]; d[1] = d[2]; d[2] = t
    end

    sum += d[4]
  end

  puts sum
end

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int x=n/2,y=n/2+1,fld[n][n];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				fld[i][j]=-1;
			}
		}
		fld[x][y]=1;
		for(int i=2;i<=n*n;i++){
			x++;y++;
			while(1){				
				if(x<0)x=n-1;
				if(x>=n)x=0;
				if(y<0)y=n-1;
				if(y>=n)y=0;
				if(fld[x][y]==-1){
					fld[x][y]=i;
					break;
				}
				if(fld[x][y]!=-1){
					x--;y++;
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				printf("%4d",fld[j][i]);
			}
			cout<<endl;
		}
	}		
}

Measured memory_bytes: 1192
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  //int xx = -1;
  int ans = 1e9;
  
  if (n == 1){
    print(1); return 0;
  }
  rep(i, n) {
    rep(j, n) {
      if (i == j) continue;
      int cnt = 0;
      int dx = x[i] - x[j], dy = y[i] - y[j];
      rep(k, n) {
        rep(l, n) {
          if (k == l) continue;
          cnt += (x[k] - x[l] == dx && y[k] - y[l] == dy);
        }
      }
      chmin(ans, n - cnt);
    }
  }

  print(ans);

  return 0;
}

Measured memory_bytes: 256