akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

string fie[200];
int h,w;

void dfs(int y,int x,char ch){
    fie[y][x]='-';
    int dy[]={1,0,-1,0};
    int dx[]={0,1,0,-1};
    
    rep(i,4){
        if( 0<=y+dy[i] && y+dy[i]<h  &&  0<=x+dx[i]  && x+dx[i]<w  &&  fie[y+dy[i]][x+dx[i]]==ch ){
            dfs(y+dy[i],x+dx[i],ch);
        }
    }
}



int main(){
    while(cin>>h>>w){
        if(h==0&&w==0)break;
        
        rep(i,h) cin>>fie[i];
        
        int c=0;
        rep(i,h){
            rep(j,w){
                if( fie[i][j]!='-' ){
                    dfs(i,j,fie[i][j]);
                    c++;
                }
            }
        }
        cout<<c<<endl;
    }
}

Measured memory_bytes: 2312
counts={}
while a = STDIN.gets
  a = a.chomp.to_i
  if counts.has_key?(a) then
    counts[a]+=1
  else
    counts[a]=1
  end
end

largest_frequency = counts.values.max_by { |item| item }

modes=[]

counts.keys.each do |k|
  if counts[k] == largest_frequency then
    modes.push(k)
  end
end

modes.sort.each do |a|
  puts a
end

Measured memory_bytes: 8640
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
L = set([int(input()) - 1 for _ in range(M)])
ans = [0] * N

if 0 not in L:
    ans[0] = 1
    
if N > 1 and 1 not in L:
    ans[1] = ans[0] + 1

for i in range(2, N):
    if i in L:
        continue
    
    if ans[i - 2] != 0 or ans[i - 1] != 0:
        ans[i] = ans[i - 2] + ans[i - 1]
        
print(ans[-1] % (1000000007))

Measured memory_bytes: 460020
num = raw_input()
num_list = []
for i in range(int(num)):
    a = raw_input()
    num_list.append(int(a))

min_ans = num_list[0]
max_ans = float("-inf")
for i in num_list[1:]:
    if i - min_ans > max_ans:
        max_ans = i - min_ans
    if i < min_ans:
        min_ans = i

print max_ans

Measured memory_bytes: 18980
#include<iostream>
#include<map>
#include<vector>

int main(void){
    std::vector<int> ns(1500), ms(1500);
    std::map<int, int> nc, mc;
    while(1){
        int nl, ml, r = 0;
        std::cin >> nl >> ml;
        if(!(nl || ml)) break;
        for(int i = 0; i != nl; i++) std::cin >> ns[i];
        for(int i = 0; i != ml; i++) std::cin >> ms[i];
        nc.clear(); mc.clear();
        for(int i = 0; i != nl; i++) for(int acc = 0, j = i; j != nl; j++) acc+=ns[j], nc[acc]++;
        for(int i = 0; i != ml; i++) for(int acc = 0, j = i; j != ml; j++) acc+=ms[j], mc[acc]++;
        for(std::map<int, int>::iterator it = nc.begin(); it != nc.end(); it++)
            r += (*it).second * mc[(*it).first];
        std::cout << r << std::endl;
    }
    return 0;
}

Measured memory_bytes: 32464
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
int a[128];

int cnt[128];

void as( bool f ){
  if( not f ){
    puts( "Impossible" );
    exit( 0 );
  }
}

int main(){

  n = in();
  REP( i , n ){
    a[i] = in();
    cnt[ a[i] ]++;
  }
  sort( a, a+n );

  int ma = a[n-1];
  int mi = a[0];

  as( ma == a[n-2] );
  as( mi == ( ma + 1 ) / 2 );
  
  if( ma % 2 == 0 ){
    as( cnt[mi] == 1 );
  } else {
    as( cnt[mi] == 2 );
  }
  
  FOR( i , mi , ma ){
    as( cnt[i] >= 1 );
  }

  puts( "Possible" );
  
  return 0;
}


Measured memory_bytes: 256
from collections import deque

H,W=map(int,input().split())
if H==1 and W==1:
    print(0)
    exit()

A=[]
B=deque([])
C=[[-1]*W for i in range(H)]
ans=[]
for h in range(H):
    temp=list(input())
    A.append(temp)
    for w in range(W):
        if A[h][w]=="#":
            B.append([h,w,0])
            C[h][w]=0
            ans.append(0)



step=[[1,0],[-1,0],[0,1],[0,-1]]

while B:
    P=B.popleft()
    for x,y in step:
        if 0<=P[0]+y<=H-1 and 0<=P[1]+x<=W-1:
            if C[P[0]+y][P[1]+x]==-1:
                B.append([P[0]+y,P[1]+x,P[2]+1])
                C[P[0]+y][P[1]+x]=1
                ans.append(P[2]+1)


print(max(ans))




