akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
void fail() {
    cout << -1 << '\n';
    exit(0);
}
int main() {
    int N; cin >> N;
    if (N == 2) fail();
    vector<Int> D(N);
    map<Int, pair<int, int>> M; // D[i] -> idx, num
    vector<vector<int>> G(N);
    for (int i = 0; i < N; i++) {
        cin >> D[i];
        M[D[i]] = make_pair(i, 1);
    }
    int root = -1;
    for (auto it = rbegin(M), ite = rend(M); it != ite; ++it) {
        int idx, num; tie(idx, num) = it->second;
        if (num == N) { root = idx; continue; }
        Int diff = num - (N - num);
        if (diff >= 0) fail();
        Int dnext = it->first + diff;
        if (!M.count(dnext)) fail();
        G[M[dnext].first].emplace_back(idx);
        M[dnext].second += num;
    }
    auto recur = [&](auto&& recur, int node) -> pair<Int, Int> {
        Int val = 0, cnt = 1;
        for (int next : G[node]) {
            auto p = recur(recur, next);
            val += p.first + p.second;
            cnt += p.second;
        }
        return { val, cnt };
    };
    if (recur(recur, root).first != D[root]) {
        fail();
    }
    for (int i = 0; i < N; i++) {
        for (int j : G[i]) {
            cout << i + 1 << ' ' << j + 1 << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 15616
#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;
    cin >> n;
    ll sum=0, mincnt=0, absmin=INT64_MAX;
    rep(i, n){
        ll a;
        cin >> a;
        sum += abs(a);
        if(a < 0){
            mincnt++;
        }
        absmin = min(absmin, abs(a));
    }
    if(mincnt%2){
        cout << sum - 2 * absmin << endl;
    }else{
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main{
	public static void main(String[] args) {
     
      Scanner in =new Scanner(System.in);
      int k=in.nextInt();
      int A=in.nextInt();
      int B=in.nextInt();
      
      if  (B-A<=2) System.out.println(1+k);
      else{
        long kk=k-(A-1);
        long ans=kk/2*(B-A)+A;
        if (kk%2!=0)ans++;
        System.out.println(ans);
      }
      return;
    }
}


Measured memory_bytes: 23252
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int main()
{
	int N,M;
	while( ~scanf(" %d %d",&N,&M) ){
		int flag = 0;
		if( N % 2 == 1 )
			flag += 1;
		if( M % 2 == 1 )
			flag += 1;
		if( flag < 2 )
			printf("Even\n");
		else
			printf("Odd\n");
	}
}

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

using namespace std;
   
        
      


    void solve(){
         int n, w ;
         cin>>n>>w;
         vector<int>values(n);
         vector<int>weights(n);
         for(int i = 0; i < n;++i) cin>>weights[i]>>values[i];
        int sum = 0;
         for(int x : values) sum += x;
         vector<long long> dp (sum+1,(long long )1e18);
         dp[0] = 0;
         for(int i = 0;i<n;++i){
             for(int temp = sum - values[i];temp>=0;--temp){
                    
                        dp[temp + values[i] ] = min(dp[temp + values[i] ], dp[temp] + weights[i]);
                    
             }
         }    
         int an = 0;
            for(int i = 0;i<=sum;++i){
                if(dp[i]<=w) an = i;
            }

        
        cout<<an<<'\n';
    }

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    //cin>>tc;
    while (tc--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3992
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        char[] c = N.toCharArray();
        
        int K = sc.nextInt();
        long[][] dp1 = new long[105][7];
        long[][] dp2 = new long[105][7];
        
        dp1[0][1]=1;
        dp2[0][1]=1;
        dp1[1][1]=10;
        dp2[1][1]=1;
        dp2[1][2]=9;
        
        
        for(int i=2;i<105;i++) {
        	for(int j=1;j<5;j++) {
            	dp1[i][j]=dp1[i-1][j]+9*dp2[i-1][j];
            	if(j==1) {
                	dp2[i][j]=1;            		
            	} else {
                	dp2[i][j]=dp1[i][j-1];
                	if(2==j)dp2[i][j]--;
            	}
            	//if(j==1)dp1[i][j]++;        		
        	}
        }
        long sum=0;
        int cnt=0;
        for(int i=N.length()-1;i>=0;i--) {
        	int tmp =Character.getNumericValue(c[N.length()-1-i]);;
        	if(tmp==0) continue;
        	sum=sum+dp1[i][Math.max(0,K-cnt)];
        	sum=sum+(tmp-1)*dp2[i][Math.max(0,K-cnt)];
        	cnt++;
        }
     
        System.out.println(sum);        	
                		
    }
    
    
}

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

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
解説参考
再帰関数で候補の数を作っていく版
"""

N = int(input())

def dfs(s):
    # N以下しかやらない
    if int(s) > N:
        return 0
    # 753数かどうか
    if '7' in s and '5' in s and '3' in s:
        res = 1
    else:
        res = 0
    # sの後ろに753を付けたもので再帰していく
    for c in '753':
        res += dfs(s + c)
    # 最終的に自分より大きい桁で増えた分を返却していく
    return res

print(dfs('0'))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// https://atcoder.jp/contests/abc172/tasks/abc172_d

int main() {
  int n;
  ll ans = 0, sum = 0;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    ll e = n / i;
    ll l = e * i;
    sum += (i + l) * e / 2; 
  }  
  cout << sum << endl;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.14159265359;
const int INF = (int)1e9;
const ll LINF = 1e18;
const int IMOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    s += "#####";
    n += 5;

    int dpA[n], dpB[n];
    irep(i, n) {
        dpA[i] = 0;
        dpB[i] = 0;
    }
    dpA[a] = 1; 
    dpB[b] = 1;

    irep(i, n) {
        if(s[i] == '.') { 
            dpA[i+1] += dpA[i];
            dpB[i+1] += dpB[i];
        }
        if(s[i+1] == '.') { 
            dpA[i+2] += dpA[i];
            dpB[i+2] += dpB[i];
        }
    }

    if(c <= d) {
        if(dpA[c] && dpB[d]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        int idx = b;
        while(idx < d) {
            while(idx < d) {
                if(s[idx-2] == '.' && s[idx-1] == '.' && s[idx] == '.' && dpB[idx]) {
                    break;
                } else {
                    idx++;
                }
            }
            if(dpA[idx-1] && dpA[idx+1] && dpA[c] && dpB[d]) {
                cout << "Yes" << endl;
                return 0;
            } else {
                idx++;
            }
        }
        cout << "No" << endl;
    }
    //irep(i, n) { cout << dp[0][i] << ","; } cout << endl;
    return 0;
}
/** atcoder **/



Measured memory_bytes: 2052
#include <iostream>
#include <cstring>
using namespace std;
int mid[200002];
int main() {
	memset(mid,0,sizeof(mid));
	int n,m;
	int a,b;
	cin>>n>>m;
	while (m--) {
		scanf("%d%d",&a,&b);
		if (a==1) mid[b]++;
		if (b==n) mid[a]++;
	}
	for (int i=0;i<sizeof(mid)/sizeof(mid[0]);++i) {
		if (mid[i]>1) {
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
} 

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

int main()
{
  	long long int n, m, res = 0;
  	cin>>n>>m;
  	if(n > (m/2))
      cout<<m/2<<"\n";
  	else
      cout<<(n*2+m)/4<<"\n";
	return 0;
}

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

int main(){
	int n,g;
  cin>>n>>g;
  g/=100;
  vector<int> p(100);
  vector<int> c(100);
  for(int i=0;i<n;i++){
    cin>>p[i]>>c[i];
    c[i]/=100;
  }

  int ans=1e9;
  for(int i=0;i<(1<<n);i++){
    int tmp=0;//回数
    int score=0;//点数
    for(int j=0;j<n;j++){
      if(i&(1<<j)){
        tmp+=p[j];
        score+=c[j]+((j+1)*p[j]);
      }
    }
    int f=1;
    if(score<g){
      int id;
      for(int j=n-1;j>=0;j--){
        if(!(i&(1<<j))){
          id=j+1;
          break;
        }
      }
      int x=g-score;
      if(x%id==0){
        tmp+=x/id;
        if(x/id>p[id-1])f=0;
      }else{
        tmp+=x/id+1;
        if(x/id+1>p[id-1])f=0;
      }
    }
    if(f)ans=min(ans,tmp);
    //cout<<ans<<" "<<i<<endl;
  }
  cout<<ans<<endl;
}


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

int main() {
  int n;
  cin >> n;
  
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += to_string(i).size() & 1;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int h, n, count;
    cin >> h;
    cin >> n;
   int arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }

    while (h > 0)
   {
       for (int i = 0; i < n; i++)
       {
           h -= arr[i];
           count++;
       }
   }
    if (count > n)
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }
}

Measured memory_bytes: 640
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
  t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
for i in range(q):
  l, r = map(int, input().split())
  print(t[r - 1] - t[l - 1])

Measured memory_bytes: 7748
<?php
  $n = trim(fgets(STDIN));
  
  $d = array_fill(0,3,0);
  $dp = [];
  $dp[] = $d;
  for($i=0; $i<$n; $i++){
      fscanf(STDIN, "%d%d%d", $a[$i][0], $a[$i][1], $a[$i][2]);
      $dp[] = $d;
  }
  
  
  for($i=0; $i<$n; $i++){
      for($j=0; $j<3; $j++){
          for($k=0; $k<3; $k++){
              if($j==$k) continue;
              $dp[$i+1][$k] = max($dp[$i][$j] + $a[$i][$k], $dp[$i+1][$k]);
          }
      }
  }
  
  echo max($dp[$n]);
  
//   print_r($dp);

Measured memory_bytes: 91764
(* Vicfred
 * https://atcoder.jp/contests/abc073/tasks/abc073_a
 * implementation
 * *)
Scanf.scanf "%s\n" (fun n ->
    if n.[0] == '9' || n.[1] == '9' then "Yes"
    else "No"
) |> Printf.printf "%s\n"



Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n;
ll a[100010];
ll res=0;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	for (int i=0;i<n;i++)
	{
		res+=a[i]/2;
		a[i]%=2;
		if (!a[i]) continue;
		else
		{
			if (i!=n-1 && a[i+1])
			{
				a[i]--;
				a[i+1]--;
				res++;
			}
			else if (i && a[i-1])
			{
				a[i]--;
				a[i-1]--;
				res++;
			}
		}
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        sc.nextLine();
        Map<String,Integer> map1 = new HashMap<>();
        Map<String,Integer> map2 = new HashMap<>();
        String[] x = new String[a];
        for(int i =0;i<a;i++){
            String b = sc.nextLine();
            x[i] = b;
            if(map1.get(b) != null){
                map1.put(b,map1.get(b)+1);
            }else{
                map1.put(b,1);
            }
        }
        int c = sc.nextInt();
        sc.nextLine();
        for(int i =0;i<c;i++){
            String d = sc.nextLine();
            if(map2.get(d) != null){
                map2.put(d,map2.get(d)+1);
            }else{
                map2.put(d,1);
            }
        }
        int max = 0;

        //map1からmap2を引いたものの最大値をmaxに代入
        for(int i = 0;i<a;i++){
            int y = map1.get(x[i]);
            int z = 0;
            if(map2.get(x[i]) != null){
                z = map2.get(x[i]);
            }
            max = Math.max(max,y-z);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int dist(int x1, int y1, int x2, int y2)
{
	return abs(x1 - x2) + abs(y1 - y2);
}
int main()
{
	int N;
	scanf("%d", &N);
	int t, x, y;
	int nowt = 0, nowx = 0, nowy = 0;
	bool flag = true;
	for (int i = 1;i <= N;i++)
	{
		scanf("%d %d %d", &t, &x, &y);
		int dis = dist(nowx, nowy, x, y);
		if (dis > t - nowt || ((t - nowt) - dis) % 2)
			flag = false;
	}
	if (flag)puts("Yes");
	else puts("No");


}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


int main(){
    int n, k;   cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }

    vector<int> cum(n+1);
    cum[0] = 0;
    for(int i = 1; i <= n; i++){
        cum[i] = cum[i-1] + p[i-1];
    }

    int ma = 0;
    for(int i = k; i <= n; i++){
        ma = max(ma, cum[i] - cum[i-k]);
    }

    ma += k;

    printf("%.6f\n", (double)ma / 2.0);




    return 0;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s1, s2, s3 string
	fmt.Scan(&s1, &s2, &s3)

	fmt.Println(strings.ToUpper(string(s1[0])) + strings.ToUpper(string(s2[0])) + strings.ToUpper(string(s3[0])))
}


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

int main() {
  int k;
  cin >> k;
  queue<long long> q;
  for (long long i = 1; i <= 9; ++i) {
    q.push(i);
  }
  for (int i = 0; i < k-1; ++i) {
    long long x = q.front(); q.pop();
    if (x % 10 != 0) {
      q.push(10 * x + (x%10-1));
    }
    q.push(10*x + (x % 10));
    if (x % 10 != 9) {
      q.push(10 * x + (x%10+1));
    }
  }
  cout << q.front() << endl;
  return 0;
}

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

signed main(void)
{
	int n, cnt;
	cin >> n;
	cnt = 0;
	for(int i = 1; i <= n / 2; i++)
	{
		int j = n - i;
		if (j != i) 
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

#define N 3

int main()
{
    int k, n, i, count=0;
    string s, t;
    cin >> s;
    cin >> t;

    for(i=0;i<N;i++){
        if(s[i]==t[i]){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

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

int main() {
  ll X;
  cin >> X;

  for(ll i = -200; i < 200; i++){
    bool judge  = false;
    for(ll j = -200; j < 200; j++){
      ll A = i * i * i * i * i;
      ll B = j * j * j * j * j;

      if(A - B ==  X){
        cout << i << " " << j << endl;
        judge = true;
        break;
      }
    }
    if (judge) break;
  }
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,x;
 cin >> n >> x;
  int A[n];
 long int d;
  long int sum = 0;
 for( int i=0; i<n; i++){
   cin >> A[i];
 }
 for( int i=0; i<(n-1); i++){
    d = A[i]+A[i+1]-x;
   if(d>0){
     A[i+1] = A[i+1]-d;
    if(A[i+1]<0){
      A[i+1] = 0;
    }
      sum +=d;
   }
 }
 cout << sum << endl;



}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int pre[100005];
int find(int x){
    return (x==pre[x])?x:(pre[x]=find(pre[x]));
}
void merge(int x,int y){
    pre[find(x)]=find(y);
}
set<int> s;
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		pre[i]=i;
	}
	for(int i=1;i<=m;i++){
		int x,y,w;
		cin>>x>>y>>w;
		merge(x,y);
	}
	for(int i=1;i<=n;i++){
		s.insert(find(i));
	}
	cout<<s.size()<<endl;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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


    int N;
    cin >> N;
    ll ans = 0;


    rep(i,0,N){
        int tmp;
        cin >> tmp;
        ans += tmp - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n;
  cin>>n;
  int m=n;
  int sum=0;
  int res=0;
  while(n>0){
    res=n%10;
    n-=res;
    sum+=res;
    n/=10;
  }
  cout<<(m%sum==0?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

char maxAlphabet(string s)
{
  char ret = 'a';
  rep(i, s.size())
      ret = max(ret, s[i]);
  return ret;
}

int main()
{
  int N;
  cin >> N;
  vector<string> ans(0);
  ans.push_back("a");
  rep(i, N - 1)
  {
    vector<string> temp(0);
    rep(k, ans.size())
    {
      string preAns = ans[k];
      char max = maxAlphabet(preAns);
      rep(j, max - 'a' + 2)
      {
        char moji = j + 'a';
        string s = preAns + moji;
        temp.push_back(s);
      }
    }
    ans = temp;
  }
  sort(ans.begin(), ans.end());
  printVector(ans);
  return 0;
}

Measured memory_bytes: 9116
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
	for j in range(W + 1):
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])


Measured memory_bytes: 120684
def main():
    n = int(input())
    l = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
    
    for _ in range(n):
        b,f,r,v = map(int,input().split())
        b -= 1
        f -= 1
        r -= 1
        l[b][f][r] += v
    
    for i,b in enumerate(l):
        for f in b:
            s = ""
            for r in f:
                s += " " + str(r)
            print(s)
        if i != 3:print("#"*20)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<int> A(N);
    for(auto& x:A) cin >> x;
    for(int i=K;i<N;i++){
        cout << (A[i-K]<A[i]? "Yes\n":"No\n");
    }
}

Measured memory_bytes: 3984
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var MaxInt = 1000000000
var scanner = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	scanner.Scan()
	return strconv.Atoi(scanner.Text())
}

func printArray(arr []int) {
	separator := " "
	for j, element := range arr {
		fmt.Print(element)
		if j < len(arr)-1 {
			fmt.Print(separator)
		}
	}
	fmt.Print("\n")
}

func merge(arr []int, l, m, r int) int {
	left := append(append([]int{}, arr[l:m]...), MaxInt)
	right := append(append([]int{}, arr[m:r]...), MaxInt)

	i := 0
	j := 0
	inversionNumber := 0
	for k := l; k < r; k++ {
		if left[i] <= right[j] {
			arr[k] = left[i]
			i++
		} else {
			arr[k] = right[j]
			j++
			if i < len(left) {
				inversionNumber += len(left) - i - 1
			}
		}
	}
	// fmt.Println(arr, left, right, inversionNumber)
	return inversionNumber
}

func mergeSort(arr []int, l, r int) int {
	if l+1 < r {
		mid := (l + r) / 2
		n1 := mergeSort(arr, l, mid)
		n2 := mergeSort(arr, mid, r)
		nCompare := merge(arr, l, mid, r)

		return n1 + n2 + nCompare
	}
	return 0
}

func main() {
	scanner.Split(bufio.ScanWords)
	size, _ := nextInt()
	arr := make([]int, size)
	for i := range arr {
		n, _ := nextInt()
		arr[i] = n
	}

	nCompare := mergeSort(arr, 0, len(arr))

	//	printArray(arr)
	fmt.Println(nCompare)
}



Measured memory_bytes: 7956
import fractions
a, b, c, d = map(int, input().split())

bc = b // c
ac = (a-1) // c
bd = b // d
ad = (a-1) // d

m = (c * d) // fractions.gcd(c, d)

bm = b // m
am = (a-1) // m
aa = (bc - ac) + (bd - ad) - (bm - am)

print(b-(a-1)-aa)

Measured memory_bytes: 5372
import math
import statistics

n = int(input())
a = [int(i) for i in input().split()]

b = [a[i]-(i+1) for i in range(n)]
median = statistics.median(b)

med1 = math.floor(median)
med2 = med1+1

t = sum([abs(i-med1) for i in b])
u = sum([abs(i-med2) for i in b])

print(min(t,u))


Measured memory_bytes: 29620
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;

    ll ans = 0;
    while (1) {
        if (N < K) break;
        N /= K;
        ans++;

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

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

int main() {

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

    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (x >= a[i]) {
            ++ans;
            x -= a[i];
        }
    }
    if (x == a[n - 1]) ++ans;

    cout<<ans<<endl;
}

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

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const ll INF = 1e9+1;

int main() {
    ll N;
    cin >> N;
    vector<ll> res;

    ll D = 1;
    ll K = 2;
    if (N == 0) {
        cout << 0 << endl;
    }
    while (N != 0) {
        if (abs(N) % K != 0) {
            res.push_back(1);
            N -= D;
        } else res.push_back(0);
        K *= 2;
        D *= -2;
    }

    for (ll i = res.size()-1; i >= 0; i--) {
        cout << res[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
int n;
vector<vector<vector<double> > >dp;
double exptimes(int ones,int twos,int threes){
    if(ones<0 || twos<0 || threes<0){
        return 0;
    }
    if(dp[ones][twos][threes]>=0){
        return dp[ones][twos][threes];
    }
    dp[ones][twos][threes] = n+ ones*exptimes(ones-1,twos,threes) +twos*exptimes(ones+1,twos-1,threes) + threes*exptimes(ones,twos+1,threes-1);
    dp[ones][twos][threes] /= (ones+twos+threes);
    return dp[ones][twos][threes];
}
void solve(){
  cin>>n;
  dp.resize(n+1,vector<vector<double>>(n+1,vector<double>(n+1,-1)));
  dp[0][0][0]=0;
  int ones=0,twos=0,threes=0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(a==1){
        ones++;
    }else if(a==2){
        twos++;
    }else{
        threes++;
    }
  }
  cout<<exptimes(ones,twos,threes)<<"\n";
}

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

    cout.precision(14);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 219984
#include<bits/stdc++.h>
using namespace std;
typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

void bfs(const vvi &graph, vi &arrive, vi &ans, int start){
    queue<int> que;
    que.push(start);
    arrive[start]=0;
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(auto next : graph[v]){
            if(arrive[next]!=-1) continue;
            arrive[next]=arrive[v]+1;
            ans[arrive[next]]++;
            que.push(next);
        }
    }
    return;
}

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    vvi graph(n+1);
    graph[1].push_back(2);
    for(int i=2;i<n;i++){
        graph[i].push_back(i+1);
        graph[i].push_back(i-1);
    }
    graph[n].push_back(n-1);
    graph[x].push_back(y);
    graph[y].push_back(x);
    vi ans(n);
    for(int i=1;i<=n;i++){
        vi arrive(n+1,-1);
        bfs(graph,arrive,ans,i);
    }
    for(int i=1;i<n;i++){
        cout << ans[i]/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n,m;
  cin >> n >> m;
  vector<int>s(m);
  vector<char>c(m);
  rep(i,m)cin >> s[i] >> c[i];
  int num=pow(10,n-1);
  if(n==1)num=0;
  if(m==0){
    cout << num << endl;
    return 0;
  }
  for(int i=num;i<pow(10,n);i++){
    string t=to_string(i);
    bool ok=true;
    rep(j,m){
      if(t[s[j]-1]!=c[j]){
        ok=false;
        break;
      }
    }
    if(ok){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int k, s, count = 0;
	scanf("%d%d", &k, &s);
	rep(x, k + 1) {
		rep(y, k + 1) {
				if (s - x - y >= 0 && s - x - y <= k)++count;
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 256
N = gets.to_i
xs = gets.split.map(&:to_i)
medians = xs.sort[N/2-1, 2]
if medians.uniq.count == 1
  N.times do
    puts medians[0]
  end
else
  xs.each do |x|
    if x <= medians[0]
      puts medians[1]
    else
      puts medians[0]
    end
  end
end


Measured memory_bytes: 22012
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ACCELERATE;

	string s;
	cin >> s;
	for (int i = 0; i < sz(s); i++) cout << 'x';
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
string S;
LL dp[5145][5145];

LL mypow(LL base, LL exp) {
  if (!exp) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base%MOD;
  return res;
}

void Add(LL &d, LL v) {
  d += v;
  if (d >= MOD) d -= MOD;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin >> N;
  cin >> S;

  dp[0][0] = 1;
  rep(i, N) {
    rep(j, i+1) {
      if (j > 0) Add(dp[i+1][j-1], dp[i][j]);
      else Add(dp[i+1][j], dp[i][j]);

      Add(dp[i+1][j+1], dp[i][j]);
      Add(dp[i+1][j+1], dp[i][j]);
    }
  }

  cout << dp[N][S.size()] * mypow(mypow(2, MOD-2), S.size()) % MOD << "\n";
}


Measured memory_bytes: 201216
use std::fmt::Write;

fn main() {
    let n: usize = read();
    let mut vec: Vec<i32> = read_as_vec();
    build_max_heap(n, &mut vec);
    println!(" {}", join(' ', &vec));
}

fn build_max_heap(len: usize, slice: &mut [i32]) {
    for i in (0..(len / 2)).rev() {
        max_heapify(len, slice, i);
    }
}

fn max_heapify(len: usize, slice: &mut [i32], idx: usize) {
    let left  = idx * 2 + 1;
    let right = idx * 2 + 2;
    let me = slice[idx];
    if right < len {      // 子ノードが2つ
        let max = if slice[left] > slice[right] { left } else { right };
        if slice[max] > me {
            slice[idx] = slice[max];
            slice[max] = me;
            max_heapify(len, slice, max);
        }
    } else if left < len { // 子ノードが1つ
        if slice[left] > me {
            slice[idx] = slice[left];
            slice[left] = me;
            max_heapify(len, slice, left);
        }

    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().parse::<T>().ok().unwrap()
}

fn read_as_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}

fn join<T: std::fmt::Display>(delimiter: char, arr: &[T]) -> String {
    let mut text = String::new();
    for e in arr.iter() {
        write!(text, "{}", e).unwrap();
        text.push(delimiter);
    }
    text.pop();
    text
}


Measured memory_bytes: 16224
import math

N = int(input())
if N == 0:
    print('0')
    quit()

a = 1
res = ""
while N != 0:
    if N % (2 * a) == 0:
        res = "0" + res
    else:
        res = "1" + res
        N -= a
    a *= -2
print(res)

Measured memory_bytes: 3060
n, l = gets.strip.split(" ").map(&:to_i)

aji = 0
abs = nil
0.upto(n - 1) do |i|
  aji += l + i
end

ans = nil
0.upto(n - 1) do |i|
  a = 0
  0.upto(n - 1) do |j|
    a += l + j if i != j
  end

  if abs.nil? || (aji - a).abs < abs
    abs = (aji - a).abs
    ans = a
  end
end

puts ans


Measured memory_bytes: 1916
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int N;in(N);
  vector<string>S(N);
  vector<int>T(N);
  rep(i,N)in(S[i],T[i]);
  string X;in(X);
  long ans=0;
  bool f=false;
  rep(i,N){
    if(S[i]==X){
      f=true;
      continue;
    }
    if(f)ans+=T[i];
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
void main()
{
    long[][] a = 3.rdMat;
    long n = rdElem;
    long[] b = n.rdCol;

    bool[][] bingo = new bool[][](3, 3);
    foreach (x; b)
    {
        foreach (i; 0 .. 3)
        {
            foreach (j; 0 .. 3)
            {
                if (x == a[i][j]) bingo[i][j] = true;
            }
        }
    }

    bool ok;
    foreach (i; 0 .. 3)
    {
        bool row = true, col = true;
        foreach (j; 0 .. 3)
        {
            row &= bingo[i][j];
            col &= bingo[j][i];
        }
        if (row || col) ok = true;
    }
    if (bingo[0][0] && bingo[1][1] && bingo[2][2]) ok = true;
    if (bingo[0][2] && bingo[1][1] && bingo[2][0]) ok = true;

    writeln(ok ? "Yes" : "No");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
using namespace std;

map<string,int> ma;

int main()
{
	ma["SUN"]=7;
	ma["MON"]=6;
	ma["TUE"]=5;
	ma["WED"]=4;
	ma["THU"]=3;
	ma["FRI"]=2;
	ma["SAT"]=1;
	string s; cin>>s;
	cout<<ma[s]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i])
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3884
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
let mizu = readInts()
let a = mizu[0]
let b = mizu[1]
let c = mizu[2]
let anogoukei = b + c - a
if anogoukei>0 {
  print(anogoukei)
} else { 
  print(0)
}

Measured memory_bytes: 8292
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())), dtype=np.int64)
B = np.array(list(map(int, input().split())), dtype=np.int64)
ans = 0
for i in range(30):
  t = 1<<i
  C = B.copy()%(2*t)
  E = A.copy()%(2*t)
  C.sort()
  E.sort()
  D = np.searchsorted(C, 2*t-E, side="left")
  D -= np.searchsorted(C, t-E, side="left")
  D += np.searchsorted(C, 4*t-E, side="left")
  D -= np.searchsorted(C, 3*t-E, side="left")
  cnt = D.sum()%2
  ans |= cnt << i
print(ans)

Measured memory_bytes: 52848
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e10 + 10;;
unsigned long long fac[1000010];

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

unsigned long long power(unsigned long long x, unsigned long long y){
    unsigned long long res = 1;
    x = x % MOD;

    while (y > 0) {
        // If y is odd, multiply x with result 
        if (y & 1)
            res = (res * x) % MOD;

        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n) {
    return power(n, MOD - 2);
}


int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}

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

#define ll long long

int main() {
  int N;
  cin >> N;
  
  vector<ll> a(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  vector<ll> sum(N+1, 0);
  
  for (int i = 0; i < N; i++) {
    sum[i+1] = sum[i] + a[i];
  }
  
  
  int ans = 1;
  
  for (int i = N-1; i >= 1; i--) {
    if (a[i] > 2 * sum[i]) {
      break;
    }
    ans++;

  }
  
  cout << ans << endl;
}

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

using namespace std;

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

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

int main() {
  int N, K;
  cin >> N >> K;
  map<int, int> m;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    m[A]++;
  }
  vector<int> ball;
  for (auto itr = m.begin(); itr != m.end(); ++itr) ball.push_back(itr->second);
  sort(ball.begin(), ball.end());
  int kind = ball.size();
  int ans = 0;
  for (int i = 0; i < kind - K; ++i) ans += ball[i];
  cout << ans << endl;
}

Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < (n);i++)
#define lint long long
const lint mod=1e9+7;
const lint inf=2.19e15+1;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> card;

    UnionFind(int N) : par(N), card(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        for(int i = 0; i < N; i++) card[i] = 1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        int a = card[rx], b = card[ry];
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        card[ry] = a + b;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int getCard(int x){
        return card[root(x)];
    }
};

signed main(){
    int n, m;
    cin >> n >> m;
    UnionFind uni(n);
    int maxv = -100000;
    REP(i,m){
        int a, b;
        cin >> a >> b;
        a--;b--;
        uni.unite(a, b);
    }
    REP(i,n){
        chmax(maxv, uni.getCard(i));
    }
    cout << maxv << endl;
}

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


int main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s;
    for(int i=0;i<m;++i){
        int k;
        cin>>k;
        s.push_back({});
        while(k--){
            int x;
            cin>>x;
            --x;
            s.back().push_back(x);
        }
    }
    vector<int> p;
    for(int i=0;i<m;++i){
        int x;
        cin>>x;
        p.push_back(x);
    }
    int ans=0;
    for(int b=0;b<(1<<n);++b){
        int on=0;
        for(int i=0;i<m;++i){
            int cnt=0;
            for(int j:s[i]){
                if(b&(1<<j))cnt++;
            }
            if(cnt%2==p[i])on++;
        }
        if(on==m)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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


def main():

    N = int(input())
    points = []
    for i in range(N):
        points.append(list(map(int, input().split())))

    x = [p[0] for p in points]
    y = [p[1] for p in points]

    M = 998244353

    c = 1 + N + N * (N - 1) // 2
    for i in range(N):
        xi = x[i]
        yi = y[i]
        dx = [xj - xi for xj in x]
        dy = [yj - yi for yj in y]

        for j in range(i + 1, N):
            xj = dx[j]
            yj = dy[j]
            cc = 1
            for k in range(j + 1, N):
                if xj * dy[k] - dx[k] * yj == 0:
                    cc *= 2
                    cc %= M
            c += cc - 1

    r = 1
    for i in range(N):
        r *= 2
        r %= M

    r -= c
    r %= M

    print(r)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
/**
*    created: 05.05.2020 01:38:47
**/

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

int main() {
    int n;
    cin >> n;
    int x[n];
    rep(i, n) cin >> x[i];
    int s;
    rep(i,101){
        if(i==0)
            continue;
        int a=0;
        rep(j,n){
            a += (x[j] - i) * (x[j] - i);
        }
        if(i==1){
            s = a;
        }
        s = min(a, s);
    }
    cout << s << endl;
}

Measured memory_bytes: 256