akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
  int n,i,j=101,tmp=0,flag=0;
  int s[100],a[100];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
    tmp+=s[i];
    if(s[i]%10!=0){
      flag=1;
    }
  }
  
  if(flag==0){
    printf("0");
    return 0;
  }
  if(tmp%10!=0){
    printf("%d",tmp);
    return 0;
  }
  
  for(i=0;i<n;i++){
    if(s[i]%10!=0 && s[i]<j){
      j=s[i];
    }
  }
  printf("%d",tmp-j);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

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

    string one = "", zero = "";
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            one += '1';zero += '0';
        }
        else {
            one += '0';zero += '1';
        }
    }
    int o = 0, z = 0;
    for (int i = 0; i < n; ++i) {
        if (in[i] != one[i])o++;
        if (in[i] != zero[i])z++;
    }
    cout << min(o, z);
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll n,d;
    cin >> n >> d;
    int cnt = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

int main()
{
	int a[3];
	int k;
	for(int i=0; i<3; i++){
		scanf("%d", &a[i]);
	}
	scanf("%d", &k);
	sort(a, a+3);
	for(int i=0; i<k; i++){
		a[2]=a[2]*2;
	}
	printf("%d\n", a[0]+a[1]+a[2]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >>n;
    vector<ll> a(n);
    vector<ll> order(n);

    rep(i,0,n) cin>>a[i], a[i]--;

    rep(i,0,n){
        order[a[i]] = i;
    }

    rep(i,0,n)
        cout << ++order[i] << " ";
    cout << endl;
    

    return 0;
}


Measured memory_bytes: 2432
import java.util.*;
public class Main {
	public static void main(String[] args) {
		C();
	}
	
	public static void A() {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		if(s1.compareTo(s2) < 0) System.out.println("<");
		else if(s1.compareTo(s2) == 0) System.out.println("=");
		else System.out.println(">");
	}
	
	public static void B() {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		if(X<Y || X<Z) {
			System.out.println(0);
			return;
		}
		X -= Z;
		System.out.println(X/(Y+Z));
	}
	
	public static void C() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		int ret = (int) ((M*1900+(N-M)*100)*Math.pow(2, M));
		System.out.println(ret);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            

            int ans = 0;
            int n;
            cin >> n;
            for(int i = 0; i < n-1; i++)
            {
                int u,v;
                cin >> u >> v;
                if(u > v)
                    swap(u,v);
                ans -= u * (n - v + 1);
            }
            for(int i = 1; i <= n; i++)
            {
                ans += i*(n-i+1);
            }
            cout << ans << '\n';




           return 0;
        }
          

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

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

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    unordered_set<lint> distinct_elems;
    range(i, 0, 3) {
        lint e; cin >> e;
        distinct_elems.emplace(e);
    }
    cout << (distinct_elems.size() == 2 ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 384
n = int(input())
s = input()
counter_l = 0
pairs = 0
double_check = set()

for i in range(n):
    if s[i] == "(":
        counter_l += 1
        for j in range(i + 1, n):
            if s[j] == ")" and j not in double_check:
                pairs += 1
                double_check.add(j)
                break
counter_r = n - counter_l
s = s + ")" * (counter_l - pairs)
s = "(" * (counter_r - pairs) + s

print(s)


Measured memory_bytes: 9180
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>    // for pair
using namespace std;

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

ll gcd(ll a, ll b){ if (a % b) return (gcd(b, a % b)); else return b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

signed main()
{
    int X, A; cin >> X >> A;
    if (X < A) puts("0");
    else puts("10");

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

list1 = input().split()
list2 = input().split()
N = int(list1[0])
K = int(list1[1])
a = [int(i) for i in list2]

cnt_l = 0
cnt_r = 0
for j in range(len(a)):
    for i in range(j):
        if a[i] > a[j]:
            cnt_l = cnt_l + 1
    for i in range(j, len(a)):
        if a[i] > a[j]:
            cnt_r = cnt_r + 1

res = ((cnt_l * K * (K+1) // 2) + (cnt_r * (K-1) * K //2)) % (10**9 + 7)

print(int(res))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int a,b,c,x;
	cin >> a >> b >> c >> x;
	
	int ans = 0;
	
	/*
	if(x % 500 == 0 and (x / 500) <= a) ans++;
	if(x % 100 == 0 and (x / 100) <= b) ans++;
	if(x % 50 == 0 and (x / 50) <= c) ans++;
	*/
	
	for (int anum = 0; anum <= a; anum++) {
	    for (int bnum = 0; bnum <= b; bnum++) {
	        for (int cnum = 0; cnum <= c; cnum++) {
	            if(anum*500 + bnum*100 + cnum*50 == x) ans++;
	        }
	    }
	}
	
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

void Main() {
    int N, L;
    cin >> N >> L;

    vector<int> taste_list(N);
    vector<int> abs_list(N);
    for(int i = 0; i<N; ++i){
        taste_list[i] = L + i;
        abs_list[i] = abs(L + i);
    }
    auto itr = min_element(abs_list.begin(), abs_list.end());
    int num = distance(abs_list.begin(), itr);

    int ans = 0;
    for(int i = 0; i < N; ++i){
        if(i != num){
            ans += taste_list[i];
        }
    }
    cout << ans << endl;
}


int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)


// ------------debug用------------
#define FALSE cout<<"false"<<endl;
#define TRUE cout<<"true"<<endl;
// ------------debug用------------


// ------------計算用------------
#define ALL(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)
// ------------計算用------------


// ------------出力用------------
#define PRINT(x) cout<<x<<endl;
// ------------出力用------------


using namespace std;
typedef long long ll;

int main(){
  int N,K;
  cin>>N>>K;
  int ans = N;
  ans -= K;
  if(K == 1)ans = 0;
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

int main() {
	int N, K;
	cin >> N >> K;
	cout << ceil((double)(N-1)/(K-1)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 1002
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int main(){
	int a[10], b[10], ans1, ans2;
	rep(i,10)scanf("%d", &a[i]);
	rep(i,10)scanf("%d", &b[i]);
	sort(a, a+10);sort(b, b+10);
	ans1 = a[7]+a[8]+a[9];
	ans2 = b[7]+b[8]+b[9];
	printf("%d %d\n", ans1, ans2);
	return 0;
}

Measured memory_bytes: 3288
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int a,b,f[5];
	memset(f,0,sizeof(f) ) ;
	for(int i=1;i<=3;i++) {
		cin >> a >> b ;
		f[a]++;f[b]++;
	}
	int ff=1;
	for(int i=1;i<5;i++){
		if(f[i]>2)  {
			ff=0;break;
		}
	}
	if(ff==1) cout << "YES" ;
	else cout <<"NO" ;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

bool can[2][10][10];
int x,y,n,sx,sy,dx1[]={2,2,2,1,1,0,0,-1,-1,-2,-2,-2},dy1[]={1,0,-1,2,-2,2,-2,2,-2,1,0,-1},dx2[]={1,1,1,0,0,0,-1,-1,-1},dy2[]={1,0,-1,1,0,-1,1,0,-1};

int main(){
	while(cin>>x>>y&&(x+y)){
		rep(i,10){fill(can[0][i],can[0][i]+10,0);fill(can[1][i],can[1][i]+10,0);}
		can[0][x][y]=1;
		cin>>n;
		rep(i,n){
			cin>>sx>>sy;
			rep(j,10)rep(k,10)if(can[0][j][k])rep(l,12)rep(m,9)if(j+dx1[l]>=0&&j+dx1[l]<=9&&j+dx1[l]==sx+dx2[m]&&k+dy1[l]>=0&&k+dy1[l]<=9&&k+dy1[l]==sy+dy2[m])can[1][j+dx1[l]][k+dy1[l]]=1;
			rep(j,10)rep(k,10){can[0][j][k]=can[1][j][k];}
			rep(j,10)fill(can[1][j],can[1][j]+10,0);
		}
		bool ans=0;
		rep(i,10)rep(j,10)if(can[0][i][j])ans=1;
		cout<<(ans?"OK":"NA")<<endl;
	}
}

Measured memory_bytes: 0
n = int(input())
lst = [list(map(int, input().split())) for _ in range(n)]
a_start = [x[0] * 60 + x[1] for x in lst]
a_end = [x[2] * 60 + x[3] for x in lst]
h_start = [x[4] * 60 + x[5] for x in lst]
h_end = [x[6] * 60 + x[7] for x in lst]
b_start = [x[8] * 60 + x[9] for x in lst]
b_end = [x[10] * 60 + x[11] for x in lst]

def make_sets(start, end):
  sets = []
  member = []
  for i in range(1440):
    upd = False
    for j in range(n):
      if start[j] == i:
        member.append(j)
        upd = True
      if end[j] == i - 1:
        member.remove(j)
        upd = True
    if upd:
      sets.append(set(member))
  return sets

a_sets = make_sets(a_start, a_end)
h_sets = make_sets(h_start, h_end)
b_sets = make_sets(b_start, b_end)

ans = 0
for s1 in a_sets:
  for s2 in h_sets:
    for s3 in b_sets:
      ans = max(ans, len(s1 & s2 & s3))

print(ans) 


Measured memory_bytes: 5856
#include <stdio.h>
int main(){
    int n;
    int a,b,c;
    
    a=b=c=0;
    
    for(int i=0;i<10;i++){
        scanf("%d",&n);
        if(n>=a){
            c=b;b=a;a=n;
        }else if(n>=b){
            c=b,b=n;
        }else if(n>c){
            c=n;
        }
    }
    printf("%d\n%d\n%d\n",a,b,c);
    
    return(0);
    
}



Measured memory_bytes: 2044
#include<stdio.h>
int main(void)
{
	int a,b,x,t;
	scanf("%d %d %d",&a,&b,&t);
	x=a*b;
	if(x<=t){
		printf("%d\n",x);
	}
	else if(t<=x){
		printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 128
Scanf.scanf "%d %d %d %s" (fun n k c s ->
    let forward = Array.make k 0 in
    let reverse = Array.make k 0 in
    let rec loop cur i =
        if cur = k then () else
            if s.[i] = 'o' then (forward.(cur) <- i; loop (cur + 1) (i + c + 1))
                           else loop cur (i + 1)
    in
    loop 0 0;

    let rec loop cur i =
        if cur < 0 then ()  else
            if s.[i] = 'o' then (reverse.(cur) <- i; loop (cur - 1) (i - c - 1))
                           else loop cur (i - 1)
    in
    loop (k - 1) (n - 1);
    for i = 0 to k - 1 do
        if forward.(i) = reverse.(i) then Printf.printf "%d\n" @@ forward.(i) + 1
    done
)

Measured memory_bytes: 9732
#include<bits/stdc++.h>
using namespace std;
  int a,b,d,e=0,r=0;
  bool q[1000000];
int w[10000000];
signed main (){
  string c;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    cin>>d>>c;
    if(q[d]==false){
      if(c=="WA") w[d]++;
      else{
        r++;
        q[d]=true;
      }
    }
  }
  for(int i=0;i<=a;i++){ 
    if(q[i]==true) e+=w[i];
  }
  cout<<r<<" "<<e<<"\n";
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A,B;
  int a,b;
  FOR(i, 1, N+2) {
    cin >> a;
    A.pb(a);
  }
  FOR(i, 1, N+1) {
    cin >> b;
    B.pb(b);
  }

  int cnt = 0;
  REP(i, N) {
    cnt += min(A[i], B[i]);
    B[i] -= min(A[i], B[i]);
    cnt += min(A[i+1], B[i]);
    A[i+1] -= min(A[i+1], B[i]);
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> counts(M);
  for (int i = 0; i < N; ++i) {
    int K, A;
    cin >> K;
    for (int j = 0; j < K; ++j) {
      cin >> A;
      ++counts[A - 1];
    }
  }
  int ans = 0;
  for (auto x : counts) {
    if (x == N) ++ans;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    ll ans = -1e18;
    vector<ll> p(n);
    vector<ll> c(n);
    rep(i,n){
        cin >> p.at(i);
        --p.at(i);
    }
    rep(i,n) cin >> c.at(i);
    for(i = 0;i < n;++i){
        vector<ll> v(n, -1);
        vector<ll> pnt(n, -1e18);
        pnt.at(i) = c.at(i);
        v.at(i) = 1;
        ll now = i;
        ll cnt = 2;
        ll next;
        while(true){
            next = p.at(now);
            if(v.at(next) != -1) break;
            v.at(next) = cnt;
            ++cnt;
            pnt.at(next) = pnt.at(now) + c.at(next); 
            now = next; 
        }
        ll pre = now;
        now = next;
        ll start = v.at(now);
        ll end = v.at(pre);
        ll isyu_pnt = pnt.at(pre) - pnt.at(now) + c.at(now);
        ll isyu_cnt = v.at(pre) - v.at(now) + 1;
        for(j = 0;j < n;++j){
            if(v.at(j) == -1 || v.at(j) > k) continue;
            if(v.at(j) < start){
                ans = max(ans, pnt.at(j));
            }else{
                if(isyu_pnt <= 0) ans = max(ans, pnt.at(j));
                else{
                    ll tmp = k - v.at(j);
                    ll tmp_ans = pnt.at(j) + tmp/isyu_cnt*isyu_pnt;
                    ans = max(ans, tmp_ans);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3792
#include<iostream>
using namespace std;
int main()
{
   int n;
   cin>>n;
   if(n<=1000)
    cout<<1000-n<<endl;
   else
   {
       for(int i=1;i<=11;i++)
        if(n>=1000*i&&n<=(i+1)*1000)
            {
                cout<<(i+1)*1000-n<<endl;
                break;
            }
   }
   return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#define rep(i,n) for (int i=0; i< n; i++)
using namespace std;


int main() {
	int n;
    string w;
	cin >> n;
    vector<pair<string,int>> v(n);
    for (int i=0;i < n;i++){
      int t;
      string s;
      cin >> s >> t;
      pair<string,int> p=make_pair(s,t);
      v[i]=p;
    }
    cin >> w;
  int sum=0;
  for (int i=0;i<n;i++){
    sum+=v[i].second;
    if (v[i].first==w) sum=0;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[0]*10**5
b=[0]*10**5
v=list(map(int,input().split()))
v1=[]
v2=[]
if len(set(v))==1:
    print(n//2)
else:
    for i in range(n):
        if i%2==0:
            a[v[i]-1]+=1
            v1.append(v[i])
        else:
            b[v[i]-1]+=1
            v2.append(v[i])
    max1=0
    max2=0
    for j in range(len(a)):
        if max1<a[j]:
            max1=a[j]
            c1=j
    for k in range(len(b)):
        if max2<b[k]:
            max2=b[k]
            c2=k
    if c1!=c2:
        print(len(v1)+len(v2)-max1-max2)
    else:
        a=sorted(a)
        b=sorted(b)
        print(min(n-max1-b[-2],n-max2-a[-2]))


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

int main(){
  string S,T;
  cin>>S>>T;
  int s=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)==T.at(i)){
      s++;
    }
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	s := make([]pair, n)

	for i := 0; i < n; i++ {
		a := nextInt()
		b := nextInt()

		s[i] = pair{a, b}
	}

	sortPairs(s)

	fmt.Println(s[n-1].f + s[n-1].s)

}

type pair struct { // f=first, s=second
	f int
	s int
}

// []pair をf->sの順でソートする
func sortPairs(s []pair) {
	sort.Slice(s, func(i, j int) bool {
		if s[i].f == s[j].f { // fが同じ場合はsを比較する
			return s[i].s < s[j].s
		}
		return s[i].f < s[j].f
	})
	return
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int A[100001];
vector <pair<int,int>> adj[100001];
int n,m,x,y,z;

void dfs(int now,int val)
{
    for(auto it : adj[now])
    {
        int next = it.first;
        int cost = it.second;
        if(A[next]!=-1)
        {
            continue;
        }
        cost += val;
        if(cost%2==1)
        {
            A[next] = 1;
        }
        else
        {
            A[next] = 0;
        }
        dfs(next,A[next]);
    }
}

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

    int res = 0;
    cin >> n >> m;

    for(int i=0;i<m;i++)
    {
        cin >> x >> y >> z;
        z%=2;
        adj[x].push_back(make_pair(y,z));
        adj[y].push_back(make_pair(x,z));
    }

    memset(A,-1,sizeof(A));

    for(int i=1;i<=n;i++)
    {
        if(A[i]==-1)
        {
            res++;
            A[i] = 0;
            dfs(i,0);
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 9216
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}

int N, K, C;
int F[200100],B[200100];
int szf[200100], szb[200100];
string S;
int main()
{
	cin >> N >> K >> C;
	cin >> S;
	F[1] = 1;
	int res = 1;
	for(int i =1;i<N+1;i++) {
		//F[i] = F[res];
		
		if (i - res > C&&S[i-1]=='o') {
			F[i] = F[res]+1;
			res = i;
		}
		szf[i] = res;
	}
	res = N;
	B[res] = 1;
	for (int i = N; i > 0; --i) {
		//B[i] = B[res];
		if (res - i > C&& S[i-1] == 'o') {
			B[i] = B[res]+1;
			res = i;
		}
		szb[i] = res;
	}
	rep(i, N+1) {
		//cout << B[i] << " e" << endl;
		if(B[i]!=0)B[i] = K-B[i]+1;
		//cout << B[i] << endl;
	}
	
	szf[0] = -INF; szb[N + 1] = INF;
	int ans = 0;
     for(int i=1;i<N+1;i++) {
		 if (F[i] == B[i] && F[i] != 0) {
			// cout << F[i] << endl;
			 cout<<i<<endl;
		}
	}
	
	
}

Measured memory_bytes: 4996
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public  static void main(String[] args){
	int n = kbd.nextInt();
	while(n>0){
	    solve(n);
	    n--;
	}
    }

    static void solve(int n){
	String s = kbd.next();
	int cnt = 0;
	while(s.length()>1){
	    //System.out.println(s);
	    s = cut(s);
	    cnt++;
	    if(cnt > (100000000)){
		cnt = -1;
	    }
	    //System.out.println(n+"ぐるぐるっ！");
	}
	System.out.println(cnt);
    }

    static String cut(String s){
	int ans = 0;
	int a, b, i;
	for(i=1; i<s.length(); i++){
	    a = Integer.parseInt(s.substring(0, i));
	    b = Integer.parseInt(s.substring(i, s.length()));
	    if(a*b > ans) ans = a*b;
	    //System.out.println(ans);
	}
	return Integer.toString(ans);
    }
}

Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  cin >> n >> k;
  long long ans=0;
  for(int i=k+1;i<=n;i++){
    ans+=n/i*(i-k)+max((long long)0,n%i-k+(k!=0));
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[100][100];
	int x,y;
	int row_no, col_no;
	int work_no;
	int i;
	while(scanf("%d %d", &col_no,&row_no) != EOF){
		if(col_no == 0 && row_no == 0) break;
	
	for (x = 1; x <= col_no; x++){
		for (y = 1; y <= row_no; y++){
			a[x][y] = 0;
		}
	}
	a[1][1] = 1;
	
	scanf("%d", &work_no);
	
	for (i = 0; i < work_no; i++){
		scanf("%d", &x);
		scanf("%d", &y);
		
		a[x][y] = -1;
	}
	
	for (x = 1; x <= col_no; x++){
		for (y = 1; y <= row_no; y++){
			if (a[x][y] == 0){
			if (x == 1){
				a[x][y] = a[x][y - 1];
			}
			else if (y == 1){
				a[x][y] = a[x - 1][y];
			}
			else {
				if (a[x-1][y] == -1){
					a[x][y] = a[x][y - 1];
				}
				else if (a[x][y - 1] == -1){
					a[x][y] = a[x-1][y];
				}
				else {
					a[x][y] = a[x - 1][y] + a[x][y - 1];
				}
			}
		}
	}
	}
	printf("%d\n", a[col_no][row_no]);
	}
	return (0);
}

Measured memory_bytes: 612
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = 0
for i in range(n):
    town_a = a[i]
    town_b = a[i+1]
    power = b[i]
    if power > town_a:
        ans += town_a
        power -= town_a
    else:
        ans += power
        continue
    if power > town_b:
        ans += town_b
        a[i+1] = 0
    else:
        ans += power
        a[i+1] -= power
print(ans)


Measured memory_bytes: 19116
#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <bitset>
#include<bits/stdc++.h>
#define clean(x, y) memset(x, y, sizeof(x))
const int maxn = (1e6 + 100);
const int inf = 0x3f3f3f3f;
typedef long long LL;
using namespace std;

template <typename T>
inline void read(T &s) {
    s = 0;
    T w = 1, ch = getchar();
    while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); }
    while (isdigit(ch))  { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); }
    s *= w;
}

template<typename T>
inline void write(T s) {
	if (s < 0) putchar('-'), s = -s;
	if (s > 9) write(s / 10);
	putchar(s % 10 + 48);
}

int n;
int a[maxn];
struct tree { int l, r, dat; }t[maxn << 2];

inline int ls(int p) { return p << 1; }
inline int rs(int p) { return ((p << 1) | 1); }

inline void build(int p, int l, int r) {
	t[p].l = l, t[p].r = r;
	if (l == r) { t[p].dat = a[l]; return ; }
	int mid = (l + r) >> 1;
	build(ls(p), l, mid);
	build(rs(p), mid + 1, r);
	t[p].dat = max(t[ls(p)].dat, t[rs(p)].dat);
}

inline void change(int p, int x, int v) {
	if (t[p].l == t[p].r) { t[p].dat = v; return ; }
	int mid = (t[p].l + t[p].r) >> 1;
	if (x <= mid) change(ls(p), x, v);
	else change(rs(p), x, v);
	t[p].dat = max(t[ls(p)].dat, t[rs(p)].dat);
}

inline int ask(int p, int l, int r) {
	if (l <= t[p].l && r >= t[p].r) return t[p].dat;
	int mid = (t[p].l + t[p].r) >> 1;
	int val = -inf;
	if (l <= mid) val = max(val, ask(ls(p), l, r));
	if (r > mid) val = max(val, ask(rs(p), l, r));
	return val;
}

int main() {
	read(n);
	int k;
	cin>>k;
	clean(a, 0);
	build(1, 0, maxn-1);
	for (int i = 1; i <= n; ++i) {
		scanf("%d",&a[i]);
		a[i]+=300001;
	}
	change(1,a[1],1);
	for(int i=2;i<=n;i++){
        int l=a[i]-k;
        int r=a[i]+k;
        int mx=ask(1,l,r);
        change(1,a[i],mx+1);
	}
	int ans=0;
	for(int i=0;i<maxn;i++) ans=max(ans,ask(1,i,i));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 32240
#include <iostream>

using namespace std;

int main()
{
	int n,k;
	string s;

	cin >> n >> s >> k;

	for(int i=0; i<n; ++i){
		if(s[i] != s[k-1]){
			s[i] = '*';
		}
	}

	cout << s << endl;
	
	return 0;
}


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

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	int a, b;

	while ( cin >> a >> b )
	{
		VI deg( 101, 0 );
		deg[a]++;
		deg[b]++;

		while ( true )
		{
			cin >> a >> b;

			if ( !( a | b ) )
			{
				break;
			}

			deg[a]++;
			deg[b]++;
		}

		cout << ( count_if( ALL( deg ), []( int a ) -> bool { return a % 2; } ) == 2 ? "OK" : "NG" ) << endl;
	}

	return 0;
}

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

def string_two_numbers_spliter():
    x, y = [int(i) for i in input().split()]
    return x, y


def swap_two_numbers_asc(x, y):
    x, y = y, x
    return x, y


def main():
    while True:
        x, y = string_two_numbers_spliter()
        if x == 0 and y == 0:
            break
        if x > y:
            x, y = swap_two_numbers_asc(x, y)
        print('%d %d' % (x, y))


if __name__ == '__main__':
    main()

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

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int x,y;
    x=C/B;
    y=A/D;
    if (C%B!=0) x+=1;
    if (A%D!=0) y+=1;
    if (x<=y) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0; 
}

Measured memory_bytes: 3620
#include<stdlib.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	if (C<B&&C > A)
	{
		cout << "Yes" << endl;
	}
	else if (C<A&&C>B)
	{
		cout << "Yes" << endl;
	}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
//const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int h,w;
		cin>>h>>w;
		if(h==0) break;
		vi a(h),b(w);
		for(auto &i:a) cin>>i;
		for(auto &i:b) cin>>i;
		vi dp(1<<h,inf);
		dp[0]=0;
		for(int i=0;i<w;i++){
			vi DP(1<<h,inf);
			vi nx;
			for(int k=1;k<1<<h;k++){
				int mx=0,cnt=0;
				for(int l=0;l<h;l++) if(k&1<<l) mx=max(mx,min(a[l],b[i])),cnt+=min(a[l],b[i]);
				if(mx!=b[i]) continue;
				nx.push_back(k);
			}
			for(int j=0;j<1<<h;j++) if(dp[j]!=inf){
				for(auto k:nx){
					int cnt=0,I=j;
					for(int l=0;l<h;l++) if(k&1<<l) cnt+=min(a[l],b[i]);
					for(int l=0;l<h;l++) if(k&1<<l&&a[l]<=b[i]) I|=1<<l;
					DP[I]=min(DP[I],dp[j]+cnt);
				}
			}
			dp=DP;
		}
		cout<<dp.back()<<endl;
	}
}


Measured memory_bytes: 3132
#include <stdio.h>

int main() {
int original[3][3],im[101];
int i,j,k,number,judge=0;
for(i=0;i<3;i++){
  for(j=0;j<3;j++){
  scanf("%d",&original[i][j]);
  }
}

scanf("%d",&number);

for(i=0;i<number;i++){
scanf("%d",&im[i]);
}

for(k=0;k<number;k++){
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(original[i][j]==im[k]){
        original[i][j]=0;
      }
    }
  }
}

for(i=0;i<3;i++){
if(original[i][1]==0&&original[i][2]==0&&original[i][0]==0){
      judge=1;
    }
}

for(i=0;i<3;i++){
if(original[1][i]==0&&original[2][i]==0&&original[0][i]==0){
      judge=1;
    }
} 


if(original[0][0]==0&&original[1][1]==0&&original[2][2]==0){
      judge=1;
    }

if(original[0][2]==0&&original[1][1]==0&&original[2][0]==0){
      judge=1;
    }

if(judge==1){
printf("Yes\n");
}
else{
  printf("No\n");
}
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	int x;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		a[i]=m-k;
	}
	for(int i=1;i<=k;i++)
	{
		cin>>x;
		a[x]+=1;
	}
	for(int i=1;i<=n;i++)
	{
		
		if(a[i]>0)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
typedef struct node{
	int key;
	int pri;
	struct node *right , *left;
}Node;

Node * Delete(Node **,int);
Node * del(Node **,int);

int find(Node *p,int x)
{
	while(p!=NIL)
	{
		if(p->key==x)return 1;
		else if(p->key > x)p = p->left;
		else p = p->right;
	}
	return 0;
}

void inorder(Node *a)
{
	if(a->left!=NIL) inorder(a->left);
	printf(" %d",a->key);
	if(a->right!=NIL) inorder(a->right);
	return;
}

void preorder(Node *p)
{
	printf(" %d",p->key);
	if(p->left!=NIL) preorder(p->left);
	if(p->right!=NIL) preorder(p->right);
	return;
}

void print(Node *p)
{
	inorder(p);
	printf("\n");
	preorder(p);
	printf("\n");
	return;
}

Node * makenode(int x , int y)
{
	Node *new = malloc(sizeof(Node));
	new->key = x;
	new->pri = y;
	new->left = NIL;
	new->right = NIL;
	return new;
}

Node *rightRotate(Node *p)
{
	Node *q = p->left;
	p->left = q->right;
	q->right = p;
	return q;
}

Node *leftRotate(Node *p)
{
	Node *q = p->right;
	p->right = q->left;
	q->left = p;
	return q;
}

Node* insert(Node **t , int key, int pri)
{
	Node *new;
	if((*t)==NIL)
	return new = makenode(key,pri);
	if((*t)->key == key)
	return *t;
	
	if(key < (*t)->key)
	{
		(*t)->left = insert(&(*t)->left,key,pri);
		if((*t)->pri < (*t)->left->pri)
		(*t) = rightRotate(*t);
	}
	else{
		(*t)->right = insert(&(*t)->right,key,pri);
		if((*t)->pri < (*t)->right->pri)
		(*t) = leftRotate((*t));
	}
	return *t;
}

Node * Delete(Node **t , int key)
{
	if((*t)==NIL)
	return NIL;
	
	if(key < (*t)->key)
	(*t)->left = Delete(&((*t)->left),key);
	
	else if(key > (*t)->key)
	(*t)->right = Delete(&((*t)->right),key);

	else return del(t,key);
	return *t;
}

Node * del(Node **t , int key)
{
	if((*t)->left == NIL && (*t)->right == NIL)
	{
		return NIL;
	}
	else if((*t)->left == NIL)
	{
		(*t) = leftRotate(*t);
	}
	else if((*t)->right ==NIL)
	{
		(*t) = rightRotate(*t);
	}
	else{
		if((*t)->left->pri > (*t)->right->pri)
		(*t) = rightRotate(*t);
		else
		(*t) = leftRotate(*t);
	}
	return Delete(t,key);
}

int main(void)
{
	int num ,  x, y;
	char com[8];
	Node *root = NIL;
	scanf("%d",&num);
	
	for(int i = 0; i < num; i++)
	{
		scanf("%s",com);
		switch(com[0])
		{
			case 'i':scanf("%d %d",&x,&y);
			root = insert(&root,x,y);
			break;
			case 'd':scanf("%d",&x);
			root = Delete(&root,x);
			break;
			case 'f':scanf("%d",&x);
			if(find(root,x))printf("yes\n");
			else printf("no\n");
			break;
			case 'p':print(root);
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 7988
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b;
  cin >> a;
  cin >>b;
  
  if(a-b<0){
    cout << 0 << endl;
  }else{
    cout << a-b << endl;
  }
  
   return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main()
{
    int n,ma,mb;
    cin>>n>>ma>>mb;
    int dp[45][420][420];
    int inf = 1e9;
    
    for(int i = 0; i < 45; i++)
    {
        
        for(int j = 0; j < 420; j++)
        {
            
            for(int k = 0; k < 420; k++)
            {
                dp[i][j][k]=inf;
            }
            
        }
        
    }
    dp[0][0][0]=0;
    
    
    for(int drug = 0; drug < n; drug++)
    {
        int a,b,c;
        cin >>a>>b>>c;
        
        for(int ia = 0; ia < 402; ia++)
        {
            
            for(int ib = 0; ib < 402; ib++)
            {
                dp[drug+1][ia][ib]=min(dp[drug+1][ia][ib], dp[drug][ia][ib]);
                dp[drug+1][ia+a][ib+b]=min(dp[drug+1][ia+a][ib+b], dp[drug][ia][ib] +c);
            }            
        }
    }
    int ans = inf;
    
    for(int i = 1; ; i++)
    {
        if(ma*i >400 || mb*i>400) break;
        ans=min(ans,dp[n][ma*i][mb*i]);
    }
    if(ans==inf)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 31232
//In The Name Of GOD
 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const int mod = 998244353;
const int inf = 2000000000;
const int maxn = 500*1000+500*1000+15;
const int MLOG = 18;

#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())

int main(){
	ll n, m;
	cin >> n >> m;
	if( m/2 > n ){
		cout << n + (m-2*n)/4;
	}else{
		cout << m/2;
	}	
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(0,n-1):
  if p[i] == i + 1:
    ans += 1
    p[i], p[i + 1] = p[i + 1], p[i]
if p[n - 1] == n:
  ans += 1
print(ans)

Measured memory_bytes: 53676
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x,int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int L, R;
	cin >> L >> R;

	if (R - L > 2019) cout << 0 << endl;
	else
	{
		L %= 2019;
		R %= 2019;

		int ans = 3000;
		if (L < R)
		{
			for (int i = L; i < R; i++)
			{
				for (int j = i+1; j <= R; j++)
				{
					ans = min(ans, (i*j) % 2019);
				}
			}
			cout << ans << endl;
		}
		else
		{
			L += 2019;
			for (int i = R; i < L; i++)
			{
				for (int j = i+1; j <= L; j++)
				{
					ans = min(ans, (i*j) % 2019);
				}
			}
			cout << ans << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
using namespace std;
ll dp[22][(1<<22)];
ll ans(vector<vector<int>> &compatible, int m, int women, int n){
    if(m==n){
        if(women==0)
            return 1;
        return 0;
    }
    if(dp[m][women] != -1)
        return dp[m][women];
        
    ll ret = 0;
    for(int i=0; i<n; i++){
        int available = ( (women) & (1<<i) ) == 0 ? 0 : 1;
        available = available && compatible[m][i];
        if(available){
            int newwomen =  (women) ^ (1<<i);
            ret =  (ret%M + ans(compatible, m+1, newwomen, n)%M )%M;
        }
    }
    
    return dp[m][women] = ret;
}
int main() {
	int n;
	cin>>n;
	
	vector<vector<int>> compatible(n, vector<int>(n, 0));
	for(int i=0; i<n; i++)
	    for(int j=0; j<n; j++)
	        cin>>compatible[i][j];
	memset(dp, -1, sizeof(dp));
	int women = ( (1<<n)-1 );
	//cout<<women;
	cout<<ans(compatible, 0, women, n);
	return 0;
}

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

int main () {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int h1_m = h1 * 60;
  int h2_m = h2 * 60;
  int a1 = h1_m + m1;
  int a2 = h2_m + m2;
  int ans;
  int a3 = a2 - a1;
  ans = a3 - k;
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (X[i] == Y[j]) {
        if (i == 0 || j == 0) 
          c[i][j] = 1;
        else 
          c[i][j] = c[i - 1][j - 1] + 1;
      }
      else {
        if (i == 0 && j == 0)
          c[i][j] = 0;
        else if (i == 0)
          c[i][j] = c[i][j - 1];
        else if (j == 0)
          c[i][j] = c[i - 1][j];
        else 
          c[i][j] = max(c[i][j - 1], c[i - 1][j]);
      }
    }
  }
  return c[m - 1][n - 1];
}

int main() {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}



Measured memory_bytes: 7120
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 
    vector<int> x(3);
    cin>>x.at(0)>>x.at(1)>>x.at(2);

    sort(x.begin(),x.end());
    cout<<x.at(0)+x.at(1)<<endl;

    return 0;
}  

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  uint64_t x, y;
  cin >> x >> y;
  if (x % y == 0) {
    cout << -1 << "\n";
    return 0 ;
  }
  for (int i = x; i <= 1e18; i *= x) {
    if (0 < i % y) {
      cout << i << "\n";
      break;
    }
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7

N = int(input())
INF = 10**10
cost = [[INF]*N for _ in range(N)]

for u in range(N):
    C = list(map(int, input().split()))
    for v in range(N):
        if u==v: # INFのままにする
            continue
        cost[u][v] = C[v]
 
ans = 0
for u in range(N):
    for v in range(u+1,N):
        mn = INF # u-w-vのような経路の中で最小の距離を求める
        for w in range(N):
            mn = min(mn, cost[u][w]+cost[w][v])    
        if (cost[u][v] > mn): # 与えられた行列が最短経路ではない
            print (-1)
            exit()
        elif (cost[u][v] < mn): # 等しくない場合はu-vを直接結ぶ橋が必要 
            ans += cost[u][v]                      
print (ans)

Measured memory_bytes: 44252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, a[200005];
int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", a + i);
	}
	for(int i = 0; i < N; i++){
		if(a[i] > i){
			puts("-1");
			return 0;
		}
	}
	ll ans = 0;
	for(int i = 1; i < N; i++){
		if(a[i - 1] < a[i]){
			if(a[i - 1] + 1 != a[i]){
				puts("-1");
				return 0;
			}
			ans++;
		}
		else{
			ans += a[i];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
struct doubleLinkList{
	int val;
	struct doubleLinkList* pre;
	struct doubleLinkList* next;
};

struct doubleLinkList* head;
struct doubleLinkList* last;
void insert(int number){
	struct doubleLinkList* s;
	s = (struct doubleLinkList*)malloc(sizeof(struct doubleLinkList));
	s->val = number;
	s->next = head->next;
	s->pre = head;
	if(head->next!=NULL) (head->next)->pre = s;
	else last = s;
	
	head->next = s;
	
} 

void del(int number){
	struct doubleLinkList* p;
	p = head->next;
	while(p!=NULL){
		if(p->val==number){
			if(p->next==NULL){
				(p->pre)->next = NULL;
				last = p->pre;
			}else{
				(p->pre)->next = p->next;
				(p->next)->pre = p->pre;
			}
			free(p);
			break;
		}
		p = p->next;
	}
}
void deleteFirst(){
	if(head->next!=NULL){
		struct doubleLinkList* p = head->next;
		head->next = p->next;
		if(p->next!=NULL) (p->next)->pre = head;
		else last = head;
		free(p);
	}
}

void deleteLast(){
	if(last!=head){
		struct doubleLinkList* p = last;
		last = p->pre;
		(p->pre)->next = NULL; 
		free(p);
	}
}
int main(){
	// 初始化 
	head = (struct doubleLinkList*)malloc(sizeof(struct doubleLinkList));
	head->pre = NULL;
	head->next = NULL;
	last = head;
	
	int n;
	cin >> n;
	int i;
	for(i = 0; i < n; i++){
		char s[100];
		scanf("%s", s);
		int number;
		if(strcmp(s, "insert") == 0){
			scanf("%d", &number);
			insert(number);
		}else if(strcmp(s, "delete") == 0){
			scanf("%d", &number);
			del(number);
		}else if(strcmp(s, "deleteFirst") == 0){
			deleteFirst();
		}else if(strcmp(s, "deleteLast") == 0){
			deleteLast();
		}
	} 
	struct doubleLinkList* p = head->next;
	while(p!=NULL){
		if(p != head->next) cout << " " ;
		cout << p->val;
		p = p->next;
	}
	cout << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 34316