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


#define ll long long
#define ld long double
#define ull unsigned long long
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long ,long long>
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007


 
//     long long power(long long x, long long y, long long p) 
// { 
//     long long res = 1;      
  
//     x = x % p;  
  
//     while (y > 0) 
//     { 
      
//         if (y & 1) 
//             res = (res*x) % p; 

//         y = y>>1; 
//         x = (x*x) % p; 
//     } 
//     return res; 
// } 
  

// long long modInverse(long long n, long long p) 
// { 
//     return power(n, p-2, p); 
// }  

// long long ncrp(long long n, long long r, long long p) 
// { 
   
//    if (r==0) 
//       return 1; 
  
    
//     long long fac[n+1]; 
//     fac[0] = 1; 
//     // for (long long i=1 ; i<=n; i++) 
//     //     fac[i] = fac[i-1]*i%p; 
  
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }




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


   if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }


   ll n;
   cin>>n;

   ll i;

   vll v;


   while(n--)
   {
       ll x;
       cin>>x;

       v.pb(x);
       ll siz=v.size();

       while(siz>2&&v[siz-3]<=v[siz-2]&&v[siz-2]>=v[siz-1])
       {
           ll no=v[siz-1]+v[siz-3]-v[siz-2];

           for(i=0;i<3;i++)
           {
               v.pop_back();
           }
           v.pb(no);
           siz-=2;
       }
   }

   deque<ll> d;

   for(auto it:v)
   {
    //    cout<<it<<" ";
       d.pb(it);
   }
//    cout<<endl;

   ll sum=0;
   ll z=1;
   while(d.size())
   {
       if(d.front()>=d.back())
       {
           sum+=d.front()*z;
           d.pop_front();
       }
       else{
           sum+=d.back()*z;
           d.pop_back();
       }
       z*=-1;
   }

   cout<<sum<<endl;


    
 

  

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=2005*2;
int n,m,k;
set <int> e[N];
int fa[N],depth[N];
void dfs(int x,int pre,int d){
	depth[x]=d,fa[x]=pre;
	for (auto y : e[x])
		if (y!=pre)
			dfs(y,x,d+1);
}
struct Link{
	int X,Y;
	int x,y;
	int del;
	vector <int> id;
}a[N];
vector <int> id[N];
void Ins(int x,int y,int i){
	if (depth[x]<depth[y])
		swap(x,y);
	while (depth[x]>depth[y])
		id[x].pb(i),x=fa[x];
	while (x!=y){
		id[x].pb(i),x=fa[x];
		id[y].pb(i),y=fa[y];
	}
	id[x].pb(i);
}
int vis[N][N];
int Calvis(int x,int a,int b,int pre=0){
//	printf("Calvis(%d,%d,%d,%d)\n",x,a,b,pre);
	int c=0;
	for (auto y : e[x])
		if (y!=pre){
			int v=Calvis(y,a,b,x);
			c+=v;
			if (v>=2)
				vis[x][y]=vis[y][x]=1;
		}
	if (x==a)
		c++;
	if (x==b)
		c++;
	return c;
}
int main(){
	n=read(),m=k=read();
	For(i,1,n-1){
		int x=read(),y=read();
		e[x].insert(y),e[y].insert(x);
	}
	dfs(1,0,0);
	For(i,1,m){
		int x=a[i].x=a[i].X=read(),y=a[i].y=a[i].Y=read();
		a[i].id.pb(i);
		Ins(x,y,i);
	}
	int ans=0;
	For(_,1,n-1){
		int x=0;
		For(i,1,n)
			if (e[i].size()==1){
				x=i;
				break;
			}
		int y=*e[x].begin();
		vector <int> now;
		for (auto i : id[x])
			if (!a[i].del&&a[i].x!=a[i].y)
				now.pb(i);
		if (vis[x][y])
			ans+=2;
		else {
			if (now.size()>=2){
				int i=now[0],j=now[1];
				if (a[i].y!=x){
					swap(a[i].x,a[i].y);
					for (auto k : a[i].id)
						swap(a[k].X,a[k].Y);
				}
				if (a[j].x!=x){
					swap(a[j].x,a[j].y);
					for (auto k : a[j].id)
						swap(a[k].X,a[k].Y);
				}
				assert(a[i].y==x&&a[j].x==x);
				Calvis(x,a[i].x,a[j].y);
				k++;
				a[k].x=a[i].x;
				a[k].y=a[j].y;
				a[i].del=a[j].del=1;
				for (auto v : a[i].id)
					a[k].id.pb(v);
				for (auto v : a[j].id)
					a[k].id.pb(v);
				Ins(a[k].x,a[k].y,k);
				ans+=2;
//				outval(i),outval(j);
			}
			else
				ans+=now.size();
		}
		for (auto i : now)
			(x==a[i].x?a[i].x:a[i].y)=y;
		e[x].erase(y),e[y].erase(x);
//		For(i,1,n){
//			For(j,1,n)
//				putchar('0'+vis[i][j]);
//			puts("");
//		}
//		cout<<ans<<endl;
//		For(i,1,k)
//			printf("%d %d %d\n",a[i].x,a[i].y,a[i].del);
	}
	cout<<ans<<endl;
	For(i,1,m)
		printf("%d %d\n",a[i].X,a[i].Y);
	return 0;
}

