akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
#include<cmath>
#include<string>
#define pb push_back
//#define x first
//#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern



signed main() {    
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> v(n);
	
	for(int i =0 ; i < n ; i++)cin >> v[i];
	
	set<int> s;
	map<int,int> m;
	
	for(int i =0 ; i < n; i++){
		int temp;
		cin >> temp;
		m[temp] += 1;
		s.insert(temp);
	} 
	
	int l = 0;
	bool ok = true;
	vector<int> ans(n);
	
	for(int i= 0 ; i < n; i++){
		int val = v[i];
		auto beg = *s.begin();
		auto en = *s.rbegin();
		if(beg != en){
			if(val == beg){
				m[en] -= 1;
				if(m[en] == 0){
					s.erase(en);
				}
				ans[i] = en;
			}
			else{
				m[beg] -= 1;
				if(m[beg] == 0){
					s.erase(beg);
				}
				ans[i] = beg;
			}
		}
		else if(beg == en && en != val){
			m[beg] -= 1;
			ans[i] = beg;
			if(m[beg] == 0){
				s.erase(beg);
			}
			
		}
		else{
			m[beg] -= 1;
			bool found = false;
			while(l != i){
				
				if(v[l] != beg && ans[l] != beg){
					int temp = ans[l];
					ans[l] = beg;
					ans[i] = temp;
					l++;
					found = true;
					break;
				}
				l++;
			}
			
			if(found){
				if(m[beg] == 0){
					s.erase(beg);
				}
			}
			else{
				ok = false;
			}
			
		}
	} 
	
	if(!ok)
		cout<<"No";
	else{
		cout<<"Yes\n";
		for(auto it : ans){
			cout<< it << " ";
		}
	}
	 
	return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int a = 0, b = 0;
    rep(i, n) if (s[i] == 'R') a++;
    int ans = max(a,b);
    rep (i, n) {
        if (s[i] == 'R') a--;
        else b++;
        int now = max(a, b);
        ans = min(ans, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3724
n = int(input())
cards = []
for i in range(n):
    s,r = input().strip().split()
    cards.append((s,int(r)))

for (s,r) in [(s,r) for s in 'SHCD' for r in range(1,14) if (s,r) not in cards]:
    print(s,r)

Measured memory_bytes: 7612
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    vector<vector<int>> vec(n, vector<int>(n - 1));
    rep(i, n){
        rep(j, n - 1){
            cin >> vec[i][j];
            vec[i][j]--;
        }
        reverse(all(vec[i]));
    }
    int ans = 0;
    set<int> nextday;
    rep(i, n) nextday.insert(i);
    while(true){
        set<int> today = nextday;
        nextday.clear();
        vector<int> played(n, 0);
        bool f = false;
        for(auto &i : today){
            if(vec[i].size() == 0) continue;
            if(vec[vec[i].back()].size() == 0) continue;
            if(vec[vec[i].back()].back() == i){
                if(played[i] || played[vec[i].back()]){
                    //cout <<"ff "<<  i << " " << vec[i].back() << endl;
                    if(nextday.find(vec[i].back()) == nextday.end()){
                        nextday.insert(i);
                    }
                } else {
                    //cout << i << " " << vec[i].back() << endl;
                    played[vec[i].back()] = 1;
                    played[i] = 1;
                    nextday.insert(i);
                    nextday.insert(vec[i].back());
                    vec[vec[i].back()].pop_back();
                    vec[i].pop_back();
                    
                    f = true;
                }
            }
        }
        if(!f){
            cout << -1 << endl;
            return 0;
        }
        ans++;
        bool fin = true;
        rep(i,n){
            if(vec[i].size() != 0){
                fin = false;
                break;
            }
        }
        if(fin){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
import math


a, b, h, m = map(int, input().split())

theta_a = 2 * math.pi * (h + m / 60) / 12
theta_b = 2 * math.pi * m / 60

c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(theta_b - theta_a)
print(str(math.sqrt(c2)))


Measured memory_bytes: 9484
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(a) (int)((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}


signed main()
{
  int X, Y;
  cin >> X >> Y;
  int ans = 1;
  while (X*2 <= Y) {
    X *= 2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math

def calc(before, cur):
    sum = 0
    for i in range(len(before)):
        sum += ((before[i] - cur[i])**2)

    return (1 if math.sqrt(sum) % 1 == 0 else 0)

n, d = map(int, input().split())
Xs = []
for i in range(n):
    Xs.append(list(map(int, input().split())))

count = 0
for i in range(n-1):
    for j in range(i+1, n):
        count += calc(Xs[i], Xs[j])

print(count)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,w,wei[105]={},val[105]={};
  cin >> n >> w;
  ll dp[105][100005]={};
  for(int i=1; i<=n; i++) {
    cin >> wei[i] >> val[i];
  }
  for(int i=1; i<=n; i++) {
    for(int j=0; j<=w; j++) {
      if(j-wei[i]>=0) {
        dp[i][j]=max(dp[i-1][j-wei[i]]+val[i],dp[i-1][j]);
      }
      else {
        dp[i][j]=dp[i-1][j];
      }
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 82432
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
char s[N];
int ma[10009];
int main() {
    int n,p;
    scanf("%d%d%s",&n,&p,s+1);
    ll ans=0;
    if(10%p==0) {
        for(int i=1;i<=n;i++) {
            if((s[i]-'0')%p==0) ans+=i;
        }
    }
    else {
        int res=0,t=1;
        for(int i=n;i>=1;i--) {
            ma[res]++;
            res=(res+(s[i]-'0')*t)%p;
            t=t*10%p;
            ans+=ma[res];
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===

template <typename WT>
class UnionFind {
private:
	Vl par;
	Vl sizes;
	vector<WT> diff_weight;
public:
	UnionFind(lli n, WT SUM_UNITY = 0) : par(n), sizes(n, 1), diff_weight(n, SUM_UNITY) {
		for (lli i = 0; i < n; ++i) par[i] = i;
	}

	lli root(lli x) {
		if (par[x] == x) return x;
		lli r = root(par[x]);
		diff_weight[x] += diff_weight[par[x]];
		return par[x] = r;
	}

	bool unite(lli x, lli y, WT w) {
		w += weight(x) - weight(y);
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (sizes[x] < sizes[y]) {
			swap(x, y);
			w = -w;
		}
		par[y] = x;
		sizes[x] += sizes[y];
		diff_weight[y] = w;
		return true;
	}

	bool issame(lli x, lli y) {
		return root(x) == root(y);
	}

	lli size(lli x) {
		return sizes[root(x)];
	}

	WT weight(lli x) {
		root(x);
		return diff_weight[x];
	}

	WT diff(lli x, lli y) {
		return weight(y) - weight(x);
	}
};


int main() {
	int N;
	cin >> N;
	
	UnionFind<lli> uf(N);
	for (int i = 0; i < N - 1; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		uf.unite(--u, --v, w);
	}

	Vi colors(N);
	for (int i = 0; i < N; ++i) {
		if (uf.diff(0, i) % 2 != 0) {
			colors[i] = 1;
		}
	}

	for (const auto& val : colors) {
		cout << val << endl;
	}
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main() {
  int A,B,m;
  cin >> A >> B >> m;
  vector<int> a(A),b(B);
  int amin=inf,bmin=inf;
  rep(i,A){cin>>a[i]; amin=min(amin,a[i]);}
  rep(i,B){cin>>b[i]; bmin=min(bmin,b[i]);}

  int ans=amin+bmin;
  rep(i,m){
    int x,y,c; cin >> x >> y >> c; x--; y--;
    int tmp = a[x]+b[y]-c;
    ans = min(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}


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

class tree{public: int id,left,right; }data[25];

void Pre(int i){
	cout<<" "<<data[i].id;
	if(data[i].left!=-1)	Pre(data[i].left);
	if(data[i].right!=-1)	Pre(data[i].right);
}
void In(int i){
	if(data[i].left!=-1)	In(data[i].left);
	cout<<" "<<data[i].id;
	if(data[i].right!=-1)	In(data[i].right);
}
void Out(int i){
	if(data[i].left!=-1)	Out(data[i].left);
	if(data[i].right!=-1)	Out(data[i].right);
	cout<<" "<<data[i].id;
}

int main(){
	int n;	cin>>n;
	bool root[n];
	for(int i=0;i<n;i++)	root[i]=true;
	int no;
	for(int i=0;i<n;i++){
		cin>>no;	data[no].id=no;
		cin>>data[no].left>>data[no].right;
		root[data[no].left]=false;
		root[data[no].right]=false;
	}
	for(int i=0;i<n;i++){
		if(root[i]){
			cout<<"Preorder"<<endl;
			Pre(i);
			cout<<"\nInorder"<<endl;
			In(i);
			cout<<"\nPostorder"<<endl;
			Out(i);
			cout<<endl;
			return 0;
		}
	}
	return 0;
}		

Measured memory_bytes: 1164
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll mod=998244353;

int main() {
    ll n,i,w;cin>>n>>w;ll v[n],wt[n];
    for(i=0;i<n;i++)
    {
        cin>>wt[i]>>v[i];
    }
    ll dp[n+1][w+1];
    for(i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(wt[i-1]<=j)
            {dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-wt[i-1]]);}
            else 
            dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
    return 0;
}

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

int gcd(int x, int y){
    int r;
    if(x < y) std::swap(x, y);

    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    
    return x;
}

int main(void){
    int a, b;
    std::cin >> a >> b;
    std::cout << gcd(a, b) << std::endl;

    return 0;
}


Measured memory_bytes: 3084
mod = 10**9+7
n, m = map(int, input().split())
a = [0]*m
oks = [True]*(n+1)
for i in range(m):
    a = int(input())
    oks[a] = False
dp = [0]*(n+1)
dp[0] = 1
for now in range(n):
    for nex in range(now+1, min(n, now+2)+1):
        if oks[nex]:
            dp[nex] += dp[now]
            dp[nex] %= mod
print(dp[n])

Measured memory_bytes: 45940
#include <stdio.h>
#define MAX 2000000

void max(int);
int n,A[MAX+1];

int main(){
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%d",&A[i]);
    for(i=n/2;i>=1;i--) max(i);
    for(i=1;i<=n;i++) printf(" %d",A[i]);
    printf("\n");
    return 0;
}
void max(int i){
    int l,r,larg,temp;
    l=2*i;
    r=2*i+1;
    if(l<=n && A[l]>A[i]) larg=l;
    else larg=i;
    if(r<=n && A[r]>A[larg]) larg=r;

    if(larg!=i){
       temp=A[i];
       A[i]=A[larg];
       A[larg]=temp;
       max(larg);
    }
}


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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  vector<ll> vi(n);
  map<ll, ll> m;
  for (int i = 0; i < n; i++)
  {
    ll num;
    cin >> num;
    vi.at(i) = num;
    if(m.count(num)) m.at(num)++;
    else m[num] = 1; 
  }
  ll sum = 0;
  for(auto e : m)
  {
    ll a = e.second;
    sum += a*(a-1)/2;
  }
  for (int i = 0; i < n; i++)
  {
    ll a = m.at(vi.at(i));
    ll ans = sum - (a - 1);
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 11136
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int a = fs.nextInt();
        System.out.println(n * n - a);
    }
}


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


N = int(input())
S = input()

sli = [ord(c) for c in S]
sli_mod = [n + N for n in sli]

for i, s in enumerate(sli_mod):
    if s > ord('Z'):
        sli_mod[i] -= 26

# print(sli_mod)
final = [chr(c) for c in sli_mod]
out = "".join(final)
print(out)


Measured memory_bytes: 3316
#include<cstdio>
#include<algorithm>
#define REP(i,a,n) for(int i = a;i < n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;
int in(){int x;scanf("%d",&x); return x;}

int field[100002];
using namespace std;
int main(void){
   int n,k;
   while(scanf("%d%d",&n,&k),n+k){
      rep(i,n+1) field[i] = 0;
      rep(i,k) field[in()] = 1;
      if(field[0] == 1){
         REP(i,1,n+1){
            if(field[i-1] == 1 && field[i] == 0) field[i] = 2;
         }
      }
      bool flag = false;
      int sub = 0;
      int cnt = 0;
      int ma = 0;
      REP(i,1,n+2){
         if(field[i] == 0){
            flag = false;
            ma = max(ma,cnt);
            cnt = 0; sub = 0;
         }
         else if(field[i] == 2){
            if(flag == true){
               ma = max(ma,cnt);
               cnt -= sub;
               cnt++;
               sub = cnt;
            }
            else{
               flag = true;
               cnt += 1;
               sub = cnt;
            }
         }
         else if(field[i] == 1){
            cnt += 1;
         }
      }
      printf("%d\n",ma);
   }
}

Measured memory_bytes: 1416
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int N;
  cin >> N;
  vector<int> a(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> a.at(i);
  }
  vector<int> b(N);
  for (int i = 0; i < N - 1; i++) {
    b.at(a.at(i) - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << b.at(i) << endl;
  }
  return 0;
}

// g++ lo.cpp
// ./a.exe
// g++ -o つくりたいふぁいるめい　もとのふぁいる.cpp
/*
for (int i = 0; i < n - 2; i++) {
  for (int j = i + 1; j < n - 1; j++) {
    int k = 2 * j - i;*/

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

int main() {
  string S;
  cin >> S;
  int count = 0;
  if (S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'R') count = 3;
  else if (S.at(0) == S.at(1) && S.at(0) == 'R') count = 2;
  else if (S.at(1) == S.at(2) && S.at(1) == 'R') count = 2;
  else if (S.at(0) == 'R' || S.at(1) == 'R' || S.at(2) == 'R') count = 1;
  else count = 0;
  cout << count << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define modulo 998244353



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    ll ans=0;
    ll p1=x/500;
    x-=500*p1;
    ll p2=x/5;
    ans=p1*1000ll + p2*5;
    cout<<ans<<nl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int[][] A = new int[H][W];
    int[][] B = new int[H][W];
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) A[i][j] = sc.nextInt();
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) B[i][j] = sc.nextInt();
    sc.close();
    
    int m = (H + W) * 80;
    boolean[][][] dp = new boolean[H][W][m * 2 + 1];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int c = Math.abs(A[i][j] - B[i][j]);
        boolean[] d = dp[i][j];
        if (i == 0 && j == 0) {
          d[m - c] = true;
          d[m + c] = true;
        } else {
          for (int k = 0; k < d.length; k++) {
            if (0 < i && dp[i - 1][j][k]) {
              //if (-1 < k - c) 
                d[k - c] = true;
              //if (k + c < d.length) 
                d[k + c] = true;
            }
            if (0 < j && dp[i][j - 1][k]) {
              //if (-1 < k - c) 
                d[k - c] = true;
              //if (k + c < d.length) 
                d[k + c] = true;
            }
          }
        }
      }
    }
    boolean[] d = dp[H - 1][W - 1];
    int ans = d.length;
    for (int k = 0; k < d.length; k++)
      if (d[k])
        ans = Math.min(ans, Math.abs(m - k));
    System.out.println(ans);
  }
}


Measured memory_bytes: 243824
#include<stdio.h>
#define N 1000000

int main()
{
  int i,j,key,n,q,cnt=0,S[N],T[N];

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

  scanf("%d",&q);
  i = 0;
  while(i<q)
    {
      scanf("%d",&T[i]);
      for(j=0;j<i;j++)
	if(T[i] == T[j]) break;
      if(i == j) i++;
    }

  for(i=0;i<q;i++)
    {
      j = 0;
      key = T[i];
      while(key != S[j])
	{
	  j++;
	  if(j == n) break;
	}
      if(j != n) cnt++;
    }

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



Measured memory_bytes: 2044
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        boolean[] a = new boolean[n];

        for(int i = 0; i < k; i++){
            int d = sc.nextInt();
            for(int j = 0; j < d; j++){
                a[sc.nextInt() - 1] = true;
            }
        }

        int sum = 0;
        for(int i = 0; i < n; i++){
            if(!a[i]){
                sum++;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 46404
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <vector>
using namespace std;
void abc117a()
{
  double t, x;
  cin >> t >> x;
  cout << t / x;
}
int main(void)
{
  abc117a();
  return 0;
}


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

int main(){
    int N, X;
    cin >> N >> X;
    int d = 0, ans = 0;
    rep(i,N) {
        int L; cin >> L;
        if(d <= X) ans++;
        d += L;
    }
    if(d <= X) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

vector<int> G[MAX_N];
vector<int> deg;

void tsort(int n, vector<int>& res) {
	queue<int> que;
	rep(i,n){
        if(deg[i] == 0){
            que.push(i);
        }
    }
	while(!que.empty()){
		int p = que.front();
        que.pop();
		res.pb(p);
		rep(i,G[p].size()){
            if(--deg[G[p][i]] == 0){
                que.push(G[p][i]);
            }
        }
	}
	if(*max_element(all(deg)) != 0){
        res.clear();
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    deg.resize(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        deg[b]++;
    }
    vector<int> res;
    tsort(n,res);
    if((int)res.size() != 0){
        rep(i,res.size()){
            cout << res[i] << endl;
        }
    }else{
        cout << "-1\n";
    }
    return 0;
}

Measured memory_bytes: 6020
from itertools import product

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

mp = {}
for ptn in product([0, 1, 2, 3], repeat=N):
    a, b, c = 0, 0, 0
    x = 0
    for i in range(N):
        if ptn[i] == 1:
            if a != 0:
                x += 10
            a += l[i]
        elif ptn[i] == 2:
            if b != 0:
                x += 10
            b += l[i]
        elif ptn[i] == 3:
            if c != 0:
                x += 10
            c += l[i]
    if a * b * c == 0:
        continue
    mp[ptn] = abs(A - a) + abs(B - b) + abs(C - c) + x
print(min(mp.values()))


Measured memory_bytes: 14116
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n, m;
  cin >> n >> m;

  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << en;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int p;
    cin>>p;
  string s;
  cin>>s;
  int l=s.length();
  int i,count=0;
  for(i=0;i<l;i++)
  {
    if(s[i]=='A'&&s[i+1]=='B'&& s[i+2]=='C')
    {
      count++;
      i+=2;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{ 
  int X,A,B;
  cin>>X>>A>>B;
  int c; 
  c=(X-A)/B;
  int d;
  d=X-A-(c*B);
  cout<<d;
  system("pause");
  return 0;
}


Measured memory_bytes: 504
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <sstream>
# include <set>
# include <cmath>
# include <algorithm>
# pragma  comment(linker,"/STACK:102400000,102400000")
using namespace std;
# define LL          long long
# define pr          pair
# define mkp         make_pair
# define lowbit(x)   ((x)&(-x))
# define PI          acos(-1.0)
# define INF         0x3f3f3f3f3f3f3f3f
# define eps         1e-8
# define MOD         1000000007

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
# define MX 205
/**************************/

int n,m,R;
int ans;
int goal[MX];
int mp[MX][MX];
int G[10][10];

void floyd()
{
    for (int k=1;k<=n;k++)
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
                if (mp[i][j]>mp[i][k]+mp[k][j])
                    mp[i][j] = mp[i][k]+mp[k][j];
}

int prim()
{
    int dis[10];
    int vis[10];
    memset(dis,0x3f,sizeof(dis));
    memset(vis,0,sizeof(vis));
    dis[1] = 0;

    int all = 0;
    for (int i=1;i<=R;i++)
    {
        int dex, mmm = INF;
        for (int j=1;j<=R;j++)
        {
            if (!vis[j]&&dis[j]<mmm)
            {
                mmm=dis[j];
                dex=j;
            }
        }
        all += dis[dex];
        vis[dex]=1;
        for (int j=1;j<=R;j++)
        {
            if (!vis[j]&&dis[j]>G[dex][j])
                dis[j]=G[dex][j];
        }
    }
    return all;
}

int vis[10];
void dfs(int s,int pos,int far)
{
    if (s>R)
    {
        ans = min(ans,far);
        return ;
    }
    for (int i=1;i<=R;i++)
    {
        if (vis[i]) continue;
        vis[i] = 1;
        dfs(s+1,i,far+G[pos][i]);
        vis[i]=0;
    }
}

int main()
{
    scanf("%d%d%d",&n,&m,&R);

    for (int i=1;i<=R;i++)
        goal[i] = scan();

    memset(mp,0x3f,sizeof(mp));
    for (int i=1;i<=m;i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        mp[a][b] = mp[b][a] = c;
    }

    floyd();
    for (int i=1;i<=R;i++)
        for (int j=1;j<=R;j++)
            G[i][j] = mp[ goal[i] ][ goal[j] ];

    ans = INF;
    for (int i=1;i<=R;i++)
    {
        vis[i]=1;
        dfs(2,i,0);
        vis[i]=0;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
int main() {
    int a, b, c;
  	int ans = 0;
  	int temp = 0;
  	int temp2 = 0;
  	cin >> a >> b >> c;
  	for(int i = 1; i <= a; ++i){
      temp = 0;
      temp2 = i;
    	while(temp2 > 0){
           temp += temp2 % 10;
           temp2 = temp2 / 10;
        }
      if(temp >= b && temp <= c) ans += i;
  	}
 	  	
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <list>
#include <deque>
#include <algorithm>
#include <stack>
#include <numeric>
#include <time.h>
#include<iomanip>
#include<sstream>
#pragma disable:4996)
using namespace std;
const long long inf = 0x7f7f7f7f;
long long GCD(long long a, long long b) { return 0 == b ? a : GCD(b, a%b); }
const long long mod = 1e9 + 7;
const double pi = acos(-1);
int main()
{
	ios_base::sync_with_stdio(false);
	int a[200],b[200];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for (int i = 0; i < n; i++)
		a[i] = a[i] - b[i];
	int sum = 0;
	for (int i = 0; i < n; i++)
		if (a[i] >= 0)
			sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll x,y;
    while(cin>>x>>y){
        if(x%y==0)cout<<"-1"<<endl;
        else cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();

        int answer = 0;
        Deque<Boolean> oneStack = new ArrayDeque<>();
        for (int i = 0; i < s.length(); i++) {
            boolean one = (s.charAt(i) == '1');
            if (oneStack.size() == 0) {
                oneStack.push(one);
            } else {
                boolean top = oneStack.pop();
                if (top != one) {
                    answer += 2;
                } else {
                    oneStack.push(top);
                    oneStack.push(one);
                }
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 27584
N = int(input())
a = list(map(int,input().split()))
M = N
W = N

mydict = {}
for i in range(N):
    mydict[i] = 0


for i in range(len(a)):
    if M-a[i] <= N:
        mydict[a[i]-1] += 1 
        N -= 1
        M -= a[i]

for i in range(W):
    print(mydict[i])

    


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

int main(){
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a){
        cout << k << endl;
    }
    else if(a<k&&k<=a+b){
        cout << a << endl;
    }
    else{
        cout << a-(k-a-b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint n, k;
    cin >> n >> k;
    vec a(n);
    vector<unordered_map<int, bool>> g2(n);
    vec g[200050];
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }

    rep(i, n) {
        if (!g2[i][a[i]]) {
            g[i].push_back(a[i]);
        }
        g2[i][a[i]] = true;
    }

    vector<bool> iv(n, false);

    int cur = 0;

    while (!iv[cur]) {
        iv[cur] = true;
        cur = a[cur];
    }

    int l = 0;
    int s = cur;
    
    while (true) {
        if (l != 0 && cur == s) break;
        cur = a[cur];
        l++;
    }

    int s_to_cur = 0;
    cur = 0;

    while (cur != s) {
        cur = a[cur];
        s_to_cur++;
    }

    if (s_to_cur > k) {
        int res = 0;
        rep(i, k) res = a[res];
        res++;
        cout << res << endl;
    }
    else {
        k = s_to_cur + ((k - s_to_cur) % l);
        int res = 0;
        rep(i, k) res = a[res];
        res++;
        cout << res << endl;
    }

    return 0;
}

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

using namespace std;

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

    int n, sum;
    vector<int> b;
    cin >> n;

    for (int i = 0; i < n - 1; ++i) {
        int x;
        cin >> x;
        b.emplace_back(x);
    }

    sum = b[0];
    for (int i = 0; i < n-2; ++i) {
        sum += min(b[i], b[i+1]);
    }

    sum += b[b.size() - 1];
    cout << sum;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int h;
int memo[11][5];
int bf,ans;
 
 
int main(){
  int i,j,k;
  while(1){
    scanf("%d",&h);
    if(h==0)break;
    bf=-1;
    ans=0;
    for(i=0;i<h;i++)for(j=0;j<5;j++)scanf("%d",&memo[i][j]);
    while(ans!=bf){
      bf = ans;
      //消す作業
      for(i=0;i<h;i++)for(j=0;j<3;j++){
      int now=j;
      while(memo[i][now]==memo[i][j]&&j<5)j++;
      if(j-now>=3&&memo[i][now]!=-1){
        ans+=(j-now)*memo[i][now];
        for(k=now;k<j;k++)memo[i][k]=-1;
      }
      j--;
    }
      //落とす作業
      for(j=0;j<5;j++)for(i=h-1;i>=0;i--){
      int now=i;
      while(memo[i][j]==-1&&i>=0)i--;
      if(i>=0&&now!=i){
        memo[now][j]=memo[i][j];
        memo[i][j]=-1;
        i=now;
      }
    }
      /*for(i=0;i<h;i++){
    for(j=0;j<5;j++)printf("%d ",memo[i][j]);
    printf("\n");
      }
      printf("\n");*/
    }
    printf("%d\n",ans);
     
  }
  return 0;
}



Measured memory_bytes: 2052
#include <iostream>

using namespace std;

int isSearch(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main() {
    int n, cnt = 0;
    cin >> n;
    int A[n+1];
    for(int i = 0; i < n; i++) cin >> A[i];
    int q;
    cin >> q;
    for(int i = 0; i < q; i++) {
        int key;
        cin >> key;
        if(isSearch(A, n, key)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct dat {
	int px, py; string s;
};
bool operator<(const dat& d1, const dat& d2) {
	if (d1.px != d2.px) return d1.px < d2.px;
	return d1.py < d2.py;
}
int H, W, z; string s[109][109];
int main() {
	while (cin >> H, H) {
		cin >> W; H++; W++;
		if (z++) cout << endl;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> s[i][j];
			}
		}
		vector<dat> ret;
		for (int i = 0; i <= 1000; i++) {
			for (int j = 0; j < H - 1; j++) {
				int a = stoi(s[j][W - 1]), cnt = 0;
				for (int k = 0; k < W - 1; k++) {
					if (s[j][k] != "?") a -= stoi(s[j][k]);
					else cnt++;
				}
				if (cnt == 1) {
					for (int k = 0; k < W - 1; k++) {
						if (s[j][k] == "?") {
							s[j][k] = to_string(a);
							ret.push_back(dat{ j, k, s[j][k] });
						}
					}
				}
			}
			for (int j = 0; j < W - 1; j++) {
				int a = stoi(s[H - 1][j]), cnt = 0;
				for (int k = 0; k < H - 1; k++) {
					if (s[k][j] != "?") a -= stoi(s[k][j]);
					else cnt++;
				}
				if (cnt == 1) {
					for (int k = 0; k < H - 1; k++) {
						if (s[k][j] == "?") {
							s[k][j] = to_string(a);
							ret.push_back(dat{ k, j, s[k][j] });
						}
					}
				}
			}
		}
		bool flag = true;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (s[i][j] == "?") flag = false;
			}
		}
		if (!flag) cout << "NO" << endl;
		else {
			sort(ret.begin(), ret.end());
			for (int i = 0; i < ret.size(); i++) cout << ret[i].s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3284
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) {                                       \
   cerr << "\e[91m";                                        \
   cerr << __LINE__ << ": " << #x << " = "; DBG::_print(x); \
   cerr <<"\e[39m";                                         \
}
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N;
   cin >> N;

   vector<llong> A(N);
   REP(i, N)
      cin >> A[i];

   vector<llong> R(N);

   REP(b, 31) {
      llong xsum = 0;
      FOR(i, 1, N-1) {
         llong x = (A[i] ^ A[0]) & (1LL<<b);
         R[i] |= x;
         xsum ^= x;
      }
      if ( (A[0] & (1LL<<b) ) != xsum) {
         R[0] |= 1LL<<b;
         FOR(i, 1, N-1) {
            R[i] ^= (1LL<<b);
         }
      }
   }

   REP(i, N)
      cout << R[i] << ' ';
   cout << endl;

   return 0;
}


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

int main(){
  long long A,B,c=1;
  cin >> A >> B;
  if(A<B){
    c=A;
    A=B;
    B=c;
  }
  long long a=A,b=B;
while(c!=0){
  c=a%b;
  a=b;
  b=c;
}  
c=a;

  
  A/=c;
  B/=c;
  
  A=A*B*c;
  
  cout << A << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll; 
#define pb push_back
#define mp make_pair
#define mod 998244353
#define vi vector <ll>
using namespace std ; 
ll power(ll x,ll y,ll m)
{            //power(x,y)=x^y  %m;
	ll res=1%m;
	while(y)
	{
	    if(y&1)
	    res=(res*x)%m;
	    x=(x*x)%m;
	    y=(y>>1)%m;
	}
	return res;
}
ll mod_inverse(ll x,ll m)
{
	return power(x,m-2,m);
}
vector<vector<ll> >g;
   vector<ll>v;
   ll vis[2005];
   vector<ll>v1;
void dfs(ll i)
{
    vis[i]=1;
    v1.pb(i);
    for(ll j=0;j<g[i].size();j++)
    {
        if(!vis[g[i][j]])
        dfs(g[i][j]);
        
    }
}
int main ()
{
    ios_base :: sync_with_stdio ( false );
    cin.tie( NULL );
    cout.tie( NULL );
ll t = 1 ;
//cin>>t;
while ( t--)  
{
  ll n;
  cin>>n;
  ll a[n+1];
  for(ll i=1;i<=n;i++)
  cin>>a[i];
  ll cnt=0;
  for(ll i=1;i<=n;i++)
  {
      if(a[i]%2==1 && i%2==1)
      cnt++;
  }
  cout<<cnt<<"\n";
  
}
 

 return 0;
}

Measured memory_bytes: 3616
import math
import numpy as np
MOD = 10**9 + 7
def create_modC(n, mod):
    if n == 0:
        return (lambda r: 1)
    b = int(math.log(mod-2, 2)) + 1
    fac = np.zeros((b, n+1), dtype=np.int64)
    inv = np.ones(n+1, dtype=np.int64)
    fac[0, 0], fac[0, 1] = 1, 1
    for i in range(2, n+1):
        fac[0, i] = (fac[0, i-1] * i) % mod
    for i in range(1, b):
        fac[i, :] = (fac[i-1, :] ** 2) % mod

    indice = []
    N = mod - 2
    i = 0
    while N > 0:
        if N % 2 == 1:
            indice.append(i)
        N = N >> 1
        i += 1
    for i in indice:
        inv *= fac[i,:]
        inv %= mod
    fac = fac[0,:]

    def _modC(r):
        result = fac[n] * inv[n-r]
        result %= mod
        result *= inv[r] % mod
        result %= mod
        return result

    return _modC

def f(s):

    n = 1
    ans = 0
    while s - 3*n >= 0:
        r = s - 3*n
        modC = create_modC(n+r-1, MOD)
        ans += modC(r)
        ans %= MOD
        n += 1
    
    return ans

def main():
    S = int(input())

    ans = f(S)

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int a,b,c;
cin>>a>>b>>c;
if(a+b+c == 17){
    cout<<"YES";
}else{
    cout<<"NO";
}
return 0;
}


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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 413

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
ll arr[MAXN];
bitset<MAXN> vis[MAXN];
ll dp[MAXN][MAXN];

ll solve(int l, int r)
{
	if (l == r) return 0;
	if (vis[l][r]) return dp[l][r];
	vis[l][r] = true;
	dp[l][r] = LLINF;
	FOR(j, l, r)
	{
		ckmin(dp[l][r], solve(l, j) + solve(j + 1, r));
	}
	FOR(j, l, r + 1) dp[l][r] += arr[j];
	return dp[l][r];
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	FOR(i, 0, N) cin >> arr[i];
	cout << solve(0, N - 1) << '\n';
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;
int inf = 1e9;
struct edge{int to, cap, rev;};
vector<edge> G[10010];
int level[10010];
int iter[10010];
void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> Q;
	level[s] = 0;
	Q.push(s);
	while(!Q.empty()){
		int v = Q.front(); Q.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to]<0){
				level[e.to] = level[v]+1;
				Q.push(e.to);
			}
		}
	}
}

int dfs(int v,int t,int f){
	if(v==t) return f;
	for(int &i=iter[v];i<G[v].size();i++){
		edge &e = G[v][i];
		if(level[v]<level[e.to] && e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow = 0;
	for(;;){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,inf))>0) flow += f;
	}
}

int V,E;

int main(){
	cin >> V >> E;
	for(int i=0;i<E;i++){
		int t,c,r;
		cin >> t >> r >> c;
		add_edge(t,r,c);
	}
	cout << max_flow(0,V-1) << endl;
}


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

int main()
{
	int n;
	cin>>n;
	
	vector<pair<int,int>> p;
	
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		p.push_back({x,y});
	}
	
	int j=1;
	int k=2;
	
	for(int i=0;i<n-2;i++)
	{
		j=i+1;
		k=i+2;
		if(p[i].first == p[i].second && p[j].first == p[j].second && p[k].first == p[k].second)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		
	}
	cout<<"No"<<endl;
	return 0;
}	


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

// 約数のvectorを返す
vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != n / i) ret.push_back(n / i);
        }
    }
    return ret;
}

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

    int n;
    cin >> n;

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

    vector <int> ans;
    for (int i = n; i > 0; i--) {
        if (a[i]) {
            ans.push_back(i);
            vector <int> div = divisor(i);
            for (int d : div) {
                a[d] = (a[d] + 1) % 2;
            }
        }
    }

    cout << ans.size() << "\n";
    for (int ret : ans) cout << ret << " ";

    return 0;
}

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

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

	cin >> a >> b >> c;

	if (a*b % 2 == 1) {
		cout << "Odd" << endl;
	}

	else {
		cout << "Even" << endl;
	}

	return 0;
}

Measured memory_bytes: 256