akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
vector <int> v;
vector <double> vd;

vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
//int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}

//int cnt =0;
//
//void SieveOfEratosthenes(int n)
//{
//   // v.push_back(1);
//
//    bool prime[n+1];
//    memset(prime, true, sizeof(prime));
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          v.push_back(p);
//}
//

//int mod(string num, int a)
//{
//    // Initialize result
//    int res = 0;
//
//    // One by one process all digits of 'num'
//    for (int i = 0; i < num.length(); i++)
//         res = (res*10 + (int)num[i] - '0') %a;
//
//    return res;
//}
long long int mx = 1000000000000000000;

long long int power(long long int base, long long int powerRaised)
{
    if (powerRaised != 0)
        return (base*power(base, powerRaised-1));
    else
        return 1;
}


int main() {
    
    
    int a,b,c,n,cnt=0;
    string s,p;
    char ch;
    
    cin >> a >> b;
    
    if(a>9||b>9)cout << -1 << endl;
    else cout << a*b << endl;
    
    
    
    return 0;
}
 
 
 


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
 
#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
 
#include <climits>
 
using namespace std;
 
int main()
 
{
	int n,t,a;
	cin >> n;
	cin >> t >> a;
	vector<int> arr(n);
 
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
 
	double point = 200001;
	int area = 0;
	for (int i = 0; i < n;i++) {
		//cout << abs(a - (t - arr[i] * 0.006)) << endl;
		if (point > abs(a - (t - arr[i] * 0.006))) {
			point = abs(a - (t - arr[i] * 0.006));
			area = i+1;
		}
	}
 
	cout << area << endl;
 
	return 0;
 
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 n;
    cin >> n;
    vs64 a(n);
    rep (i, n) cin >> a[i];

    bool found = false;
    s64 ans = 0;
    while (!found)
    {
        s64 sum = 0;
        rep (i, n) sum += CEIL(MAX(0, a[i] - n + 1), n);
        found = true;
        rep (i, n)
        {
            s64 num = CEIL(MAX(0, a[i] - n + 1), n);
            ans += num;
            if ((a[i] = a[i] + (sum - num) - num * n) >= n)
            {
                found = false;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{

    int A,B,C;

    cin >> A >>B>>C;

    cout << C <<" "<<A<<" "<<B<<endl;


    return 0;
}


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

using namespace std;

typedef pair<int, int> P;

class edge{
public:
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};

const int INF = 100000000;

int n, k;
vector<edge> G[100];
int d[100];

void add_edge(int a, int b, int c){
  G[a].push_back(edge(b, c));
  G[b].push_back(edge(a, c));
}

int dijkstra(int s, int g){
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+n, INF);
  d[s] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
  if(d[g] == INF) return -1;
  return d[g];
}

main(){
  while(cin >> n >> k && (n|k)){
    for(int i=0;i<100;i++) G[i].clear();
    for(int i=0;i<k;i++){
      int a, b, c, d;
      cin >> a;
      if(a){
        cin >> b >> c >> d;
        add_edge(b-1, c-1, d);
      }else{
        cin >> b >> c;
        cout << dijkstra(b-1, c-1) << endl;
      }
    }
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void){
    int N,p;
    int count=0;
    cin >> N;

    for(int i=0;i<N;i++){
        cin >> p;
        if(i+1 != p){
            count++;
        }
    }
    if(count == 2 || count == 0){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}

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

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> ans(N, 1);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      ans[a - 1] = 0;
    }
  }

  cout << accumulate(ans.begin(), ans.end(), 0) << endl;
  return 0;
}

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

int main(){
    int N, X;
    cin >> N >> X;
    int m[N+10];
    cin >> m[0];
    int cheap = m[0];
    int sum = m[0];
    for(int i = 1; i < N; ++i){
        cin >> m[i];
        sum += m[i];
        if (cheap > m[i]) cheap = m[i];
    }
    int left = (X - sum) / cheap;
    cout << N + left << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;

int main(){

  int n;
  cin >> n;
  map<ll,ll> m;
  vector<ll> sum(n);
  rep(i,n){
    ll a;
    cin >> a;
    ll gap = i - a;
    sum[i] = i + a;
    if(gap > 0){
      if(m.count(gap) == 0) m.insert(make_pair(gap,1));
      else{
	ll n = m[gap];
	++n;
	m.erase(gap);
	m.insert(make_pair(gap,n));
      }
    }
  }

  ll ans = 0;
  rep(i,n){
    if(m.count(sum[i]) != 0) ans += m[sum[i]];
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12908
#include <cstdio>
#include <algorithm>

#define Rep(i, n) for (int i = 1; i <= n; i ++)

using namespace std;

const int N = 100010;

int a[N], g0[N], g1[N];

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

int main()
{
	int n;
	long long sum = 0;
	scanf("%d", &n);
	Rep(i, n){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	
	if (!(n & 1)) {
		if (sum & 1) printf("First\n");
		else printf("Second\n");
	}
	else {
		if (!(sum & 1)) printf("First\n");
		else {
			int tid = 0, tmp;
			while (true){
				tid ++, sum = 0;
				bool f0 = false;
				Rep(i, n){
					g0[i] = gcd(g0[i - 1], a[i]), sum += a[i];
					if (a[i] == 1) f0 = true; 
				}
				if (f0) break;
				for (int i = n; i; i --) g1[i] = gcd(g1[i + 1], a[i]);
				bool flag = false;
				Rep(i, n) {
					tmp = gcd(gcd(g0[i - 1], g1[i + 1]), a[i] - 1);
					if (((sum - 1) / tmp) & 1){
						a[i] --, flag = true;
						break;
					}
				}
				if (!flag) break;
				else Rep(i, n) a[i] /= tmp;
			}
			if (!(tid & 1)) printf("First\n");
			else printf("Second\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1280
n=int(input())
S = [input() for i in range(n)]
ac=0
wa=0
tle=0
re=0

for s in S:
    if s=='AC':
        ac+=1
    elif s=='TLE':
        tle+=1
    elif s=='WA':
        wa+=1
    elif s=='RE':
        re+=1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))


Measured memory_bytes: 79188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        int n = Integer.valueOf(mylist.get(0));
        String arr[] = mylist.get(1).split(" ");

        int cnt = 0;
        int num = 1;
        for (int i = 0; i < n; i++) {
            Integer a = Integer.valueOf(arr[i]);
            if (num == a) {
                cnt += 1;
                num += 1;
            }
        }

        if (cnt == 0) {
            System.out.println(-1);
        } else {
            System.out.println(n - cnt);
        }

    }

}


Measured memory_bytes: 53568
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long N;
vector <int> val;

int main() {
	scanf("%lld", &N);
	while (N > 0) {
		val.push_back(N % 26);
		N /= 26;
	}
	for (int i = 0; i < val.size(); i++) {
        if (val[i] <= 0 && i != val.size() - 1) {
            val[i] += 26;
            val[i + 1]--;
        }
	}
	reverse(val.begin(), val.end());
	for (int i = 0; i < val.size(); i++) {
        if (val[i] == 0) continue;
		printf("%c", val[i] - 1 + 'a');
	}
	printf("\n");
	return 0;
}


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

using namespace std;
typedef vector< vector<int> > vv;
#define INF 10000000

void dfs(int now,vv& tree,vector<int>& dep,int d,vector<bool>& check){
  dep[now]=d;
  check[now]=true;
  int l=tree[now].size();
  for(int i=0;i<l;i++){
    if(check[tree[now][i]]==false){dfs(tree[now][i],tree,dep,d+1,check);}
  }
}



int main(){
  int n;cin >> n;
  vv tree(n);
  for(int i=0;i<n-1;i++){
    int a,b;cin >> a >> b;
    tree[a-1].push_back(b-1);
    tree[b-1].push_back(a-1);
  }
  vector<int> dep1(n,INF);
  vector<bool> check1(n,false);
  vector<int> dep2(n,INF);
  vector<bool> check2(n,false);
  dfs(0,tree,dep1,0,check1);
  dfs(n-1,tree,dep2,0,check2);
  int c1=0;int c2=0;
  for(int i=0;i<n;i++){
    if(dep1[i]<=dep2[i]){
      c1+=1;
    }else{
      c2+=1;
    }
  }
  //cout << c1 << endl;
  //cout << c2 << endl;
  //cout << c3 << endl;
  if(c1>c2){
    cout << "Fennec" << endl;
  }else{
    cout << "Snuke" << endl;
  }

}


Measured memory_bytes: 14336
// i really hope this weird dp thing works

#include <stdio.h>
#include <string>
#include <string.h>

const int SZ=3005;

int t1,t2;

int n;
std::string dp[SZ*2];

char s[SZ*2];
int pos[SZ*2];
int pa[SZ];
int pb[SZ];

int wants=0;
bool want[SZ*2];

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d %s",&n,s);
    t1=t2=0;
    for (int i=0; i<n*2; i++) {
        if (s[i]=='a') {
            pos[i]=t1;
            pa[t1]=i;
            t1++;
        }
        else {
            pos[i]=t2;
            pb[t2]=i;
            t2++;
        }
        //printf("what %d %d %c\n",i,pos[i],s[i]);
    }
    dp[2*n]="";
    for (int i=n*2-1; i>=0; i--) {
        //printf("what %d %d %d\n",i,pa[pos[i]],pb[pos[i]]);
        if (pa[pos[i]]<i || pb[pos[i]]<i) {
            dp[i]=dp[i+1];
        }
        // get the best string starting here
        else if (s[i]=='a') {
            // don't include anything in this ab interval
            dp[i]="ab"+dp[pb[pos[i]]];
        }
        else {
            // include as many things as possible?
            // because everything is in the form ba
            wants=0;
            memset(want,0,sizeof want);
            t1=i;
            for (int j=i; j<=t1; j++) {
                if (s[j]=='a') continue;
                want[j]=1;
                t1=pa[pos[j]];
                want[t1]=1;
                wants+=2;
            }
            // get the string
            std::string temp(wants,'a');
            //printf("B %d %d %s\n",i,t1,temp.c_str());
            t2=0;
            for (int j=i; j<=t1; j++) {
                if (want[j]) temp[t2++]=s[j];
            }
            dp[i]=temp+dp[t1];
        }
        if (dp[i]<dp[i+1]) {
            dp[i]=dp[i+1];
        }
        //printf("%d %s\n",i,dp[i].c_str());
    }
    //printf("\n\n\n");
    printf("%s\n",dp[0].c_str());
}


Measured memory_bytes: 10624
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String [] numbers = sc.nextLine().split("");
        
        int count = 0;
        
        for(int i = 0 ; i < numbers.length; i++){
            if(numbers[i].equals("1")){
                count++;
            }
        }
        
        System.out.println(count);
    }
}


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

#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
ll m =  2019;

int main(){
	ll ans = 0;
	string s;
	cin >> s;
	ll p = 1;
	ll suffic = 0;
	ll suf[m] = {0};
	suf[0]++;
	for(ll i = s.length() - 1; i >= 0 ; i--){
		ll d = (s[i] - '0');
		suffic = (d*p + suffic)%m;
		ans += suf[suffic];
		p = (p * 10) % m;
		suf[suffic]++;
	}
	cout << ans << endl;	
}


Measured memory_bytes: 3740
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>b)
	cout<<"a > b"<<endl;
	if(a<b)
	cout<<"a < b"<<endl; 
	if(a==b)
	cout<<"a == b"<<endl;
	return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  ll K, A, B;
  cin >> K >> A >> B;
  ll ans = 1;
  if(K < A){
    ans += K;
    cout << ans << endl;
    return 0;
  }
  ans += A-1;
  K -= A-1;
  ans += K/2 * max(2LL, B-A);
  K %= 2;
  ans += K;
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    int ans = 0;
    for (int i = 1; 2 * i < n; i++) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;

pub fn scan() -> String {
    let mut buf = String::new();
    let _ = io::stdin().read_line(&mut buf).unwrap();

    buf
}

fn main() {
    loop {
        let s1 = scan();
        if s1 == ".\n" {
            break;
        }
        let s2 = scan();
        if s1 == s2 {
            println!("IDENTICAL");
            continue;
        }

        let s1: Vec<&str> = s1.split("\"").collect();
        let s2: Vec<&str> = s2.split("\"").collect();

        let mut count: i32 = 0;
        let mut other: i32 = 0;

        for i in 0..(s1.len()) {
            if s1.len() != s2.len() {
                other = 1;
                break;
            }
            if i % 2 == 0 {
                if s1[i].to_string() != s2[i].to_string() {
                    other += 1;
                }
                continue;
            }
            if s1[i].to_string() != s2[i].to_string() {
                count += 1;
            }
        }

        if other == 0 && count == 1 {
            println!("CLOSE");
        } else {
            println!("DIFFERENT");
        }
    }
}

Measured memory_bytes: 5040
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int number(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main(){
    int n;cin>>n;
    int ans=0;
    if(n==10||n==100||n==1000||n==10000||n==100000)ans=10;
    else ans=number(n);

    cout<<ans<<endl;
}

Measured memory_bytes: 256
function main(input) {

    const reverse = (s) => {
        return s.split('').reverse().join('');
    }

    const S = reverse(input.split('\n')[0]);

    if (S === "BBB" || S === "AAA") console.log("No");
    else console.log("Yes");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29656
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	long long int cnt = 0, ans = 0;
	string s;
	cin >> s;
		for(int i=0;i<s.size();i++){
			if (s[i] == 'W') {
				ans += i - cnt;
				cnt++;
		}
		}
		cout << ans << endl;
		return 0;

	}


Measured memory_bytes: 3752
n,k = map(int,input().split())
a = [0]+sorted(filter(lambda x: x < k, map(int,input().split())))
n = len(a)

def search(m):

    dp = [1] + [0]*k
    for i in range(n):
        if i == m:
            continue
        for j in range(k,a[i]-1,-1):
            dp[j] |= dp[j-a[i]]
    for i in range(k-a[m],k):
        if dp[i]:
            return True
    return False
le = 0
ri = n


while ri > le+1:
    m = (ri+le)//2

    if search(m):
        ri = m
    else:
        le = m

print(le)

Measured memory_bytes: 41052
#include<stdio.h>
int main()
{
    int h1,m1,h2,m2,k,a,b,c;
    scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
    a=(h1*60)+m1;
    b=(h2*60)+m2;
    c=(b-a)-k;
    printf("%d\n",c);
    return 0;
}


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

int main(){
  	int A, B, C;
  	cin >> A >> B >> C;
  	if((A!=B&&B==C) || (A!=B&&A==C) || (A!=C&&A==B)){
      	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[]
c=[]
for i in range(n):
    a.append([])
    for j in range(3):
        a[i].append([])
for i in range(n):
    #for j in range(3):
    a[i][0], a[i][1], a[i][2]=map(int, input().split())
    a[i].sort()
    if(((a[i][0]*a[i][0])+(a[i][1]*a[i][1]))==(a[i][2]*a[i][2])):
        k="YES"
        c.append(k)
    else:
        k="NO"
        c.append(k)
for i in range(n):
    print(c[i])


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

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

    long long ans;
    long long cnt;
    if(a % 2 == 0 and b % 2 == 0){
        cnt = (b-2-a)/2 + 1;
        if(cnt % 2 == 0) ans = 0 ^ b;
        else ans = 1 ^ b;
    }
    else if(a % 2 == 0 and b % 2 != 0){
        cnt = (b-1-a) /2 + 1;
        if(cnt % 2 == 0) ans = 0;
        else ans = 1;
    }
    else if(a % 2 != 0 and b % 2 == 0){
        cnt = (b-2-(a+1))/2 + 1;
        if(cnt % 2 == 0) ans = a ^ b;
        else ans = a ^ 1 ^ b;
    }
    else if(a % 2 != 0 and b % 2 != 0){
        cnt = (b-1-(a+1))/2 + 1;
        if(cnt % 2 == 0) ans = a;
        else ans = a ^ 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
n=int(input())
def f(x):
    z=1
    while not(z*(z+1)<=2*x<(z+1)*(z+2)):
        z+=1
    return z

x=[-1]*(10**6+1) #2以上の自然数に対して最小の素因数を表す
x[0]=0
x[1]=1
i=2
prime=[]
while i<=10**6:
    if x[i]==-1:
        x[i]=i
        prime.append(i)
    for j in prime:
        if i*j>10**6 or j>x[i]:break
        x[j*i]=j
    i+=1
if n==1:
    print(0)
    exit()

a=[]
q=0
for i in range(len(prime)):
    p=prime[i]
    while n%p==0:
        q+=1
        n=n//p
    if q>0:a.append(q)
    q=0

ans=0
for i in range(len(a)):
    ans+=f(a[i])
print(ans if n==1 else ans+1)


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

int main(){
	int a,b,k,i,s=0;
	scanf("%d%d%d",&a,&b,&k);
	if(a>b){
		int tmp=a;
		a=b;
		b=tmp;
	}
	i=a;
	if(b%a==0){
		s=1;
	}
	while(s<k){
		--i;
		if(a%i==0&&b%i==0){
			++s;
		}
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
// https://atcoder.jp/contests/aising2020/tasks/aising2020_b
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;
    vector<ll> v(n);
    ll ans = 0;
    for(int i = 0;i<n;i++){
        cin >> v[i];
        if(i%2 == 0 && v[i]%2==1)
            ans++;
    }
    cout << ans;


	return 0;
}


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

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

int main(){
  int64_t N;
  string S;
  cin >> N >> S;

  int64_t count = 0;
  char last = S.at(0);
  for(int i=1; i<N; i++){
    if(S.at(i)!=last){count++; last = S.at(i);}
  }
  
  cout << count+1;
}

Measured memory_bytes: 512
use std::io::{Read, stdin};
use std::str::FromStr;

fn main() {
    let sx: i64 = read();
    let sy: i64 = read();
    let tx: i64 = read();
    let ty: i64 = read();
    let r = tx - sx;
    let u = ty - sy;
    let mut s: String = String::new();
    for i in 0..u {
        s.push('U');
    }
    for i in 0..r {
        s.push('R');
    }
    for i in 0..u {
        s.push('D');
    }
    for i in 0..(r+1) {
        s.push('L');
    }
    for i in 0..(u+1) {
        s.push('U');
    }
    for i in 0..(r+1) {
        s.push('R');
    }
    s.push('D');
    s.push('R');
    for i in 0..(u+1) {
        s.push('D');
    }
    for i in 0..(r+1) {
        s.push('L');
    }
    s.push('U');
    println!("{}", s);
}


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

Measured memory_bytes: 4352
<?php
    fscanf(STDIN, "%d %d %d", $a, $b, $c);
    $i = 0;
    $count = 0;
    for($i = $a; $i <= $b; $i++){
        if($c % $i == 0){
            $count++;
        }
    }
    echo $count . "\n";
?>


Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

vector<int> a(100010);
int now=1;
bool flg = false;

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

	int N;
	int ans;

	cin >> N;

	for (int i = 1; i <= N; i++)
	{
		cin >> a[i];
	}

	for (int i = 1; i <= N; i++)
	{
		now=a[now];
		if (now == 2) {
			ans = i;
			flg = true;
			break;
		}
	}

	if (flg) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}



Measured memory_bytes: 640
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  return intShift()+intShift()>=intShift()?"Yes":"No";
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
50 100 120
`);

Measured memory_bytes: 7500
def solve(N,K):
  if N == 0:
    return 1

  digit_num = 0
  while(1):
    if N >= pow(K,digit_num):
      digit_num += 1
    else:
      return digit_num
    
N, K = map(int,input().split())
ans = solve(N,K)
print(ans)

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

int main(){
  int k,s,ans = 0;
  cin >> k >> s;
  
  for(int i = 0; i <=k; i++){
      for(int j = 0; j <=k; j++){
        int K = s - i - j;
        if(K >= 0 && K <= k)
            if(i+j+K == s) ans++;
      }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    K, N = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]

    last_dist = K-A_list[-1] + A_list[0]
    res = A_list[-1] - A_list[0]

    temp_dist = res - (A_list[1] - A_list[0]) + last_dist
    res = min(res, temp_dist)

    for i in range(2,N):
        temp_dist = temp_dist - (A_list[i] - A_list[i-1]) + (A_list[i-1] - A_list[i-2])
        res = min(res, temp_dist)

    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 26444
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(S.IndexOf("YAKI") == 0 ? "Yes" : "No");
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13280
// g++ -std=c++14

//Difficulty according to solve count during contest:
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

#include<bits/stdc++.h>
using namespace std;

#define int long long
const int mod = 1e9 + 7;

int n, k;
vector<vector<int> > a;

vector<vector<int> >  multiply(vector<vector<int> > a, vector<vector<int> > b){
  int m = a.size();
  int n = a[0].size();
  vector<vector<int> > c(m, vector<int>(n, 0));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        c[i][j] += a[i][k] * b[k][j];
        c[i][j] %= mod;
      }
    }
  }
  return c;
}

vector<vector<int> > func(vector<vector<int> > a, int k){
  if(k == 1){
    return a;
  }
  auto temp = func(a, k / 2);
  temp = multiply(temp, temp);
  if(k % 2)
    temp = multiply(temp, a);
  return temp;
}

int32_t main(){
  cin >> n >> k;
  a.resize(n, vector<int>(n, 0));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }
  auto ans = func(a, k);
  int res = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      res += ans[i][j];
      res %= mod;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 4836
#include<iostream>
#include<vector>
#include<algorithm>
#include<sstream>

using namespace std;

int az, L;

vector<int> V;


string toS(int in){
  string out = "";
  while(in){
    out += in%10+'0';
    in/=10;
  }
  while(out.length()!=L) out += '0';


  reverse(out.begin(),out.end());
  return out;
}
int change(int num){

  string str = toS(num);
  string b,s;
  sort(str.begin(),str.end());
  s = str;
  reverse(str.begin(),str.end());
  b = str;
  stringstream ss_1(b),ss_2(s);
  int num_1,num_2;
  ss_1>>num_1;
  ss_2>>num_2;
  return num_1-num_2;
}


int search(int in){
  
  for(int i = 0; i < V.size(); i++)
    if(V[i] == in) return i;

  return -1;
}

int main(){
  

  while(cin >> az >> L && az+L){
    V.clear();
    int a = az;
    int i = 0,j = 0;
    while(1){
      V.push_back(a);
      a = change(a);
      i++;
      if((j = search(a)) != -1) break;
    }
    cout << j <<" " <<  a << " " <<  i-j << endl;
  }
  return 0;
}

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

ll N,M,H,W,K,Q,A,B;
string S, T;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    cout<<N*800 - 200 * (N/15)<<endl;
}

Measured memory_bytes: 256
S=input()
Q=int(input())
T=""
for i in range(Q):
    q=input().split()
    if q[0]=="1":
        T,S=S,T
    else:
        if q[1]=="1":
            T+=q[2]
        else:
            S+=q[2]
print(T[::-1]+S)

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

int main() {
  int N;
  cin >> N;
  
  int flag = 0;
  rep(i, N){
    string color;
    cin >> color;
    if (color == "Y")
      flag = 1;
  }
  
  if(flag == 1){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b;
char op;
cin>>a>>op>>b;
int ans;
if(op=='+') ans=a+b;
else ans=a-b;
cout<<ans<<endl;

//system("pause");
return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> E[202020];
vector<double> V[202020];
double T[202020];
int PE[202020];
double ret[202020];

double dfs(int cur,int pre) {
	V[cur].resize(E[cur].size());
	int i;
	int num=0;
	FOR(i,E[cur].size()) {
		int e=E[cur][i];
		if(e==pre) {
			PE[cur]=i;
		}
		else {
			V[cur][i] = 1+dfs(e,cur);
			T[cur] += V[cur][i];
			num++;
		}
	}
	
	if(T[cur]==0) return 0;
	return T[cur] / num;
}

void dfs2(int cur,int pre,double par) {
	if(PE[cur]>=0) {
		V[cur][PE[cur]]=par;
		T[cur] += par;
	}
	
	int i;
	FOR(i,E[cur].size()) {
		int e=E[cur][i];
		if(e!=pre) {
			if(E[cur].size()==1) dfs2(e,cur,1);
			else dfs2(e,cur,(T[cur]-V[cur][i])/(E[cur].size()-1)+1);
		}
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	MINUS(PE);
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	double tot=dfs(0,-1);
	dfs2(0,-1,0);
	
	FOR(i,N) _P("%.12lf\n",T[i]/E[i].size());
	/*
	FOR(i,N) {
		_P("%d : %lf : ",i,T[i]);
		FOR(j,E[i].size()) _P("%d:%lf ",E[i][j],V[i][j]);
		_P("\n");
	}*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    ll r,D,x;
    cin >>r>>D>>x;

    rep(i,10){
        x=r*x-D;
        cout <<x<<endl;
    }
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll fac(ll n){if(n<=1)return 1; else return n*fac(n-1);}
int main()
{
    int n, m, ans = 0;
    cin >> n >> m;
    for(int i=n;i<=m;i++)
    {
        string s=to_string(i);
        int f = 1;
        for(int j=0,k=s.size()-1;j<k;j++,k--)
            if(s[j]!=s[k])f=0;
        if(f)ans++;
    } cout << ans << endl;
}


Measured memory_bytes: 3760
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int d[105];
	int cot = 0;
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf("%d",&d[i]);
	}
	sort(d + 1,d + n + 1);
	for(int i = 1; i <= n; i++){
		if(d[i] == d[i + 1]) continue;
		else cot++;
	}
	printf("%d\n",cot);
}

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

int main() {
  char st[3];
  int a=0,b=0,c=0;
  scanf("%s",st);
  for(int i = 0;i < 3; i++){
  	switch(st[i]){
      case 'a':
        a++;
        break;
      case 'b':
        b++;
        break;
      case 'c':
        c++;
        break;
    }
  }
  if(a == 1 && b == 1 && c== 1){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }

return 0;
}



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

int n;					//えぬ
int a[100][100] = {0};	//辺の重さ
int f[100] = {0};		//その頂点が調査済みかどうか

int main(){
	cin >> n;
	//まず辺の重さをaに入れる
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			a[i][j] = -1;
		}
	}
	a[0][0] = 0;
	for ( int i = 0; i < n; i++ ) {
		int u;
		cin >> u;
		int k;
		cin >> k;
		for ( int j = 0; j < k; j++ ) {
			int v;
			cin >> v;
			cin >> a[u][v];
		}
	}
	for ( int i = 0; i < n - 1; i++ ) {
		int k = -1;
		int v = 0;
		for ( int j = 1; j < n; j++ ) {
			if ( a[0][j] == -1 || f[j] == 1 ) continue;
			if ( k == -1 || a[0][j] < k ) {
				v = j;
				k = a[0][j];
			}
		}
		f[v] = 1;
		for ( int j = 1; j < n; j++ ) {
			if ( v == j ) continue;
			if ( a[v][j] == -1 || f[j] == 1 ) continue;
			if ( a[0][j] == -1 || a[0][j] > a[0][v] + a[v][j] ) {
				a[0][j] = a[0][v] + a[v][j];
			}
		}
	}
	for ( int i = 0; i < n; i++ ) {
		cout << i << " " << a[0][i] << endl;
	}
	return 0;
}

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

string s;
int n;
char c[7] = {'0','1','+','-','*','(',')'};
const int up = 1<<10;

int parse(int l,int r,int p){
  if(r<=l)return -1;
  int k=0,a,b,e=0;
  for(int i=r-1;i>=l;i--){
    if(s[i]=='('){k++;e=1;}
    else if(s[i] == ')'){k--;e=1;}
    if(k>0)return -1;
    if(!k){
      if(s[i] == '+'){
	a = parse(l,i,0); b = parse(i+1,r,0);
	if(a<0 || b<0 || up<=a || up<=b || a+b<0 || up<=a+b)return -1;
	return a+b;
      }else if(s[i] == '-'){
	a = parse(l,i,0); b = parse(i+1,r,0);
	if(a<0 || b<0 || up<=a || up<=b || a-b<0 || up<=a-b)return -1;
	return a-b;
      }
    }
  }
  if(k)return -1;

  for(int i=r-1;i>=l;i--){
    if(s[i]=='(')k++;
    else if(s[i] == ')')k--;
    if(!k && s[i] == '*'){
      a = parse(l,i,0); b = parse(i+1,r,0);
      if(a<0 || b<0 || up<=a || up<=b || a*b<0 || up<=a*b)return -1;
      return a*b;
    }
  }

  if(p)return -1;
  if(s[l] == '(' && s[r-1] == ')')return parse(l+1,r-1,1);
  if(e)return -1;
  int res = 0;
  for(int i=r-1;i>=l;i--){
    if(s[i] == '1'){
      if(r-1-i>=10)return -1;
      else res += 1 << (r-1-i);
    }
  }
  return res;
}

int rec(int pos){
  int i,res = -1;
  for(i=pos;i<n;i++){
    if(s[i] == '.'){
      for(int j=0;j<7;j++){
	s[i] = c[j];
	res = max(res,rec(i+1));
      }
      s[i] = '.'; break;
    }
  }
  
  if(i==n)return parse(0,n,0);
  else return res;
}

int main(){
  cin >> s; n = s.size();
  cout << rec(0) << endl;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    map<pair<int,int>, int> cnt;
    for(int rep = 0; rep < n; ++rep) {
        double x;
        scanf("%lf", &x);
        long long i = llround(x*1e9);
        int two = 0, five = 0;
        while(i % 2 == 0) {
            two++;
            i /= 2;
        }
        while(i % 5 == 0) {
            five++;
            i /= 5;
        }
        ++cnt[{two,five}];
    }
    long long answer = 0;
    for(auto p1 : cnt) {
        for(auto p2 : cnt) {
            if(p1.first.first+p2.first.first >= 18 && p1.first.second+p2.first.second >= 18) {
                if(p1 < p2) {
                    answer += (long long) p1.second*p2.second;
                }
                else if(p1 == p2) {
                    answer += (long long) p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    printf("%lld\n", answer);
}


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

#define vi vector<int>
#define pii pair<int, int>
#define LL long long int 
#define x first
#define y second
#define f first
#define s second

using namespace std;

int main () {
    int a, b;
    
    cin >> a >> b;
    
    if(a>9 or b>9) cout << "-1" << endl;
    else cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    // ll sum=0;
    cin >> n;
    vector<ll> a;
    rep(i, n){
        ll x;
        cin >> x;
        // sum += x;
        a.push_back(x);
    }
    ll ans=0;
    rep(i, n){
        ans = 2*a[i] - ans;
    }
    ans /= 2;
    cout << ans << " ";
    rep(i, n-1){
        ans = 2*a[i] - ans;
        cout << ans << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

int main()
{
    long N,W;
    cin >>N>>W;
    vector<long> v(N+1);
    vector<long> w(N+1);

    w[0]=999;
    for(int i=1;i<N+1;i++)
    {
        cin>> w[i] >>v[i]; 
    }

    vector<vector<long>> dp(N+1,vector<long>(W+1,0)); 
    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(w[i] <=j)
            {
               //cout<<"maybe add item "<<i<<endl; 
                dp[i][j]= max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]); 
            }
            else
                dp[i][j] = dp[i-1][j]; 
        }

    }
    cout<<dp[N][W]<<endl; 
    return 0; 
}


Measured memory_bytes: 80256
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))

max_value=max(A)
max_index=A.index(max_value)
A.sort()
second_value=A[-2]

for j in range(N):
    if j==max_index:
        print(second_value)
    else:
        print(max_value)

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 1e5 + 41;
int n;
vi e[MAX];

void bad() {
	printf("-1\n");
	exit(0);
}

int v1, v2;
int d1[MAX];
int d2[MAX];

void dfs(int x, int p, int d[MAX]) {
	for (int y : e[x]) {
		if (y == p) continue;
		d[y] = d[x] + 1;
		dfs(y, x, d);		
	}
}

int f[MAX];

bool dfs1(int x, int p = -1) {
	f[x] = 1;
	if (x == v2) return true;
	for (int y : e[x]) {
		if (y == p) continue;
		if (dfs1(y, x)) return true;
	}
	f[x] = 0;
	return false;
}

void check() {
	fi(1, n) {
		for (int x : e[i]) {
			if (!f[x] && !f[i]) bad();
		}
	}
}

vi go(int x, int y) {
	vi res;
	int cur = 1;
	int p = -1;
	while (1) {
		int q = 0;
		int nx = -1;
		for (int z : e[x]) {
			if (z == p) continue;
			if (f[z]) {
				assert(nx == -1);
				nx = z;				
			} else {
				q++;
			}
		}
		fo(1, q) {
			res.pb(cur + o);
		}
		res.pb(cur);
		cur = cur + 1 + q;
		if (x == y) break;
		p = x;
		x = nx;
	}
	return res;
}

void solve() {
	dfs(1, -1, d1);
	v1 = v2 = -1;
	fi(1, n) {
		if (v1 == -1 || d1[v1] < d1[i]) v1 = i;		
	}	
	dfs(v1, -1, d2);
	fi(1, n) {
		if (v2 == -1 || d2[v2] < d2[i]) v2 = i;
	}
	assert(dfs1(v1));
	check();
	vi ans = min(go(v1, v2), go(v2, v1));
//	assert(sz(ans) == n);
	fi(0, sz(ans) - 1) {
		printf("%d ", ans[i]);
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	fi(1, n - 1) {
		int x, y;
		scanf("%d %d", &x, &y);
		e[x].pb(y);
		e[y].pb(x);
	}  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 14456
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl
#define int long long

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

signed main() {

	int n, m;

	cin >> n >> m;
	ll lcm = n / gcd(n, m) * m;
	string s, t;
	cin >> s >> t;

	int si = 0; 
	int ti = 0;
	int sv = 0;
	int tv = 0;

	int sd = lcm / n;
	int td = lcm / m;
	while (1) {
		if (sv > tv) {
			ti++;
			tv += td;
		} else if (sv < tv) {
			si++;
			sv += sd;
		} else {
			if (s[si] != t[ti]) {
				cout << "-1" NL;
				return 0;
			}
			si++, ti++;
			sv += sd, tv += td;
		}
		if (si >= s.size() || ti >= t.size()) {
			break;
		}
	}

	cout << lcm NL;


	return 0;

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    vector<string> days{"SUN","MON","TUE","WED","THU","FRI","SAT","SUN","MON","TUE","WED","THU","FRI","SAT"};

    string s;
    cin >> s;

    int today=0;
    for (int i = 0; i < 14; i++){
        if(s==days[i]) {
            //cout << days[i] << endl;
            today=i;
            break;
        }
    }
    REP2(i, today+1, 14){
        if(days[i]=="SUN") {
            cout << i-today << endl;
            break;
        }

    }

   

   return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a,b,c = LI()
    ans = 10 ** 5
    ans = min(ans, a + b)
    ans = min(ans, a + c)
    ans = min(ans, c + b)
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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

int main() {
    int n; cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int a; cin >> a;
        if (i % 2 == 0) continue;
        if (a % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <vector>
#include <algorithm>
#include <limits.h>
#include <iostream>
#include <set>
#include <cmath>
#include <queue>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#define MOD 1000000007
typedef  long long int  lli;
using namespace std;
int main() {
    lli n,m,k; cin>>n>>m>>k;
    lli a[n]; lli b[m];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int j=0;j<m;j++) cin>>b[j];
    for(int i=1;i<n;i++)
    {
        a[i]+=a[i-1];
    }
    for(int j=1;j<m;j++)
    {
        b[j]+=b[j-1];
    }

    lli j=m-1; lli ans=0;
    for(lli i=0;i<n;i++)
    {

        if(a[i]>k) break;
        if(j>=0) {
            while (j>=0 && a[i] + b[j] > k) j = j - 1;
        }
        ans=max(ans,i+1+j+1);
    }
     j=m-1;
    while(j>=0 && b[j]> k) j--;
    if(b[j]<=k) ans=max(ans,j+1);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;

int main()
{
    ll tmp, ans;

    rep(i, 5)
    {
        cin >> tmp;
        if (tmp == 0)
        {
            ans = i + 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3560