Measured memory_bytes: 37248
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,sum = 0;
  
  cin >> n >> k;
  
  vector<int> a(n);
  for(int i = 0;i < n;i++)
    cin >> a.at(i);
  sort(a.begin(),a.end());
  
  for(int i = 0;i < k;i++)
    sum += a.at(i);
  
  cout << sum << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    ll N,K ; cin >> N >> K;
    vector<ll> vp(N),vc(N);

    REP(i,N) {
        ll P; cin >> P;
        vp[i] = P-1;
    }

    REP(i,N) cin >> vc[i];

    ll ans = -INFLL;

    // find cycle
    REP(start,N) {
        ll score = 0;

        vector<ll> cycle_max;
        cycle_max.push_back(0);

        // 一回以上操作が必要
        score += vc[vp[start]];
        ll seeing = vp[start];
        cycle_max.push_back(score);

        while(start != seeing) {
            score += vc[vp[seeing]];
            seeing = vp[seeing];
            cycle_max.push_back(max(cycle_max[cycle_max.size()-1],score));

            if (cycle_max.size() > 5001) {
                cerr << "error" << endl;
                assert(false);
            }
        }

        ll pos_score;
        ll count = cycle_max.size() - 1;

        if (K >= count) {
            // サイクル利用可能回数を出す
            ll can = K/count;
            ll cyc_score1 = ((can-1) * score) + cycle_max[count];
            ll cyc_score2 = (can * score) + cycle_max[K%count];
            ll cyc_score3 = cycle_max[count];

            // 残りの回数での最大手を出す
            // 繰り返しよりも一時的にクッソ良い点あるかもい

            pos_score = max(max(cyc_score1,cyc_score2),cyc_score3);

        } else pos_score = cycle_max[K];


        chmax(ans,pos_score);
    }

    cout << ans << endl;


}

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

Measured memory_bytes: 3760
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        
        int Max = 0;
        for(int i = 1; i < N; i++){
           int count = 0;
           String str1 = S.substring(0,i);
           String str2 = S.substring(i,N);
           ArrayList <String> list = new ArrayList<>();
           for(int j = 0; j < i; j++){
             if(str2.contains(str1.substring(j,j+1)) && !list.contains(str1.substring(j,j+1))){
                  list.add(str1.substring(j,j+1));
                  count++;
              }
              
             if(Max < count){
                Max = count;
             }
           }
        }
        
        System.out.println(Max);
        
    }
}

