akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n+1],c[n+1];
	a[0]=0;
	b[0]=0;
	c[0]=0;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i]>>c[i];
	bool f=true;
	for(int i=1;i<=n;i++)
	{
		int t=a[i]-a[i-1];
		int dis=fabs(b[i]-b[i-1])+fabs(c[i]-c[i-1]);
		if(t<dis)
		{
			f=false;
			break;
		}
		else if((t-dis)%2==1)
		{
			f=false;
			break;
		}
	}
	if(f)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int main(){
    long long n,k;
    long long ans=0,tmp;
    cin>>n>>k;
    for(long long i=k+1;i<=n;i++){
    	tmp=n%i;
    	ans+=(n/i)*(i-k);
    	ans+=max(tmp-k+1,(long long)0);
	}
	if(k==0)ans=n*n; 
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
a,b,k = map(int, input().split())
n = a
c = 1
while n <= b:
    print(n)
    n += 1
    c += 1
    if c > k:
        break
if n <= (b - k):
    n = b - k + 1

c = 1
while n <= b:
    print(n)
    n += 1
    c += 1
    if c > k:
        break

Measured memory_bytes: 38384
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



k, q = LI()
D = LI()
for _ in range(q):
    n, x, m = LI()
    ret = x
    D_m = [d % m for d in D]
    zero_or_one = list(accumulate([1 if d == 0 else 0 for d in D_m]))
    Dm_acc = list(accumulate(D_m))
    ret = x + (n - 1) // k * Dm_acc[-1]
    zero_ret = (n - 1) // k * zero_or_one[-1]
    if (n - 1) % k:
        ret += Dm_acc[(n - 1) % k - 1]
        zero_ret += zero_or_one[(n - 1) % k - 1]
    print(n - 1 - (ret // m - x // m) - zero_ret)

Measured memory_bytes: 119260
s = input().strip()
n = len(s)
ret = 0
a = 0
i = 0
while i < n:
    if s[i] == 'A':
        a += 1
        i += 1
    elif s[i] == 'B':
        if i < n - 1 and s[i + 1] == 'C':
            ret += a
            i += 2
        else:
            a = 0
            i += 1
    else:
        a = 0
        i += 1
print(ret)


Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mx=0x7fffff;
int main()
{
	int i,a,b,c;
	cin>>a>>b>>c;
	for(i=a;i<=mx;i+=a){
		if(i%b==c){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	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++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  int a,b;
  cin >> a >> b;
  if( (a+b)%2 == 0 ) cout << ((a+b)/2);
  else cout << "IMPOSSIBLE";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
typedef pair<int,int>pii;
int n,m,i,j,x,y,c[N],d[N],ans;
vector<int>e[N],ee[N];
int dad[N][N],bel[N][N],xb,id[N],en[N];
void getfa(int x,int fa){dad[::i][x]=fa;for(int y:e[x])if(y!=fa)getfa(y,x);}
void add(int x,int y){
	if(x==y || bel[y][x]==x)return;
	if(bel[x][y])return add(y,bel[x][y]);
	if(bel[y][x])return add(x,bel[y][x]);
	bel[y][x]=x;bel[x][y]=y;
	static int q[N];int t,w,u;
	vector<pii>v;
	for(q[t=0,w=1]=y;t<w;)for(int i:e[u=q[++t]])if(i!=dad[x][u]){if(bel[x][i])v.push_back(pii(y,i));else q[++w]=i,bel[x][i]=y;}
	swap(x,y);
	for(q[t=0,w=1]=y;t<w;)for(int i:e[u=q[++t]])if(i!=dad[x][u]){if(bel[x][i])v.push_back(pii(y,i));else q[++w]=i,bel[x][i]=y;}
	for(auto u:v)add(u.first,u.second);
}
void getdfn(int x,int fa){id[x]=++xb;for(int y:e[x])if(y!=fa)getdfn(y,x);en[x]=xb;}
bool vi[N];
void dfss(int x){vi[x]=1;for(int y:ee[x])if(!vi[y] && id[x]<=id[y] && id[y]<=en[x])++ans,dfss(y);}
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<n;++i)scanf("%d%d",&x,&y),e[x].push_back(y),e[y].push_back(x);
	for(i=1;i<=n;++i)getfa(i,0);
	for(i=1;i<=m;++i){
scanf("%d%d",&x,&y),add(x,y);
}
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)if(bel[i][j]==j)ee[i].push_back(j);
	for(i=1;i<=n;++i)
		xb=0,getdfn(i,0),memset(vi+1,0,n),dfss(i);
	printf("%d\n",ans/2);
	return 0;
}

Measured memory_bytes: 32128
#include<stdio.h>
int main(void)
{
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    S=S%3600;
    m=S/60;
    s=S%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}   

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <map>
using namespace std;
main(){
	int n,c,m,x;
	for(;cin>>n,n;){
		string s,t;
		map<string,int>M;
		for(;n;n--)cin>>s>>c,M[s]=c;
		for(cin>>n;n;M[s]=M[s]<x?M[s]:x,n--)for(x=0,cin>>s>>m;m;m--)cin>>t,x+=M[t];
		cin>>s,cout<<M[s]<<endl;
	}
}

Measured memory_bytes: 1224
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main(){
  auto x = readln.chomp.to!int;
  auto a = readln.chomp.to!int;
  auto b = readln.chomp.to!int;
  writeln((x - a) % b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  ll n,k;
  cin>>n>>k;
  ll h[n+1];
  h[0]=0;
  for(int i=1;i<=n;i++)
    cin>>h[i];
  
  ll dp[n+1];
  memset(dp,0,sizeof dp);
  for(int i=2;i<=n;i++)
  {
    dp[i]=INT_MAX;
    for(int j=(i-1);j>=max(i-k,1ll);j--)
      dp[i]=min(dp[i],(dp[j]+labs(h[j]-h[i])));
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	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]++;
		}
	}

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

int h, w;
string b[102];

void dfs(int y, int x){
	int dx[4] = {-1, 0, 1, 0};
	int dy[4] = {0, 1, 0, -1};
	char a = b[y][x];

	b[y][x] = '.';
	REP(i, 4){
		if(b[y+dy[i]][x+dx[i]] == a){
			dfs(y+dy[i], x+dx[i]);
		}
	}
}

int main(void){
	cin >> h >> w;
	while(h != 0 || w != 0){
		int res = 0;
		b[0] = string(w+2, '.');
		b[h+1] = string(w+2, '.');
		for(int i = 0;i < h;i++){
			cin >> b[i+1];
			b[i+1] = '.' + b[i+1] + '.';
		}
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(b[i+1][j+1] != '.'){
					dfs(i+1, j+1);
					res++;
				}
			}
		}
		cout << res << endl;
		cin >> h >> w;
	}
	return 0;
}

Measured memory_bytes: 2336
fn main() {
    let v: Vec<i32> = read_vec();
    println!(
        "{}",
        if v.iter().any(|&x| x % 2 == 0) {
            "No"
        } else {
            "Yes"
        }
    );
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <queue>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define all(v) v.begin(),v.end()
#define show(v) for(int i = 0; i < v.size(); ++i){cout<<i<<": "<<v[i]<<" "<<endl;}
#define enld endl
#define INF 999999999

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a=0, b=0;
	loop(i, 4)
	{
		int t;
		cin >> t;
		a += t;
	}
	loop(i, 4)
	{
		int t;
		cin >> t;
		b += t;
	}
	cout << max(a, b) << endl;
	return 0;
}



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

INF = 10**10
dp = [[-INF]*2 for i in range(N+1)]
dp[0][0] = 0

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
for i, (a1,a2) in enumerate(zip(A1,A2)):
    # 右
    dp[i+1][0] = dp[i][0] + a1
    # 下
    dp[i+1][1] = max(dp[i][1] + a2, dp[i+1][0] + a2)

print(max(dp[N]))

Measured memory_bytes: 3064
#include<stdio.h>
struct
{
    int Q[10000];
    int head=0,last=0;
    void push_Back(int x)
    {
        Q[last]=x;
        last=(last+1)%10000;
    }
    int pop()
    {
        int x=Q[head];
        head=(head+1)%10000;
        return x;
    }
    bool Empty()
    {
     return head==last;
    }
}myqueue;
const int N=100;
const int nil=10000000;
int n;
int tu[N][N];
int juli[N];
void BFS()
{
    for (int i=0;i<n;i++)
        juli[i]=nil;
  myqueue.push_Back(0);
  juli[0]=0;
  int u;
  while(!myqueue.Empty())
  {
      u=myqueue.pop();
      for (int v=0;v<n;v++)
      {
          if(tu[u][v]==0) continue;
          if(juli[v]!=nil) continue;
          juli[v]=juli[u]+1;
          myqueue.push_Back(v);
      }
  }
  for (int i=0;i<n;i++)
  {
      printf("%d %d\n",i+1,((juli[i]==nil)?(-1):juli[i]));
  }
}
int main()
{
    int u,v,k;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
    {
        scanf("%d%d",&u,&k);
        u--;
        for (int j=0;j<k;j++)
        {
            scanf("%d",&v);
            v--;
            tu[u][v]=1;
        }
    }
    BFS();
    return 0;
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}


struct UnionFind{
  int num;
  vector<int> rs,ps;
  UnionFind(){}
  UnionFind(int n):num(n),rs(n,1),ps(n,0){iota(ps.begin(),ps.end(),0);}
  int find(int x){
    return (x==ps[x]?x:ps[x]=find(ps[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(rs[x]<rs[y]) swap(x,y);
    rs[x]+=rs[y];
    ps[y]=x;
    num--;
  }
  int size(int x){
    return rs[find(x)];
  }
  int count() const{
    return num;
  }
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);


  int n,m;
  cin>>n>>m;
  UnionFind uf(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf.unite(a,b);
  }
  cout<<uf.count()-1<<newl;
  return 0;
}


Measured memory_bytes: 3992
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();

			int m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}

			String in[] = new String[n];

			for (int i = 0; i < n; i++) {
				in[i] = sc.next();
			}

			String buffer = "";
			
			for (int i = 0; i < m; i++) {
				buffer += sc.next();
			}
			int len = buffer.length();

			boolean[][] ans = new boolean[1 << n][len + 100];
			Arrays.fill(ans[0],true);
			long res = 0;
			for (int j = 0; j < len; j++) {
				for (int i = 0; i < n; i++) {
					if (buffer.startsWith(in[i])) {
						for (int k = 0; k < 1 << n; k++) {
							if (!ans[k][j]) {
								continue;
							}
							int shi = 1 << i;
							if ((k & shi) != 0) {
								continue;
							}
							if(ans[k|shi][j+in[i].length()]){
								continue;
							}
							ans[k | shi][j + in[i].length()] = ans[k][j];
							if ((k | shi) == (1 << n) - 1) {
//								System.out.println(j);
								res++;
							}
						}
					}

				}
				buffer = buffer.substring(1);
//				System.out.println(buffer);
			}
			System.out.println(res);
		}
	}
	

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

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

