akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    d = sorted(set(S))
    cnt = {}
    m = 0
    for w in S:
        if not cnt.get(w):
            cnt[w] = 0
        cnt[w] += 1
        m = max(m, cnt[w])
    for w in d:
        if cnt[w] == m:
            print(w)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44572
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int n, x;
    cin >> n >> x;

    int cnt = 0;
    int min_cost = 1000000;
    int total_cost = 0;
    vector<int> powder(n);
    rep(i, n) {
        int cost;
        cin >> cost;
        min_cost = min(min_cost, cost);
        total_cost += cost;
        powder.at(i) = cost;
        cnt++;
    }

    x -= total_cost;

    while (true) {
        // cout << x << " " << min_cost << " " << cnt << endl;
        if (x - min_cost >= 0) {
            x -= min_cost;
            cnt++;
        } else {
            break;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int power(int num)
{
    int ans=1;
    for(int i=0;i<num;i++)ans*=10;
    return ans;
}
int main() {
    int n,m;
    while(cin>>m>>n,n,m){
        string str,fb[3]={"FizzBuzz","Fizz","Buzz"};
        bool player[1000]={};
        for(int i=1,now=0,out=m;i<=n;i++,now=(now+1)%m){
			cin>>str;
			int num=0,co=-1;
			if(out>1){
				while(player[now])now=(now+1)%m;
				if(i%15<1)co=0;
				else if(i%3<1)co=1;
				else if(i%5<1)co=2;
				else for(int j=0;j<str.size();j++)num+=(str[j]-'0')*power(str.size()-1-j);
				if(co>-1&&str!=fb[co]||co<0&&i!=num)player[now]=1;
				if(player[now])out--;
			}
		}
		for(int i=0,co=0;i<m;i++){
			if(co==0&&!player[i]){
				cout<<i+1;
				co++;
			}
			else if(!player[i])cout<<" "<<i+1;
		}
		cout<<endl;
	}
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  int ans=0;
  int a,b;cin>>a>>b;
  if(a<=5)ans=0;
  else if(a<=12)ans=b/2;
  else ans=b;
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 256
import sys

#        1  2  3  4  5  6  7  8  9 10 11 12
s = [-1, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]

def solve():
    x, y = map(int, input().split())

    if s[x] == s[y]:
        ans = 'Yes'
    else:
        ans = 'No'

    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
 
int main() {
    int N,K;
    cin >> N >> K;
    int ans = 1;
    rep(i, 0, N){
        ans = min(ans*2,ans+K);
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    int n;
    cin >> n;
    int k = -1;
    for (int i = 1; i <= n + 1; i++)
        if ((long long)i * (i - 1) / 2 == n){
            k = i - 1;
            break;
        }
    if (k == -1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    vector<vector<int> > x(k + 1);
    FOR (i, k + 1)
        x[i].resize(k);
    int cur_i = 0, cur_j = 0;
    int num = 1;
    while (num <= n){
        for (int i = cur_i + 1; i < k + 1; i++)
            x[i][cur_j] = num + i - cur_i - 1;
        for (int j = cur_j; j < k; j++)
            x[cur_i][j] = num + j - cur_j;
        num += k - cur_i;
        cur_i++;
        cur_j++;
    }
    cout << x.size() << '\n';
    FOR (i, x.size()){
        cout << x[i].size() << ' ';
        FOR (j, x[i].size())
            cout << x[i][j] << ' ';
        cout << '\n';
    }
}

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

#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define F first
#define S second
#define all(v) v.begin(),v.end()
ll mod=1e9+7;
 ll fun(ll x,ll y){
        return ((x*x)+(y*y));
    }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t=1,tc;
    //cin>>t;
    for(tc=1;tc<=t;tc++){
       ll n,d,i,x,y,c=0;
      cin>>n>>d;
      for(i=0;i<n;i++){
          cin>>x>>y;
          if(fun(x,y)<=d*d)c++;
      }
      cout<<c;
    }
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  int a[n * (n - 1)];
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n - 1; j++){
      scanf("%d", &a[(n - 1) * i + j]);
    }
  }
  
  int current[n], count[n], active[n], finish = 0, day = 0;
  
  for (int i = 0; i < n; i++){
    current[i] = a[(n - 1) * i];
    count[i] = 0;
  }
  
  while (finish < n){
    int activenum = 0;
    for (int i = 0; i < n; i++){
      if (count[i] == n - 1) active[i] = 1;
      else active[i] = 0;
    }
    for (int i = 0; i < n; i++){
      if (active[i] == 1) continue;
      int j = current[i] - 1;
      if (active[j] == 0 && current[j] == i + 1){
        active[i] = 1;
        active[j] = 1;
        count[i]++;
        count[j]++;
        if (count[i] < n - 1) current[i] = a[(n - 1) * i + count[i]];
        else finish++;
        if (count[j] < n - 1) current[j] = a[(n - 1) * j + count[j]];
        else finish++;
        activenum++;
      }
    }
    if (activenum == 0){
      printf("%d\n", -1);
      return 0;
    }
    day++;
  }
  printf("%d\n", day);
  return 0;
}

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

string S;

int main(){
  cin >> S;
  int red=0,blue=0;

  for(int i=0;i<S.length();i++){
    red+=S[i]=='0'?1:0;
    blue+=S[i]=='1'?1:0;
  }
  cout << S.length()-abs(red-blue) << endl;
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h" // {{{
using namespace std; typedef long long ll; typedef pair<int,int> pii;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define repr(i,h,l) for(int i=(h); i >= (int)(l); --i)
#define reps(i,s,t) for(int i=(s); i <= (int)(t); ++i)
#define ALL(x)      begin(x), end(x)
#define UNQ(x)      (x).erase(std::unique(ALL(x)), end(x))
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#define YDK(f,a,b)  ((f)? (a):(b))
#ifdef  DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t\t= " << (x) << '\n'
#define show2(x,y)  clog << '(' << #x << ',' << #y << ")\t\t= " << '(' << (x) << "\t, " << (y) << ")\n"
#define LN()        fputs("\n--------------------------------\n", stderr)
struct NullPointer{};
#else
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
struct NullPointer{ NullPointer(){cin.tie(0);ios::sync_with_stdio(false);} };
#endif
#define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; }
template<class T> struct Ordered
{ virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); };
#undef def
namespace {
  constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL; ostringstream _oss;
  TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
  { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
  TMPLT(T,U) inline bool chmax(T &a, const U &b){return b>a ? a=b,1 : 0;}
  TMPLT(T,U) inline bool chmin(T &a, const U &b){return b<a ? a=b,1 : 0;}
  TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
  template<class T>   string toString(const T &x){ _oss.str(""); _oss << x; return _oss.str(); }
  template<class Itr> string mkString(Itr begin, Itr end, const char *sp = " ") {
    _oss.str(""); for(Itr i=begin; i != end; ++i) { if(i != begin)_oss << sp; _oss << *i; }
    return _oss.str();
  }
  // }}}

constexpr int MX = ten(5) + 10;

void Xx_main_xX(const vector<char*> &args)
{
  string s;
  cin >> s;

  int N = s.length();
  ll cnt = 0;
  ll ans = 0;
  for (int i= N-1; i >= 0; --i) {
    if (s[i] == 'W') ++cnt;
    else ans += cnt;
  }

  outl(ans);
}

} // {{{
signed main(signed argc, char *argv[]) {
  NullPointer Exception;
  cout << fixed << setprecision(9); Xx_main_xX(vector<char*>(argv, argv+argc)); return 0;
} // }}}



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

int main()
{
    //typedef std::numeric_limits< double > dbl;


    float pi;
    int r;
    cin>>r;
    pi = 6.28318530717958623200/2;
    cout.precision(20);

//    cout.precision(dbl::max_digits20);

    cout<<2*pi*r<<fixed;


}




Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>

using namespace std;

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

	for (int i = 0; i < m; i++){
		int initmoney, year, n, maxmoney = 0;
		cin >> initmoney >> year >> n;

		for (int j = 0; j < n; j++){
			int course, charge;
			double rate;

			//入力
			cin >> course >> rate >> charge;
			int money = initmoney;

			//複利計算
			if (course == 1){
				for (int k = 0; k < year; k++){
					money = money * (1 + rate) - charge;
				}
			}

			//単利計算
			else{
				int risi = 0;
				for (int k = 0; k < year; k++){
					risi += money * rate;
					money -= charge;
				}
				money += risi;
			}
			maxmoney = max(maxmoney, money);
		}
		cout << maxmoney << endl;


	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef map<int,int> MPi; typedef pair<Int,Int> Pl;
const int mod = 1000000007;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int n,a,b,c,d; cin>>n>>a>>b>>c>>d; string s; cin>>s;
    string ans="No"; bool ok=true;
    if(c>d){
        ok=false;
        for (int i = b-1; i <= d-1; i++)if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){ok=true; break;}
    }
    for (int i = a; i < c-2; i++)if(s[i]=='#'&&s[i+1]=='#')END
    for (int i = b; i < d-2; i++)if(s[i]=='#'&&s[i+1]=='#')END
    cout<<(ok?"Yes":"No")<<'\n';
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int n;

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    if(n%2) {
        cout << 0 << endl;
    } else {
        int a = n/2;
        int ret = 0;
        int base = 5;
        while(base <= a) {
            ret += a/base;
            base *= 5;
        }
        cout << ret << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

#define X first
#define Y second

int n;
vector<pii> p;

int memo[1001][1001];

int solve(int l, int r){
	if(l+1 == r) return 0;
	if(memo[l][r]) return memo[l][r];
	int res = INF;
	for(int i=l+1;i<r;i++){
		int sum = 0;
		sum += solve(l, i) + solve(i, r);
		sum += p[i-1].Y - p[r-1].Y + p[i].X - p[l].X;
		res = min(res, sum);
	}
	return memo[l][r] = res;
}
main(){
	ios::sync_with_stdio(false);
	while(cin >> n){
		p.resize(n);
		REP(i, n) cin >> p[i].X >> p[i].Y;
		cout << solve(0, n) << endl;
	}
	return 0;
}

Measured memory_bytes: 5208
ABC = list(map(int, input().split()))
ABC.sort()
A = ABC[2]
B = ABC[1]
C = ABC[0]
ans = A-B
C += ans
if (A - C) % 2 == 1:
    ans += (A+1-C)//2 + 1
else:
    ans += (A-C)//2
print(ans)


Measured memory_bytes: 3060
x=require('fs').readFileSync('/dev/stdin', 'utf8');
y=x.trim().split("\n");
while(true){
   if(y.length==0)break;
   var z=y.shift().split(" ");
   var s=[];
   z.forEach(function(v){
      if(/\d/.test(v)){
         s.unshift(v-0);
      }else{
         a=s.shift();
         b=s.shift();
         if(v=="+")s.unshift(b+a);
         if(v=="-")s.unshift(b-a);
         if(v=="*")s.unshift(b*a);
         if(v=="/")s.unshift(b/a);
      }
   });
   console.log(s[0].toFixed(6));
}

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

int main(){
    
    int n,x,y;
    
    while(cin >> n,n!=0){
        int masu[20][20]={};
        x = n/2;
        y = n/2+1;
        for(int i=1;i<=n*n;i++){
            masu[y][x] = i;
            x=(x+1)%n;
            y=(y+1)%n;
            if(masu[y][x] != 0){
                x=(x-1+n)%n;
                y=(y+1)%n;
            }
        }
    
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                printf("%4d",masu[i][j]);
            }
            cout << endl;
        }
    }
    
    return(0);
}


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

#define ALL(a)  (a).begin(),(a).end()

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    ll n;
    ll ans = 0;

    vector<int> l;

    cin >> n;

    ll r = (ll)sqrt((double)n);

    for (ll i = r; r > 0; i--) {
        if (n % i == 0) {
            ans = i + (n / i) - 2;
            break;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
H,W = map(int, input().split())
L = []
for i in range(H):
    L.append(input())
    
ans = "Yes"
for i in range(H):
    for j in range(W):
        if L[i][j] == "#":
            temp = []
            if i != 0:
                temp.append(L[i-1][j])
            if i != H-1:
                temp.append(L[i+1][j])
            if j != 0:
                temp.append(L[i][j-1])
            if j != W-1:
                temp.append(L[i][j+1])
            if "#" not in temp:
                ans = "No"
                break

print(ans)

Measured memory_bytes: 3064
n=int(input())
ans = 0
score=[]
for i in range(1, n+1, 2):
  li=[]
  for j in range(1, n+1):
    if i%j==0:
      li.append(j)
  if (len(li))== 8:
    score.append(i)
long=len(score)
print(long)

Measured memory_bytes: 9184
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod 1e9+7
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define vpll vector<pair<ll,ll>>
#define INF 0x3f3f3f3f
#define mp make_pair

ll dp[105][int(1e5)+5];

int main()
{
    ll n,lt;
    in2(n,lt);
    for(ll i=1;i<=n;i++) {
        ll a,b;
        in2(a,b);
        for(ll j=lt;j>=a;j--) dp[i][j] = max(dp[i-1][j], dp[i-1][j-a] + b);
        for(ll j=a-1;j>=0;j--) dp[i][j] = dp[i-1][j];
    }
    cout<<dp[n][lt]<<endl;
    return 0;
}

Measured memory_bytes: 79360
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int n, a, t[1010], deg[1000010];
set<int> vert;
vector<int> G[1000010];

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n;

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < n-1; ++j) {
      cin >> a;
      --a;
      int k = i;
      if(k > a) swap(k, a);
      t[j] = k * 1000 + a;
    }
    for(int j = 0; j < n-2; ++j) {
      G[t[j]].push_back(t[j+1]);
      ++deg[t[j+1]];
      vert.insert(t[j]);
    }
    vert.insert(t[n-2]);
  }

  queue<int> q;
  map<int, int> cost; for(int v : vert) cost[v] = -1;

  for(int v : vert) if(deg[v] == 0) {
    q.push(v);
    cost[v] = 0;
  }
  if(q.empty()) {
    cout << -1 << endl;
    return 0;
  }


  vector<int> sorted;
  while(q.size()) {
    int v = q.front(); q.pop();
    sorted.push_back(v);
    for(int nv : G[v]) {
      cost[nv] = max(cost[nv], cost[v] + 1);

      --deg[nv];
      if(deg[nv] == 0) q.push(nv);
    }
  }
  if(vert.size() != sorted.size()) {
    cout << -1 << endl;
    return 0;
  }

  int ans = 0;
  for(int v : vert) ans = max(ans, cost[v]);
  cout << ans + 1 << endl;

  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A[3][3];
	REP(i, 3)REP(j, 3) cin >> A[i][j];

	bool flag = true;
	REP(i, 2) if(A[i+1][0]-A[i][0]!=A[i+1][1]-A[i][1]||A[i+1][1]-A[i][1]!=A[i+1][2]-A[i][2]) flag = false;
	REP(j, 2) if(A[0][j+1]-A[0][j]!=A[1][j+1]-A[1][j]||A[1][j+1]-A[1][j]!=A[2][j+1]-A[2][j]) flag = false;
    cout << (flag?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int i,j;
  int n,m,r;
  while(cin>>n>>m>>r,n||m||r){
    r*=4;
    int x[100000],y[100000];
    for(i=0;i<n;++i)
      cin>>x[i]>>y[i];
    vector<int> a[10000];
    for(i=0;i<m;++i){
      int p,q;
      cin>>p>>q;
      a[q].push_back(p);
    }
    for(i=0;i<10000;++i){
      if(a[i].size()>1)
	sort(a[i].begin(),a[i].end());
    }
    int b[90],c[90];
    for(i=-r;i<=r;++i){  
      for(j=-40;i*i+j*j>r*r;++j);
      b[i+40]=j;
      for(;i*i+j*j<=r*r;++j);
      c[i+40]=j;
    }
    int sm=0;
    for(i=0;i<n;++i){  
      for(j=max(0,y[i]-r);j<=min(9999,y[i]+r);++j){
	vector<int>::iterator it=lower_bound(a[j].begin(),a[j].end(),x[i]+b[j-y[i]+40]);
	sm+=lower_bound(it,a[j].end(),x[i]+c[j-y[i]+40])-it;
      }
    }
    cout<<sm<<endl;
  }
  return 0;
}

Measured memory_bytes: 2208
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K <= 3 * N:
    cur = 1
    for i in range(K):
        cur = A[cur-1]
    print(cur)
else:
    d = defaultdict(int)
    cur = 1
    for i in range(3*N):
        cur = A[cur-1]
        d[cur] += 1
    if d[1] != 0:
        cur = 1
        for i in range(1,N+1):
            cur = A[cur-1]
            if cur == 1:
                f = i
        num = K % f
        if num == 0:
            print(1)
        else:
            cur = 1
            for i in range(num):
                cur = A[cur-1]
            print(cur)
    else:
        cnt = 0
        for i in range(1,N+1):
            if d[i] == 1:
                cnt += 1
        cur = 1
        for i in range(cnt+1):
            cur = A[cur-1]
        start = cur
        for i in range(1,N+1):
            cur = A[cur-1]
            if cur == start:
                f = i
                break
        K = K - cnt -1
        num = K % f
        if num == 0:
            print(start)
        else:
            cur = start
            for i in range(num):
                cur = A[cur-1]
            print(cur)

Measured memory_bytes: 58136
import java.util.*;

public class Main{
	static private Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args){
		long n = sc.nextLong();
		
		if(n % 2 == 1){
			System.out.println(0);
			return;
		}
		
		long ans = 0;
		for(long num = 10; num <= n; num *= 5){
			ans += n / num;
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	string s;cin>>s;
	string t;
	vector<int>v;
	v.push_back(-1);
	rep(i,s.size()){
		if(s[i]!='x'){
			t+=s[i];
			v.push_back(i);
		}
	}
	v.push_back(s.size());
	string e=t;reverse(e.begin(),e.end());
	if(e!=t){
		puts("-1");return 0;
	}
	//for(auto p:v)cout<<p<<endl;
	int cnt=0;
	rep(i,v.size()/2){
		int a=max(0,v[i+1]-v[i]-1);
		int b=max(0,v[v.size()-i-1]-v[v.size()-i-2]-1);
		cnt+=abs(a-b);
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1148
n = int(input())
A_l = [(A,i) for i, A in enumerate(map(int,input().split()))]
A_l.sort(reverse=True)

dp = []
for _ in range(n+1):
    dp.append([0] * (n+1))
for j in range(1,n+1): # all go bigger
    a, i = A_l[j-1]
    dp[j][0] = dp[j-1][0] + a*(n-(j-1) - (i+1))
for k in range(1,n+1): # all go smaller
    a, i = A_l[k-1]
    dp[0][k] = dp[0][k-1] + a*((i+1) - (1+(k-1)))

for j in range(1,n+1):
    for k in range(1,n-j+1):
        a, i = A_l[j+k-1]
        j_plus = a*(n-(j-1) - (i+1))
        k_plus = a*((i+1) - (1+(k-1)))
        dp[j][k] = max(dp[j-1][k]+j_plus, dp[j][k-1]+k_plus)

result = 0
for j in range(0,n+1):
    k = n-j
    result = max(result, dp[j][k])
print(result)
#for l in range(n+1):
#    print(dp[l])

Measured memory_bytes: 124536
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000009;
//ll mod = 998244353;

int gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n%m);
}

int main() {
	string s;
	cin >> s;
	int ans = 0;
	int n = s.size();
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - 1 - i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int A[M], ltx = 0, mtx = 0;
  rep(i,0,M-1) {
    cin >> A[i];
    if (A[i] < X) ltx++;
    else mtx++;
  }
  int ans;
  if (X < A[0] || A[M-1] < X) ans = 0;
  else ans = min(ltx, mtx);
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();
		int cnt = 0;
		
		for (int i = 1; i * i < a ; i++) {
			for (int j = i; i * j < a; j++) {
				if (i == j) {
					cnt += 1;
				} else {
					cnt += 2;
				}
			}
		}
		System.out.println(cnt);
	}
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};



int main(){

  int n,m,c,res = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  REP(i,m)cin >> b[i];
  vector<vector<int>> v(n);
  REP(i,n){
    REP(j,m){
      int x;cin >> x;
      v[i].push_back(x);
    }
  }
  REP(i,n){
    int sum = 0; 
    REP(j,m){
      sum += v[i][j]*b[j];
    }
    if(sum > -c)res++;
  }
  cout << res << endl;

  return 0;
}


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

u = []
for i in range(1,n):
    for j in range(i+1,n+1):
        u.append(min(j-i,abs(x-i)+abs(y-j)+1))

import collections
u2 = collections.Counter(u)
u2 = list(u2.items())
for k in range(n):
    u2.append((0,0))

for i in range(n-1):
    if u2[i][0] == i+1:
        print(u2[i][1])
    else:
        print(0)

Measured memory_bytes: 114828
import java.util.Scanner;

class Main {

	public void rec() {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		int b = sc.nextInt();

		System.out.println(a * b +" "+ (a + b) * 2);

	}

	public static void main(String[] args) {

		new Main().rec();

	}

}

Measured memory_bytes: 26404
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
// Practice is the only shortcut to improve
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.rbegin(),v.rend());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define PI 2*acos(0.0)
#define pii pair<int,int>
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define coutv(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define cinv(v) for(auto &it:v)cin>>it;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using ordered_set =tree<T, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;
*/
//sieve bool b[1000005];void primenire(){int i, j;b[0]=true;b[1]=true;for(i=4; i<=1000000; i+=2){b[i]=true;}for(i=3; i<=1001; i+=2){if(!b[i]){for(j=i*i; j<=1000001; j+=2*i){b[j]=true;}}}}
// power ll power(ll a,ll b){if(b==0)return 1LL;if(b&1)return a*power(a,b-1);else{ll x=power(a,b/2);return x*x;}}
//bigmod long long int m(long long int a,long long int b,long long int c){if(b==0)return 1;if(b%2==0){long long int  tmp=m(a,b/2,c);return ((tmp%c)*(tmp%c))%c;}elsereturn ((a%c)*(m(a,b-1,c)%c))%c;}
//MaxSubarraySum ll mss(vector<ll>v){ll mx=v[0];ll sz=v.size();for(int i=1;i<=sz;i++){ll t=v[i]+v[i-1];if(t>=v[i]) v[i]=t;mx=max(mx,v[i]*1LL);}return mx;}
//combination ll com[1001][1001];void combination(){com[1][1]=1;com[1][0]=1;for(ll i=2; i<=1000; i++){com[i][0]=1;for(ll j=1; j<=i; j++){com[i][j]=com[i-1][j]+com[i-1][j-1];}}}
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

void solve()
{
  ll a;
  cin>>a;
  fr(i,1,a)
  {
     cout<<"ACL";
  }
     cout<<endl;
}
int main()
{
    rj
    solve();
    return 0;
}


Measured memory_bytes: 3548
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main() {
    int N;
    scanf("%d\n", &N);
    int sum = 0;
    int m = 0;
    for (int i = 0; i < N; i++) {
        int temp;
        scanf("%d", &temp);
        sum += temp;
        m = max(m, temp);
    }
    printf("%d\n", sum - m / 2);
    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 

template <class T>
void printArray(vector<T> arr) {for (T a: arr) cout << a << " ";cout << '\n';}
void printVerdict(bool verdict) {cout << (verdict ? "APPROVED": "DENIED") << '\n';}
void printDecimal(double d) {printf("%.9f\n", d);}
bool inrange(int val, int start, int end) {return val >=start && val <= end;}
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	bool verdict = true;
	int n; cin >> n;
	int a[n];
	for (int i = 0; i<n; i++) cin >> a[i];
	for (int i = 0; i<n && verdict; i++) {
		if (a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0) verdict = false;
	}
	printVerdict(verdict);
}



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

int main() {
    int a, b, k; cin >> a >> b >> k;
    vector<int> v;
    for(int i = 1; i <= min(a, b); ++i) {
        if(a % i == 0 && b % i == 0) {
            v.push_back(i);
        }
    }
    sort(rbegin(v), rend(v));
    cout << v[k - 1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define inf 999999999999
#define N  500009
#define M  (L+R)/2
#define ll long long
#define pb push_back
using namespace std;

ll n,m,i,j,ans,sum,x,y;

int main()
{

	ios::sync_with_stdio(0);
	cin>>n>>x>>y;
	
	cout<<min(x,y)<<" "<<max(0ll,x+y-n)<<endl;

return 0;
}






Measured memory_bytes: 256
c,m,x=map(int,input().split())
book=[list(map(int,input().split())) for i in range(c)]
ans=[False,float('inf')]
for i in range(1<<c):
  p=[0 for i in range(m)]
  num=0
  money=0
  while i>0:
    if i&1==1:
      money+=book[num][0]
      for j in range(1,m+1):
        p[j-1]+=book[num][j]
    num+=1
    i=i>>1
  if min(p)>=x and ans[1]>money:
    ans[0]=True
    ans[1]=money
if ans[0]:
  print(ans[1])
else:
  print(-1)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll eru[222222][2];
ll aru[222222][2];
ll ans[222222];

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	string str;cin >> str;

	REP(i, str.size()){
		if(str[i] == 'R'){
			aru[i][0]++;
			aru[i+1][0] += aru[i][1];
			aru[i+1][1] += aru[i][0];
			aru[i][0] = 0;
			aru[i][1] = 0;
		}
	}
	REV(i, str.size()){
		if(str[i] == 'L'){
			eru[i][0]++;
			eru[i-1][0] += eru[i][1];
			eru[i-1][1] += eru[i][0];
			eru[i][0] = 0;
			eru[i][1] = 0;
		}
	}
	REP(i, str.size()){
		if(eru[i][0]){
			ans[i] += eru[i][0];
		}
		if(eru[i][1]){
			ans[i+1] += eru[i][1];
		}
		if(aru[i][0]){
			ans[i] += aru[i][0];
		}
		if(aru[i][1]){
			ans[i-1] += aru[i][1];
		}
	}

	REP(i, str.size())cout << ans[i] << " ";cout << endl;

	//REP(i, str.size())cout << eru[i][0] << " ";cout << endl;
	//REP(i, str.size())cout << eru[i][1] << " ";cout << endl;
	//REP(i, str.size())cout << aru[i][0] << " ";cout << endl;
	//REP(i, str.size())cout << aru[i][1] << " ";cout << endl;

	return 0;
}


Measured memory_bytes: 7888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll z = 1;
    cin >> n;
    for (int i = 1; i <= n; i++) z = z * i % mod;
    cout << z;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

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

int main() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = b-a+1;
    ans -= b/c-(a+c-1)/c+1;
    // cout << ans << endl;
    ans -= b/d-(a+d-1)/d+1;
    // cout << ans << endl;
    ll g = c/gcd(c,d)*d;
    // cout << g << endl;
    ans += b/g-(a+g-1)/g+1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();

    HashMap<Integer,Integer> map = new HashMap<>(n*2/3);

    int result = 0;
    for(int i = 1; i <= n; i++) {
      int love = scan.nextInt();
      if(map.containsKey(love)) {
        if(map.get(love) == i) {
          result++;
          map.remove(love);
        }
      }else {
        map.put(i,love);
      }
    }

    System.out.println(result);
  }
}


Measured memory_bytes: 52492
S = input()

ans = "AC"
if S[0] != 'A':
        ans = "WA"

count = 0
for i in range(1, len(S)):
        if S[i].isupper():
                if (i == 1) or (i == len(S) - 1) or (S[i] != 'C'):
                        ans = "WA"
                count += 1
        
if count != 1:
        ans = "WA"
print(ans)

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

int main() {
    int N, M, C;
    cin >> N >> M >> C;

    vector<int> B(M);
    for (int i = 0; i < M; i++) cin >> B.at(i);

    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A.at(i).at(j);
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int num = 0;
        for (int j = 0; j < M; j++) {
            num += A.at(i).at(j) * B.at(j);
        }
        if (num + C > 0) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  vector<ll> v;
  for(ll i=1; i<=pow(n, 0.5); i++){
    if(n%i==0) v.push_back(i+n/i);
  }
  sort(v.begin(), v.end());
  cout << v[0]-2;
  return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
	var n, m int
  fmt.Scan(&n, &m)
  a := make([]int, m)
  b := make([]int, m)
  for i := 0; i < m; i++ {
    fmt.Scan(&a[i])
    fmt.Scan(&b[i])
  }
  result := make([]int, n)
  for i := 0; i < m; i++ {
    result[a[i] - 1]++
    result[b[i] - 1]++
  }
  for _, num := range result {
    fmt.Println(num)
  }
  
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main()
{
	int Y, M, D;
	char d;
	cin >> Y;
	cin  >> d;
	cin >> M;
	cin >> d;
	cin >> D;
	
	if(Y > 2019)
	{
		cout << "TBD" << endl;
		return 0;
	}
	else if(M > 4 && Y == 2019)
	{
		cout << "TBD" << endl;
		return 0;
	}
	else if(D > 30 && M == 4 && Y == 2019)
	{
		cout << "TBD" << endl;
		return 0;
	}
	else
	{
		cout << "Heisei" << endl;
	}
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector<int> A;
    A.resize(n);

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

    int zeroes[n + 1];
    zeroes[n] = 0;

    for (int i=n-1; i>=0; i--) {
        zeroes[i] = (A[i] != 0 ? 0 : (1 + zeroes[i+1]));
    }

    long long pairs = 0;

    for (int i=0; i<n; i++) {

        int next = 1000;
        long long x_or = A[i], sum = A[i];

        int pos = i;

        for (int j=0; j<next && pos < n; j++) {

            if (x_or == sum) {
                pairs++;
            }

            if (zeroes[pos] > 1) {
                if (x_or == sum) {
                    pairs += (zeroes[pos] - 1);
                }

                pos = pos + zeroes[pos];
                if (pos < n) {
                    x_or = x_or ^ A[pos];
                    sum = sum + A[pos];
                }

                continue;
            }

            pos++;
            if (pos < n) {
                x_or = x_or ^ A[pos];
                sum = sum + A[pos];
            }
        }
    }


    cout << pairs << endl;
    return 0;
}


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

int main(){
    int L, R; cin >> L >> R;
    if( R - L >= 2019 ){
        cout << 0 << endl;
        return 0;
    }
    L %= 2019; R %= 2019;
    if( L >= R )R += 2019;
    int ans = 2020;
    for( int i = L; i <= R; i++ ){
        for( int j = i+1; j <= R ; j++ ){
            ans = min(ans, (i*j)%2019);
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
typedef long long ll;
const ll M = 1e9 + 7;

ll qpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b & 1) {
			res = (res * a) % M;
		}
		a = (a * a) % M;
		b >>= 1;
	}
	return res % M;
}

int main() {
	int n;
	cin >> n;
	
	if(n == 1) {
		cout << 0;
	} else {
		ll res = ((qpow(10, n) - 2 * qpow(9, n) + qpow(8, n)) % M + M) % M;
		cout << res << endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 3588
// Aizu Vol-2 0211: Jogging
// 2017.8.10

#include <stdio.h>

typedef long long INT;

INT gcd(INT a, INT b)
{
	INT r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

INT gcdn(INT *a, int n)
{
	INT g;
	if (n == 1) return *a;
	g = gcd(*a, *(a + 1));
	for (a += 2, n -= 2; n-- > 0; a++) g = gcd(g, *a);
	return g;
}

INT lcm(INT *a, int n)
{
	INT g, c;
	if (n == 1) return *a;
	g = gcd(*a, *(a + 1));
	c = (*a * *(a + 1)) / g;
	for (a += 2, n -= 2; n-- > 0; a++) g = gcd(c, *a), c = (c * *a) / g;
	return c;
}

#define MAX 10
INT d[MAX + 2], v[MAX + 2];

int main(void)
{
	int i, n;
	INT a, b, g;

	while (1) {
		scanf("%d", &n); if (n == 0) return 0;
		for (i = 0; i < n; i++) {
			scanf("%lld%lld", &a, &b);
			g = gcd(a, b), a /= g, b /= g;
			d[i] = a, v[i] = b;
		}
		g = lcm(d, n);
		for (i = 0; i < n; i++) d[i] = (g/d[i]) * v[i];
		g = gcdn(d, n);
		for (i = 0; i < n; i++) printf("%lld\n", d[i]/g);
	}
	return 0;
}

Measured memory_bytes: 600
s = str(input())
n = len(s)
dp = [[0]*2 for _ in range(n+1)]
dp[0][1] = 1
for i in range(n):
    p = int(s[i])
    dp[i+1][0] = min(dp[i][1]+10-p,dp[i][0]+p)
    dp[i+1][1] = min(dp[i][1]+10-p-1,dp[i][0]+p+1)
print(dp[-1][0])

Measured memory_bytes: 138312
#include<stdio.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d%d%d",&a,&b,&c);
    d=b-a;
    e=c-b;
    if(d==e)
    {
    printf("YES");
    }
    else
    {
    printf("NO");
    }
return 0;

}





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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define int long long
#define maxn 1e5+4
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

signed main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for (int r = 0; r <= N; r++) {
        for (int g = 0; g <= N; g++) {
            int b = N - (r * R + g * G);
            if (b >= 0 && b % B == 0)ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1]*(n+1)#それぞれの要素がどの要素の子であるか

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]#それぞれの要素の根を再帰的に求める

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        
        self.par[x] += self.par[y]
        self.par[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)#x,yが同じ集合に属するかどうか
    
    def size(self, x):
        return -self.par[self.find(x)]
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if root == self.find(i)]        

def main():
    n, m = map(int, input().split())
    
    union = UnionFind(n)
    
    for i in range(m):
        x, y = map(int, input().split())
        union.union(x, y)
    
    ans = -min(union.par)
    print(ans)
    
    
    
    
if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;

// Scan and Debug
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F f, R... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

const int MAX = 100010;
int n,
	arr[MAX], pfx[MAX], sfx[MAX];

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

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

	scan(n);

	for (int i = 1; i <= n; ++i) {
		scan(arr[i]);
		pfx[i] = sfx[i] = arr[i];
	}
	for (int i = 1; i <= n; ++i)
		pfx[i] = gcd(pfx[i - 1], pfx[i]);
	for (int i = n; i >= 1; --i)
		sfx[i] = gcd(sfx[i + 1], sfx[i]);

	int best = -1;
	for (int i = 1; i <= n; i++)
		best = max(best, gcd(pfx[i - 1], sfx[i + 1]));

	cout << best << "\n";

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = 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; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, m;
  cin >> n >> m;
  ll k[n];
  ll ans[m] = {};
  ll rec[m] = {};

  REP(i, n){
    cin >> k[i];
    ll a[k[i]];

    REP(j, m) rec[j] = 0;

    REP(j, k[i]){
      cin >> a[j];
      rec[a[j] - 1]++;
    }

    REP(j, m){
      if(rec[j] == 0) ans[j]++;
    }
  }

  ll p = m;
  REP(i, m){
    if(ans[i]) p--;
  }
  cout << p << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    char c;
    cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256