Measured memory_bytes: 36880
#include<iostream>
using namespace std;
int main()
{
    int n, a = 0, f = 0;
    cin >> n;
    a = n;
    while(n > 9)
    {
        f = f + n % 10;
        n = n / 10;
    }
    f = f + n;
    if(a % f == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

typedef long long ll;

int gcd(int a, int b) {
  if( b == 0 ) return a;
  return gcd(b,a%b);
}

int main() {
  vector<int>data;
  vector<int>dis;
  int N,X;
  cin >> N >> X;
  data.push_back(X);
  int x;  
  for ( int i = 0; i < N; i++ ) {

    cin >> x;
    data.push_back(x);
  }
  
  if ( N == 1 ) {
    cout << abs(X-x) << endl;
    return 0;
  }
    
  sort(data.begin(),data.end());
  for ( int i = 0; i < data.size()-1; i++ ) {
    dis.push_back(data[i+1]-data[i]);
  }

  //for ( int i = 0; i < dis.size(); i++ ) cout << dis[i] << endl;
  int ans=gcd(dis[0],dis[1]);  
  for ( int i = 2; i < dis.size(); i++ ) {
    ans = gcd(ans,dis[i]);
  }

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


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define fi first
#define se second
#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)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<int,P> PP;

vector<PP> v;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main()
{
	
	int n,m;
	cin >> n >> m;
	priority_queue<P, vector<P>, greater<P> > Q;
	priority_queue<int, vector<int>, greater<int> > tmp;

//	priority_queue<T,v(T),greater<T> >
	rep(i,n){
		int a,b;
		cin >> a >> b;
		Q.push(P(a,b*-1));
	}
	int ans =0;
	int tmp_ans = 0;
	int now = 0;//Q.top().fi;
	while(now <= m){
		//P p = Q.top();
		//Q.pop();
		now++;
		if(now > m) break;
		while(!Q.empty()){
			P pp = Q.top();
			//cout << "roop now" << now << " pp.fi " << pp.fi << endl;
			if(now>= pp.fi){
			//	cout << "tmp add " << endl;
				Q.pop();
				tmp.push(pp.se);
			}
			else break;
		}
		if(!tmp.empty()){
			
			ans += tmp.top() * -1;
			tmp.pop();
		}
		//cout << "ans " << ans << " now " <<now  <<endl;

//		prev = now;
		
		
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, k; cin >> n >> k;

    vector<ll> h(n);

    for (ll i = 0; i < n; ++i) {
        cin >> h[i];
    }

    sort(h.rbegin(), h.rend());

    ll ans = 0;

    for (ll i = 0; i < n; ++i) {
        if (i <= k-1) {
            continue;
        }

        ans += h[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;

#define all(x)  x.begin(), x.end()
#define pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
int A, B, M;
vi a, b, c, x, y;
void sol() {

}

void MN(int& x, const int& y){
    if(x > y) x = y;
}

int main() {
    cin.tie(nullptr)->ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    
    cin >> A >> B >> M;
    a.resize(A), b.resize(B);

    int mina(inf), minb(inf);

    for(int i=0; i<A;i++)
        cin >> a[i], MN(mina, a[i]);
    for(int i=0; i<B;i++)
        cin >> b[i], MN(minb, b[i]);

    int ans(mina + minb);
    for(int i=0; i<M;i++){
        int x, y, c; 
        cin >> x >> y >> c; x--,y--;
        MN(ans, a[x] + b[y] - c);
    }

    cout << ans <<endl;

    return 0;
}

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

using namespace std;

#define ld long double
#define ll long long int
#define endl '\n'
#define check_time() cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 0x3f3f3f3f

int main()
{
	fastio();
	int K,A,B,flag=0;;
	cin>>K>>A>>B;

	for(int i=A;i<=B;i++)
	{
		if(i%K==0)
		{
			flag++;
			break;
		}
	}
	if(flag)
		cout<<"OK"<<endl;
	else
		cout<<"NG"<<endl;
	
	//check_time();
	return 0;   
}   


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[]){
	long long A, B, C, K;

	cin >> A >> B >> C >> K;

	long long ans = 0;

	if(A>=K){
		ans = K;
	}
	else if(A+B>=K){
		ans = A;
	}
	else{
		//ans = A - (K-A-B);
		ans = A-K+A+B;
	}
	printf("%lld\n", ans);
	return 0;

}

Measured memory_bytes: 3764
s=input()
ans=0
for i in range(2**(len(s)-1)):
    bit="{:010b}".format(i)[11-len(s):]
    formula = s[0]
    for j in range(len(bit)):
        if bit[j] =="1":
            formula+="+"
        formula+=s[j+1]
    ans+=eval(formula)
print(ans)

Measured memory_bytes: 3188
p Hash[2,36,238782,454374808,144,32814836,4,554339559,58814,520986437,111744,297236648,90,279097713,1942902,114140798,151236,987179407,752,619036289,700452,549057875,300240,373228583,2359296,86106881,2005794,279939077,2359278,626367168,700452,549057875,30,10199246,18,902102979,700452,549057875,6,121788,4356,935020271,36810,421246711][gets.to_i*gets.split[0].to_i]

Measured memory_bytes: 22152
using System;
using System.Collections.Generic;

namespace ITP1_2_C
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] inputs = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(inputs[0], 10);
            int b = Convert.ToInt32(inputs[1], 10);
            int c = Convert.ToInt32(inputs[2], 10);

            List<int> list = new List<int>(3);

            list.Add(a);
            list.Add(b);
            list.Add(c);

            list.Sort();

            Console.WriteLine(list[0] +" "+list[1] +" "+list[2]);
        }
    }
}

Measured memory_bytes: 9876
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();
		int c = sc1.nextInt();

		if (a < c && c < b) {
			System.out.println("Yes");
		}
		else if(a > c && c > b ) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

		sc1.close();

	}

}

Measured memory_bytes: 24276
import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

def dfs(v,prev = -1):
    for u in graph[v]:
        if u == prev:
            continue
        sign[u] = v
        dfs(u,v)

def bfs(v):
    que = deque([])
    que.append(v)
    while que:
        p = que.popleft()
        if visited[p] == 0:
            visited[p] = 1
            for u in graph[v]:
                que.append(u)

import heapq

def dijkstra(s):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * (N+1) # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for u in graph[v]:
            tmp = 1 + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                path[u] = v
                heapq.heappush(hq, (tmp, u))
    return path

N,M = map(int,input().split())
graph = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
path = [0]*(N+1)
c = dijkstra(1)
print("Yes")
for i in range(2,N+1):
    print(c[i])


