akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

signed main() {
  int N; cin>> N;
  rep(i, N) {
    cin >> Input[i];
  }

  sort(Input, Input+N);
  
  int ans = 0;
  for (int i = 0; i < N-2; i++) {
    for (int j = i+1; j < N-1; j++) {
      for (int k = j+1; k < N; k++) {
        if (Input[i] < Input[j] + Input[k] && Input[j] < Input[i] + Input[k] && Input[k] < Input[i]+ Input[j]) {
          ans++;
        } else {
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy
n, m = map(int, input().split())
pyi = []
for i in range(m):
    p,y= map(int, input().split())
    pyi.append([p,y,i])

pyi.sort(key=lambda x: x[1])
pyi.sort(key=lambda x: x[0])

ken = 0
for i in range(m):
    if pyi[i][0] != ken:
        ken = pyi[i][0]
        x = 1
    else:
        x += 1
    pyi[i].append(x)


pyi.sort(key=lambda x: x[2])
for i in range(m):
    print(str(pyi[i][0]).zfill(6)+str(pyi[i][3]).zfill(6))

Measured memory_bytes: 108244
import java.io.*;
import java.util.*;
class Solution {
	final int SIZE = 20;
	int[] dr = { 0, 1, 0, -1 };
	int[] dc = { 1, 0, -1, 0 };
	int w;
	int h;
	int[][] graph = new int[SIZE][SIZE];
	int ans;
	int sr;
	int sc;
	void compute() {
		Scanner scanner = new Scanner(new BufferedInputStream(System.in));
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if (w == 0 && h == 0) {
				break;
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					graph[i][j] = scanner.nextInt();
					if (graph[i][j] == 2) {
						sr = i;
						sc = j;
					}
				}
			}
			ans = 11;
			dfs(sr, sc, 0);
			if (ans <= 10) {
				System.out.println(ans);
			} else {
				System.out.println(-1);
			}
		}
		scanner.close();
	}

	void dfs(int r, int c, int step) {
		if (step == 10) {
			return;
		}
		for (int direction = 0; direction < 4; direction++) {
			int nr = r;
			int nc = c;
			int cnt = 0;
			while (nr >= 0 && nr < h && nc >= 0 && nc < w && graph[nr][nc] != 1) {
				if (graph[nr][nc] == 3) {
					ans = Math.min(ans, step + 1);
					return;
				}
				nr += dr[direction];
				nc += dc[direction];
				cnt++;
			}
			if (nr >= 0 && nr < h && nc >= 0 && nc < w && graph[nr][nc] == 1 && cnt > 1) {
				graph[nr][nc] = 0;
				dfs(nr - dr[direction], nc - dc[direction], step + 1);
				graph[nr][nc] = 1;
			}
		}
	}
}
public class Main {
	public static void main(String args[]) {
		Solution solution = new Solution();
		solution.compute();
	}
}



Measured memory_bytes: 42316
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include <bits/stdc++.h>
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int lli;
void solve(){
    string ans = "";
    string s1, s2;
    lli n;
    cin >> n;
    cin >> s1 >> s2;

    for(lli i = 0; i < n; i++){
        ans += s1[i];
        ans += s2[i];
    }
    cout << ans << endl;
}
int main(){
    //freopen("input.txt","r",stdin);
    fastio
    solve();

    return 0;
}




Measured memory_bytes: 256
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=float("inf")
tmp=0
for i in range(2**d):
    count=0
    s=0
    nokori=set(range(1,d+1))
    for k in range(d):
        if i &(1<<k):
            s+=pc[k][0]*(k+1)*100+pc[k][1]
            count+=pc[k][0]
            nokori.discard(k+1)
    if s<g:
        use=max(nokori)
        n=min(pc[use-1][0],-(-(g-s)//(use*100)))
        count+=n
        s+=n*use*100
    if s>=g:
        ans=min(ans,count)
print(ans)

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

int main() 
{
    lli n;
    cin >> n;
    lli a[n];
    lli count  = 1, mi;
    for(lli i = 0; i < n; i++)
    {
        cin >> a[i];
        if(i > 0)
        {
            if(a[i] < mi)
            {
                count++;
                mi = a[i];
            }
        }
        else
            mi = a[i];
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define DEBT 100000
#define INTEREST 0.05
#define ROUNDDEV 1000
int main(void){
    int w,i;
    long int result = DEBT;
    scanf("%d",&w);
    for(i=0;i<w;i++){
        result*=(INTEREST+1.0);
        //printf("R*0.9=%ld\n",ROUNDDEV-ROUNDDEV/10);
        //printf("r+R*0.9=%ld\n",result+(ROUNDDEV-ROUNDDEV/10));
        //printf("(r+R*0.9)/R=%ld\n",(result+(ROUNDDEV-ROUNDDEV/10))/ROUNDDEV);
        //printf("((r+R*0.9)/R)*R=%ld\n",((result+(ROUNDDEV-ROUNDDEV/10))/ROUNDDEV)*ROUNDDEV);
        if(result%ROUNDDEV!=0){
            result+=ROUNDDEV-(result%ROUNDDEV);
        }
        //result=((result+(ROUNDDEV-ROUNDDEV/10))/ROUNDDEV)*ROUNDDEV;
        //printf("r=%ld\n",result);
    }
    printf("%ld\n",result);
    
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int K, X;
    cin>>K >>X;

    REP(i, X-K+1, X+K) cout << i << " ";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        String result = "Impossible";
        if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) result = "Possible";

        System.out.println(result);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;
  int n = s.size();

  Vll c(n+1);
  rep(i, n) {
    int x = s[i] - 'a';
    c[i+1] = c[i]^(1ll<<x);
  }

  V dp(n+1, INF);
  V dpmin(1ll<<26, INF);
  dp[0] = 0;
  dpmin[0] = 0;
  rep2(i, 1, n+1) {
    chmin(dp[i], dpmin[c[i]]+1);
    chmin(dpmin[c[i]], dp[i]);
    rep(x, 26) {
      int y = c[i]^(1ll<<x);
      chmin(dp[i], dpmin[y]+1);
      chmin(dpmin[c[i]], dp[i]);
    }
  }

  int ans = dp[n];
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 265108
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  string A,B;
  cin >> A >> B;
  if(A.size() > B.size()){
    cout << "GREATER";
  }
  else if(A.size() < B.size()){
    cout << "LESS";
  }
  else{
    rep(i,A.size()){
      if(A[i] > B[i]){
        cout << "GREATER";
        return 0;
      }
      else if(A[i] < B[i]){
        cout << "LESS";
        return 0;
      }
    }
    cout << "EQUAL";
  }
}
     

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>>ab(m);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		ab.at(i) = { a,b };
	}
	ll ans = 0;
	for (int i = 0; i < m; i++) {
		int tg_a = ab.at(i).first;
		int tg_b = ab.at(i).second;
		vector<vector<int>>graph(n, vector<int>(0));
		for (int j = 0; j < m; j++) {
			if (j != i) {
				graph.at(ab.at(j).first).push_back(ab.at(j).second);
				graph.at(ab.at(j).second).push_back(ab.at(j).first);
			}	
		}
		vector<int>alr(n,0);
		queue<int>search;
		search.push(tg_a);
		bool b = true;
		while (search.size() > 0) {
			int x = search.front();
			if (x == tg_b) {
				b = false;
				break;
			}
			alr.at(x) = -1;
			for (int i = 0; i < graph.at(x).size(); i++) {
				if (alr.at(graph.at(x).at(i)) != -1)search.push(graph.at(x).at(i));
			}
			search.pop();
		}
		if (b)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ctype.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

void func_A() {

    char s;
    cin >> s;

    if (isupper(s)) cout << "A";
    else cout << "a";

}

void func_B() {

    int n, k;
    cin >> n >> k;
    vector<int> p(n);

    for (int i = 0; i < n; ++i) cin >> p[i];
    sort(p.begin(), p.end());
    long long ans = 0;
    for (int i = 0; i < k; ++i) ans += p[i];

    cout << ans;
}


void func_C() {

    unsigned long long n;
    cin >> n;
    string ans = "";

    while (n > 0) {


        int temp = n % 26;
        n /= 26;
        if (temp == 0) {
            temp = 26;
            --n;
        }
        char c = 'a' - 1 + temp;
        ans += c;
    }

    reverse(ans.begin(), ans.end());
    cout << ans;
}

void func_D() {

    int n;
    unsigned long long ans = 0;
    cin >> n;
    vector<int> a(pow(10, 5));
    for (int i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        ans += temp;
        ++a[temp - 1];
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int b, c;
        cin >> b >> c;
        if (a[b - 1] > 0) {
            ans += (c - b) * a[b - 1];
            a[c - 1] += a[b - 1];
            a[b - 1] = 0;
        }
        cout << ans << "\n";
    }



}

int main() {

    //func_A();
    //func_B();
    //func_C();
    func_D();

    return 0;
}

Measured memory_bytes: 3700
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
s = sorted(list(set(a)),reverse=True)
x = []
ans = 0
for si in s:
    if len(x)>=2:
        break
    cs=c[si]
    if cs>=4:
        x.append(si)
        x.append(si)
    elif cs>=2:
        x.append(si)
if len(x)<=1:
    print(0)
else:
    print(x[0]*x[1])

Measured memory_bytes: 20772
#pragma comment(linker, "/STACK:102400000,102400000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200010
#define M 2000100
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define FJ(i,a,b) for(int i=a;i<b;++i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define FD T&q=fd[rt],&ql=fd[rt<<1],&qr=fd[rt<<1|1]
#define MID int mid=((l+r)>>1)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define zero(x) (((x)>0?(x):-(x))<EPS)
#define PB push_back
#define SZ size
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define MP make_pair
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;
const int MOD=1000000007;
const double PI=acos(-1.0);
const double EPS=1e-8;
inline int II(){int n=0,ch=getchar();bool t=0;if(ch==-1)return 0;
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')t=1;
for(;ch>='0'&&ch<='9';n=n*10+ch-'0',ch=getchar());if(t)return -n;return n;}
inline void OO(int a){if(a<0){putchar('-');a=-a;}
if(a>=10)OO(a/10);putchar(a%10+'0');}
inline int sgn(double x){return(x>EPS)-(x<-EPS);}
struct edge{int v,nx;}E[M*2+N*2];int head[N],EN;
void init_edge(){EN=0;CL(head,-1);}
void add_edge(int u,int v){
    E[EN]=(edge){v,head[u]};head[u]=EN++;
  //  E[EN]=(edge){u,head[v]};head[v]=EN++;
}
int n,x,cnt=0;
int main(){
 //   IN;
    SC(n);
    FF(i,1,n){
        SC(x);
        if(x&1)++cnt;
    }
    if(cnt&1)puts("NO");
    else puts("YES");
    return 0;
}


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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007

ll binExpo(ll a, ll n)
{
    ll res = 1;
    ll base = a;
    while(n)
    {
        if(n%2)
            res = (res*base)%mod;
        
        n/=2;
        base = (base*base)%mod;
    }
    
    return res;
    
}

void solve()
{
    int n;
    
    cin>>n;
    
    ll ans  = (binExpo(10, n) - (2*binExpo(9, n))%mod + binExpo(8, n)+mod)%mod;
    
    cout<<ans;
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







Measured memory_bytes: 3644
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, M = MI()
    if N == M:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=4005,mo=1e9+7;

typedef long long LL;

int n,m,k,f[N][N][2],g[N],ans;

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	f[1][0][0]=1;
	for (int i=1;i<k;i++) f[1][i][1]=1;
	for (int i=2;i<N;i++)
	{
		g[0]=f[i-1][0][0];
		for (int j=1;j<=n;j++) g[j]=(g[j-1]+(LL)f[i-1][j][0]+f[i-1][j][1])%mo;
		for (int j=0;j<=n;j++)
		{
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mo;
			if (j)
			{
				if (j>=k) f[i][j][1]=(g[j-1]-g[j-k]+mo)%mo;
				else f[i][j][1]=g[j-1];
			}
		}
	}
	for (int i=1;i<N;i++) for (int j=0;j<=n;j++)
		if ((k-1)*i-j<m && j%(k-1)==n%(k-1) && ((k-1)*i-j)%(k-1)==(m-1)%(k-1))
			ans=(ans+f[i][j][1])%mo;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 124544
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! printvec {
    ( $item:expr ) => {
        for &i in &$item {
            print!("{} ", i);
        }
        println!("");
    }
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;


fn main() {
    input!{
        r: usize,
    }

    println!("{}", r*r);
}

Measured memory_bytes: 4352
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		//sc.next();
		HashSet<String> str = new HashSet<String>();
		String[] s = new String[N];
		for(int i =0;i<N;i++){
			String ss =sc.next();
			s[i] = ss;
			str.add(ss);
		}
		int M = sc.nextInt();
		String[] t = new String[M];
		//sc.next();
		for(int i =0;i<M;i++){
			String ss =sc.next();
			t[i] = ss;
			str.add(ss);
		}

		String[] st = str.toArray(new String[0]);
		int[] sb=new int[str.size()];
		int[] sr =new int[str.size()];
		for(int i =0;i<str.size();i++){
			sb[i]=0;
			sr[i]=0;
		}
		for(int i =0;i<str.size();i++){
			for(int j =0;j<N;j++){
				if(st[i].equals(s[j])){
					sb[i]++;
				}
			}
			for(int j =0;j<M;j++){
				if(st[i].equals(t[j])){
					sr[i]++;
				}
			}
		}
		int ans=0;
		for(int i =0;i<str.size();i++){
			ans=Math.max(ans,sb[i]-sr[i]);
		}
		System.out.println(ans);
 		sc.close();
	}
}


Measured memory_bytes: 21332
# 入力
N=int(input())
A=list(map(int,input().split()))

count=0
# 選択ソート
for i in range(N):
    minj=i
    for j in range(i,N):
        if A[j]<A[minj]:
            minj=j
    if A[i]!=A[minj]:
        A[i],A[minj]=A[minj],A[i]
        count+=1

# 出力
B=list(map(str,A))
print(' '.join(B))
print(count)



Measured memory_bytes: 5600
#include <iostream>
#include <array>
#include <string>
using namespace std;
int q;
int main() {
  cin >> q;
  for (int i = 0; i < q; i++) {
    string x, y;
    cin >> x >> y;
    int L[(int)x.length() + 1][(int)y.length() + 1];
    for (int a = 0; a <= x.length(); a++) {
      for (int b = 0; b <= y.length(); b++) {
        if (a <= 0 || b <= 0) {
          L[a][b] = 0;
        } else if (x[a - 1] == y[b - 1]) {
          L[a][b] = L[a - 1][b - 1] + 1;
        } else {
          L[a][b] = max(L[a - 1][b], L[a][b - 1]);
        }
      }
    }
    cout << L[(int)x.length()][(int)y.length()] << endl;
  }
}


Measured memory_bytes: 7076
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
using namespace std;

#define N 107
#define INF 10000007

typedef pair<int, int> P;

int main() {
	int n;
	string s;
	int cost[N];
	string go[N];
	map<string, int> label;
	vector<string> lstr;
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> s;
		if(s=="goto") {
			cin >> s;
			go[i] = s.substr(0, s.length()-1);
		}else {
			label[s.substr(0, s.length()-1)] = i;
		}
	}
	priority_queue<P, vector<P>, greater<P> > q;
	for(int i=0; i<n+1; ++i) cost[i] = INF;
	q.push(P(0, 0));
	cost[0] = 0;
	while(!q.empty()) {
		int li = q.top().second, c = q.top().first; q.pop();
		if(cost[li] < c) continue;
		if(!go[li].empty()) {
			int jmp = label[go[li]];
			if(cost[li] < cost[jmp]) {
				cost[jmp] = cost[li];
				q.push(P(cost[jmp], jmp));
			}
			if(cost[li] + 1 < cost[li+1]) {
				cost[li+1] = cost[li] + 1;
				if(li!=n) q.push(P(cost[li+1], li+1));
			}
		}else {
			if(cost[li] < cost[li+1]) {
				cost[li+1] = cost[li];
				if(li!=n) q.push(P(cost[li+1], li+1));
			}
		}
	}
	cout << cost[n] << endl;
	return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  int comp(const void *a,const void *b){
    int *x=(int *)a;
    int *y=(int *)b;
    if (*x>*y) {
      return 1;
    }
    if (*x<*y) {
      return -1;
    }
    return 0;
  }

  int main() {
    int n;
    int tab[100000];
    scanf("%d",&n);
    if (n%2) {
      printf("0");
      return 0;
    }
    for (int i = 0; i < n; i++) {
      scanf("%d",&tab[i]);
    }
    qsort(tab,n,sizeof(int),comp);
    printf("%d\n",tab[n/2]-tab[(n/2)-1]); 
    return 0;
  }


Measured memory_bytes: 1020
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
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")
}

//main function
fn main() {
    let mut vec: Vec<i64> = vec![1,2,3,4,5,6,7,8,9];
    let mut point:i64 = 0;
    let n:usize = read();
    if n < 10 {
	println!("{}",n);
	return;
    }
    let mut i:i64 = n as i64-9 as i64;
    while i>=0 {
	if vec[point as usize]%10==0{
	    let pusho: i64 = vec[point as usize]*10;
	    vec.push(pusho);
	    i -=1;
	    vec.push(pusho+1);
	    i -= 1;
	}else if vec[point as usize]%10==9{
	    let pushoe: i64 = vec[point as usize]*10+8;
	    vec.push(pushoe);
	    i -=1;
	    vec.push(pushoe+1);
	    i -= 1;
	}else {
	    let pushone:i64 = vec[point as usize]*10+(vec[point as usize]%10)-1;
	    vec.push(pushone);
	    i -=1;
	    vec.push(pushone+1);
	    i -= 1;
	    vec.push(pushone+2);
	    i -= 1;
	}
	point += 1;
    }
    println!("{}",vec[n-1]);
}


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

int main() {
  int N, C;
  cin >> N >> C;
  vector<vector<int>> dp(10200, vector<int>(C + 200, -1));
  vector<int> a(N), b(N), c(N);
  for(int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  dp[0][0] = 0;
  for(int k = 0; k < N; k++) {
    for(int i = 9999; i >= 0; i--) {
      for(int j = C-1; j >= 0; j--) {
	if (dp[i][j] == -1) continue;
	// cout << i << " " << j << " " << dp[i][j] << " " << a[k] << " " << b[k] << " " << c[k] <<endl;
	dp[i+b[k]][j+c[k]] = max(dp[i+b[k]][j+c[k]], dp[i][j]+a[k]);
	dp[i+a[k]][j+c[k]] = max(dp[i+a[k]][j+c[k]], dp[i][j]+b[k]);
      }
    }
  }
  int maxi = 0;
  for(int i = 0; i <= 10000; i++) {
    for(int j = 0; j <= C; j++) {
      // if(dp[i][j] >= 0) cout << maxi << " " << i << " "  << dp[i][j] << " " << j << endl;
      maxi = max(maxi, min(i, dp[i][j]));
    }
  }
  cout << maxi << endl;
}

Measured memory_bytes: 15248
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    string s, t;
    cin >> s >> t;
    int N = s.length();
    bool f = false;
    for (int i = 0; i < N; i++)
    {
        string rot = "";
        for (int j = i; j < N; j++)
        {
            rot += s[j];
        }
        if (rot.length() < N)
        {
            int k = 0;
            while (k < i)
            {
                rot += s[k];
                k++;
            }
            k = 0;
        }
        if (rot == t)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ll n;
cin>>n;
ll arr[n];
for(int i=0;i<n;i++){
    cin>>arr[i];
}
ll t=0;
sort(arr,arr+n);
for(ll i=0;i<n-1;i++){
    for(ll j=i+1;j<n;j++){
        ll x = arr[i]+arr[j];
        ll v = lower_bound(arr,arr+n,x)-arr;
        t+=max((ll)0,v-j-1);
    }
}
cout<<t<<endl;
return 0;}


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

int main() {
  int N;
    cin >>N;
  int sum=0;
  int M=0;
  for(int i=0;i<N;i++){
    int p;
      cin >>p;
    sum+=p;
    if(M<=p){
      M=p;
    }
    
}
  cout<<sum-M/2<<endl;
}


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

int main(){
  int n, l, i, sum=0, mini, mini_sum, eat_sum;
  cin >> n >> l;


  for(i=1; i<=n; i++){
    sum += l + i - 1;
  }

  mini = 10000;

  for(i=1; i<=n; i++){
    eat_sum =  sum - (l+i-1);
    if(mini > abs(sum-eat_sum))
    {
      mini = abs(sum-eat_sum);
      mini_sum = eat_sum;
    }
  }

  cout << mini_sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int i,j;
        char s[201];

        scanf("%s",s);

        for(i=0;s[i]!='\0';i++);

        i = i-2;

        for(i=i;i>=0;i-=2){
                for(j=i/2;j<i;j++){
                        if(s[j]!=s[j-i/2])
                                break;
                }
                if(j==i){
                        printf("%d\n",i);
                        return 0;
                }
        }

}


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

int main() {
  string s;
  cin >> s;
  
  int i, a = 0, b = 0, c = 0, d = 0;
  for(i = 0; i < s.size(); i++){
    if(i % 2 == 0){
      if(s.at(i) == '0') a++;
      else c++;
      }
      
    else{
      if(s.at(i) == '1') b++;
      else d++;
    }
  }
  
  cout << min(a + b, c + d) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  string s,t;
  cin >> s >> t;
  int ans=10000;
  for(int i=0;i<s.size()-t.size()+1;i++){
    int p=0;
    for(int j=0;j<t.size();j++){
      if(s.at(i+j)!=t.at(j)){
        p++;
      }
    }
    ans=min(ans,p);
  }
  cout << ans;
}
      
      

Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define mid ((l+r)>>1)
#define ls (root<<1)
#define rs (root<<1|1)
using namespace std;

int n, q, cnt, b[MAXN], t[MAXN*4];

vector<int> vec[MAXN];

void up(int root)
{
    t[root]=min(t[ls], t[rs]);
}

void build(int root, int l, int r)
{
    if(l==r)
    {
        t[root]=(l?INF:0);
        return;
    }
    build(ls, l, mid);
    build(rs, mid+1, r);
    up(root);
}

void update(int root, int l, int r, int x, int k)
{
    if(l>x || r<x) return;
    if(l==r)
    {
        t[root]=min(t[root], k);
        return;
    }
    update(ls, l, mid, x, k);
    update(rs, mid+1, r, x, k);
    up(root);
}

int query(int root, int l, int r, int x, int y)
{
    if(l>y || r<x) return INF;
    if(l>=x && r<=y) return t[root];
    return min(query(ls, l, mid, x, y), query(rs, mid+1, r, x, y));
}

int main()
{
    scanf("%d", &n);
    for(rint i=1; i<=n; ++i)
    {
        scanf("%d", &b[i]);
        cnt+=(!b[i]);
    }
    scanf("%d", &q);
    for(rint i=1, l, r; i<=q; ++i)
    {
        scanf("%d%d", &l, &r);
        vec[l].push_back(r);
    }
    build(1, 0, n);
    for(rint i=1; i<=n; ++i)
    {
        for(rint j=0; j<vec[i].size(); ++j)
            update(1, 0, n, vec[i][j], query(1, 0, n, i-1, vec[i][j]));
        update(1, 0, n, i, query(1, 0, n, i-1, i-1)+2*b[i]-1);
    }
    printf("%d\n", cnt+query(1, 0, n, n, n));
    return 0;
}


Measured memory_bytes: 14464
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();

			double distance = Math.Sqrt(Math.Pow(array[0] - array[2], 2.0) + Math.Pow(array[1] - array[3], 2.0));

			Console.WriteLine($"{distance:f6}");

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 18512
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a+b==15) printf("+\n");
	else
		if(a*b==15) printf("*\n");
		else printf("x\n");
	return 0;
}


Measured memory_bytes: 128
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(n: usize, a: [usize; n], b: [usize; n]);

    if let Some(ans) = solve(n, &a, &b) {
        println!("Yes");
        println!("{}", ans.iter().map(|&v| v.to_string()).join(" "))
    } else {
        println!("No")
    }
}

fn solve(n: usize, a: &[usize], b: &[usize]) -> Option<Vec<usize>> {
    let mut cnt = vec![0; n];
    for x in [a, b].concat() {
        cnt[x - 1] += 1;
    }
    if cnt.iter().any(|&c| c > n) {
        return None;
    }
    let mut d = 0;
    let b = [b; 2].concat();
    while (0..n).any(|i| a[i] == b[i + d]) {
        for i in (0..n).rev() {
            while a[i] == b[i + d] {
                d += 1;
            }
        }
    }
    Some((&b[d..d + n]).into())
}


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

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;

const int inf = 1e9;

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

    int n;
    cin >> n;
    vi h(n), dp(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    for (int i = 1; i < n; ++i) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), i >= 2 ?
                    dp[i - 2] + abs(h[i] - h[i - 2]) : inf);
    }
    cout << dp[n - 1] << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	while(1) {
		int a=1, b=1;
		cin >> a >> b;
		if(a == 0 && b == 0) {
			return 0;
		}
		if(a > b)swap(a, b);
		cout << a << ' '<<b << endl;
	}
}


Measured memory_bytes: 3076
#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;
  
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  int flag=0;
  map<int, int> taiou;
  rep(i, N){
    taiou[A[i]]++;
    if(taiou[A[i]] > 1){
      flag=1;
      break;
    }
  }
  if(flag==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 10368
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	long long int x = 0;

	if (b) {
		if (c >= b) {
			x += b * 2;
			c -= b; b = 0;
		}
		else {
			x += c * 2;
			 b -= c;c -= c;
			x += b;
			cout << x << endl;
			return 0;
		}
	}
	if (c) {
		if (c > a) {
			x += a + 1;
		}
		else {
			x += c;
		}
	}
	cout << x << endl;

	return 0;

}

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

long long int dp[ 1 << 16 ][ 31 ] = {};

long long int score( long long int k ) {

  long long int ans = 0;

  while( k > 0 ) {

    ans += ( k % 2 );
    k /= 2;

  }

  return ans;

}

int main() {

  while( true ) {

    long long int n, c;

    cin >> n >> c;
    if ( n == 0  ) break;

    vector< long long int > a, b;

    for ( long long int i = 0; i < n; i++ ) {

      long long int k = 0;

      for ( long long int j = 0; j < 16; j++ ) {

	long long int in;
	cin >> in;
	k = k * 2 + in;

      }

      a.push_back( k );

    }

    for ( long long int i = 0; i < c; i++ ) {

      long long int k = 0;

      for ( long long int j = 0; j < 16; j++ ) {

	long long int in;
	cin >> in;
	k = k * 2 + in;

      }

      b.push_back( k );

    }

    for ( long long int i = 0; i <= n; i++ ) {
      for ( long long int j = 0; j < ( 1 << 16 ); j++ ) {
	dp[j][i] = 0;
      }
    }

    dp[0][0] = 1;

    for ( long long int i = 0; i < n; i++ ) {

      for ( long long int j = 0; j < ( 1 << 16 ); j++ ) {

	if ( dp[j][i] == 0 ) continue;
	long long int k = j | a[i];

	for ( long long int p = 0; p < c; p++ ) {

	  long long int q = k & b[p];
	  dp[ k ^ q ][ i + 1 ] = max( dp[k^q][i+1], dp[j][i] + score(q) );

	}

      }

    }

    long long int ans = 0;

    for ( long long int i = 0; i < ( 1 << 16 ); i++ ) {
      ans = max( ans, dp[i][n] );
    }

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

  }

  return 0;

}

Measured memory_bytes: 17088
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
int f(int n){
    if(n%2==0) return n/2;
    else return 3*n+1;
}
int n,t,a;
vector<int> p;
void input(){
    cin>>n;
}
void src(){
    p.push_back(n);
    int i=1;
    do{
        p.push_back(f(p.back()));++i;
    }while(find(p.begin(),p.end(),p.back())==p.end()-1);
    cout<<i;
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

using namespace std;

typedef struct
{
    string name;
    int point;
    int num;
}food;
food A[10001];
bool paixu(const food &a,const food &b)
{
    if(a.name != b.name)
        return a.name<b.name;
    return a.point > b.point;
    
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>A[i].name>>A[i].point;
        A[i].num = i+1;
    }
    sort(A,A+n,paixu);
    for(int i=0;i<n;i++)
        cout<<A[i].num<<endl;
        return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>


int main()
{
    int sum;

    while (1) {
        sum = 0;
        std::string str;
        std::cin >> str;
        if (str == "0") {
            break;
        } else {
            for (int i = 0; i < str.length(); i++) {
                sum += (int)str[i] - 48;
            }

        }
        std::cout << sum << std::endl;
    }


    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ll long long
#define db double
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define inf LONG_LONG_MAX
#define inf1 INT_MAX
using namespace std;
/*
ll mpow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=mpow(a,b/2);
    temp=(temp*temp)%mod;
    if(b%2)
        return (a*temp)%mod;
    return temp;
}

ll _pow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=_pow(a,b/2);
    temp=(temp*temp);
    if(b%2)
        return (a*temp);
    return temp;
}

ll mod_in(ll n){
    return mpow(n,mod-2);
}
*/

void arrange(ll w[], ll v[], ll n)
{
    pair <ll, ll> p[n];
    ll i;
    for(i=0; i<n; i++)
    {
        p[i].first=w[i];
        p[i].second=v[i];
    }
    sort(p, p+n);
    for(i=0; i<n; i++)
    {
        w[i]=p[i].first;
        v[i]=p[i].second;
    }
}

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

Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <algorithm>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(){
	int n;
	int result = 0;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

	for(;;){
#if INPUT_FROM_FILE
		ifs >> n;
#else
		std::cin >> n;
#endif
		if(n == 0){ break; }

		result = 0;
		for(int i = 5; i <= n; i++){
			int tmp = i;

			if(tmp % 5 == 0){
				while(tmp % 5 == 0){
					result++;
					tmp /= 5;
				}
			}
		}
		std::cout << result << std::endl;
	}

	return 0;
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
A = [None] * N
for i in range(N):
    A[i] = [a-1 for a in LIST()]

k = 0
valid = [1] * M
ans = INF
while k < M:
    cnt = [0] * M
    for i in range(N):
        mn = INF
        idx = -1
        for j in range(M):
            a = A[i][j]
            if valid[a]:
                # まだ有効なもののうち、一番順位が高いスポーツにカウント追加
                cnt[a] += 1
                break
    mx = max(cnt)
    ans = min(ans, mx)
    for i in range(M):
        # 票が最も集まったものは次から選ばないようにする
        if cnt[i] == mx:
            valid[i] = 0
            k += 1
print(ans)


Measured memory_bytes: 42972
n,C=map(int,input().split())
stc=[[int(i) for i in input().split()] for _ in range(n)]
dp=[0]*(2*10**5+2)
for j in range(1,C+1):
  tmp=[0]*(2*10**5+2)
  for s,t,c in stc:
    if j == c:
      tmp[2*s-1]+=1
      tmp[2*t]-=1
  for i in range(2*10**5+1):
    tmp[i+1]+=tmp[i]
    dp[i+1]+=tmp[i+1]>0
print(max(dp))


Measured memory_bytes: 107068
<?php
fscanf(STDIN, "%d %d", $N, $M);
$min = 1; $max = $N;
while($M-- > 0){
	fscanf(STDIN, "%d %d", $l, $r);
	$min = max($min, $l);
	$max = min($max, $r);
}
$put = $max-($min-1);
if($put > 0) echo $put;
else echo 0;


Measured memory_bytes: 4728
s = input()
mmyy = (1 <= int(s[:2]) <= 12)
yymm = (1 <= int(s[2:]) <= 12)
if mmyy and yymm:
    print('AMBIGUOUS')
elif mmyy:
    print('MMYY')
elif yymm:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 8968
#include <stdio.h>
int main()
{
  int a=100000,n;
  scanf("%d",&n);
  for(;n>0; n--){
    a += a * 0.05;
    if (a % 1000 != 0) {
      a -= a % 1000;
      a += 1000;
    }
  }
  printf("%d\n", a);
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  for (int i = 1; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3428
n, y = gets.split.map(&:to_i)

a = b = c = -1

valid = false
([2_000, y / 10_000].min).downto(0) do |i|
  break if valid

  rest = y - 10_000 * i
  (rest / 5_000).downto(0) do |j|
    rest = y - 10_000 * i - 5_000 * j

    k = rest / 1_000
    valid = k && (i + j + k == n)

    if valid
      a, b, c = [i, j, k]
      break
    end
  end
end

puts [a, b, c].join(" ")


Measured memory_bytes: 3836
#include <stdio.h>
#define SIZ 1400
int m[SIZ+1][SIZ];
long long st[SIZ];
char z[9999999];
int get(){
	static int input_count=0;
	int r=0;
	for(;'0'<=z[input_count]&&z[input_count]<='9';)r=r*10+z[input_count++]-'0';
	input_count++;
	return r;
}
int main(){
	fread(z,1,sizeof(z),stdin);
	int i,j,k,y=get(),x=get(),r,ptr,h;
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++){
		int t=get();
		r=t==0?r+1:0;
	}
	for(r=i=0;i<x;i++)for(ptr=j=0;j<=y;j++){
		int left=j;
		for(;ptr && (h=st[ptr-1]>>32)>m[j][i];){
			int l=st[--ptr]&0xffffffff;
			if(r<(j-l)*h)r=(j-l)*h;
			left=l;
		}
		st[ptr++]=((long long)m[j][i]<<32)|left;
	}

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

Measured memory_bytes: 14268
#include <stdio.h>
int main(){
    int min, max = 0, n;
    scanf("%d\n",&n);
    int vetor[n];
    for(int i=0;i<n;++i){
        scanf("%d", &vetor[i]);
        if (i == 0) min = vetor[0];
        else if (min > vetor[i]) min = vetor[i];
        if (max < vetor[i]) max = vetor[i];
    }
    printf("%d\n", max - min);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int A,B,X;
  scanf("%d%d%d",&X,&A,&B);
  if(A - B >= 0){
    printf("delicious\n");
  }else if(A - B < 0 && A + X - B >= 0){
    printf("safe\n");
  }else{
    printf("dangerous\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  ld a, b;
  cin >> a >> b;
  ld ans = a*b;
  cout << (ll) ans << endl;
  return 0;
}

Measured memory_bytes: 3724
n, k = map(int, input().split())
a = list(map(int, input().split()))

x = 0
y = 0
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            if i < j:
                x += 1
            else:
                y += 1

print((x*(k**2-((k-1)*k//2)) + y*(k**2-((1+k)*k//2))) % (10**9+7))

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

from collections import deque

k = int(input())

que = deque(reversed([i for i in range(1, 10)]))

x = -1
for _ in range(k):
    # print(f"loop: {_}")
    # print(f"que: {que}")
    x = que.pop()
    # print(f"x: {x}\n")
    r_10 = x % 10
    if r_10 == 0:
        # 10, 100, 1000, ...
        que.appendleft(x * 10)
        que.appendleft(x * 10 + 1)
    elif r_10 == 9:
        # 9, 99, 989, 999, ...
        que.appendleft(x * 10 + x % 10 - 1)
        que.appendleft(x * 10 + x % 10)
    else:
        # 1, 2, ..., 8, 11, 12, 21, 22, 23, ...
        que.appendleft(x * 10 + x % 10 - 1)
        que.appendleft(x * 10 + x % 10)
        que.appendleft(x * 10 + x % 10 + 1)

print(x)


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

void solve(){
  int N, K;
  cin >> N >> K;
  int cur = K;
  int ret = 1;
  while(cur < N){
    cur += K-1;
    ret++;
  }
  cout << ret << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int64_t> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int64_t score = 1;
  
  for (int i = 0; i < K; i++) {
  score *= A.at(i);
  }
  
  for (int i = K; i < N; i++ ) {
    if (A.at(i) > A.at(i - K)) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
    score = score / A.at(i - K) * A.at(i);
  }
}


Measured memory_bytes: 4824