akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define i(a) insert(a)
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7 ;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
  {
      ll n ; cin>>n ; ll ans = 0 ;
      for( ll i = 1 ; i <=n-1 ; i++ ){
       for( ll j = 1 ; j<= n/i ; j++ ){
         if( i*j < n ) ans++;
       }
      }
      cout<<ans;
  }
 return 0;
}




Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <random>

using namespace std;

mt19937 mt(132);

const long long mod = 1e9 + 7;
const int N = 5;

char g[1000][1000];
char gg[1000][1000];
long long b[5];
long long h1[5][1000][1000];
long long h2[5][1000][1000];
long long pw[5][1000];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 5; i++) {
    b[i] = mt() % mod;
    pw[i][0] = 1;
    for (int j = 1; j < 1000; j++) {
      pw[i][j] = b[i] * pw[i][j - 1] % mod;
    }
  }

  for (int i = 0; i < n; i++) {
    scanf("%s", g[i]);
    for (int j = 0; j < n; j++) {
      g[i + n][j] = g[i][j + n] = g[i + n][j + n] = g[i][j];
    }
  }
  for (int i = 0; i < n * 2; i++) {
    for (int j = 0; j < n * 2; j++) {
      for (int k = 0; k < 5; k++) {
        h1[k][i][j + 1] = (h1[k][i][j] * b[k] + g[i][j]) % mod;
      }
    }
  }
  for (int j = 0; j < n * 2; j++) {
    for (int i = 0; i < n * 2; i++) {
      for (int k = 0; k < 5; k++) {
        h2[k][i + 1][j] = (h2[k][i][j] * b[k] + g[i][j]) % mod;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      bool ok = true;
      for (int k = 0; k < 5; k++) {
        for (int ii = 0; ii < n; ii++) {
          long long x = h1[k][i + ii][j + n] - h1[k][i + ii][j] * pw[k][n];
          long long y = h2[k][i + n][j + ii] - h2[k][i][j + ii] * pw[k][n];
          if ((x - y) % mod != 0) {
            ok = false;
          }
        }
      }
      ans += ok;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 69888
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

vec b(8);
ll cost(ll a, ll s){
    ll temp = 0, m = -10;
    rep(i,N){
        if((s>>i)&1) {
            temp += b.at(i);
            m += 10;
        }
    }
    return abs(a - temp) + m;
}

int main(){
    ll Q;
    cin>>A>>B>>Q;
    vec s(A), t(B), x(Q);
    rep(i,A) cin>>s[i];
    rep(i,B) cin>>t[i];
    rep(i,Q) cin>>x[i];
    rep(i,Q){
        ll si = lower_bound(s.begin(),s.end(),x[i]) - s.begin();
        ll ti = lower_bound(t.begin(),t.end(),x[i]) - t.begin();
        ll temp = 1e+11;
        if(si != 0 && ti != 0){//あくまで、「左に向かう場合」
            temp = min(temp,max(x[i] - s[si-1], x[i] - t[ti-1]));
        }
        if(si != A && ti != B){
            temp = min(temp,max(s[si] - x[i], t[ti] - x[i]));
        }
        if(si != 0 && ti != B){
            temp = min(temp,t[ti]-s[si-1]+min(t[ti]-x[i], x[i]-s[si-1]));
        }
        if(si != A && ti != 0){
            temp = min(temp,s[si]-t[ti-1]+min(s[si]-x[i], x[i]-t[ti-1]));
        }
        cout<<temp<<endl;
    }
}

Measured memory_bytes: 3712
#include<algorithm>
#include<cstdio>
#include<utility>
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 2e5;
int n, d, a;
P p[MAX_N];
long b[MAX_N], e[MAX_N + 1];
int c[MAX_N];

int main() {
    scanf("%d %d %d", &n, &d, &a);
    for (int i = 0; i < n; i++) scanf("%d %d", &p[i].first, &p[i].second);
    sort(p, p + n);
    for (int i = 0; i < n; i++) b[i] = p[i].first;
    for (int i = 0; i < n; i++) {
        int j = upper_bound(b, b + n, b[i] + 2 * d) - b - 1;
        c[i] = j;
    }
    long ans = 0;
    for (int i = 1; i <= n; i++) {
        int j = lower_bound(c, c + i, i - 1) - c;
        int k = p[i - 1].second - (e[i - 1] - e[j]) * a;
        if (k <= 0) k = 0;
        else if (k % a == 0) k /= a;
        else k = k / a + 1;
        e[i] = e[i - 1] + k;
    }
         
    printf("%ld\n", e[n]);
    return 0;
}


Measured memory_bytes: 5632
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if (j!=i):
            uf.union(a[j][0]-1,a[j][1]-1)
    if (uf.group_count() !=1):
        ans += 1
print(ans)

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    ll N, M, L;
    cin >> N >> M >> L;
    vector<vector<ll>> dist1(N, vector<ll>(N, LINF));
    for(int i=0; i<N; i++) dist1[i][i]=0;
    for(int i=0; i<M; i++){
        int A, B, C;
        cin >> A >> B >> C;
        A--, B--;
        dist1[A][B]=C;
        dist1[B][A]=C;
    }
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                if(dist1[i][k]+dist1[k][j] < dist1[i][j]){
                    dist1[i][j]=dist1[i][k]+dist1[k][j];
                }
            }
        }
    }
    vii dist2(N, vi(N, INF));
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(dist1[i][j] <= L) dist2[i][j]=1;
        }
    }
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                if(dist2[i][k]+dist2[k][j] < dist2[i][j]){
                    dist2[i][j]=dist2[i][k]+dist2[k][j];
                }
            }
        }
    }
    int q; cin >> q;
    while(q--){
        int s, t;
        cin >> s >> t;
        s--, t--;
        if(dist2[s][t] == INF) cout << -1 << endl;
        else cout << dist2[s][t]-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4720
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int a[5],ans;
	rep(i, 0, 5)
	{
		cin >> a[i];
		if (a[i] == 0)ans = i + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c,d;
  cin >> a;
  cin >>b;
  cin >>c;
  if(a<=c&&c<=b){
	cout <<"Yes" <<endl;
  }else{
	cout << "No" <<endl;
  }
    return 0;
}


Measured memory_bytes: 256
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	int k,x;
	inp(k);
	inp(x);
	int i;
	forin(i,x-k+1,x+k-1)
	{
		cout<<i<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
typedef long double ld;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int N, K, T, A, P;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> K;
	ordered_set O;
	O.insert(0);
	for (int i = 1; i <= N; i++) {
		cin >> A;
		P += A;
		T += O.order_of_key(P - K * i + 1);
		O.insert(P - K * i);
	}
	cout << T << '\n';
}


Measured memory_bytes: 12800
import numpy as np
import sys

X, N=list(map(int, input().split()))
p=list(map(int, input().split()))

def search_list(x, p):
    flag = False
    for ii in range(len(p)):
        if p[ii]==x:
            flag = True
    return flag

if not search_list(X, p):
    print(X)
    sys.exit()

X_small = X
diff_small = 0

while search_list(X_small, p):
    X_small -= 1
diff_small = abs(X-X_small)

X_big = X
diff_big = 0

while search_list(X_big, p):
    X_big += 1
diff_big = abs(X-X_big)

if diff_small<=diff_big:
    print(X_small)
else:
    print(X_big)


Measured memory_bytes: 27100
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b;
int32_t main(){
CODE_START;
cin>>a>>b;
ll x=b*10;
for(ll i=0;i<10;i++)
{
    if(((x+i)*8)/100==a){
        cout<<x+i<<endl;
        return 0;
    }
}
cout<<"-1"<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fo(i, n) for(int i = 1; i <= (n); i ++)
#define out(x) cout << #x << " = " << x << "\n"
using namespace std;
//by piano
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}

const int N = 3e5 + 233;
const int mo = 1e9 + 7;
int fac[N + 10], inv[N + 10], fac_inv[N + 10];

inline int C(int n, int m) {
  if(m == 0 || m == n) return 1;
  else return fac[n] * fac_inv[n - m] % mo * fac_inv[m] % mo;
}

inline int GetStep(int fx, int fy, int sx, int sy) {
  return C(sx - fx + sy - fy, sx - fx);
}
int n, m, a, b;
main(void) {
  fac[0] = 1;
  fo(i, N) fac[i] = (fac[i - 1] * i) % mo;
  inv[0] = inv[1] = 1;
  for(int i = 2; i <= N; i ++)
    inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo;
  fac_inv[0] = 1;
  fo(i, N) fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mo;
  // for(int i = 1; i <= 5; i ++)
  //   cout << inv[i] << " " << fac_inv[i] << "\n";
  read(n); read(m);
  int ans = GetStep(1, 1, n, m) * 0;
  read(a); read(b);
  for(int i = b + 1; i <= m; i ++) {
    int res = GetStep(1, 1, n - a, i) * GetStep(n - a + 1, i, n, m) % mo;
    ans = (ans + mo + res) % mo;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 7296
n = int(input())

dic = {}
for i in range(n):
    si = input()
    if si in dic:
        dic[si] += 1
    else:
        dic[si] = 1

maxi = 0
lst = []
for key in dic.keys():
    if dic[key] > maxi:
        maxi = dic[key]
        lst = [key]
    elif dic[key] == maxi:
        lst.append(key)

lst = sorted(lst)
for i in lst:
    print(i)

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

int main(void)
{
    int N, L;
    cin >> N >> L;

    int taste[N];
    for (int i = 0; i < N; i++) {
        taste[i] = L + i;
    }
    
    int minTaste = taste[0];
    for (int i = 1; i < N; i++) {
        if (abs(minTaste) > abs(taste[i]))
            minTaste = taste[i];
    }

    cout << accumulate(taste, taste + N, 0) - minTaste << endl;

}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(S: str, T: str):
    ret = T + S
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
    int x,i;
    int array[256];
    cin>>x;
    for(i=0;i<x;i++){
        cin>>array[i];
    }
    for(i=x-1;i>=0;i--){
        cout<<array[i];
        if(i==0)break;
        cout<<" ";
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 3120
# 未知のアルゴリズムか天才系DPかと思ってすぐ諦めて解説読んでしまった

d, g = map(int, input().split())
points = []
for _ in range(d):
    p, c = map(int, input().split())
    points.append((p, c))
ans = 10**12
for bit in range(2**d):
    arr = [False] * d
    for i in range(d):
        if bit >> i & 1 == 1:
            arr[i] = True
    tmp_sum = 0
    count = 0
    for i in range(d):
        if arr[i]:
            # kompuli-to
            tmp_sum += points[i][1]
            tmp_sum += (i + 1) * 100 * points[i][0]
            count += points[i][0]
    if tmp_sum < g:
        # 達成できるまで得点の高いやつからやっていく
        for i in range(d - 1, -1, -1):
            if arr[i]:
                # すでにkompuli-toしてるので
                continue
            used = 0
            for j in range(points[i][0]):
                if tmp_sum < g:
                    tmp_sum += (i + 1) * 100
                    count += 1
                    used += 1
            if used == points[i][0]:
                tmp_sum += points[i][1]
            if tmp_sum >= g:
                break
    ans = min(ans, count)
print(ans)


Measured memory_bytes: 9280
n=int(input())

def sgs(s):
  if int(s) > n: 
    return 0
  if all (s.count(c)>0 for c in '753'):
    ans=1
  else:
    ans=0
  for c in '753':
  	ans+=sgs(s + c)
  return ans

print (sgs('0'))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0;i < n;i++) {
    ll water;
    cin >> water;
    water *= 2;
    a[i] = water;
  }
  vector<ll> ans(n);
  ll ans02 = 0;
  for (int i = 0;i < n;i += 2) ans02 += a[i];
  for (int i  =1;i < n;i += 2) ans02 -= a[i];
  ans[0] = ans02 / 2;
  cout << ans[0] << endl;
  for(int i = 1;i < n;i++) {
    ans[i] = a[i-1] - ans[i-1];
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 2944
n,d = gets.chomp.split(" ").map(&:to_i)

count = 0

tree = []
kansi = []
n.times do |i|
  tree << (i + 1).to_s
  count += 1

  if count > d * 2 + 1
    count = 1
  end

  if count <= d
    kansi << "L"
  else
    if count == d+1
      kansi << "o"
    else
      kansi << "R"
    end
  end

end

#p tree
#p kansi
cnt = kansi.count("o")
if kansi.last == "L"
  cnt += 1
end

puts cnt

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

int main()
{
    int i, n, mx=0;
    map <string, int> m;
    string s;

    cin>>n;

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

    for(auto p : m)
    {
        mx = max(mx, p.second);
    }

    for(auto p : m)
    {
        if(mx==p.second)
        {
            cout<<p.first<<endl;
        }
    }
    //cout<<mx<<endl;

    return 0;
}


Measured memory_bytes: 25216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> T(N),A(N);
    for(int i = 0; i < N;i++) cin >> T[i] >> A[i];
    ll nowT = 1,nowA = 1;
    for(int i = 0; i < N;i++){
        ll M = max((nowT+T[i]-1)/T[i],(nowA+A[i]-1)/A[i]);
        nowT = M * T[i];
        nowA = M * A[i];
    }
    res = nowT + nowA;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  int n=0,a=0,b=0,r=1;
  cin>>n>>b;
  for(int i=1;i<=n;i++){
    int p=0;
    cin>>p;
    a+=p;
    if(a<=b)r++;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int x,y;

  cin >> x >> y;

  if(x>y){
    cout << "a > b" << endl;
  }
  else if(x<y){
    cout << "a < b" << endl;
  }
  else{
  cout << "a == b" << endl;
  }
  
  return 0;		 
}


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

using namespace std;
int a[200010],b[200010] = {};
vector<int> v[200010],w;
int main(){
	int i,j,n;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> a[i];
	}
	for(i=1;i<=n;i++){
		for(j=i;j<=n;j+=i){
			v[j].push_back(i);
		}
	}
	for(i=n;i>=1;i--){
		if((b[i]&1)!=a[i]){
			a[i] = (a[i] + 1)&1;
			w.push_back(i);
			for(j=0;j<v[i].size();j++){
				b[v[i][j]]++;
			}
		}
	}
	cout << w.size() << endl;
	for(i=(int)w.size() - 1;i>=0;i--){
		cout << w[i] << " ";
	}
	cout << endl;
}
			

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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++) { cin>>a[i]; }
    long long prefix[n];
    prefix[0] = a[0];
    for (int i=1; i<n; i++) { prefix[i] = prefix[i-1]+a[i]; }
    long long dp[n][n];
    for (int len=1; len<=n; len++)
    {
        for (int l=0; l<n; l++)
        {
            int r = l + len - 1;
            if (r==n) break;
            if (len==1) dp[l][l] = 0;
            else
            {
                dp[l][r] = 2e18;
                for (int mid=l; mid<r; mid++)
                {
                    long calc;
                    if (l==0) calc = dp[l][mid] + dp[mid + 1][r] + prefix[r];
                    else calc = dp[l][mid] + dp[mid+1][r]+prefix[r]-prefix[l-1];
                    if (dp[l][r] > calc) dp[l][r] = calc;
                }
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	vl vec(n);
	map<ll,ll> mp;
	ll v=0,ans=0;
	rep(i,0,n){
		ll a;
		cin>>a;
		--a;
		vec[i]=a;
	}
	while(true){
		if(v==1) break;
		ans++;
		if(mp[v]){
			cout<<-1;
			return 0;
		}
		mp[v]++;
		v=vec[v];
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vi in(m+1);
	while(n--){
		int a,b;
		cin>>a>>b;
		in[a]++;
		in[b]--;
	}
	rep(i,m)in[i+1]+=in[i];
	rep(i,m)in[i+1]=max(in[i+1],in[i]);
	cout<<in[m]<<endl;
}

Measured memory_bytes: 3112
def kaijou(n)
	kekka = 1
	1.upto(n) do |i|
		kekka = kekka * (i ** 2) % (10**9 + 7)
	end
	kekka
end

N, M = gets.split(" ").map(&:to_i)
N, M = M, N if N < M
if N - M > 1
	puts 0
elsif N - M == 1
	puts (kaijou(M) * N) % (10**9 + 7)
else
	puts (kaijou(M) * 2) % (10**9 + 7)
end


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

int main(){
    long long N,A,B;
    cin>>N>>A>>B;
    long long ans;

    if(A == 0){
        ans = 0;
    }

    else{

        ans = (N/(A+B));
        ans *= A;
        if( N % (A+B) != 0){
            ans +=  min(A,N-(A+B)*(N/(A+B)));
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
peer = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
now = [0]
seen = [0 for _ in range(n)]
ans = [0 for _ in range(n)]
seen[0] = 1
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] = 1
        now.append(y)
        ans[y] = x
ans = ans[1:]
print('Yes')
for x in ans:
  print(x+1)

Measured memory_bytes: 113188
fn main() {
    let (n, k, c): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    let s: Vec<char> = read::<String>().chars().collect();
    let mut memol = vec![0; n];
    let mut memor = vec![std::usize::MAX; n];
    let mut tmp = 0;
    let mut i = 0;
    while i < n && tmp < k {
        if s[i] == 'o' {
            memol[i] = tmp + 1;
            tmp += 1;
            i += c + 1;
        } else {
            i += 1;
        }
    }
    i = n - 1;
    tmp = k;
    while tmp > 0 {
        if s[i] == 'o' {
            memor[i] = tmp;
            tmp -= 1;
            match i.checked_sub(c + 1) {
                Some(v) => i = v,
                None => break,
            }
        } else {
            match i.checked_sub(1) {
                Some(v) => i = v,
                None => break,
            }
        }
    }
    let mut ans = vec![];
    for i in 0..n {
        if memor[i] == memol[i] {
            ans.push(i + 1);
        }
    }

    for a in ans {
        println!("{}", a);
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 13692
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <iterator>
#include <math.h>
#include <cstdlib>
#include <cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(c - a) <= d){
    cout << "Yes" << endl;
  }else{
    if(abs( b - a) <= d && abs(c -b) <= d){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<char>> v(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> v.at(i).at(j);
    }
  }

  vector<int> dx{ -1, -1, -1,  0, 0,  1, 1, 1 };
  vector<int> dy{ -1,  0,  1, -1, 1, -1, 0, 1 };

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (v.at(i).at(j) == '.') {
        int num = 0;
        for (int k = 0; k < 8; k++) {
          int x = i - dx.at(k);
          int y = j - dy.at(k);
          if (x >= 0 && x < h && y >= 0 && y < w) {
            if (v.at(x).at(y) == '#') {
              num++;
            }
          }
        }
        cout << num;
      } else {
        cout << '#';
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3648
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>

using namespace std;

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

int h;
int w;

void dfs(int y, int x, int g, vector<string> &b, vector<vector<int>>& vis) {
	vis[y][x] = g;
	for (int dir = 0; dir < 4; ++dir) {
		int ny = y + dy[dir], nx = x + dx[dir];
		if (ny >= 0 && ny < h && nx >= 0 && nx < w) {
			if (b[ny][nx] != '#' && vis[ny][nx] < 0) {
				dfs(ny, nx, g, b, vis);
			}
		}
	}
}

int main(int argc, char* argv[]) {
	int sh, sw, eh, ew, ans;
	cin >> h >> w >> sh >> sw >> eh >> ew;
	--sh, --sw, --eh, --ew;
	vector<string> b(h);
	for (int i = 0; i < h; ++i) {
		cin >> b[i];
	}
	vector<vector<int>> vis(h, vector<int>(w, -1));
	int g = 0;
	for (int r = 0; r < h; ++r) {
		for (int c = 0; c < w; ++c) {
			if (b[r][c] != '#' && vis[r][c] < 0) {
				dfs(r, c, g++, b, vis);
			}
		}
	}
	vector<set<int>> e(g);
	for (int r = 0; r < h; ++r) {
		for (int c = 0; c < w; ++c) {
			if (b[r][c] != '#') {
				for (int dy = -2; dy <= 2; ++dy) {
					for (int dx = -2; dx <= 2; ++dx) {
						int y = r + dy, x = c + dx;
						if (y >= 0 && y < h && x >= 0 && x < w) {
							if (vis[y][x] >= 0 && vis[r][c] != vis[y][x]) {
								e[vis[r][c]].emplace(vis[y][x]);
								e[vis[y][x]].emplace(vis[r][c]);
							}
						}
					}
				}
			}
		}
	}
	vector<int> q;
	vector<int> vg(g);
	q.emplace_back(vis[sh][sw]);
	vg[vis[sh][sw]] = 1;
	for (ans = 0; !q.empty(); ++ans) {
		vector<int> nq;
		for (int next : q) {
			if (next == vis[eh][ew]) {
				cout << ans << endl;
				return 0;
			}
			for (int a : e[next]) {
				if (vg[a] == 0) {
					vg[a] = 1;
					nq.emplace_back(a);
				}
			}
		}
		q = nq;
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 33768
n,m=map(int,input().split())
D=[1] * (n + 1)
for _ in range(m):
    D[int(input())] = 0
for i in range(n+1):
    if i > 1:
        D[i] = (D[i-1] + D[i-2]) % 1000000007 * D[i]
print(D[i])


Measured memory_bytes: 6976
#include "bits/stdc++.h"
using namespace std;

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;

int n, k, dp[N], a[N];

int go(int rem) {
    int &ans = dp[rem];
    if (~ans)
        return ans;
    ans = 0;

    // Each player tries to find atleast one losing state for his opponent

    FOR(i,1,n) if (rem - a[i] >= 0) {
        int get = go(rem - a[i]);
        ans |= get == 0;
    }
    return ans;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> k;

    FOR(i,1,n) {
        cin >> a[i];
    }    

    memset(dp, -1, sizeof(dp));

    cout << (go(k) ? "First" : "Second") << '\n';
}


Measured memory_bytes: 9868
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;

#define ll long long
#define mst(a) memset(a, 0, sizeof a)

const int mod = 1e9+7;
const int maxn = 1e5+50;
const int inf = 1e9;

char x[] = {'M', 'A', 'R', 'C', 'H'};
char s[maxn][15];
ll cnt[5];

int main()
{
  //  freopen("in", "r", stdin);
    int n;
    scanf("%d", &n);
    mst(cnt);
    for (int i = 0; i < n; ++i)
    {
        scanf("%s", s[i]);
        for (int j = 0; j < 5; ++j) if (s[i][0] == x[j]) 
            cnt[j]++;
    }
    ll ans = 0;
    for (int i = 0; i < 5; ++i)
        for (int j = i+1; j < 5; ++j)
            for (int k = j+1; k < 5; ++k)
                ans += cnt[i]*cnt[j]*cnt[k];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1664
import std.stdio, std.algorithm, std.conv, std.array, std.string;

int[int][10^^5 + 1] MEMO;

void main()
{
    auto s = readln.chomp;
    int v, p;

    foreach (gp; s) {
        switch (gp) {
            case 'g':
                if (p == 0) {
                    ++p;
                } else {
                    --p;
                    ++v;
                }
                break;
            case 'p':
                if (p == 0) {
                    --v;
                    ++p;
                } else {
                    --p;
                }
                break;
            default:
        }
    }

    writeln(v);
}

Measured memory_bytes: 3196
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N - 1; i++){
    cin >> A.at(i);
    cout << A.at(i) << " ";
  }
  cin >> A.at(N - 1);
  cout << A.at(N - 1) << endl;
  
  for(int i = 1; i < N; i++){
    int v = A.at(i);
    int j = i - 1;
    while(j >= 0 && A.at(j) > v){
      A.at(j + 1) = A.at(j);
      j--;
    }
    A.at(j + 1) = v;

    for(int k = 0; k < N - 1; k++){
      cout << A.at(k) << " ";
    }
    cout << A.at(N - 1) << endl;
  }
}



Measured memory_bytes: 3088
N, P = map(int, input().split())
A = list(map(int, input().split()))
ev = 0
od = 0
for a in A:
    if a % 2 == 0:
        ev += 1
    else:
        od += 1
if P == 0 and od == 0:
    print(2**ev)
else:
    print(2**ev * (2**od//2))

Measured memory_bytes: 3060
n,a,b=map(int,input().split())
if ((b-a)%2)==0:
    print(int(((b-a)//2)))
elif ((b-a)%2)==1:
    if (a-1)<(n-b):
        dis=(a-1)
        b=b-1
        print(int(((b-a)//2))+dis+1)
    elif (a-1)>=(n-b):
        dis=(n-b)
        a=a+1
        print(int(((b-a)//2))+dis+1)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

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


void solve()
{
	string sa, sb, sc;
	cin >> sa >> sb >> sc;
	int turn = 0;
	while (true) {
		if (turn == 0) { 
			if (sa.length() == 0) {
				cout << "A" << endl;
				return;
			}
			else {
				if (sa[0] == 'a')turn = 0;
				else if (sa[0] == 'b')turn = 1;
				else if (sa[0] == 'c')turn = 2;
				sa = sa.substr(1);
			}
		}
		else if (turn == 1) {
			if (sb.length() == 0) {
				cout << "B" << endl;
				return;
			}
			else {
				if (sb[0] == 'a')turn = 0;
				else if (sb[0] == 'b')turn = 1;
				else if (sb[0] == 'c')turn = 2;
				sb = sb.substr(1);
			}
		}
		else if (turn == 2) {
			if (sc.length() == 0) {
				cout << "C" << endl;
				return;
			}
			else {
				if (sc[0] == 'a')turn = 0;
				else if (sc[0] == 'b')turn = 1;
				else if (sc[0] == 'c')turn = 2;
				sc = sc.substr(1);
			}
		}
	}
}

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

Measured memory_bytes: 256
main(n){
	double x,y,z=1.570796,u;
	for(;scanf("%d",&n),--n>0;printf("%f\n%f\n",x,y))
		for(x=1,y=0;n--;x+=cos(z+u),y+=sin(z+u))u=atan2(y,x);
	exit(0);
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  char y, a, k, i;
  cin >> y >> a >> k >> i;
  
  string ans = "No";
  if (y == 'Y' && a == 'A' && k == 'K' && i == 'I') ans = "Yes";
  
  cout << ans << endl;
}

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

using namespace std;

void Main()
{
    int p, q, r;
    cin >> p >> q >> r;
    cout << p + q + r - max({p, q, r});
}

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

    std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
inline int read()
{
    int sum=0,p=1;char ch=getchar();
    while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
    if(ch=='-')p=-1,ch=getchar();
    while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
    return sum*p;
}

const int maxn=1e5+20;

int n,m;
int x[maxn],y[maxn];

bitset<500>a[500];

inline void init()
{
    n=read();m=read();
    REP(i,1,m)
    {
	x[i]=read();y[i]=read();
    }
    REP(i,1,n)
    {
	a[i][i]=1;
	DREP(j,m,1)
	{
	    if(a[i][x[j]] && a[i][y[j]]){ a[i].set();break;}
	    else if(!a[i][x[j]] && !a[i][y[j]]);
	    else a[i][x[j]]=a[i][y[j]]=1;
	}
    }
}

inline void doing()
{
    int ans=0;
    REP(i,1,n)REP(j,i+1,n)if(!(a[i]&a[j]).any())ans++;
    printf("%d\n",ans);
}

int main()
{
    init();
    doing();
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
using namespace std;
const long long m1=1e9+7;
long long  pow(long long a,long long n,long long m)
{
    long long ans=1;
    while(n){
        if(n&1){
            ans=(ans*a)%m;
        }
        a=(a*a)%m;
        n >>= 1;
    }
    return ans;
}
long long c(long long n,long long a)
{
	long long ans=1,ans1=1;
	for(long long i=n-a+1;i<=n;i++)
	ans=(ans*i)%m1;
	for(long long i=2;i<=a;i++)
	ans1=(ans1*i)%m1;
	ans1=pow(ans1,m1-2,m1);
	return ((ans%m1)*ans1)%m1;
}

int main()
{
	long long n,a,b,ans2;
	cin>>n>>a>>b;
	ans2=pow(2,n,m1);
	ans2=(ans2-1+4*m1-c(n,a)-c(n,b))%m1;
	cout<<ans2<<endl;
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> S.at(i).at(j);

  vector<vector<int>> T(H, vector<int>(W)), R(H, vector<int>(W)), B(H, vector<int>(W)), L(H, vector<int>(W));
  for (int i = 0; i < W; i++) for (int j = 0, k = 0; j < H; j++) T.at(j).at(i) = (S.at(j).at(i) != '#') ? ++k : k = 0;
  for (int i = 0; i < H; i++) for (int j = W - 1, k = 0; j >= 0; j--) R.at(i).at(j) = (S.at(i).at(j) != '#') ? ++k : k = 0;
  for (int i = 0; i < W; i++) for (int j = H - 1, k = 0; j >= 0; j--) B.at(j).at(i) = (S.at(j).at(i) != '#') ? ++k : k = 0;
  for (int i = 0; i < H; i++) for (int j = 0, k = 0; j < W; j++) L.at(i).at(j) = (S.at(i).at(j) != '#') ? ++k : k = 0;

  int ans = 0;
  for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) ans = max(ans, T.at(i).at(j) + R.at(i).at(j) + B.at(i).at(j) + L.at(i).at(j) - 3);
  cout << ans << "\n";
}

Measured memory_bytes: 67072
N = int(input())
A,B,C=[],[],[]
for i in range(N):
    a,b,c = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
dpa,dpb,dpc = A[0],B[0],C[0]
for i in range(1,N):
    a,b,c = dpa,dpb,dpc
    dpa = max(c,b)+A[i]
    dpb = max(c,a)+B[i]
    dpc = max(a,b)+C[i]
print(max(dpa,dpb,dpc))

Measured memory_bytes: 65368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n;
    double x;
    char s[10];
    double sum;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
	scanf("%lf %s", &x, s);
	if (!strcmp(s, "JPY")) {
	    sum += x;
	} else {
	    sum += x * 380000.0;
	}
    }

    printf("%lf\n", sum);

    return 0;
}



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

int main()
{
    int N;
    scanf("%d", &N);
    std::vector<int> p(N);
    for(int i=0; i<N; i++){
        scanf(" %d", &p[i]); p[i]--;
    }

    int count = 0;
    for(int i=0; i<N-1; i++){
        if(p[i] == i){
            p[i+1] = i; count++;
        }
    }
    if(p[N-1] == N-1) count++;

    std::cout << count << std::endl;
}

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

int main() {

    string s[3];
    cin >> s[0];
    cin >> s[1];
    cin >> s[2];

    int p[3] = {0};
    int i = 0;
    while (true) {
        if (p[i] >= s[i].length() )
            break;
        ++ p[i];
        i = s[i][p[i]-1]-'a';
    }

    char res = 'A' + i;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  if (N == 1)
    cout << 0 << endl;
  else
    cout << (N - 1) * N / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, count=0;
    bool tf=true;
    cin >> n;
    string s;
    while(n--){
        cin >> s;
        if(s=="A") count++;
        else if(s=="Un") count--;
        if(count<0) tf=false;
    }
    cout << (count==0&&tf? "YES":"NO") << "\n";
}



Measured memory_bytes: 3140
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        var tempArray = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

        var N = tempArray[0];
        var K = tempArray[1];
        var Q = tempArray[2];

        var memberPoints = Enumerable.Repeat(K - Q, N).ToList();

        for (var i = 0; i < Q; i++)
        {
            var A = int.Parse(Console.ReadLine());

            memberPoints[A - 1]++;
        }

        var ret = memberPoints.Select(f => f > 0 ? "Yes" : "No").ToList();

        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        /*何らかの出力処理*/
        Console.WriteLine(string.Join("\n", ret));
        Console.Out.Flush();
        
    }
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    ull a, b, k;
    cin >> a >> b >> k;
    if(a > k)
        cout << a - k << " " << b << endl;
    else if(a + b > k)
        cout << 0 << " " << b - (k - a) << endl;
    else
        cout << 0 << " " << 0 << endl;
    return 0;
}
//===========================================

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >> F;
    int ans1 = 0;
    int ans2 = 0;
    double noudo = 0.0;
    set<int> water;
    set<int> sugar;
    rep(i,F/100+1){
        rep(j,F/100+1){
            if(100*A*i+100*B*j <= F) water.insert(100*A*i+100*B*j);
        }
    }
    rep(i,F+1)rep(j,F+1){
        if(C*i+D*j <= F) sugar.insert(C*i+D*j);
    }
    for(int x : water)for(int y : sugar){
        double nownoudo = 0.0;
        if(x+y != 0) nownoudo = (double)(100*y)/(x+y);
        if(nownoudo >= noudo && x+y <= F && x*E >= 100*y){
            ans1 = x+y;
            ans2 = y;
            noudo = nownoudo;
        }
    }
    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r,d) for(ll i=(l);i<(r);i+=(d))
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define abs(p) ((p)>=(0)?(p):(-(p)))
ll A[2001], lowp[2001], lowa[2001];
int main(void){
    ll N, K, MOD=1000000007, k;
    scanf("%lld %lld", &N, &K);
    rep(i, 0, N, 1) scanf("%lld", A+i);
    //A[i]より後ろにいくつ小さいのがあるか
    rep(i, 0, N, 1){
        rep(j, i+1, N, 1) if(A[i]>A[j])lowp[i]++;
    }
    //全体として小さいのがいくつあるか
    rep(i, 0, N, 1) rep(j, 0, N, 1) if(A[i]>A[j]) lowa[i]++;
    if(K%2==0)k=((K+1)*(K/2) - K)%MOD;
    else k=(K*(K/2))%MOD;
    rep(i, 0, N, 1){
        A[2000] += (lowp[i]*K)%MOD + lowa[i]*k;
        A[2000] = A[2000]%MOD;
    }
    printf("%lld\n", A[2000]);
    return 0;
}


Measured memory_bytes: 256
import java.awt.Point;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();

		char[][] block = new char[h][w];
		Point[] point = new Point[n + 1];

		for (int y = 0; y < h; y++) {
			String s = sc.next();
			for (int x = 0; x < w; x++) {
				char c = s.charAt(x);
				if (c == 'S') {
					point[0] = new Point(x, y);
				} else if ('1' <= c && c <= '9') {
					point[c - '0'] = new Point(x, y);
				}
				block[y][x] = c;
			}
		}

		sc.close();

		int total = 0;

		for (int i = 0; i < n; i++) {
			int[][] time = new int[h][w];
			Queue<Point> q = new LinkedList<>();
			q.offer(point[i]);
			while (!q.isEmpty()) {
				Point p = q.poll();
				if (p.equals(point[i + 1])) {
					total += time[p.y][p.x];
					break;
				}
				for (int j = 0; j < 4; j++) {
					int _x = p.x + dx[j];
					int _y = p.y + dy[j];
					if (((0 <= _y && _y < h) && (0 <= _x && _x < w)) && time[_y][_x] == 0 && block[_y][_x] != 'X') {
						time[_y][_x] = time[p.y][p.x] + 1;
						q.offer(new Point(_x, _y));
					}
				}
			}
		}

		System.out.println(total);
	}
}

Measured memory_bytes: 105560
import java.util.*;
class Main{
    /*
     * 整数 -> nextInt() (遅い場合は下のni())
     * 単語 -> next()
     * 1行 -> nextLine()
     * 注意 : nextLIneをnext(),nextInt()のあとに呼び出す場合、次が改行だと改行だけ取ってしまうので注意
     */
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N];
        long[] b = new long[N];
        for(int i=0;i<N;i++){
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
        }

        long add = 0;
        for(int i=N-1;i>=0;i--){
            a[i] += add;

            long t = (a[i] + b[i] - 1) / b[i] * b[i] - a[i];
            add += t;
        }

        System.out.println(add);
    }
}


Measured memory_bytes: 86184