Measured memory_bytes: 100120
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){
    int m;
    cin >> m;

    if(m == 0) break;

    vector<pii> ans;

    REP(i,m){
      int id;
      cin >> id;

      int point[23] = {};
      REP(i,23){
        point[i] = -1;
      }

      int game = 0;
      while(game != 9){
        int tmp;
        int pin = 10;

        cin >> tmp;
        pin -= tmp;

        //strikeの時
        if(pin == 0){
          point[game*2] = 10;
          game++;
          continue;
        }

        point[game*2] = tmp;

        cin >> tmp;
        pin -= tmp;

        point[game*2+1] = tmp;

        game++;
      }

      //game = 10
      int tmp;
      int cnt = 0;

      cin >> tmp;
      point[game*2] = tmp;
      cnt += tmp;

      cin >> tmp;
      cnt += tmp;
      point[game*2+1] = tmp;

      if(cnt >= 10){
        cin >> tmp;
        point[game*2+2] = tmp;
      }

      //点数計算
      int sum = 0;
      REP(i,9){
        //stike
        if(point[i*2] == 10){
          if(point[(i+1)*2] == 10){
            if(i == 8){
              sum += 10 + 10 + point[(i+1)*2+1];
            }else{
              sum += 10 + 10 + point[(i+2)*2];
            }
          }else{
            sum += 10 + point[(i+1)*2] + point[(i+1)*2+1];
          }
          //spare
        }else if(point[i*2] + point[i*2+1] == 10){
          sum += point[i*2] + point[i*2+1] + point[(i+1)*2];
        }else{
          sum += point[i*2] + point[i*2+1];
        }

      //cout << sum << endl;
      }

      sum += point[9*2] + point[9*2+1] + max(0, point[9*2+2]);
      //cout << sum << endl;
      ans.pb(MP(-sum, id));
    }
    SORTV(ans);
    REPI(itr, ans){
      cout << itr->second << " " << itr->first * -1 << endl;
    }
  }
  return 0;
}




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


int main() {

    long long  n,a,b;

    cin >> n >> a >> b;
    
    long long num1 = a + b;

    if (n>a+b){
        cout << min(n%num1,a)+(n/num1)*a << endl;
    } else{
        cout << min(n,a) << endl;
    }
    
}

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

using namespace std;

int caseCnt, numbers[10], curNum;
stack<int> Left, Right;

bool used[10], result;

void clear_stack(){
    while( !Left.empty())  Left.pop();
    while(!Right.empty()) Right.pop();
}

bool dfs(int index, int left_or_right){
    if(!left_or_right){
        if(Left.empty() || numbers[index] > Left.top())
            Left.push(numbers[index]);
        else
            return false;
    }else{
        if(Right.empty() || numbers[index] > Right.top())
            Right.push(numbers[index]);
        else
            return false;
    }
    if(index == 9)return true;
    else if(dfs(index+1, 0))return true;
    else if(dfs(index+1, 1)) return true;
    else return false;
}

int main(){
    cin >> caseCnt;

    while(caseCnt--){
        result = false;
        clear_stack();

        for(int i=0; i<10; ++i) cin >> numbers[i];

        result = dfs(0, 0);
        if(result){
            cout << "YES\n";
            continue;
        }

        result = dfs(0, 1);
        if(result) cout << "YES\n";
        else       cout << "NO\n";
    }
    return 0;
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long LL;

LL factorialNumber(int N){
  LL ans=N;
  while(--N) ans*=N;
  return ans;
}

int main() {
  int n; cin>>n;
  int x[n],y[n]; for(int i=0;i<n;i++) cin>>x[i]>>y[i];
  double routeSum=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      routeSum+=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
    }
  }
  double ans=factorialNumber(n-1)*2*routeSum/factorialNumber(n);
  printf("%.7lf",ans);
}



Measured memory_bytes: 3816
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string.h>
#include <queue>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int dp[305][305][305];
char arr[305][305];

int main(){
    int n; cin >> n;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            scanf(" %c",&arr[i][j]);
        }
    }
    for(int i = 0 ;i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            dp[i][j][0] = 1;
            for(int k = 1; k < n ; k++){
                if(arr[(i+n-k)%n][j]==arr[i][(j+n-k)%n]){
                    dp[i][j][k] = 1;
                }
                else break;
            }
        }
    }
    int cnt = 0;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j ++){
            int ck = 1;
            for(int k = 0 ; k < n ; k++){
                if(dp[(i+k)%n][(j+k)%n][k]==0){
                    ck = 0;
                    break;
                }
            }
            cnt+=ck;
        }
    }
    cout <<cnt;
}

Measured memory_bytes: 110848
s = input()
a = int(s[:2])
b =  int(s[-2:])

def is_mm(a):
    if 0 < a < 13:
        return True
    return False

if is_mm(a) and is_mm(b):
    print("AMBIGUOUS")
elif is_mm(a):
    print("MMYY")
