akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int main(){
	char s[5];
	cin>>s;
	sort(s,s+4);
	if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[3])o("Yes");else o("No");
}


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

int div100(int n){
    if(n % 100 != 0) return 0;
    return div100(n / 100) + 1;
}

int main(void) {
    int d, n;
    int cnt = 0;
    cin >> d >> n;
    for(int i = 1;; i++){
        if(div100(i) == d){
            cnt++;
            if(cnt == n){
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string.h>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;

int main(){
	int n, m, k;
	cin >>n >>m >>k;
	if (n * m > k)
		cout <<k <<endl;
	else cout <<n * m <<endl;

}





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

using namespace std;

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

	int cnt = 0, atual = 1;
	for(int i = 0; i < n; i++){
		int aux; cin >> aux;
		if(aux == atual){
			atual++; cnt++;
		}
	}

	if(atual == 1) cout << "-1\n";
	else 
		cout << n - cnt << '\n';

	return 0;
}

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

const lli INF=1e8+8;

int main()
{
    lli n;
    cin>>n;
    if(n>=30)
    {
        cout<<"Yes"<<"\n";
    }else
    {
        cout<<"No"<<"\n";
    }
    
    

    return 0;
    
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;

li a[22];
li b[22];
li c[22];

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

	li prev = -2;
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n - 1) {
		cin >> c[i];
	}

	li res = 0;
	rep(i, n) {
		res += b[a[i]];
		if (prev == a[i] - 1) {
			res += c[a[i] - 1];
		}
		prev = a[i];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

cost = 0
diff = max(0, sum(A[0:2]) - X)
A[0] -= max(0, diff - A[1])
A[1] -= min(A[1], diff)
cost += diff

for i in range(2, N):
    diff = max(0, A[i - 1] + A[i] - X)
    A[i - 1] -= max(0, diff - A[i])
    A[i] -= min(A[i], diff)
    cost += diff

print(cost)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    i64 K;
    cin >> K;
    int N = 50;
    cout << N << endl;
    string delim = "";
    i64 q, r;
    q = K / N, r = K % N;
    for(int i = 0; i < N; i++) {
        cout << delim << (N - 1 + q - r + (N - r <= i ? N + 1 : 0));
        delim = " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (N, A, B) = readInputLine().split(" ").map { it.toLong() }

    var ans = 0L

    if ((B - A) % 2L == 0L) {
        ans = (B - A) / 2L
    } else {
        if (A - 1L < N - B) {
            ans = A
            B -= A
            A = 1
            ans += (B - A) / 2L
        } else {
            ans = N - B + 1L
            A += N - B + 1L
            B = N
            ans += (B - A) / 2L
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36072
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var A = AB[0];
            var B = AB[1];

            if((A-B)%2 == 0)
            {
                Console.WriteLine((A + B) / 2);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
            
        }
    }

}


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
	int n;
	cin >> n;
	map<string, int> mp;
	rep(i, n) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++; //ない要素が来たら0初期化
	}
	ll ans = 0;
	for (auto& p : mp) {
		int s = p.second;
		ans += (ll)s*(s - 1) / 2;
	}
	cout << ans << endl;
}

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

int		main(void)
{
	for (int i = 0; i < 3; i++)
	{
		char	a;
		cin >> a;
		cout << (a == '1' ? 9 : 1);
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

multiset<int> setik;
int n, m;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &m);
	while(n--) {
		int x;
		scanf("%d", &x);
		setik.insert(x);
	}
	while(m--) {
		auto it = setik.end();
		it--;
		int x = *it;
		setik.erase(it);
		setik.insert(x / 2);
	}
	ll ans = 0;
	for (int t : setik) ans += t;
	printf("%lld\n", ans);

	return 0;
}


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

int N;
int H[100100];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> H[i];
    int ans = 0;
    int now = 0;
    rep(i, N-1) {
        if (H[i]>=H[i+1]) now++;
        else now = 0;
        ans = max(ans, now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=1e5+11;
struct Edge{
	int v;Edge *nex;
}pl[N<<1],*cur=pl,*G[N];
void ins(int u,int v){
	cur->v=v,cur->nex=G[u],G[u]=cur++;
}
int n,A[N],d[N],f[N],g[N];
void dfs(int x,int fa=0){
	int th=0,mx=0;
	Es(x,i)if(i->v!=fa){
		dfs(i->v,x);
		g[x]+=g[i->v];
		f[x]+=f[i->v];
		mx=max(mx,g[i->v]-f[i->v]);
		th+=g[i->v]-f[i->v];
	}
	if(!g[x]){
		g[x]=A[x];return;
	}else if(th<A[x]){
		puts("NO");
		exit(0);
	}
	if(th>2*A[x]||mx>A[x]){
		puts("NO");
		exit(0);
	}
	f[x]+=2*(th-A[x]);
}
int main(){
	n=rd();
	rep(i,1,n)A[i]=rd();
	rep(i,2,n){
		int u=rd(),v=rd();
		ins(u,v),ins(v,u);
		d[u]++,d[v]++;
	}
	if(n==2){
		return puts(A[1]==A[n]?"YES":"NO"),0;
	}
	int rt;
	rep(i,1,n){
		if(d[i]^1){
			rt=i;
			break;
		}
	}
	dfs(rt);
	puts(f[rt]==g[rt]?"YES":"NO");
}

Measured memory_bytes: 11008
M=998244353
f=lambda:[*map(int,input().split())]
n,k=f()
lr=[f() for _ in range(k)]
dp=[0]*n
dp[0]=1
S=[0]
for i in range(1,n):
  S+=[S[-1]+dp[i-1]]
  for l,r in lr:
    dp[i]+=S[max(i-l+1,0)]-S[max(i-r,0)]
  dp[i]%=M
print(dp[-1])

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

A = [-1] + [int(x) for x in input().split()] + [10**9 + 1]

b, c = 0, 0
for i in range(1, n + 2):
    if A[i - 1] >= A[i]:
        c += 1
    else:
        b = max([b, c])
        c = 0

print(b)


Measured memory_bytes: 63984
#include <stdio.h>

int main(void) {
  int N, M, L, n, m, l;
  int vecA[100][100], vecB[100][100];

  /* 情報数読取り */
  scanf("%d %d %d\n", &N, &M, &L);

  /* 情報格納 */
  for (n = 0; n < N; n++)
    for (m = 0; m < M; m++)
      scanf("%d", &vecA[n][m]);
  for (m = 0; m < M; m++)
    for (l = 0; l < L; l++)
      scanf("%d", &vecB[m][l]);

  /* 情報表示 */
  for (n = 0; n < N; n++) {
    for (l = 0; l < L; l++) {
      long sum = 0;
      for (m = 0; m < M; m++) {
        sum = sum + vecA[n][m] * vecB[m][l];
      }
      printf("%ld", sum);
      if (l != (L-1))
        printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 680
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    string s, t;
    cin >> s >> t;
    int ans = t.size();
    rep(i, s.size()-t.size()+1) {
        int tmp = 0;
        rep(j,t.size()){
            if(s[i+j] != t[j]) tmp++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3632
from itertools import starmap

n, m, c = map(int, input().split())
B = list(map(int, input().split()))

A = [ list(map(int, input().split())) for _ in range(n) ]

count = 0
for i in range(n):
	pair = list(zip(A[i], B))
	mul = starmap(lambda a, b: a*b, pair)
	if sum(mul) + c > 0:
		count += 1


print(count)

Measured memory_bytes: 3188
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut a: Vec<i64> = Vec::with_capacity(n + 1);
    let mut before: i64 = 0;
    for _i in 0..(n + 1) {
        let ai = iterator.next().unwrap().parse().unwrap();
        a.push(ai);
        before += ai;
    }

    let mut after: i64 = 0;
    for i in 0..n {
        let mut b: i64 = iterator.next().unwrap().parse().unwrap();
        if a[i] < b {
            b -= a[i];
            a[i] = 0;
            a[i + 1] = max(0, a[i + 1] - b);
        } else {
            a[i] -= b;
        }
        after += a[i];
    }
    after += a[n];

    let ans: i64 = before - after;

    return ans.to_string();
}


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

int g;
int prior[128];
int lft[16];
string s;
int pos;

void expr(int pr, deque<char> &res){
	if( pr == g ){
		if( s[pos] == '(' ){
			++pos;
			expr(0, res);
			++pos;
		}
		else{
			res.push_back( s[pos] );
			++pos;
		}
	}
	else{
		deque<char> dq;

		expr(pr + 1, dq);

		while( prior[s[pos]] == pr ){
			dq.push_front('(');
			dq.push_back( s[pos] );
			++pos;
			expr(pr + lft[pr], dq);
			dq.push_back(')');
		}
		
		res.insert( res.end(), dq.begin(), dq.end() );
	}
}

int main(){
	int d, m, n;
	char a, p;
	
	prior['('] = prior[')'] = -1;
	
	cin >> d;
	while( d-- ){
		cin >> g;
		for(int i = 0; i < g; ++i){
			cin >> a >> m;
			lft[i] = (a == 'L');
			
			for(int j = 0; j < m; ++j){
				cin >> p;
				prior[p] = i;
			}
		}
		
		cin >> n;
		for(int i = 0; i < n; ++i){
			cin >> s;
			s = '(' + s + ')';
			pos = 0;
			deque<char> res;
			expr(g, res);
			cout << string(res.begin(), res.end()) << '\n';
		}
		
		if( d ) cout << '\n';
	}
}

Measured memory_bytes: 1332
# 他参加者の回答を参考にした．現在のAtcoderでのpythonのバージョンではdequeにinsertできないので（全ての値に-1をかけて）heapqがよさそう？
import bisect
N, M = map(int, input().split())
B = [int(x) for x in input().split()]
A = sorted(B, reverse=True)
ite = 0
for i in range(M):
    A[ite] //= 2
    if ite < N - 1:
        if A[ite] < A[ite + 1] and A[0] < A[ite+1]:
            ite += 1
        else:
            A = sorted(A, reverse=True)
            ite = 0
    else:
        A = sorted(A, reverse=True)
        ite = 0

ans = sum(A)
print(ans)


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

using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			//if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
};

int main(){
	long long int n,q;
	while(cin >> n >> q,n||q){
		int a[100002];
		a[1] = 1;
		for(long long int i=2;i<=n;i++){
			cin >> a[i];
		}
		vector<bool> roots(n);
		roots[1] = true;
		vector<pair<char,long long int>> queries;
		for(long long int i=0;i<q;i++){
			char c;
			long long int v;
			cin >> c >> v;
			if(c == 'M' && roots[v]) continue;
			if(c == 'M') roots[v] = true;
			queries.emplace_back(make_pair(c,v));
		}
		UnionFind uf(n+2);
		for(long long int i=2;i<=n;i++){
			if(!roots[i]){
				//cout << a[i] << " - " << i << endl;
				uf.unionSet(a[i],i);
			}
		}
		long long int sum = 0;
		for(long long int i=(long long int)queries.size()-1;i>=0;i--){
			//cout << queries[i].first << " " << queries[i].second << endl;
			if(queries[i].first == 'M'){
				uf.unionSet(a[queries[i].second],queries[i].second);
			}
			if(queries[i].first == 'Q'){
				//cout << uf.find(queries[i].second) << endl;
				sum += uf.root(queries[i].second);
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 6628
from collections import Counter
N = int(input())
L = sorted([list(map(int,input().split())) for k in range(N)])
D = []
if N == 1:
    print(1)
    exit(0)
for k in range(N-1):
    for l in range(k+1,N):
        D.append((L[k][0]-L[l][0],L[k][1]-L[l][1]))

E = Counter(D).most_common()[0]
x, y = E[0][0], E[0][1]
used = []
ans = N
for k in range(N-1):
    for l in range(k+1,N):
        if L[k][0]-L[l][0] == x and L[k][1]-L[l][1] == y:
            if L[k] not in used and L[l] not in used:
                used.append(L[k])
                used.append(L[l])
                ans -= 1
            elif L[k] in used and L[l] not in used:
                used.append(L[l])
                ans -= 1
            elif L[k] not in used and L[l] in used:
                used.append(L[k])
                ans -= 1
            else:
                pass
print(ans)


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	ll res = oo;
	for (ll a = 1; a*a <= n; a++) {
		if (n%a) continue;
		res = min(res, a + n/a - 2);
	}
	cout << res << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y, z, w;
    y = x / 3600;
    z = (x % 3600) / 60;
    w = (x%3600) % 60;
    System.out.println(y + ":" + z + ":" + w);
  }
}


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

void solve(){
  string s; cin >> s;
  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == '1') ans++;
  }
  cout << ans << endl;
  return;
}

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


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

using namespace std;

int main(){
	long long q, h, s, d, x, y, n;

	scanf("%lld%lld%lld%lld", &q, &h, &s, &d);
	scanf("%lld", &n);

	x = min(4 * q, min(2 * h, s));
	y = d;

	if (2 * x <= y){
		printf("%lld\n", n * x);
	}
	else{
		if (n % 2){
			printf("%lld\n", (n / 2) * y + x);
		}
		else{
			printf("%lld\n", (n / 2) * y);
		}
	}

	return 0;
}

Measured memory_bytes: 256
t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]
        if imos[c][i] > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = imos[c][i]

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)


Measured memory_bytes: 71256
import sys


def main():
    input = sys.stdin.buffer.readline
    n, d = map(int, input().split())
    d *= d
    ans = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x ** 2 + y ** 2 <= d:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[3005],mx=0,cnt=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		cnt+=a[i]-1;
	}
	printf("%d",cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n, x; cin >> n >> x;
	int c = 0;
	int ans = 0;
	while( n-- ){
		int l; cin >> l;
		c += l;
		if( c <= x ) ++ans;
	}
	cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    string s,t;cin>>s>>t;
    vector<char>m;
    for(int i=0;i<n;i++){
        m.pb(s[i]);m.pb(t[i]);
    }
    for(int i=0;i<2*n;i++){
        cout<<m[i];
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int n, x, ans=0, MIN=INF;

int main() {
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        x -= t;
        if (t < MIN)MIN = t;
        ans++;
    }
    cout << ans + x / MIN << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> p[100010];
int vis[100010];
long long s[100010];
void dfs(int x,long long y)
{
    int i,j;
    long long k;
    for(i=0;i<p[x].size();i=i+2)
    {
        j=p[x][i];
        k=p[x][i+1];
        if(vis[j]==0)
        {
            vis[j]=1;
            s[j]=y+k;
            dfs(j,y+k);
        }
    }
}
int main()
{
    int n,i,j,k,x,y,z,q;
    long long s1,s2,sum;
    scanf("%d",&n);
    memset(s,0,sizeof(s));
    for(i=1;i<n;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        p[x].push_back(y);
        p[x].push_back(z);
        p[y].push_back(x);
        p[y].push_back(z);
    }
    scanf("%d%d",&q,&k);
    memset(vis,0,sizeof(vis));
    vis[k]=1;
    dfs(k,0);
    while(q--)
    {
        scanf("%d%d",&x,&y);
        s1=s[x];
        s2=s[y];
        sum=s1+s2;
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 13184
#include<stdio.h>

int main(void) {
  int N, P[11], max = 0, maxIdx = 0;
  scanf("%d", &N);

  for(int i=0;i<N;i++) {
    scanf("%d", &P[i]);
    if(max < P[i]) {
      max = P[i];
      maxIdx = i;
    }
  }

  int sum = 0;
  for(int i=0;i<N;i++) {
    int price = (i==maxIdx) ? P[i] / 2 : P[i];
    sum += price;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define ZERO 0
#define ONE 1
#define TWO 2
#define THREE 3
#define FOUR 4
#define FIVE 5
#define DICE_SURF 6

int main( void )
{

	unsigned char ubW_DdiceONE[ DICE_SURF ];
	unsigned char ubW_DdiceTWO[ DICE_SURF ];
	unsigned char ubW_Dtrade;
	unsigned char ubW_Dcalc;
	unsigned char ubW_Ci;

	for( ubW_Ci = ZERO; ubW_Ci < DICE_SURF; ubW_Ci++ ) {
		scanf("%d",&ubW_DdiceONE[ubW_Ci]);
	}
	for( ubW_Ci = ZERO; ubW_Ci < DICE_SURF; ubW_Ci++ ) {
		scanf("%d",&ubW_DdiceTWO[ubW_Ci]);
	}

	for( ubW_Ci = ONE; ubW_Ci <= DICE_SURF; ubW_Ci++ ){
		ubW_Dcalc = ubW_Ci % TWO;
		/*????????¢??¨????????¢?????°?????????????????£????????¨????????¢????????????*/
		switch( ubW_Dcalc ){
		case ZERO:/*??¶??°???????????¢*/
			ubW_Dtrade = ubW_DdiceTWO[ ZERO ];
			ubW_DdiceTWO[ ZERO ] = ubW_DdiceTWO[ TWO ];
			ubW_DdiceTWO[ TWO ] = ubW_DdiceTWO[ FIVE ];
			ubW_DdiceTWO[ FIVE ] = ubW_DdiceTWO[ THREE ];
			ubW_DdiceTWO[ THREE ] = ubW_Dtrade;
			break;
		case ONE:/*?\???°???????????¢*/
			ubW_Dtrade = ubW_DdiceTWO[ ZERO ];
			ubW_DdiceTWO[ ZERO ] = ubW_DdiceTWO[ ONE ];
			ubW_DdiceTWO[ ONE ] = ubW_DdiceTWO[ FIVE ];
			ubW_DdiceTWO[ FIVE ] = ubW_DdiceTWO[ FOUR ];
			ubW_DdiceTWO[ FOUR ] = ubW_Dtrade;
			break;
		default:
			break;
		}

		/*?????¢??¨?????¢????????´??????????????????????????¨????????´??¢??????????????????????????????*/
		if( ( ubW_DdiceONE[ ZERO ] == ubW_DdiceTWO[ ZERO ] ) && ( ubW_DdiceONE[ FIVE ] == ubW_DdiceTWO[ FIVE ] ) ){
			if( ( ubW_DdiceONE[ ONE ] == ubW_DdiceTWO[ ONE ] ) && ( ubW_DdiceONE[ TWO ] == ubW_DdiceTWO[ TWO ] ) ){
				if( ( ubW_DdiceONE[ FOUR ] == ubW_DdiceTWO[ FOUR ] ) && ( ubW_DdiceONE[ THREE ] == ubW_DdiceTWO[ THREE ] ) ){
					printf("Yes\n");
					return ZERO;
				}
			}else if( ( ubW_DdiceONE[ ONE ] == ubW_DdiceTWO[ TWO ] ) && ( ubW_DdiceONE[ TWO ] == ubW_DdiceTWO[ FOUR ] ) ){
				if( ( ubW_DdiceONE[ FOUR ] == ubW_DdiceTWO[ THREE ] ) && ( ubW_DdiceONE[ THREE ] == ubW_DdiceTWO[ ONE ] ) ){
					printf("Yes\n");
					return ZERO;
				}
			}else if( ( ubW_DdiceONE[ ONE ] == ubW_DdiceTWO[ FOUR ] ) && ( ubW_DdiceONE[ TWO ] == ubW_DdiceTWO[ THREE ] ) ){
				if( ( ubW_DdiceONE[ FOUR ] == ubW_DdiceTWO[ ONE ] ) && ( ubW_DdiceONE[ THREE ] == ubW_DdiceTWO[ TWO ] ) ){
					printf("Yes\n");
					return ZERO;
				}
			}else if( ( ubW_DdiceONE[ ONE ] == ubW_DdiceTWO[ THREE ] ) && ( ubW_DdiceONE[ TWO ] == ubW_DdiceTWO[ ONE ] ) ){
				if( ( ubW_DdiceONE[ FOUR ] == ubW_DdiceTWO[ TWO ] ) && ( ubW_DdiceONE[ THREE ] == ubW_DdiceTWO[ FOUR ] ) ){
					printf("Yes\n");
					return ZERO;
				}
			}
		}
	}
	printf("No\n");

	return ZERO;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

string ans = "NO";
int H, W;
string S[12];
int center;

vector<int> makepair(vector<int> &P);
void check(vector<int> pair);

void fors(vector<int> &P, int i, int N){
    if(N <= 0){
        vector<int> pair = makepair(P);
        check(pair);
    }else{
        for(P[i] = 0; P[i] < N; P[i]++){
            fors(P, i + 1, N - 2);
        }
    }
}

vector<int> makepair(vector<int> &P){
    vector<int> index(W), pair(W);
    REP(i, W){
        index[i] = i;
    }
    if(W % 2 == 1) index.erase(index.begin() + center);

    REP(i, W / 2){
        pair[2 * i] = index[0];
        index.erase(index.begin() + 0);
        pair[2 * i + 1] = index[P[i]];
        index.erase(index.begin() + P[i]);
    }
    if(W % 2 == 1) pair[W - 1] = center;
    return pair;
}

void check(vector<int> pair){
    string S2[12];
    REP(i, H){
        S2[i] = S[i];
    }
    REP(i, H){
        REP(j, W / 2){
            S2[i][j] = S[i][pair[2 * j]];
            S2[i][W - j - 1] = S[i][pair[2 * j + 1]];
        }
        if(W % 2 == 1) S2[i][(W - 1) / 2] = S[i][pair[W - 1]];
    }
    vector<int> index(H);
    REP(i, H){
        index[i] = i;
    }
    bool found = true;
    while(index.size() >= 2){
        int i1 = index[0];
        index.erase(index.begin() + 0);
        found = false;
        reverse(S2[i1].begin(), S2[i1].end());
        REP(i, index.size()){
            if(S2[i1] == S2[index[i]]){
                found = true;
                index.erase(index.begin() + i);
                break;
            }
        }
        if(!found) break;
    }
    if(!found && H % 2 == 1){
        swap(index[0], index[1]);
        while(index.size() >= 2){
            int i1 = index[0];
            index.erase(index.begin() + 0);
            found = false;
            reverse(S2[i1].begin(), S2[i1].end());
            REP(i, index.size()){
                if(S2[i1] == S2[index[i]]){
                    found = true;
                    index.erase(index.begin() + i);
                    break;
                }
            }
            if(!found) break;
        }
    }
    if(found && index.size() == 0) ans = "YES";
    if(found && index.size() == 1){
        string S3 = S2[index[0]];
        reverse(S3.begin(), S3.end());
        if(S3 == S2[index[0]]) ans = "YES";
    }
}

signed main(){

    cin >> H >> W;
    REP(i, H){
        cin >> S[i];
    }

    vector<int> P(W / 2);
    for(center = 0; center < W; center++){
        fors(P, 0, W - (W % 2) - 1);
    }
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string s;
  cin >> s;
  if(s.size() >= 4){
    if(s.substr(0,4) == "YAKI"){
      //cout << s.substr(0,4) << endl;
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
# D - Sum of Large Numbers

N, K = map(int, input().split())

cnt = 0
for i in range(K, N + 2):
    mn = i * (i - 1) // 2
    mx = i * (N + (N - i + 1)) // 2
    cnt += mx - mn + 1

print(cnt % ((10 ** 9) + 7))


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

int main(){
  ll N;
  cin >> N;
  string A;

  while (N) {
    N--;
    A += string(1, 'a'+N%26);
    N /= 26;
  }
  reverse(A.begin(),A.end());
  cout << A << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

int n;
LL k;
int a[200005];
int vis[200005];

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif

  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }

  for (int i = 1; i <= n; i++) {
    vis[i] = -1;
  }

  int u = 1;
  int d = -1;
  int ans = -1;

  while(true) {
    if (vis[u] >= 0) {
      int sz = d - vis[u] + 1;
      for (int i = 1; i <= n; i++) {
        if (vis[i] == (k - vis[u]) % sz + vis[u]) {
          ans = i;
        }
      }
      break;
    }
    d += 1;
    vis[u] = d;
    if (d == k) {
      ans = u;
      break;
    }
    u = a[u];
  }
  printf("%d\n", ans);
  return 0;
}

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

const long long INF = 9223372036854775807;

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

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

	vector<int> dp(n + 1, INF);

	dp[1] = 0;

	for (int i = 2; i <= n; i++) {
	
		if (i == 2)	dp[i] = abs(h[i] - h[i - 1]);
		else dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	
	cout << dp[n] << endl;

	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

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

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

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

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

    vector<int> rank;
    vector<int> parent;
};

bool U[100005];

int main() {
    ll N, M;
    cin >> N >> M;
    UnionFind uf(N);

    REP(i, M) {
        ll x, y, z;
        cin >> x >> y >> z;
        uf.unit(x - 1, y - 1);
    }
    memset(U, 0, sizeof(U));
    ll ans = 0;
    REP(i, N) {
        ll p = uf.find(i);
        if (U[p])
            continue;
        U[p] = true;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        _k: usize,
        ss: [Chars; h],
    }

    let mut ans = vec![vec![0; w]; h];
    let mut id = 1;
    let mut vec = vec![0; w];

    for i in 0..h {
        let mut line = vec![];
        for j in 0..w {
            if ss[i][j] == '#' {
                line.push(j);
            }
        }
        if line.len() > 0 {
            line.push(w);
            for i in 0..line[0] {
                vec[i] = id;
            }
            for i in 1..line.len() {
                let (l, r) = (line[i - 1], line[i]);
                for i in l..r {
                    vec[i] = id;
                }
                id += 1;
            }
        }
        if vec[0] != 0 {
            for i in (0..=i).rev() {
                if ans[i][0] != 0 {
                    break;
                }
                for (j, &e) in vec.iter().enumerate() {
                    ans[i][j] = e;
                }
            }
        }
    }

    for line in ans.iter() {
        let line = line
            .into_iter()
            .map(|e| e.to_string())
            .collect::<Vec<_>>()
            .join(" ");
        println!("{}", line);
    }
}


Measured memory_bytes: 3028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[5];
		for (int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < 5; i++) {
			int sum = 0;
			for (int j = 0; j < 5; j++) {
				if (i != j) {
					sum += a[j];
				}
				int m = sum % 10;
				if (m > 0) {
					sum += 10 - m;
				}
			}
			sum += a[i];
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25684
#include <stdio.h>
int main(){
	int a,b;
	char t;
	for(;;){
		scanf("%d %c %d",&a,&t,&b);
		if(t=='?') break;
		if(t=='+') a+=b;
		if(t=='-') a-=b;
		if(t=='*') a*=b;
		if(t=='/') a/=b;
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{ int count=0,count1=0,i,j,len;
    string s;
    cin>>s;
    len=s.size();
    for(int i=0;i<len;i++){
        if(i&1){
                if(s[i]!='1')count++;
        else count1++;
        }
        else{
            if(s[i]!='1')count1++;
            else count++;
        }
    }


cout<<min(count,count1)<<endl;}


Measured memory_bytes: 512
using System;
using System.IO;
using System.Linq;

namespace AtCoder.R170.B
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        private static void WriteAnswer(TextWriter tw, string answer)
        {
            tw.WriteLine(answer);
        }

        private static string Parse(TextReader tr)
        {
            var a = tr.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            return Calc(a[0], a[1]);
        }

        public static string Calc(int x, int y)
        {
            for (var i = 0; i <= x; ++i)
            {
                if (i * 2 + (x - i) * 4 == y)
                    return "Yes";
            }
            return "No";
        }
    }
}


Measured memory_bytes: 28320
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import collections
import sys
INF = 10**10
def main(H, W, K, x1, y1, x2, y2, C):
    dist = [[INF] * W for _ in range(H)]
    q = collections.deque([(x1, y1)])
    dist[x1][y1] = 0
    while q:
        i, j = q.popleft()
        d = dist[i][j]
        for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            for dt in range(1, K + 1):
                ni, nj = i + di * dt, j + dj * dt
                if not (0 <= ni < H and 0 <= nj < W): break
                if C[ni][nj] == '@': break
                if dist[ni][nj] == d + 1: continue
                if dist[ni][nj] < d + 1: break
                dist[ni][nj] = d + 1
                q.append((ni, nj))
    ans = dist[x2][y2]
    if ans == INF:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    x1, y1, x2, y2 = map(lambda x: int(x) - 1, input().split())
    C = [input().rstrip() for _ in range(H)]
    main(H, W, K, x1, y1, x2, y2, C)


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(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 FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL A, B, C; cin >> A >> B >> C;
  if(A%2==0||B%2==0||C%2==0) cout << 0 << endl;
  else cout << min(A*B, min(B*C, C*A)) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    int k,i;
    char s[104];
    cin>>k>>s;
    for(i=0;i<strlen(s);i++){
        if(i==k){cout<<"...\n";break;}
        else cout<<s[i];
    }
    return 0;
}


Measured memory_bytes: 3636
#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>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
		tree_order_statistics_node_update> indexed_multiset;

/*
int n , m;
int par[200005];
bool ok[200005];
int getpar(int node){
	if(par[node] == node)
		return node;
	return getpar(par[node]);
}
bool uni(int fnode , int snode){
	int ff = getpar(fnode) ,  ss = getpar(snode);
	if(ff==ss)
		return false;
	par[ff] = ss;
	return true;
}
*/
int n ,m ;
vector<int>vi2;
vector<vector<int>>vi(200005);
bool vis[200005];
int last[200005];
int group ;
void dfs(int node){
	last[node] = group;
	vis[node] = true;
	for(auto it : vi[node]){
		if(!vis[it])dfs(it);
	}
	
}
int main(){
	cin>>n>>m;
	vi2.resize(n);
	for(auto &it : vi2)
		cin>>it;
	for(int i = 0; i <m ; i++){
		int  u , v;
		cin>>u>>v;
		vi[u].push_back(v);
		vi[v].push_back(u);
	}
	for(int i = 1 ; i <=n ; i++){
		if(!vis[i]){
			++group;
			dfs(i);
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(vi2[i] == i + 1 ||(last[i+1] == last[vi2[i]])){
			ans++;
		}
	}
	cout<<ans;
	/*
	cin>>n>>m;
	for(int i = 1; i <=n ;i++)
		par[i] = i;
	for(int i = 0; i < m ; i++){
		int u , v;
		cin>>u>>v;
		if(uni(u,v))cout<<u<<" "<<v<<endl;
	}
	*/
   	return 0;	
}


Measured memory_bytes: 11008
from heapq import heappop, heappush

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
S, T = map(lambda x: int(x)-1, input().split())

ans = -1
visited = set()
q = [(0, S)]
ans = -1
while q:
    c, v = heappop(q)  # cはカウント, vは頂点の番号
    key = (c % 3, v)
    if key in visited:
        continue
    visited.add(key)
    if v == T and c % 3 == 0:
        ans = c//3
        break
    c += 1
    d = c % 3
    for u in graph[v]:
        new_key = (d, u)
        if new_key in visited:
            continue
        heappush(q, (c, u))

print(ans)

Measured memory_bytes: 45384
using System;

namespace AtCoder
{
	public class ProblemA
	{
		public static void Main(string[] args)
		{
			string[] line = Console.ReadLine().Split(' ');
			int a = int.Parse(line[0]);
			int b = int.Parse(line[1]);
			int c = int.Parse(line[2]);

			int sumA = a;

			bool result = false;

			for (int i = 1; !result && i <= b; i++, sumA += a)
			{
				result = sumA % b == c;
			}

			Console.WriteLine(result ? "YES" : "NO");
		}
	}
}


Measured memory_bytes: 27076
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;


int main(){

    int N, temp;
    cin >> N;
    vector<int> As(N);

    for(int i=0;i<N;++i){
        cin >> temp;
        As[i] = temp;
    }

    sort(As.begin(), As.end());

    for(int i=0;i<N-1;++i){
        if(As[i]==As[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    
    return 0;
}


Measured memory_bytes: 1024
A = list(map(int , input().split()))
B = list(map(int , input().split()))
kitaiti =[(i+1)/2 for i in B]
ans = []
dd = [0]
for i in range(A[0]):
    dd.append(dd[i] + kitaiti[i])
for i in range(A[1] , A[0]+1):
    ans.append(dd[i] - dd[i - A[1]])
print(max(ans))

Measured memory_bytes: 28232
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

bool iswin(vs& field,char c)
{
	int a,b;
	rep(i,3){
		a=b=0;
		rep(j,3){
			a+=field[i][j]==c;
			b+=field[j][i]==c;
		}
		if(a==3 || b==3)
			return true;
	}
	a=b=0;
	rep(i,3){
		a+=field[i][i]==c;
		b+=field[i][2-i]==c;
	}
	return a==3 || b==3;
}

int main()
{
	for(vs field(3);cin>>field[0],field[0][0]!='0';){
		cin>>field[1]>>field[2];
		bool winb=iswin(field,'b');
		bool winw=iswin(field,'w');
		if(winb)
			puts("b");
		else if(winw)
			puts("w");
		else
			puts("NA");
	}
	
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

void Init(int N);
int Root(int x);
bool Unite(int x, int y);

int root[SIZE];
int sz[SIZE];

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

    LL N, M;
    cin >> N >> M;
    Init(N);

    vector<P> bridges(M);
    for(int i = 0; i < M; ++i) {
        cin >> bridges[i].F >> bridges[i].S;
    }

    vector<LL> res;
    res.pb(N * (N - 1) / 2);
    LL t = res[0];
    for(int i = M - 1; i >= 0; --i) {
        Root(bridges[i].F);
        Root(bridges[i].S);
        LL szf, szs;
        szf = sz[bridges[i].F];
        szs = sz[bridges[i].S];
        if(Unite(bridges[i].F, bridges[i].S)) {
            t -= szf * szs;
        }
        res.pb(t);
    }
    reverse(all(res));

    for(int i = 1; i < res.size(); ++i) {
        cout << res[i] << endl;
    }

    return 0;
}

void Init(int N) {
    for(int i = 1; i <= N; ++i) {
        root[i] = i;
        sz[i] = 1;
    }
}

int Root(int x) {
    if(x == root[x]) return x;
    root[x] = Root(root[x]);
    sz[x] = sz[root[x]];
    return root[x];
}

bool Unite(int x, int y) {
    x = Root(x);
    y = Root(y);
    if(x == y) return false;

    sz[x] += sz[y];
    sz[y] = sz[x];
    root[x] = y;

    return true;
}


Measured memory_bytes: 3828
N,M = map(int,input().split())
list = [list(map(int,input().split())) for j in range(N)]
list = sorted(list)
tm = M
ans = 0
for li in list:
    if li[1] < tm:
        ans += li[0]*li[1]
        tm -= li[1]
    else:
        ans += li[0]*tm
        print(ans)
        exit()

Measured memory_bytes: 28652
/*
 * iraira.cpp
 *
 *  Created on: 2018/05/02
 *      Author: J01003
 */
/*
 * taete.cpp
 *
 *  Created on: 2018/04/26
 *      Author: J01003
 */
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    double f1,f2,r;
    scanf("%lf", &r);
    f1 = r*r*3.141592653589;
    f2= 2*r*3.141592653589;
    printf("%.10lf\n %.10lf\n",f1,f2);
	return 0;
}




Measured memory_bytes: 3212