#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    REP(i,n) cin>>l[i];
    sort(ALL(l));
    int sum = 0;
    REP(i,n-1) sum += l[i];
	cout << ((sum > l[n-1]) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;


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

ll lcm(ll a, ll b) {
    ll ans = a*b/gcd(a, b);
    return ans;
}

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll l = lcm(n, m);
    bool f = true;
    map<ll, char> as;
    map<ll, char> at;
    for(ll i = 0; i < n; ++i) as[i*(l/n)] = s[i];
    for(ll i = 0; i < m; ++i) at[i*(l/m)] = t[i];
    for (auto x: as) {
        if (at.count(x.first) != 0) {
            if (at[x.first] != x.second) f = false;
        }
    }

    if (f) cout << l << std::endl;
    else cout << -1 << std::endl;
    return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1000
#define INF 1e9
typedef pair<double,int> P;
 
int H,W;
 
double make(int x,int y){
    if(x == 0) return INF;
    return (double)y / x;
}
 
int pat(char a,char b,char c,char d){
    if(a == '.' && b == '#' && 
       c == '#' && d == '#'){
	return 1;
    }
    if(a == '#' && b == '.' && 
       c == '.' && d == '.'){
	return 1;
    }
    if(a == '.' && b == '.' && 
       c == '.' && d == '#'){
	return -1;
    }
    if(a == '#' && b == '#' && 
       c == '#' && d == '.'){
	return -1;
    }
  
    return 0;
}
 
int main(){
    string in;
    char a[MAX][MAX];
 
    for(int i = 0 ; i < MAX ; i++){
	for(int j = 0 ; j < MAX ; j++){
	    a[i][j] = '.';
	}
    }
 
    cin >> H >> W;
    for(int i = H ; i > 0 ; i--){
	cin >> in;
	for(int j = 1 ; j <= W ; j++){
	    a[i][j] = in[j-1];
	}
    }
 
    vector<P> v;
    for(int i = 0 ; i <= H ; i++){
	for(int j = 0 ; j <= W ; j++){
	    char u1 = a[i+1][j],u2 = a[i+1][j+1];
	    char u3 = a[i][j],u4 = a[i][j+1];
	    int n = pat(u1,u2,u3,u4);
 
	    if(n != 0){
		double r = make(j,i);
		v.push_back(P(r,n));
	    }
	}
    }
 
    sort(v.begin(),v.end());
    int len = (int)v.size(),ans = 1,sum = 1;
    for(int i = 0 ; i < len ; i++){
	sum += v[i].second;
	ans = max(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

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

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

  if (a > b) {
    cout << 0 << endl;
  } else if (n == 1) {
    if (a == b) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  } else {
    cout << (b - a) * (n - 2) + 1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string n;
    cin >> n;
    char c;
    if (n[0] < n[1]) {
        c = n[0] + 1;
    } else if (n[0] == n[1]) {
        if (n[1] < n[2]) c = n[0]+1;
        else c = n[0];
    } else {
        c = n[0];
    }
    for (int i = 0; i < n.size(); ++i) {
        n[i] = c;
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}

    int N;

int si (vector<char> &c, int i) {
    while (i < N+1 && c[i] != 'W') {
        i++;
    }
    return i;
}

int sj (vector<char> &c, int j) {
    while (j > -2 && c[j] != 'R') {
        j--;
    }
    return j;
}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    

    cin >> N;
    vector<char> c(N);
    REP (i, N) {
        cin >> c[i];
    }

    int i = 0, j = N-1;
    while (i < j) {
        j = sj(c,j);
        if (j == -1) {
            break;
        }
        i = si(c,i);
        if (i == N) {
            break;
        }
        swap (c[i],c[j]);
        ans++;
    }

    cout << ans-1 << endl;


    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc174/abc174_d && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc174/abc174_d && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc174/abc174_d && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3700
<?php
fscanf(STDIN, "%d %d", $price,$max);
$checkList = explode( " ", trim(fgets(STDIN)) );

$notPay = true;
$result = $price;
while( $notPay )
{
  $pay = true;
  foreach( $checkList as $check )
  {
    if ( strpos( $result, $check ) === false ) {
    }
    else
    { $pay = false; break; }
  }

  if( $pay ) { break; }
  
  $result++;
}

echo $result;

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a((x%mod+mod)%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend std::ostream& operator<<(std::ostream &os, const modint &X){
    return os << X.a;
  }
  friend std::istream& operator>>(std::istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};


int main(){
  using mint = modint<(int)1e9+7>;
  // using mint = long long;
  int N, K;
  cin >> N >> K;
  vector<long long> pos, neg;
  for(int i = 0; i < N; ++i){
    long long a;
    cin >> a;
    if(a >= 0) pos.push_back(a);
    else neg.push_back(a);
  }
  int p = pos.size(), n = neg.size();
  sort(pos.rbegin(), pos.rend());
  sort(neg.begin(), neg.end());
  mint ans = 1;

  if(n == N and K%2){
    reverse(neg.begin(), neg.end());
    for(int i = 0; i < K; ++i)
      ans *= neg[i];
    cout << ans << endl;
    return 0;
  }
  int i = 0, j = 0;

  while(K > 0){
    if(K == 1){
      --K;
      if(i < p) ans *= pos[i++];
      else ans *= neg[j++];
      break;
    }else{
      if(i+1 == p and j+1 == n){
        ans *= pos[i++];
        ans *= neg[j++];
        K -= 2;
        break;
      }
      long long pp = -1, nn = -1;
      if(i+1 < p) pp = pos[i]*pos[i+1];
      if(j+1 < n) nn = neg[j]*neg[j+1];
      if(pp > nn) i += 2, ans *= pp;
      else j += 2, ans *= nn;
      K -= 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5472
#include <iostream>

using namespace std;

bool sosuu[10000000] = {0};

int main() {
	fill(&sosuu[0], &sosuu[0]+10000000, true);
	sosuu[0] = false;
	sosuu[1] = false;
	for (int i = 2; i < 10000000; ++i) {
		for (int j = i*2; j < 10000000; j += i) {
			sosuu[j] = false;
		}
	}

	int n;
	while ( cin >> n, n ) {
		int l = n, r = n;
		for (; l > 0; --l) {
			if (sosuu[l]) {
				break;
			}
		}
		for (; r < 10000000; ++r) {
			if (sosuu[r]) {
				break;
			}
		}
		cout << r-l << endl;
	}
}

Measured memory_bytes: 10924
#include "bits/stdc++.h"

using namespace std;

using l = long;
using ll = long long;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using pii = vector<pair<int, int>>;

int main()
{
    priority_queue<int, vi, greater<int>> pq;
    int N; cin >> N;
    vi A(N), idx(N + 1, -1);

    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        idx[A[i]] = i + 1;
        pq.push(A[i]);
    }

    for (int i = 0; i < N; ++i) {
        cout << idx[pq.top()] << " ";
        pq.pop();
    }

    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<int> A(101, 0);

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) scanf("%d", &A[i]);
    sort(A.begin(), A.end(), greater<int>());
    
    int a = 0, b = 0;
    for(int i = 0; i < N; ++i){
        if(i % 2 == 0) a += A[i];
        else b += A[i];
    }
    printf("%d\n", a - b);
    
    return 0;
}


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

int main(void){
   int N,M;
   cin>>N>>M;
   long long N1=min(N,M);
   long long M1=max(N,M);
   if(N1==1&&M1==1) cout<<1<<endl;
   else if(N1==1&&M1!=1) cout<<M1-2<<endl;
   else cout<<(N1-2)*(M1-2)<<endl;
   return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<int, int> mpa, mpb;
  rep(i, n) {
    int a;
    cin >> a;
    mpa[a]++;
  }
  int m;
  cin >> m;
  vector<int> B(m);
  rep(i, m) {
    int b;
    cin >> b;
    B[i] = b;
    mpb[b]++;
  }
  
  bool flag = true;
  rep(i, m) {
    if (mpb[B[i]] > mpa[B[i]]) {
      flag = false;
      break;
    }
  }
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k <= a) {
    cout << k << endl;

  } else if (a < k && k - a < b) {
    cout << a << endl;
  } else {
    cout << 2 * a - k + b << endl;
  }
}

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

#define pb push_back
#define f first
#define s second

using namespace std;

const int N = 1e5 + 10;
const int md = 1e9 + 7;

int n;

int a[N];

long long sum;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    if (sum % (n * 1LL * (n + 1) / 2) != 0) return cout << "NO", 0;
    int cycle = sum / (n * 1LL * (n + 1) / 2);
    for (int i = 1; i <= n; i++) {
        int nxt = (i + 1) % n;
        if (!nxt) nxt += n;
        if (cycle - (a[nxt] - a[i]) >= 0 && (cycle - (a[nxt] - a[i])) % n == 0)
            continue;
        else return cout << "NO", 0;
    }
    cout << "YES";
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int main(){
    int n,W;
    while(cin>>n>>W){
        vector<int>v(n);
        vector<int>w(n);
        rep(i,n)cin>>v[i]>>w[i];
        int dp[n+1][W+1];
        rep(i,n+1)rep(j,W+1)dp[i][j] = 0;
        rep(i,n){
            rep(j,W+1){
                if(j-w[i]>=0)dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
                dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            }
        }
        cout<<dp[n][W]<<endl;
    }
}




Measured memory_bytes: 7052
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<long long,int> P;
static const int INF=1<<24;

string s;

int main(){
	while(cin>>s,s!="0000"){
		if(s=="6174"){
			cout<<0<<endl;
			continue;
		}
		if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){
			cout<<"NA\n";
			continue;
		}
		int c=0;
		while(1){
		int MIN,MAX;
		vector <int> v;
		rep(i,4){
			s[i]-='0';
			v.PB(s[i]);
		}
		MIN=0;MAX=0;
		sort(v.begin(),v.end());
		rep(i,4){
			MIN*=10;
			MIN+=v[i];
		}
		sort(v.begin(),v.end(),greater<int>());
		rep(i,4){
			MAX*=10;
			MAX+=v[i];
		}
			int a=MAX-MIN;
			if(MAX-MIN==6174) break;
			
			else{
				rep(i,4){
					s[3-i]=a%10;
					a/=10;
				}
				c++;
			}
		}
		cout<<c+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
# 2020/01/18
# キーエンス プログラミング コンテスト 2020 - A

# Input
h = int(input())
w = int(input())
n = int(input())

# Calc
if h > w:
    wkv = h
else:
    wkv = w

ans = int(n / wkv) + 1

if (n % wkv) == 0:
    ans = ans - 1

# Output
print(ans)

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll n,k; 
vll G[100100];
ll dist[100100];

void dfs(ll v, ll p){
  ll cnt;
  if(v==0) cnt=k;
  else cnt=k-1;
  for(auto nv: G[v]){
    if(nv==p) continue;
    dist[nv]=--cnt;
    dfs(nv,v);
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>k;
  rep(i,n-1){
    ll a,b; cin>>a>>b; a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  dist[0]=k;
  dfs(0,-1);
  ll ans=1;
  rep(i,n){
    (ans*=dist[i])%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            a[i][j] = int(s[j] == '#');
        }
    }
    int res = 0;
    for (int mask_rows = 0; mask_rows < (1 << n); mask_rows++) {
        for (int mask_cols = 0; mask_cols < (1 << m); mask_cols++) {
            int pre_res = 0;
            for (int i = 0; i < n; i++) {
                if (mask_rows & (1 << i)) {
                    for (int j = 0; j < m; j++) {
                        if (mask_cols & (1 << j)) {
                            pre_res += a[i][j];
                        }
                    }
                }
            }
            if (pre_res == k) {
                res++;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3644
N, K = map(int, (input().split()))
ans_zero = set()
ans_notzero = set()
for i in range(1, N+1):
    if i % K == 0:
        ans_zero.add(i)

    elif i % K == K / 2:
        ans_notzero.add(i)

print(len(ans_zero) ** 3 + len(ans_notzero) ** 3)

Measured memory_bytes: 20884
a = list(input())
b = list(input())
c = list(input())

t = a.pop(0)
l = 0
while True:
    if t == 'a':
        if len(a) == 0:
            break
        t = a.pop(0)
    elif t == 'b':
        if len(b) == 0:
            break
        t = b.pop(0)
    elif t == 'c':
        if len(c) == 0:
            break
        t = c.pop(0)

print(t.upper())

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


int main(){
	long long x,y;
	cin >> x >> y;
	long long c = y / x;
	for(long long i = 60;i >= 0;i--){       
		if((1LL << i) <= c) { //         
			cout << i + 1;         
			return 0;   
		}   
	} 
	return 0;       
}

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

struct edge{
  int to,cost;
  edge(int t, int c){
    to = t; cost = c;
  }
};

typedef vector<vector<edge> > AdjList;

#define INF 1e+9

int MinSpanningTree(AdjList g){

  int n = g.size();
  int res = 0;

  vector<int> d(n,INF);
  d[0] = 0;
  vector<int> use(n,0);

  while(1){
    int v = -1;
    for(int u=0;u<n;u++){
      if( !use[u] and (v<0 or d[v] > d[u]))
	v = u;
    }
    if(v<0) break;
    use[v] = 1;
    res += d[v];
    for(int i=0; i<g[v].size();i++)
      d[ g[v][i].to ] = min( d[ g[v][i].to ], g[v][i].cost);
  }
  return res;
}

int main(){

  while(1){
    int n,m; cin >> n;
    if(!n) break;
    cin >> m;

    AdjList g(n);
    for(int i=0; i<m; i++){
      int from,to,c;
      //cin >> from >> to >> c;
      scanf("%d,%d,%d",&from,&to,&c);
      g[from].push_back(edge(to,c/100 - 1));
      g[to].push_back(edge(from,c/100 - 1));
    }
    int ans = MinSpanningTree(g);
    cout << ans << endl;
  }
  

}

Measured memory_bytes: 1432
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  
  int ans = 0;
  int m = 99999999;
  
  for(int i=0;i<n;i++){
    if(m > p[i]){
      ans++;
      m = p[i];
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdarg>
using namespace std;
int main(){
    int k, s, z;
    cin >> k >> s;
    int ans = 0;
    for(int x = 0; x <= k; x ++){
        for(int y = 0; y <= k; y ++){
            z = s - x - y;
            if (0 <= z && z <= k){
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

f = 0
ans = 1
for i in range(n-1):
    if f == 0:
        if a[i] == a[i+1]:
            f = 0
        elif a[i] < a[i+1]:
            f = 1
        else:
            f = 2
    elif f == 1:
        if a[i] <= a[i+1]:
            pass
        else:
            ans += 1
            f = 0
    elif f == 2:
        if a[i] >= a[i+1]:
            pass
        else:
            ans += 1
            f = 0

print(ans)

Measured memory_bytes: 62704
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll h,w,k;
    cin>>h>>w>>k;
    vector<string> c(h),cc(h);
    rep(i,h) cin>>c[i];
    ll ans=0;
    rep(i,1<<h){
        rep(j,1<<w){
            cc=c;
            for(ll s=0;s<6;s++){
                if((i>>s)&1){
                    rep(k,w) cc[s][k]='.';
                }
            }
            for(ll s=0;s<6;s++){
                if((j>>s)&1){
                    rep(k,h) cc[k][s]='.';
                }
            }
            ll cnt=0;
            rep(k,h){
                rep(l,w){
                    if(cc[k][l]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
 
int main() {
  int n;
  cin >>n;
  priority_queue<int> a;
  rep(i,n){
    int x;
    cin>>x;
    a.push(x);
  }
  int sum1=0;
  int sum2=0;
  rep(i,n){
    int x;
    x=a.top();a.pop();
    if(i%2==0){
      sum1+=x;
    }else{
      sum2+=x;
    }
  }
  int kotae=abs(sum1-sum2);
  cout <<kotae<<endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



#n=int(input())
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
a=set(a)
tmp=set(i for i in range(-5,103))
cal=tmp-a
cal=list(cal)
cal.sort()
ind=bisect.bisect_left(cal,n)
ans=cal[ind]
if ans-n >= n-cal[ind-1]:
    ans=cal[ind-1]
print(ans)

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

int main(){
  vector<int> v={0,13,1,2,3,4,5,6,7,8,9,10,11,12};
  int A,B;
  cin >> A >> B;
  if(v.at(A)>v.at(B)){
    cout << "Alice" <<endl;
  }else if(v.at(A)==v.at(B)){
    cout << "Draw" << endl;
  }else{
    cout << "Bob" << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int main() {
  double p[6]; rep(i,6) { cin >> p[i]; p[i]/=100; }
  double q[6]; rep(i,6) { cin >> q[i]; q[i]/=100; }

  double l = 0, r = 1;
  rep(i,50) {
    double m1 = (l*2+r)/3, m2 = (l+r*2)/3;
    double t1 = 0; rep(i,6) t1 += max(p[i]*m1, q[i]*(1-m1));
    double t2 = 0; rep(i,6) t2 += max(p[i]*m2, q[i]*(1-m2));
    if (t1>t2) l = m1;
    else r = m2;
  }
  double petr = l;
  double result = 0; rep(i,6) result += max(p[i]*petr, q[i]*(1-petr));
  cout << fixed << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	cout << ((10 * b + c) % 4 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
else:
    print(ans)

Measured memory_bytes: 21772
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n, k, tmp;
  vector<int> h;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    h.push_back(tmp);
  }
  sort(h.begin(), h.end());
  int min = h[k-1] -h[0];
  for(int i = 1; i < n-k+1; i++){
    int tmp_min = (h[k+i-1] - h[i]);
    if(min > tmp_min) min = tmp_min;
  }
  cout << min << endl;
  return 0;
}


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

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d){
    cout << "Left" << endl;
  }else if(a+b < c+d){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef pair <string, string> pss;

const int MAXN = 20;	

int N;
char s[2 * MAXN];
map <pss, int> lft, rig;

int main() {
	scanf("%d%s", &N, s);
	
	for (int i = 0; i < 1 << N; i++) {
		string l1 = "", l2 = "", r1 = "", r2 = "";
		for (int j = 0; j < N; j++) 
			if (i >> j & 1) 
				l1 += s[j];
		for (int j = N - 1; j >= 0; j--)
			if (!(i >> j & 1)) {
				l2 += s[j];
				r1 += s[N + j];
			}
		for (int j = 0; j < N; j++)
			if (i >> j & 1)
				r2 += s[N + j];
		lft[{l1, l2}]++;
		rig[{r1, r2}]++;
	}		
	
	ll ans = 0;
	for (auto it : lft)
		ans += (ll)it.second * rig[it.first];
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 108288
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
S=ns().split()
Sans=""

for i in range(N):
    Sans+=S[0][i]
    Sans+=S[1][i]

print(str(Sans))

Measured memory_bytes: 5076
H,W=map(int,input().split())
list1=[]
for i in range(10):
    A=list(map(int,input().split()))
    list1.append(A)

for c in range(10):
    for a in range(10):
        for b in range(10):
            if list1[a][b]>list1[a][c]+list1[c][b]:
                list1[a][b]=list1[a][c]+list1[c][b]
                
list2=[0,0,0,0,0,0,0,0,0,0]       
list3=[]
for d in range(H):
    w=list(map(int,input().split()))
    list3.append(w)
    
for e in range(H):
    for f in range(W):
        if abs(list3[e][f])==1:
            pass
        else:
            list2[list3[e][f]]+=1
ans=0
for g in range(10):
    ans+=list2[g]*list1[g][1]
print(ans)

Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int arr[x];
	int count = 0;
	for (int i = 0 ; i < x ; i++)
	{
		cin >> arr[i];
	}
	for (int i = 1 ; i < x - 1 ; i++)
	{
		if ((arr[i - 1] > arr[i] && arr[i] > arr[i + 1]) || (arr[i + 1] > arr[i] && arr[i] > arr[i - 1]))
		{
			count++;
		}
	}
	cout << count;
}

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

map<long long int, long long int>m;

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

	long long int x=0, a=0, ans=0;
	m[0]=1;
	for(int i=1;i<=n;i++){
		cin>>x;
		a=a+x;
		ans-=m[a]*(m[a]-1)/2;
		m[a]+=1ll;
		ans+=m[a]*(m[a]-1)/2;
	}

	cout<<ans;

}

Measured memory_bytes: 12800
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define MAXN 100000
using namespace std;
struct node
{
	int x,y,t;
}poi[MAXN+5];
bool cmp(node a,node b)
{
	if(a.t==b.t)
	{
		if(a.x==b.x)
			return a.y<b.y;
		return a.x<b.x;
	}
	return a.t<b.t;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d %d %d",&poi[i].t,&poi[i].x,&poi[i].y);
	sort(poi+1,poi+1+n,cmp);
	int posx=0,posy=0,post=0;
	for(int i=1;i<=n;i++)
	{
		int t=poi[i].t,x=poi[i].x,y=poi[i].y;
		int delt=t-post;
		int mint=abs(x-posx)+abs(y-posy);
		if(delt%2==mint%2&&delt>=mint)
			posx=x,posy=y,post=t;
		else
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1280
#!/usr/bin/env run-cargo-script

#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(lr: Vec<(u32, u32)>) -> u32 {
    lr.into_iter().map(|p| p.1 - p.0 + 1).sum()
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    let n = sc.next();
    println!("{}", solve(sc.pairs(n)));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


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

a_list = []
b_list = []

for _ in range(N):
    a,b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
    
uni = zip(a_list,b_list)
uni = sorted(uni, key=lambda x:x[0])

a_list, b_list = zip(*uni)

now = 0
money = 0
for a, b in zip(a_list, b_list):
    if M - now < b:
        kau = M -now
        now += kau
        money += a*kau
    else:
        now += b
        money += a*b
        
print(money)

Measured memory_bytes: 26780
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn = 200100;
const long long oo = 1e18;
int n;
long long a[maxn];
long long f[maxn][5];
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 1; i <= n; i ++)
		for(int j = 0; j < 5; j ++)
			f[i][j] = oo;
	for(int i = 1; i <= n; i ++)
	{
		long long mn = f[i - 1][0];
		f[i][0] = min(f[i][0], mn + a[i]);
		mn = min(mn, f[i - 1][1]);
		f[i][1] = min(f[i][1], mn + (a[i] == 0 ? 2 : a[i] % 2));
		mn = min(mn, f[i - 1][2]);
		f[i][2] = min(f[i][2], mn + (a[i] % 2 != 1));
		mn = min(mn, f[i - 1][3]);
		f[i][3] = min(f[i][3], mn + (a[i] == 0 ? 2 : a[i] % 2));
		mn = min(mn, f[i - 1][4]);
		f[i][4] = min(f[i][4], mn + a[i]);
	}
	cout << min(f[n][1], min(f[n][2], min(f[n][3], f[n][4]))) << endl;
	return 0;
}

Measured memory_bytes: 9600
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
count={}
for i in range(1,n):
    x=i-a[i]
    if x in count:
        count[x]+=1
    else:
        count[x]=1
ans=0
for i in range(n-1):
    x=i+a[i]
    if x in count:
        ans+=count[x]
    count[i+1-a[i+1]]-=1
print(ans)

Measured memory_bytes: 117076