elif is_mm(b):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	ll time = h2*60-h1*60+m2-m1;
	cout << time-k << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class WarshallFloyd{
public:
	vector<vector<ll>> dist;

	void CalcShortestPath(ConnectNodeInfo& connect){
		int V = connect.size();
		dist.resize(V,vector<ll>(V,1LL<<60));

		REP(i,V){
			dist[i][i]=0;
			int U = connect[i].size();
			REP(j,U){
				dist[i][connect[i][j].first] = connect[i][j].second;
			}
		}

		REP(k,V){
			REP(i,V){
				REP(j,V){
					if(dist[i][k]!=(1LL<<60) && dist[k][j]!=(1LL<<60)){
						dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
					}
				}
			}
		}
	}
	
	bool HasNegativeLoop(){
		bool flag = false;
		for(int i=0,ei=dist.size();i<ei;i++){
			if(dist[i][i]<0){
				flag = true;
				break;
			}
		}
		return flag;
	}
};

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

	auto N=in(),Q=in();
	ConnectNodeInfo connect(N);
	REP(i,Q){
		auto u=in(),v=in(),w=in();
		connect.AddDirectionalConnection(u,v,w);
	}
	WarshallFloyd WF;
	WF.CalcShortestPath(connect);
	if(WF.HasNegativeLoop()){
		out("NEGATIVE CYCLE");
		return 0;
	}
	REP(i,N){
		REP(j,N){
			if(WF.dist[i][j]>=(1LL<<60)){
				cout << "INF";
			}
			else{
				cout << WF.dist[i][j];
			}
			if(j==N-1) cout <<endl;
			else cout << ' ';
		}
	}

	return 0;
}



Measured memory_bytes: 3364
N = int(input())
S = [list(input()) for _ in range(N)]

def check(a) :
    for i in range(N) :
        for j in range(i, N) :
            if S[(a+i)%N][j] != S[(a+j)%N][i] :
                return False
                
    return True

ret = 0
for a in range(N) :
    if check(a) :
        ret += N
            
print(ret)

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

using namespace std;

const int N = 1e2+7;

int a, b;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> a >> b;
    cout << 1ll*a*b/__gcd(a, b) << endl;
    return 0;
}



Measured memory_bytes: 256
N,T=map(int,input().split())
ct=[list(map(int,input().split())) for i in range(N)]
m=1001
for i in range(N):
    if ct[i][1]<=T:
        if ct[i][0]<m:
            m=ct[i][0]
if m==1001:
    print('TLE')
else:
    print(m)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

	int n;
	cin>>n;
	int a=0;
	double sum=0;
	for(int i=0;i<n;i++){
        cin>>a;
        sum+=(double)a/n;
	}
	cout<<(int)sum<<endl;


	return 0;
}

Measured memory_bytes: 1160
N = int(input())
monster_list = list(map(int, input().split()))
Hero = list(map(int, input().split()))
ans = 0
for i, monster in enumerate(monster_list):
    if i == 0:
        h = Hero[i]
        if h >= monster:
            ans += monster
            Hero[i] -= monster
        else:
            ans += h
            Hero[i] = 0
    elif i == N:
        h = Hero[i-1]
        if h >= monster:
            ans += monster
        else:
            ans += h
    else:
        h1 = Hero[i-1]
        h2 = Hero[i]

        if h1 >= monster:
            ans += monster
        else:
            ans += h1
            monster -= h1
            if h2 >= monster:
                ans += monster
                Hero[i] -= monster
            else:
                ans += h2
                Hero[i] = 0

print(ans)



Measured memory_bytes: 82020
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long Int;


Int n, k, q;
Int a[2160];
Int res = 1LL << 40;

Int go(Int x){
	int cnt = 0;
	vector<int> nums;
	vector<int> tmp;
	for(int i = 0;i < n;i++){
		if(a[i] < x)continue;
		int from = i;
		while(i < n && a[i] >= x)i++;
		if(i - from > k-1){
			cnt += i-from-k+1;
			tmp.clear();
			for(int j = from;j < i;j++)tmp.push_back(a[j]);
			sort(tmp.begin(), tmp.end());
			for(int j = 0;j < i - from - k + 1;j++){
				nums.push_back(tmp[j]);
			}
		}
		i--;
	}
	if(cnt < q)return 1LL<<40;
	sort(nums.begin(), nums.end());
	return nums[q-1] - x;
}