Measured memory_bytes: 194160
#include <iostream>
#include <string>
using namespace std;
int main() {
	int H, W;
	string S[51];
	cin >> H >> W;
	for (int i = 0; i < H; ++i) cin >> S[i];

	const int dx[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
	const int dy[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (S[h][w] == '#') continue;
			int bombs = 0;
			for (int d = 0; d < 8; ++d) {
				const int nh = h + dy[d];
				const int nw = w + dx[d];
				if (nh < 0 || H <= nh) continue;
				if (nw < 0 || W <= nw) continue;
				if (S[nh][nw] == '#') ++bombs;
			}
			S[h][w] = char(bombs + '0');
		}
	}

	for (int i = 0; i < H; ++i) cout << S[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)
#define N 200010
using namespace std;
ll T,n,l[N],k[N],r[N],ans;
vector<pair<pair<ll,ll>,ll> > vv,bk;
int main(){
	fast;itt;now;
	ll i;
	cin>>T;
	while(T--)
	{
		cin>>n;
		ans=0;
		vv.clear();
		bk.clear();
		for(i=0;i<n;i++)
		{
			cin>>k[i]>>l[i]>>r[i];
			if(l[i]>=r[i])
			{
				vv.push_back(make_pair(make_pair(k[i],l[i]-r[i]),i));
			}
			else
			{
				bk.push_back(make_pair(make_pair(k[i],r[i]-l[i]),i));
			}
		}
		sort(vv.begin(),vv.end());
		sort(bk.begin(),bk.end());
		reverse(bk.begin(),bk.end());
		priority_queue<ll> pq;
		for(i=0;i<vv.size();i++)
		{
			ans+=l[vv[i].S];
			pq.push(-vv[i].F.S);
			if(pq.size()>vv[i].F.F)
			{
				ans+=pq.top();
				pq.pop();
			}
		}
		while(!pq.empty()) pq.pop();
		for(i=0;i<bk.size();i++)
		{
			ans+=r[bk[i].S];
			pq.push(-bk[i].F.S);
			if(n-pq.size()+1<=bk[i].F.F)
			{
				ans+=pq.top();
				pq.pop();
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 14464
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MAXN 100000
using namespace std;
typedef long long LL;
struct node
{
	int to;
	node *nxt;
}edges[MAXN*2+5];
node *ncnt,*Adj[MAXN+5];
int N,M,spx,spy;
LL sum[MAXN+5];
LL cirlen,dist[MAXN+5],xs[MAXN+5];
LL stk[MAXN+5],t;
bool vis[MAXN+5];
void Init()
{
	ncnt=&edges[0];
}
void AddEdge(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->nxt=Adj[u];
	Adj[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->nxt=Adj[v];
	Adj[v]=q;
}
void DFS(int u,int fa)
{
	vis[u]=true;
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		if(v==fa)
			continue;
		if(vis[v]==true)
		{
			spx=u,spy=v;
			cirlen=dist[v]-dist[u]+1;
			continue;
		}
		dist[v]=dist[u]+1;
		DFS(v,u);
	}
}
void GetXs(int u,int fa)
{
	vis[u]=true;
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		if(v==fa||vis[v]==true)
			continue;
		GetXs(v,u);
		xs[u]+=xs[v];
		sum[u]+=sum[v];
	}
}
int main()
{
//	freopen("print.in","r",stdin);
//	freopen("print.out","w",stdout);
	Init();
	scanf("%d %d",&N,&M);
	int u,v;
	for(int i=1;i<=M;i++)
	{
		scanf("%d %d",&u,&v);
		AddEdge(u,v);
	}
	dist[1]=0;
	DFS(1,-1);
	LL ans=0,tot=0;
	for(int i=1;i<=N;i++)
	{
		if(dist[i]%2==0)
			sum[i]=1LL;
		else
			sum[i]=-1LL;
		tot+=sum[i];
	}
	if(N-1==M)
	{
		if(tot!=0)
		{
			printf("-1\n");
			return 0;
		}
	}
	else
	{
		if(cirlen%2==1)
		{
			if(tot%2==1)
			{
				printf("-1\n");
				return 0;
			}
			sum[spx]-=tot/2;
			sum[spy]-=tot/2;
			ans+=abs(tot)/2;
		}
		else
		{
			if(tot!=0)
			{
				printf("-1\n");
				return 0;
			}
			xs[spx]=1LL;
			xs[spy]=-1LL;
		}
	}
	memset(vis,0,sizeof(vis));
	GetXs(1,-1);
	for(int i=1;i<=N;i++)
	{
		if(xs[i]==0)	ans+=abs(sum[i]);
		else
		{
			if(xs[i]==1)
				sum[i]=-sum[i];
			stk[++t]=sum[i];
		}
	}
	stk[++t]=0;
	sort(stk+1,stk+1+t);
	LL k=stk[(t+1)/2];
	for(int i=1;i<=t;i++)
		ans+=1LL*abs(stk[i]-k);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12032
#define min(a,b)((a)<(b)?(a):(b))
z,x,r;main(c,a,n){for(gets(&c);z=~scanf("%d%d%d",&c,&a,&n);printf("%d\n",r)){
	r=0;
	x=min(c,min(a,n));
	c-=x,a-=x,n-=x,r+=x;
	x=min(c/2,a);
	c-=x*2,a-=x,r+=x;
	r+=c/3;
}}

Measured memory_bytes: 604
#include<stdio.h>

int n,A[50];

//入力値のMから選んだ要素を引いていく再帰関数
int solve (int i,int m){
	if( m==0 ) return 1;
	if( i>=n ) return 0;
	int res = solve(i + 1, m) || solve(i+1,m-A[i]);
	return res;
}

int main(){
	int q,M,i;
	
	scanf("%d",&n);
	for(i=0; i<n; i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0; i<q; i++){
		scanf("%d",&M);
		if(solve(0,M))printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}


Measured memory_bytes: 2092
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			while(true){
				/* input */
				String line = br.readLine();
				if(line.equals("END")) break;
				
				
				int n = Integer.parseInt(br.readLine());
				
				int[] l = new int[n+1];

				for(int i=1;i<=n;i++){
					String line2 = br.readLine().replaceAll(" ","");
					l[i] = Integer.parseInt(line2,2);
				}
				

				Node t = makeTree(line,0,l);
				//t.output();
				
				int ans = 0;
				t = check(t,l);
				for(int c : t.cand){
					if(c==15) ans++;
				}
				
				System.out.println(ans);
			}
			br.close();
		} catch (Exception e) {
			e.printStackTrace();
		} 
	}
	
	static class Node{
		int v;
		int level;
		Node left,right;
		ArrayList<Integer> cand;
		
		public Node(int d){
			this.v = 0;
			this.level = d;
			this.left = null;
			this.right = null;
			this.cand = new ArrayList<Integer>();
		}
		
		public void output(){
			if(this.v!=0){
				System.out.print(this.v);
			} else {
				System.out.print("(");
				this.left.output();
				System.out.print(" ");
				this.right.output();
				System.out.print(")");
			}
		}
	}

	public static Node makeTree(String s, int d, int[] l){
		Node t = new Node(d);
		if(s.length()==1){
			t.v = Integer.parseInt(s);
			t.cand.add(l[t.v]);
			//System.err.println(t.cand.size());
		} else {
			int level = 0;
			int index = 0;
			
			while(true){
				if(s.charAt(index)=='('){
					level++;
				} else if(s.charAt(index)==')'){
					level--;
				} else if(s.charAt(index)==' '&&level==1){
					break;
				}
				index++;
			}
			t.left = makeTree(s.substring(1,index),d+1,l);
			t.right = makeTree(s.substring(index+1, s.length()-1),d+1,l);
		}
		return t;
	}
	
	public static Node check(Node r, int[] l){
		if(r.left==null&&r.right==null){
			return r;
		}
		
		//if node r does not have grand-children
		if(r.left.left==null&&r.right.left==null){
			r.cand.add(r.left.cand.get(0)&r.right.cand.get(0));
			r.cand.add(r.left.cand.get(0)|r.right.cand.get(0));
			r.cand.add(r.left.cand.get(0)^r.right.cand.get(0));
		} else {//if r has grand-children
			r.left = check(r.left,l);
			r.right = check(r.right,l);
			//System.err.println(r.left.cand.size() + ", " + r.right.cand.size());
			for(int c1 : r.left.cand){
				for(int c2 : r.right.cand){
					r.cand.add(c1&c2);
					r.cand.add(c1|c2);
					r.cand.add(c1^c2);
				}
			}
		}
		return r;
	}
}

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

int main() {
  int k;
  cin >> k;

  queue<int64_t> lunluns;
  for (int i = 1; i <= 9;  ++i) lunluns.push(i);
  for (int i = 0; i < k-1; ++i) {
    int64_t x = lunluns.front();
    lunluns.pop();

    int64_t n = x * 10 + x % 10;
    if (x % 10 != 0) lunluns.push(n-1);
    lunluns.push(n);
    if (x % 10 != 9) lunluns.push(n+1);
  }
  cout << lunluns.front() << endl;
}

Measured memory_bytes: 5144
N = int(input())
L = list(map(int, input().split()))
cnt = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (L[i] != L[j] and L[i] != L[k] and L[j] != L[k]) and (L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[j] + L[k] > L[i]):
                cnt += 1
print(cnt)
    

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x[6];
  cin >> x[1] >> x[2] >> x[3] >> x[4] >> x[5];
  for (int i = 1; i <= 5; i++) {
    if (x[i] == 0) {
      cout << i << "\n";
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=10000000;


int main(){
    int D,G;
    cin >> D >> G;
    G/=100;
    int p[D],c[D];
    for(int i=0;i<D;i++){
        cin >> p[i] >> c[i];
        c[i]/=100;
    }
    int ans=INF;
    for(int bit=0;bit<(1<<D);bit++){
        vector<int> v;
        int k=-1;
        int sum=0,t=0;
        for(int i=0;i<D;i++){
            if(bit&(1<<i)){
                sum+=(i+1)*p[i]+c[i];
                t+=p[i];
            }
            else k=i; 
        }
        if(G<=sum){
            ans=min(ans,t);
            continue;
        }
        for(int i=0;i<p[k];i++){
            if(G<=sum){
                ans=min(ans,t);
                break;
            }
            sum+=k+1;
            t++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <stdio.h>

int main(){
    char alphabet[26] = {0};
    char word[1200] = "word";
    while (scanf("%s", word) != EOF){

        int length = strlen(word);
        for(int i=0; i < length; i++){
            if (isalpha(word[i])){
                int num;
                num = tolower(word[i]) - 'a';
                alphabet[num] += 1;
            } 
            else continue;
        }  
    }
    for(int i=0; i<26; i++){
        char ch1 = i + 'a'; 
        printf("%c : %d\n", ch1, alphabet[i]);
    }
    return 0;
}


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

using namespace std;

int n;
int a[300005];
int b[300005];
int c[300005];
int d[300005];
int e[300005];
int f[300005];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        b[a[i]]++;
        c[b[a[i]]]++;
    }
    for(int i = 1; i <= n; i++)
    {
        d[i] = d[i - 1];
        d[i] += c[i];
        e[d[i] / i]++;
    }
    for(int i = n; i >= 1; i--)
    {
        f[i] = f[i + 1];
        f[i] += e[i];
    }
    for(int i = 1; i <= n; i++)
    {
        printf("%d\n", f[i]);
    }
    return 0;
}


Measured memory_bytes: 7168
x, y = map(int,input().split( ))
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

ans = 'No'
if x in a and y in a:
	ans = 'Yes'
elif x in b and y in b:
	ans = 'Yes'
elif x in c and y in c:
	ans = 'Yes'

print(ans)

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

using namespace std;
int main(){
    int n,x,d,cnt;
    vector<int> l;

    cin>>n>>x;

    l.resize(n);
    for(int i=0; i<n; i++){
        cin>>l[i];
    }

    d=0;
    cnt=1;
    for(int i=0; i<n; i++){
        d=d+l[i];
        if(d<=x){
            cnt++;
        }
        //cout<<d<<" ";
    }
    //cout<<endl;
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
ans = 0
for b in range(2**(len(S)-1)):
    opes = []
    for i in range(len(S)-1):
        if b&(1<<i):
            opes.append('+')
        else:
            opes.append('')
    formula = ''.join([c+o for c,o in zip(S, opes)])
    ans += eval(formula + S[-1])
print(ans)

Measured memory_bytes: 3060
N,K = map(int,input().split())
A = list(map(int,input().split()))

left = 0
right = 10**9

while right - left > 1:
    center = (right+left)//2
    count = 0
    for a in A:
        if a%center == 0:
            count += a//center-1
        else:
            count += a//center
            
    if count >  K:
        left = center
    else:
        right = center
        
print(right)

Measured memory_bytes: 30904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9 + 55;
ll a, b, c, d;

void solve(){
  if(a - b < 0){
    cout << "No\n";
    return;
  }

  if(d - b < 0){
    cout << "No\n";
    return;
  }

  ll delta = __gcd(b, d);
  ll lo = ((c + 1 - b - a) / delta) - 10;
  ll hi = ((c - b + d - a) / delta) + 10;
  ll ans = INF;
  while(lo <= hi){
    ll mid = (lo + hi) / 2;
    ll cur = a + mid * delta;
    if(cur >= c + 1 - b){
      ans = cur;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }

  cout << ((ans >= 0) ? "Yes" : "No") << '\n';
}

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

  int nTest;  cin >> nTest;

  while(nTest--){
    cin >> a >> b >> c >> d;
    solve();
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 1000010
struct no{
	int x,y,z;
}a[N];
int operator <(no x,no y){
	return x.z<y.z;
}
int p[N],n,q,d[N],ct;
void add(int x,int y,int z){
	ct++;
	a[ct]={x,y,z}; 
}
int fd(int x){return p[x]==x?x:p[x]=fd(p[x]);} 
signed main(){
	cin>>n>>q;
	memset(d,63,sizeof(d));
	while(q--){
		int a,b,c;
		cin>>a>>b>>c;
		a++;b++;
		add(a,b,c);
		d[a]=min(d[a],c+1);
		d[b]=min(d[b],c+2);
	}
	for(int i=1;i<=n;i++)
		d[i%n+1]=min(d[i%n+1],d[i]+2);
	for(int i=1;i<=n;i++)
		d[i%n+1]=min(d[i%n+1],d[i]+2);
	for(int i=1;i<=n;i++)
		add(i,i%n+1,d[i]);
	sort(a+1,a+ct+1);
	int r=0;
	for(int i=1;i<N;i++)p[i]=i;
	for(int i=1;i<=ct;i++){
		int xx=fd(a[i].x),yy=fd(a[i].y);
		if(xx!=yy){
			p[xx]=yy;
			r+=a[i].z;
		}
	}
	cout<<r;
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll N;
    cin >> N;
    VL a(N);
    rep(i,0,N)cin>>a[i];
    ll ans=0;
    sort(a.begin(),a.end());
  	reverse(a.begin(),a.end());
    rep(i,0,N){
        if(i%2==0)ans+=a[i];
        else if(i%2!=0)ans-=a[i];
    }
    cout << ans << endl;
    return 0;
}

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

int binarySearch(int A[],int n,int data){
  int k=0,l=n;
  int h;
  while(k<l){
    h=(k+l)/2;
    if(A[h]==data) return 1;
    else if(A[h]<data) k=h+1;
    else l=h;
  }
  return 0;
}

int main(){
  int n,count=0;
  cin>>n;
  int S[100000];
  for(int i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  int q,data;
  cin>>q;
  for(int i=0;i<q;i++){
    scanf("%d",&data);
    if(binarySearch(S,n,data)) count++;
  }
  cout<<count<<endl;
  return 0;
}



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

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashSet<String> spoken = new HashSet<String>();
		String before = sc.next();
		spoken.add(before);
		boolean valid = true;
		for(int i = 0; i < N - 1; i++) {
			String W = sc.next();
			if(spoken.contains(W)) {
				valid = false;
			}
			if(before.charAt(before.length() - 1) != W.charAt(0)) {
				valid = false;
			}
			before = W;
			spoken.add(W);
		}
		System.out.println(valid ? "Yes" : "No");
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <ctime>
#include <map>
#include <queue>

using namespace std; using ll=long long; using P=pair<ll,ll>; const int INF=1e9; const ll LNF=1e18;

int main(){
  int n; cin>>n;
  int f=0,g=0,h=0;
  for(int i=0;i<n;i++) {
    int a; cin>>a;
    if (a%4==0) f++;
    else if (a%2==0) g++;
    else h++;
  }
  if (g==0) {
    if (f+1 >= h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  } else {
    if (f >= h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
	while(true){
		int n;
		scanf("%d", &n);
		if(n == 0){ break; }
		int lnum = 0, lok = 0;
		int dnum = 0, dok = 0;
		int mnum = 0, mok = 0;
		for(int i = 0; i < n; ++i){
			int h, m, a;
			scanf("%d:%d %d", &h, &m, &a);
			int ok = 0;
			if(a - m >= 0 && a - m <= 8){
				ok = 1;
			}else if(a < m && 60 - m + a <= 8){
				ok = 1;
			}
			if(11 <= h && h < 15){
				++lnum; lok += ok;
			}else if(18 <= h && h < 21){
				++dnum; dok += ok;
			}else if((21 <= h && h < 24) || (0 <= h && h < 2)){
				++mnum; mok += ok;
			}
		}
		if(lnum){
			printf("lunch %d\n", lok * 100 / lnum);
		}else{
			printf("lunch no guest\n");
		}
		if(dnum){
			printf("dinner %d\n", dok * 100 / dnum);
		}else{
			printf("dinner no guest\n");
		}
		if(mnum){
			printf("midnight %d\n", mok * 100 / mnum);
		}else{
			printf("midnight no guest\n");
		}
	}
	return 0;
}

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



int main() {
    string s;
    cin >> s;
    
    vector<string> week = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    
    rep(i,7) {
        if(s == week[i])
            cout << 7-i << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long K = GetLong();
		var A = GetLongs(N).Select(x => x - 1).ToArray();

		if(K <= 2 * N)
		{
			long c = 0;
			for(long i = 0; i < K; i++)
				c = A[c];

			WriteLine(c + 1);
			return;
		}

		var cnt = Enumerable.Repeat(-1L, (int)N).ToArray();
		cnt[0] = 0;
		long pos = 0;
		long ini = -1;
		long loop = -1;
		long ltop = -1;
		while(true)
		{
			long next = A[pos];
			if(cnt[next] != -1)
			{
				ini = cnt[next];
				loop = cnt[pos] - cnt[next] + 1;
				ltop = next;
				break;
			}
			cnt[next] = cnt[pos] + 1;
			pos = next;
		}

		long rest = K;
		if(ini != -1)
			rest -= ini;

		if(loop != -1)
			rest %= loop;

		pos = (ltop != -1 && ini <= K) ? ltop : 0;
		for(long i = 0; i < rest; i++)
			pos = A[pos];
		
		WriteLine(pos + 1);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

using namespace std;

int A;
vector<int> L;

int searchPuddle(int start, string s) {
	double a = 0, h = 0;
	for (int i = start; i < s.size(); i++) {
		switch (s[i]) {
			case '\\':
				a += h + 0.5;
				h++;
				break;
			case '/':
				h--;
				a += h + 0.5;
				if (h == 0) {
					A += a;
					L.push_back((int)a);
					return i;
				}
				break;
			case '_':
				a += h;
				break;
			default:
				break;
		}
	}
	return start;
}

int main() {
	double a = 0, h = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '\\')
			i = searchPuddle(i, s);
	}
	cout << A << endl;
	cout << L.size();
	vector<int>::iterator it = L.begin();
	while (it != L.end()) {
		cout << " " << *it;
		it++;
	}
	cout << endl;
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll X, N;
    cin >> X >> N;

    vector<ll> P(N);

    REP(i, N){
        cin >> P[i];
    }
    sort(P.begin(), P.end());
    
    vector<ll> A;
    
    for(ll i= -104; i<=105; i++){
        // A[i] = i-104;
        bool flag = true;
        REP(j, N){
            if(P[j] == i) flag = false;
        }
        if(flag) A.push_back(i);
    }

    sort(A.begin(), A.end());

    ll minx = INF;
    ll ans = -104;
    for(auto a: A){
        if(abs(a-X) < minx){
            ans = a;
            minx = abs(a-X);
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
/* 
* ID: juryc
* PROG: Low Elements
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n; 
vector<int> v(n); 
for(int& i: v) cin>>i;
int mi=0x3f3f3f3f,cnt=0;
for(int i: v){
mi=min(mi,i); if(mi==i) cnt++; 
}
cout<<cnt<<"\n"; 
return 0;
}

Measured memory_bytes: 3984
//# define FLAG
///delet....................................
# include   <bits/stdc++.h>
using namespace std;
# define    pb                      push_back
# define    mp                      make_pair
# define    IOS                     ios::sync_with_stdio(false)
# define    mem(a,b)                memset(a,b,sizeof(a))
# define    FO(i,n,a)               for(int i=n; i>=a; --i)
# define    FOR(i,a,n)              for(int i=a; i<=n; ++i)
# define    MAX(a,b)                ((a)>(b)?(a):(b))
# define    MIN(a,b)                ((a)<(b)?(a):(b))
# define    lowbit(x)               ((x)&(-x))
# define    LINF                    0xfcfcfcfcfcfcfcf
# define    INF                     0x3f3f3f3f
# define    MOD                     1000000007
# define    eps                     0.00000001
# define    pi                      3.141592653
# define    ee                      2.718281828459
# define    hr                      ptc('\n')
# define    kb                      ptc(' ')
# define    bug                     puts("H");
# pragma    comment(linker,"/STACK:1024000000,1024000000")
typedef     pair<int,int>           PII;
typedef     vector<int>             VI;
typedef     long long               LL;
typedef     unsigned long long      ULL;
inline char gtc() {
    static char buf[1000000],*p1=buf-1,*p2=buf-1;
    return p1==p2&&(p2=(p1=buf-1)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*++p1;
}
static char bufout[2000000],*chout=bufout-1;
inline void ptc(char ch) {
    *++chout=ch;
}
# define    Template                int
inline Template read() {
    char ch=gtc();
    while(!(ch>='0'&&ch<='9'||ch=='-'))ch=gtc();
    Template sum=0,flag=(ch=='-'?(ch=gtc()):0);
    while(ch>='0'&&ch<='9')sum=sum*10+ch-'0',ch=gtc();
    return flag?-sum:sum;
}
inline void out(Template x) {
    if(x<0)ptc('-'),x=-x;
    if(x>9)out(x/10);
    ptc(x%10+'0');
}
inline void write() {
    fwrite(bufout,1,chout-bufout+1,stdout);
}
///coding...................................

const int N=55;
char a[N][N];
int b[8]={-1,-1,0,1,1,1,0,-1};
int c[8]={0,1,1,1,0,-1,-1,-1};

int main() {
    IOS;
#ifdef FLAG
    //freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
    int h,w;
    cin>>h>>w;
    FOR(i,1,h)cin>>a[i]+1;
    FOR(i,1,h)FOR(j,1,w) {
        int ans=0;
        if(a[i][j]=='.') {
            FOR(k,0,7) {
                if(a[i+b[k]][j+c[k]]=='#')ans++;
            }
            a[i][j]=ans+48;
        }
    }
    FOR(i,1,h) {
        puts(a[i]+1);
    }
    return 0;
}










///delete FLAG..............................




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  rep (i, m) cin >> s[i] >> c[i];
  vector<int> v(n);
  rep (i, m) {
    v[s[i] - 1] = c[i];
  }
  if(n != 1 && v[0] == 0) v[0] = 1;
  bool ok = true;
  rep (i, m) {
    if(v[s[i] - 1] != c[i]) ok = false;
  }
  string ans;
  rep (i, n) ans += to_string(v[i]);
  cout << (ok ? ans : "-1") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <map>

using namespace std;

int main(){

    string S;
    cin >> S;
    map<char, int> m;
    for(int i = 0; i < 4; i++){
        m[S[i]]++;
    }

    if((int)m.size() == 2){
        for(int i = 0; i < 4; i++){
            if(m[S[i]] != 2){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
 * 17-05-13_ABC061_A.cpp
 *
 *  Created on: 2017/05/13
 *      Author: ryoma
 */

#include<iostream>

using namespace std;

int A,B,C;

int main(){
	cin >> A >>B >>C;
	cout << (A<= C && C <= B? "Yes":"No")<<endl;
	return 0;
}




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

int main() {
  int a,b,c,k;
  int n = 0;
  cin >> a >> b >> c >> k;
  if(a + b >= k) {
    n = min(a,k);
  } else {
    n = 2 * a + b - k ;
  }
  cout << n << endl;
}

Measured memory_bytes: 3592
from heapq import heappop, heappush
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
AB = [[int(x) for x in readline().split()] for _ in range(N)]

AB.sort()

STOCK = []
ans = 0

idx = 0
for d in range(1, M+1):
    for i in range(idx, N):
        a, b = AB[i]
        if a <= d:
            heappush(STOCK, -b)
            idx += 1
        else:
            break

    if STOCK:
        p = heappop(STOCK)
        ans -= p


print(ans)


Measured memory_bytes: 25384
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

long long num[100010];

int main()
{
    for(long long i=1;i<100010;i++)
        num[i]=i*i;
    long long N;
    while(cin >> N)
    {
        int tp=upper_bound(num,num+100010,N)-num;
        cout << num[tp-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int year,month,date;
    while(cin>>year>>month>>date){
        if(year<1868||year==1868&&month<9||year==1868&&month==9&&date<8)cout<<"pre-meiji"<<endl;
        else if(year<1912||year==1912&&month<7||year==1912&&month==7&&date<30)cout<<"meiji "<<year-1867<<" "<<month<<" "<<date<<endl;
        else if(year<1926||year==1926&&month<12||year==1926&&month==12&&date<25)cout<<"taisho "<<year-1911<<" "<<month<<" "<<date<<endl;
        else if(year<1989||year==1989&&month==1&&date<8)cout<<"showa "<<year-1925<<" "<<month<<" "<<date<<endl;
        else cout<<"heisei "<<year-1988<<" "<<month<<" "<<date<<endl;
    }
}

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

struct edge {
    int to, cost;
};

vector<vector<edge>> tree;

void dfs(int u, int p, vector<int>& ans) {
    for (edge e : tree[u]) {
        int v = e.to;
        int cost = e.cost;
        if (v == p) {
            continue;
        }

        if (cost % 2 == 1) {
            ans[v] = 1 - ans[u];
        } else {
            ans[v] = ans[u];
        }
        dfs(v, u, ans);
    }
}

int main() {
    int N;
    cin >> N;
    tree.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        tree[u].push_back(edge({v, w}));
        tree[v].push_back(edge({u, w}));
    }

    vector<int> ans(N, 0);
    dfs(0, -1, ans);

    for (int a : ans) {
        cout << a << endl;
    }
}


Measured memory_bytes: 8960
# 2019/10/24
# 解答かんにんぐ

s=input().replace('BC','X')
n=len(s)
cnt=0
ans=0
for i in range(1,n):
    tmp=s[i-1]+s[i]
    if s[i-1]=='A':
        cnt+=1
    if tmp[1]=='X':
        ans+=cnt
    if tmp not in ['AX','AA','XX','XA']:
        cnt=0
print(ans)

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int>P;
int main(void){
	int n,t;
	int i;
	P p[101];
	cin>>n>>t;
	for(i=0;i<n;i++){
		cin>>p[i].F>>p[i].S;
	}
	int MIN=INT_MAX;
	for(i=0;i<n;i++){
		if(p[i].S<=t){
			MIN=min(MIN,p[i].F);
		}
	}
	if(MIN==INT_MAX){
		cout<<"TLE"<<endl;
		return 0;
	}
	cout<<MIN<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
namespace Program_0152 {
	class Program {
		static void Main(string[] args) {
			while(true) {
				int n = int.Parse(Console.ReadLine());
				if (n == 0) break;
				int[] d = new int[n];
				for(int i = 0; i < n; i++) {
					string[] sc = Console.ReadLine().Split();
					d[i] = int.Parse(sc[0]);
					int[] a = new int[sc.Length - 1];
					for (int j = 0; j < sc.Length - 1; j++) a[j] = int.Parse(sc[j + 1]);
					int ret = 0, ptr = 0;
					for(int j = 0; j < 9; j++) {
						if (a[ptr] == 10) { ret += 10 + a[ptr + 1] + a[ptr + 2]; ptr++; }
						else if (a[ptr] + a[ptr + 1] == 10) { ret += 10 + a[ptr + 2]; ptr += 2; }
						else { ret += a[ptr] + a[ptr + 1]; ptr += 2; }
					}
					for (int j = ptr; j < a.Length; j++) ret += a[j];
					d[i] += (300 - ret) * 10000;
				}
				Array.Sort(d);
				for(int i = 0; i < n; i++) Console.WriteLine((d[i] % 10000) + " " + (300 - (d[i] - d[i] % 300) / 10000));
			}
		}
	}
}

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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

   cout << (t / a) * b << endl;

   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{ int d,n,i,j,k,cnt,dis;
  double distance;
  int za[10][10]={0};
  scanf("%d %d",&n,&d);
 k=cnt=dis=0;
 distance=0;
 for(i=0;i<n;i++)
 { for(k=0;k<d;k++)
   { scanf("%d",&j);
     za[i][k]=j;
   }
 }
for(i=0;i<n;i++)
 for(k=i+1;k<n;k++)
 { dis=distance=0;
   for(j=0;j<d;j++)
    dis+=(za[i][j]-za[k][j])*(za[i][j]-za[k][j]);
    distance=sqrt((double)dis);
    dis=sqrt(dis);
    if(distance==dis)cnt++;
 }
 printf("%d",cnt);
  return 0;
}

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

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

	if (a == b && b == c && c == a)
		cout << 1 << endl;
	else if (a != b && b != c && c != a)
		cout << 3 << endl;
	else
		cout << 2 << endl;
}


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

ll value(string s) {
	ll ans = 0;
	ll fact = 1;
	for (int i = 0; i < s.size(); i++) {
		ans += (s[s.size() - 1 - i] - 48) * fact;
		fact *= 10;
	}
	return ans;
}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	ll ans = 0;
	for (int bit = 0; bit < (1 << n - 1); bit++) {
		ll sum = 0;
		int len = 1;
		for (int i = 0; i < n - 1; i++) {
			if (!(bit & (1 << i)))
				len++;
			else {
				sum += value(s.substr(n - 1 - i, len));
				len = 1;
			}
		}
		sum += value(s.substr(0, len));
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<int>> graph;
vector<vector<bool>> reached;


int main(){
    int N;
    cin >> N;
    unordered_map<ll,ll> mp;
    ll x;
    for(int i=0;i<N;i++){
        cin >> x;
        mp[x]++;
    }

    ll ans = 0;
    for(auto x : mp){
        if(x.first == 0) continue;
        if(x.second >= x.first){
            ans += x.second-x.first;
        }
        else{
            ans += x.second;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
ll f[110][10];
ll p[110][11];

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin>>f[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<11;j++){
			cin>>p[i][j];
		}
	}
	
	ll ans=-INFl;
	
	for(int i=1;i<(1<<10);i++){
		ll tans=0;
		for(int j=0;j<n;j++){
			int cou=0;
			for(int k=0;k<10;k++){
				if(((i>>k)&(1))&&f[j][k]){
					cou++;
				}
			}
			tans+=p[j][cou];
		}
		//cout<<tans<<endl;
		ans=max(ans,tans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int,input().split())

cnt = [[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
    L, R = map(int,input().split())
    cnt[L][R] += 1

for i in range(N):
    for j in range(N):
        cnt[i+1][j+1] += cnt[i+1][j] + cnt[i][j+1] - cnt[i][j]

for _ in range(Q):
    p, q = map(int,input().split())
    print(cnt[q][q] - cnt[q][p-1] - cnt[p-1][q] + cnt[p-1][p-1])


Measured memory_bytes: 18396
H, W = map(int, input().split())
N = int(input())
A = [int(x) for x in input().split()]
T = []
for i in range(N):
  T += [str(i + 1)] * A[i]
for h in range(H):
  output = T[h * W:(h + 1) * W]
  if h % 2:
    output = output[::-1]
  print(' '.join(output))

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

int main() {
    int n;
    cin >> n;
    int ans = 1;
    while(2*ans <= n) ans *= 2;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long n;

    cin >> n;

    long long k;

    cin >> k;

    long long diff[4*200005];

    memset(diff,0,sizeof diff);

    vector<pair<long long,long long> > v;

    for(long long i = 0 ; i < k ; i++) {

        long long x;

        cin >> x;

        long long y;

        cin >> y;

        v.push_back({x,y});

    }

    diff[0]=0;

    diff[1]=1;

    long long last=0;

    for(long long i=1; i<=n+5; i++) {

        if(i>2) {

            diff[i]+=diff[i-1];

        }

        long long cur = diff[i]%998244353;

        for(long long j=0; j<v.size(); j++) {

            diff[i+v[j].first]+=cur;

            diff[i+v[j].second+1]-=cur;

        }

    }

    cout << diff[n]%998244353 << '\n';

    return 0;

}



Measured memory_bytes: 9908
#include <stdio.h>

int main(void) {

  int a, b, temp;
  int i = 0;

  while (1) {
    scanf("%d %d", &a, &b);

    if (a == 0 && b == 0) {
      break;
    } else {
      if (a > b) {
        temp = a;
        a = b;
        b = temp;
      }
      printf("%d %d\n", a, b);
    }
  }

  return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=1E5+10;
const int MAXK=16;
const int P=1E9+7;

template<typename T1,typename T2>
	void Inc(T1 &a,T2 b){a+=b;if(a>=P) a-=P;}

template<typename T1,typename T2>
	void Dec(T1 &a,T2 b){a-=b;if(a<0) a+=P;}

template<typename T1,typename T2>
	T1 Add(T1 a,T2 b){a+=b;return a>=P?a-P:a;}

template<typename T1,typename T2>
	T1 Sub(T1 a,T2 b){a-=b;return a<0?a+P:a;}

ll ksm(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1,(a*=a)%=P)
		if(b&1)
			(ret*=a)%=P;
	return ret;
}

int a,b;
ll fac[MAXN],ifac[MAXN];

ll C(int n,int m)
{
	if(n<0||m<0||n<m)
		return 0;
	return fac[n]*ifac[n-m]%P*ifac[m]%P;
}

int main()
{
	fac[0]=ifac[0]=1;
	for(int i=1;i<MAXN;i++)
		fac[i]=fac[i-1]*i%P;
	ifac[MAXN-1]=ksm(fac[MAXN-1],P-2);
	for(int i=MAXN-2;i;i--)
		ifac[i]=ifac[i+1]*(i+1)%P;
	scanf("%d%d",&a,&b);
	ll Ans=a+1;
	for(int i=max(1,b-a);i<b;i++)
		for(int j=max(1,2*(b-i)-a);j<=b-i;j++)
			Inc(Ans,C(b-1,i-1)*C(b-i-1,j-1)%P*C(a-2*(b-i)+j+2,2)%P);
	printf("%lld\n",Ans);
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,res=0;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		res+=(r-l+1);
	}
	printf("%d\n",res);
}


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

using namespace std;

int main(void){

  string s;
  while( cin >> s ){

    int t[s.size()];
    for( int i = 0 ; i < s.size() ; i++ ){
      switch( s[i] ){
      case 'I':
	t[i] = 1;
	break;
      case 'V':
	t[i] = 5;
	break;
      case 'X':
	t[i] = 10;
	break;
      case 'L':
	t[i] = 50;
	break;
      case 'C':
	t[i] = 100;
	break;
      case 'D':
	t[i] = 500;
	break;
      case 'M':
	t[i] = 1000;
	break;
      }
    }

    // for( int i = 0 ; i < s.size() ; i++ ){
    //   cout << t[i] << "---" ;
    // }
    

    int sum = 0;
    for( int i = 0 ; i < s.size() ; i++ ){
      if( i + 1 == s.size() )break;
      if( t[i] < t[i+1] ){
	sum = sum + t[i+1] - t[i];
	t[i+1] = t[i] = 0;
	i++;
      }
      else {
	sum += t[i];
	t[i] = 0;
      }
    }
    sum += t[s.size()-1];
    cout << sum << endl;
  }
  return 0;
}

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

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (c <= b && a <= c){
    cout << "Yes";
  }else if (b <= c && c <= a){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
from collections import deque
def makePath():
    que = deque([1])
    while que:
        x = que.pop()
        for y in G[x]:
            if hist[y]==0:
                que.append(y)
                A.append(y)
                hist[y]=1
                break
N,M = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
A = [1]
hist = [0 for _ in range(N+1)]
hist[1] = 1
makePath()
B = A[:]
A = []
makePath()
A = A[::-1]
A += B
print(len(A))
print(*A)

Measured memory_bytes: 71112