int main(){
	cin >> n >> k >> q;
	for(int i = 0;i < n;i++)cin >> a[i];
	for(int i = 0;i < n;i++){
		res = min(res, go(a[i]));
	}

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

int main() {
    ll n;cin >> n;
    ll i = sqrt(n);
    while (i>0) {
        if (n%i==0) 
            break;
        --i;
    }
    //cout << i << " " << n/i <<endl;
    string z=to_string(n/i);
    cout << z.length() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		int[] lefts = new int[n];
		int[] rights = new int[n];
		for (int i = 1; i < n; i++) {
			int add = 0;
			if (arr[i - 1] == 'W') {
				add++;
			}
			lefts[i] = lefts[i - 1] + add;
		}
		for (int i = n - 2; i >= 0; i--) {
			int add = 0;
			if (arr[i + 1] == 'E') {
				add++;
			}
			rights[i] = rights[i + 1] + add;
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, lefts[i] + rights[i]);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 31700
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
int one;
int ten;
int hun;
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N ;
  hun = N/100 ;
  ten = (N - hun*100)/10;
  one = N-ten*10-hun*100; 
  if(hun >= one && hun >= ten) {
    hun = hun + hun*10 + hun*100;
    cout << hun << endl;
    return 0 ;
  }else{
    hun++;
    hun = hun + hun*10 + hun*100;
    cout << hun << endl;
    return 0 ;
  }


  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int N;
	int a[100001];
	cin >> N;
	int count4 = 0;
	int count0 = 0;
	int count2 = 0;
	bool ans = true;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		if (a[i] % 4 == 0)
			count4++;
		else if (a[i] % 4 != 0 && a[i] % 2 == 0)
			count2++;
		else
			count0++;
	}
	if (count2 == 0) {
		if (count0 > count4+1)
			ans = false;
	}
	else {
		count0++;
		if (count0 > count4+1)
			ans = false;
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
// inputに入力データ全体が入る
// @ts-ignore
const main = (input: string) => {
  const boxes = input.split(' ');

  // 1 - 2 exchange
  let tmp = [boxes[1], boxes[0], boxes[2]];

  // 1 - 3 exchange
  const tmp2 = [tmp[2], tmp[1], tmp[0]];

  console.log(tmp2.join(' '));
}

// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

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

    priority_queue<int, vector<int>, greater<int>> rq, gq;
    priority_queue<int> nq;

    int p[A];
    for(int i=0; i<A; i++){
        cin >> p[i];
    }
    int q[B];
    for(int i=0; i<B; i++){
        cin >> q[i];
    }
    for(int i=0; i<C; i++){
        int r;
        cin >> r;
        nq.push(r);
    }

    sort(p, p+A, greater<>());
    sort(q, q+B, greater<>());
    long ans = 0;
    for(int i=0; i<X; i++){
        rq.push(p[i]);
        ans = ans + p[i];
    }
    for(int i=0; i<Y; i++){
        gq.push(q[i]);
        ans = ans + q[i];
    }

    while(true){
        if(nq.empty()) break;
        int tr, tg;

        if(!rq.empty()) tr = rq.top();
        else tr = 1000000001;
        if(!gq.empty()) tg = gq.top();
        else tg = 1000000001;

        int tn = nq.top();
        nq.pop();

        if(tn < tr && tn < tg) break;
        if(tr < tg){
            ans = ans + (long)tn - tr;
            rq.pop();
        }else{
            ans = ans + (long)tn - tg;
            gq.pop();
        }
    }

    printf("%ld\n", ans);

    return 0;
}

Measured memory_bytes: 2552
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static string[] inputa = Console.ReadLine().Split(' ');
static long n = long.Parse(inputa[0]);
static long k = long.Parse(inputa[1]);
static long p = 1000000007;
static long[] factorials = new long[n+1];//i!(mod p)を先にメモ
static long[] factorialRs = new long[n+1];//i!^-1(mod p), pは素数

	static void Main()
	{
  factorials[0] = 1;
  factorialRs[n] = DivideModFactorial(n,p);
  for(long i = 1; i <= n; i++)
  {
  factorials[i] = (factorials[i-1]*i)%p;//i!(mod p)
  factorialRs[n-i] = (factorialRs[n+1-i]*(n+1-i))%p;//逆元も先にメモ
  }

    for(int i = 1; i <= k; i++)
    {
      Console.WriteLine((Comb(n-k+1,i,p)*Comb(k-1,i-1,p))%p);//nCk(mod p),pは素数
    }
	}

  static long MathPow(long x, long a)//戻り値はx^a
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x;
  
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
      }
    memo *= memo;
    num *= 2;
    }
    return answer;
  }

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

  static long Comb(long a, long b, long p)//戻り値は組み合わせC(a,b)のmod p
  {
    if(a-b < 0) return 0;
    long answer = 1;
    answer *= factorials[a];
    answer %= p;
    answer *= factorialRs[a-b];//引数a-bは負にならないようにする
    answer %= p;
    answer *= factorialRs[b];
    answer %= p;
    return answer;
  }
  
}


Measured memory_bytes: 11220
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll mod = 1000000007LL;

signed main() {
	ll a, b, k; cin >> a >> b >> k;
	ll takahashi = a - min(k, a);
	ll aoki = max(0LL, b - k + min(k, a));
	cout << takahashi << " " << aoki << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static			BufferedReader	br  = null;
	private	static	final	String[]		ERA = { "pre-meiji", "meiji", "taisho", "showa", "heisei" };

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
	// TODO Auto-generated method stub
		int[]	date = null;

		while ((date = parseDate()) != null) {
			int	nDate = date[1] * 10000 + date[2] * 100 + date[3];

			if (isMeiji(nDate)) {
				date[0] = 1;
				date[1] = date[1] - 1868 + 1;
			}
			else if (isTaisho(nDate)) {
				date[0] = 2;
				date[1] = date[1] - 1912 + 1;
			}
			else if (isShowa(nDate)) {
				date[0] = 3;
				date[1] = date[1] - 1926 + 1;
			}
			else if (isHeisei(nDate)) {
				date[0] = 4;
				date[1] = date[1] - 1989 + 1;
			}

			switch (date[0]) {
			case 0:
				System.out.printf("%s\n", ERA[date[0]]);
				break;
			default:
				System.out.printf("%s %d %d %d\n", ERA[date[0]], date[1], date[2], date[3]);
				break;
			}
		}
	}

	private static boolean isMeiji(int nDate) {
		return (18680908 <= nDate && nDate <= 19120729);
	}
 
	private static boolean isTaisho(int nDate) {
		return (19120730 <= nDate && nDate <= 19261224);
	}
 
	private static boolean isShowa(int nDate) {
		return (19261225 <= nDate && nDate <= 19890107);
	}
 
	private static boolean isHeisei(int nDate) {
		return (19890108 <= nDate);
	}
 
	private static  int[] parseDate() {
		int[]		date = null;
		String[]	split = null;
		String		strIn = null;
 
		if ((strIn = parseStdin()) != null) {
			split = strIn.split(" ");
			date = new int[split.length + 1];
			for (int n = 0; n < split.length; n++) {
				date[n + 1] = Integer.parseInt(split[n]);
			}
		}
		 
		return date;
	}
 
	private static String parseStdin() {
		String	strNum = null;
 
		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}
 
		return strNum;
	}
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, X;
    cin >> N >>X;
    ll countSum[N + 1];
    ll countPatty[N + 1];
    // B L(n-1) P L(n-1) B で区切ってバーガーの層数とパティをカウント
    map<int, vector<pair<ll, ll>>> countBurger;
    countSum[0] = 1;
    countPatty[0] = 1;
    countBurger[0].push_back(make_pair(1, 1));
    for (int i = 1; i <= N; ++i)
    {
        countSum[i] = 2 * countSum[i - 1] + 3;
        countPatty[i] = 2 * countPatty[i - 1] + 1;
        countBurger[i].push_back(make_pair(1, 0));
        countBurger[i].push_back(make_pair(countSum[i -1], countPatty[i - 1]));
        countBurger[i].push_back(make_pair(1, 1));
        countBurger[i].push_back(make_pair(countSum[i -1], countPatty[i - 1]));
        countBurger[i].push_back(make_pair(1, 0));
    }

    ll currentIndex = 0;
    ll ans = 0;
    bool isEnd = false;
    for (int i = N; i >= 0; --i)
    {
        for (auto iter = countBurger[i].begin(); iter != countBurger[i].end(); ++iter)
        {
            if (currentIndex  + (*iter).first < X)
            {
                currentIndex += (*iter).first;
                ans += (*iter).second;
            }
            else if (currentIndex  + (*iter).first > X)
            {
                break;
            }
            else
            {
                isEnd = true;
                currentIndex += (*iter).first;
                ans += (*iter).second;
                break;
            }
        }
        if (isEnd) break;
    }

    cout << ans << endl;
}


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

bool li[55][55];
int n, m;

int main(){
	int n, m; cin >> n >> m; std::vector<int> a(m), b(m);
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i]; a[i]--; b[i]--;
		
		li[a[i]][b[i]] = li[b[i]][a[i]] = true;
	}
	
	int c = 0;
	for(int i = 0; i < m; i++){
		std::set<int> st; li[a[i]][b[i]] = li[b[i]][a[i]] = false;
		std::queue<int> qu; qu.push(a[i]); st.insert(a[i]);
		
		while(!qu.empty()){
			auto p = qu.front(); qu.pop();
			
			for(int i = 0; i < n; i++){
				if(!li[p][i]) continue;
				if(st.count(i)) continue;
				
				st.insert(i); qu.push(i);
			}
		}
		
		if(st.size() < n) c++;
		li[a[i]][b[i]] = li[b[i]][a[i]] = true;
	}	
	
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){String r="";for(Scanner s=new Scanner(System.in);s.hasNext();System.out.print(r+(s.hasNext()?"\n":"")),r="")for(int n=s.nextInt(),k=0,i,x;k++<8;r+="\n")for(i=10000;i>0;r+=k<3?x/5<1?k<2?"*":" ":k<2?" ":"*":k>3?x%5==k-4?" ":"*":"=",i/=10)x=n/i%10;}}

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

map<int, int> rec;
int n, x, a;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		rec[x]++;
	}
	for (const pair<int, int>& i : rec) {
		if (i.second < i.first) {
			a += i.second;
		} else {
			a += i.second - i.first;
		}
	}
	printf("%d", a);
}

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

using namespace std;

int main()
{
    long long x;
    cin>>x;
    x=x*x*x;
    x*=1000000000ll;
    x/=27;
    cout<<x/1000000000ll<<".";
    long long p10=1000000000ll,aux=x%1000000000ll;
    while(p10>aux*10){
        cout<<0;
        p10/=10;
    }
    cout<<aux;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long 
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;
 
bool isPrime(int n){
    if(n < 2)return 0;
    if(n < 4)return 1;
    if(n % 2 == 0 or n % 3 == 0)return 0;
    for(int i = 5; i*i <= n; i += 6)if(n % i == 0 or n % (i+2) == 0)return 0;
    return 1;
}
 
int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
 
int max(int a,int b){return (a>b?a:b);}
 
int min(int a,int b){return (a<b?a:b);}
 
struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};
 
struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int N =200005;
int seg[4*N];
int n;

void update(int i,int l,int r,int pos,int val){
    if(l > r){
        return;
    }
    if(l == r){
        seg[i] = val;
        return;
    }
    int mid = (l+r) >> 1;
    if(pos > mid){
        update(2*i+1,mid+1,r,pos,val);
    }
    else{
        update(2*i,l,mid,pos,val);
    }
    seg[i] = max(seg[2*i],seg[2*i+1]);
}

int query(int i,int l,int r,int u,int v){
    if(l > r || u > v || r < u || l > v){
        return 0;
    }
    if(u <= l && r <= v){
        return seg[i];
    }
    int mid = (l+r) >> 1;
    return max(query(2*i,l,mid,u,v),query(2*i+1,mid+1,r,u,v));
}

int32_t main(){
    IOS
    cin >> n;
    int arr[n];
    int brr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    for(int i=0;i<n;i++){
        cin >> brr[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        int cur = query(1,1,n,1,arr[i]-1);
        cur += brr[i];
        update(1,1,n,arr[i],cur);
        ans = max(ans,cur);
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 10884
/**
 *      purpose : ABC 75 D
 *      author  : kyomukyomupurin
 *      created : 2019-01-27 19:29:15
**/

// in, out
#include <iostream>
// container class
/*
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
*/
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>

// etc
/*
#include <bitset>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
*/
// using-directive
using namespace std;
// alias templates
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
/*
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k; cin >> n >> k;
    int64 x[n], y[n], tx[n], ty[n]; 
    rep(i, n) {
      cin >> x[i] >> y[i];
      tx[i] = x[i]; ty[i] = y[i];
    }

    sort(x, x + n); sort(y, y + n);

    int64 ans = (x[n - 1] - x[0]) * (y[n - 1] - y[0]);  // largest rectangle

    for (int64 xleft = 0; xleft < n; ++xleft){
        for (int64 xright = xleft + 1; xright < n; ++xright){
            for (int64 ybottom = 0; ybottom < n; ++ybottom){
                for (int64 yupper = ybottom + 1; yupper < n; ++yupper){
                    int cnt = 0;
                    int64 left = x[xleft], right = x[xright], upper = y[yupper], bottom = y[ybottom];
                    for (int i = 0; i < n; ++i){
                        if (tx[i] >= left && tx[i] <= right && ty[i] >= bottom && ty[i] <= upper) ++cnt;
                    }

                    if (cnt >= k) ans = min(ans, (right - left) * (upper - bottom));
                }
            }
        }
    }

    print(ans);
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<float.h>

int main(void){
  int l[10];
  double v[2];
  int k,n;
  int total[10];
  double dist;
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1])!=EOF){
    total[0] = l[0];
    for(k=2;k<=10;k++){
      total[k-1] = total[k-2] + l[k-1];
    }
    dist = total[9] * v[0] / (v[0] + v[1]);  // ??????1??´????????°????????????????????????????????¨

 //   printf("%d %lf\n",total[9],dist);

    for(k=1 ; fabs(total[k] - dist) < DBL_EPSILON || total[k-1] < dist ; k++){
    }
    printf("%d\n",k);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define ZERO(a) memset(a,0,sizeof(a))
using namespace std;
typedef signed long long ll;

void solve(){
 int cnt=0;
 string w,s;
 cin>>w;
 FOR(i,w.size())
  w[i]=tolower(w[i]);
 while(1){
  cin>>s;
  if(s=="END_OF_TEXT") break;
  FOR(i,s.size())
   s[i]=tolower(s[i]);
  if(s==w) cnt++;
 }
 cout<<cnt<<endl;
}

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

Measured memory_bytes: 1192
#include<iostream>
using namespace std;
int main(){
	long long h,w;
	cin>>h>>w;
	if(w==1||h==1) cout<<"1";
	else if(w%2==0||h%2==0) cout<<w*h/2;
	else cout<<((h*w)/2)+1;
	return 0;}	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
 
using namespace std;
 
void call(int n){
 
    for (int i = 1; i <= n; i++){
        if (i % 3 == 0){
            cout << " " << i;
        }
        else {
            for (int s = i; s >= 3; s /= 10){
                if (s % 10 == 3){
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
}
 
int main(void){
 
    int n;
    cin >> n;
    call(n);
 
    return 0;
}

Measured memory_bytes: 3092