akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int Dice[6][6] = { { 1,5,2,3,0,4 },{ 4,0,2,3,5,1 },{ 3,1,0,5,4,2 },{ 2,1,5,0,4,3 },{ 0,2,4,1,3,5 },{ 0,3,1,4,2,5 } }, power[6] = { 1,3,9,27,81,243 };
struct Saikoro { int x[6]; }; Saikoro T[30]; int n, vis[30]; char F[7] = "CYRMGB"; bool G[30][30];
bool bfs(int p, int q) {
	for (int i = 0; i < 729; i++) {
		int bit[6]; for (int j = 0; j < 6; j++) { bit[j] = (i / power[j]) % 3; }
		Saikoro U = T[p];
		for (int j = 0; j < 6; j++) {
			for (int k = 0; k <= bit[j]; k++) {
				Saikoro V = U; for (int l = 0; l < 6; l++)V.x[l] = U.x[Dice[j][l]]; U = V;
			}
		}
		bool OK = true; for (int j = 0; j < 6; j++) { if (T[q].x[j] != U.x[j])OK = false; }
		if (OK == true)return true;
	}
	return false;
}
int main() {
	while (true) {
		for (int i = 0; i < 30; i++) { for (int j = 0; j < 30; j++)G[i][j] = false; vis[i] = 0; }
		cin >> n; if (n == 0)break; for (int i = 0; i < n; i++) { for (int j = 0; j < 6; j++) { string S; cin >> S; for (int k = 0; k < 6; k++) { if (S[0] == F[k])T[i].x[j] = k; } } }
		for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { G[i][j] = bfs(i, j); G[j][i] = G[i][j]; } }
		int cnt = 0; for (int i = 0; i < n; i++) { if (vis[i] != 0)continue; cnt++; vis[i] = cnt; for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { if (vis[k] != cnt)continue; for (int l = 0; l < n; l++) { if (G[k][l] == true)vis[l] = cnt; } } } }
		cout << n - cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include <stdio.h>

int		main(void)
{
	long	a, b, c, d;
	long	ans;

	scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
	if (a < 0)
	{
		if (b < 0)
		{
			if (c < 0)
				ans = a * c;
			else
				ans = b * c;
		}
		else
		{
			if (d < 0)
				ans = a * c;
			else if (c < 0)
				ans = a * c > b * d ? a * c : b * d;
			else
				ans = b * d;
		}
	}
	else
	{
		if (d < 0)
			ans = a * d;
		else
			ans = b * d;
	}
	printf("%ld\n", ans);
	
	return (0);
}


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

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 501

using namespace std;

void quick () {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);/*//*/
}

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

int diva (int n) {
    int counter = 0;
    for (int i = 1 ; i <= n ;i++){
        if (n%i==0)counter++;
    }
    return counter;
}

void readFromText(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif // ONLINE_JUDGE
}

int main()
{
    quick();
//    readFromText();
    int n ; cin >> n ; int counter = 0 ;
    for (int i = 1 ; i <= n ; i++){
        if (diva(i)==8&&i%2!=0)counter++;
    }
    cout << counter;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#include<utility>
#include<cmath>
using namespace std;
#define TxT for(int i = 0; i < 4; i++)for(int j = 0; j < 4; j++)
#define int long long
#define INF (int)(1e9)

typedef struct tep{
	int e[4][4];
	int c;
	bool operator  == (const tep& r) const{
		TxT if(e[i][j] != r.e[i][j]) return false;
		return true;
	}
} EP;

map<pair<int,int>,bool> z;
map<pair<int,int>,bool> v;
EP e;
int dxy[] = {1,-1,0,0};
int limit = 50, mi;

int temphoge(EP hoge){
	int re = 0;
	for(int i = 0; i < 4; i++)for(int j = 0; j < 4; j++){
		int ee = hoge.e[i][j]?hoge.e[i][j]:16;
		re += abs((ee-1)/4-i)+abs((ee+3)%4-j);
	}
	return re;
}

pair<int,int> hogefuga(EP hoge){
	int ten = 1, re = 0, re2 = 0;
	for(int i = 0; i < 2; i++)for(int j = 0; j < 4; j++) re += ten*hoge.e[i][j],ten*=100; ten = 1;
	for(int i = 2; i < 4; i++)for(int j = 0; j < 4; j++) re2 += ten*hoge.e[i][j],ten*=100;
	
	return make_pair(re,re2);
}

void print(EP hoge){	
	cout<<hoge.c<<" +++++ "<<endl;;
	pair<int, int> temp = hogefuga(hoge);
	cout<<temp.first<<" "<<temp.second<<endl;
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++) cout<<hoge.e[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
	string hogehogehoge;
	cin>>hogehogehoge;
}

bool hogehoge(EP hoge){
	int count = 1;
	TxT{ if(hoge.e[i][j] != (count++)%16) return false;}
	return true;
}

int fuga2(EP hoge, int depth, int mad, int ma, int p){//cout<<depth<<" <><><> "<<mad<<" "<<ma<<endl;print(hoge);
	int x, y,t, ti, th;
		
	// if(depth > mad)return false;

	if(ma == 0){
		// cout<<ma<<depth<<" "<<endl;print(hoge);
		mi = min(mi, depth);
		 return true;
	}
	if(depth + ma > limit)return false;
	// if(z[hogefuga(hoge)] > depth) return false;;
	// z[hogefuga(hoge)] = depth;
	// if(z[hogefuga(hoge)] >= depth) return false;
	// else z[hogefuga(hoge)] = depth;
	
	TxT if(hoge.e[i][j] == 0)y = i, x = j;
	
	for(int i = 0; i < 4; i++){
		int ny = y + dxy[i], nx = x + dxy[3-i];
		if(ny < 0 || ny >= 4 || nx < 0 || nx >= 4) continue;
		if(p != -1 && i/2 == p/2 && p != i) continue;
		EP fuga = hoge;
		int tma = ma;
		swap(fuga.e[y][x],fuga.e[ny][nx]);
		// if(fx == fuga) continue;
		
		int ee = fuga.e[y][x];
		tma += (abs((16-1)/4-ny)+abs((16+3)%4-nx))  - (abs((16-1)/4-y)+abs((16+3)%4-x));
		tma += (abs((ee-1)/4-y)+abs((ee+3)%4-x))  - (abs((ee-1)/4-ny)+abs((ee+3)%4-nx));
		
		// if(temphoge(fuga) > temphoge(hoge)+10)continue;
		fuga2(fuga,depth+1,mad,tma, i);
		
	}
	return false;
}


int solve(){
	int th;
	mi = INF;
	int m = temphoge(e);
	for(int i = m; ; i++){//cout<<i<<endl;
		z.clear();
		limit = i;
		fuga2(e,1,INF, m, -1);
		if(mi != INF)return mi-1;
	}
}
signed main(){
	
	TxT cin>>e.e[i][j];
	
	//z[hogefuga(e)] = true;
	
	cout<<solve()<<endl;
	
	return 0;
}


Measured memory_bytes: 3132
function bomb(start,sum){
   dp[start][sum]++;
   if(start==card.length)return;
   var v=card[start][0];
   var k=card[start][1];
   for(var i=0;i<=k;i++){
      bomb(start+1,sum+v*i);
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var m=arr.shift()-0;
   if(m==0)break;
   var card=[];
   while(m--)card.push(arr.shift().split(" ").map(Number));
   var g=arr.shift()-0;
   var dp=[];
   for(var i=0;i<=card.length;i++){
      dp[i]=[];
      for(var j=0;j<=1000;j++){
         dp[i][j]=0;
      }
   }
   bomb(0,0);
   while(g--)console.log(dp[card.length][arr.shift()-0]);
}

Measured memory_bytes: 25968
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int n,k;
    cin>>n>>k;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());

    int lo=1,hi=mod;
    int ans=mod;

    while(lo<=hi)
    {
        int m=lo+(hi-lo)/2;
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            cnt+=(a[i]+m-1)/m-1;
        }
        if(cnt<=k) ans=min(ans,m),hi=m-1;
        else lo=m+1;
    }
    cout<<ans<<endl;
    return 0;
}



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

#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 drrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);

	int n; std::cin >> n;
	string s; std::cin >> s;
	int ans = 0;
	rep(i, 10) rep(j, 10) rep(k, 10) {
		int cnt = 0;
		int pass[] = {i, j, k};
		for (auto & c : s) {
			if (c - '0' == pass[cnt])
				cnt++;
			if (cnt == 3) break;
		}
		if (cnt == 3)
			ans++;
	}
	std::cout << ans << "\n";
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g,h,i,j,k,l,m,n,y;
	while(1){
		scanf("%d",&a);
		if(a==0)	break;
		b=1000-a;
		c=b/500;
		d=b%500;
		e=d/100;
		f=d%100;
		g=f/50;
		h=f%50;
		i=h/10;
		j=h%10;
		k=j/5;
		l=j%5;
		m=l/1;
		n=l%1;
		y=c+e+g+i+k+m;
		printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 1724
package main

import (
	"fmt"
)

func main() {
	const mod int = 1000000007
	var n int
	var a int
	fmt.Scan(&n)

	ans := 1
	table := make([][]int, n+1)
	table[0] = make([]int, 3)
	for i := 1; i <= n; i++ {
		table[i] = make([]int, 3)
		fmt.Scan(&a)
		cnt := 0
		for j := 0; j < 3; j++ {
			table[i][j] = table[i-1][j]
			if a == table[i-1][j] {
				cnt++
				if cnt == 1 {
					table[i][j]++
				}
			}
		}
		ans = (ans * cnt) % mod
	}

	fmt.Println(ans)
}


Measured memory_bytes: 8704
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define ll long long 
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
using namespace std;
using namespace std::chrono;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	itn n,m;
	cin>>n>>m;
	if(n==m)
		cout<<"Yes";
	else
		cout<<"No";

	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


int main(int argc, const char * argv[]) {
    ll N,M; cin >>N >> M;
    
    ll cnt=0;
    if(N%2){
        for(ll i=1;i<=M;i++){
            cout << i+1 << " " << N-i+1 << endl;
        }
        return 0;
    }
    else{
        ll r=1,l=N;
        bool flag = false;
        for(ll i=1;i<=M;i++){
            if(l-r<=N/2 && !flag){
                flag=true;
                r++;
            }
            cout << r << " " << l << endl;
            r++; l--;
        }
    }
    
    
    
//    ll delta = 1;
//    for(ll i=1;i<=M;i++){
//        cout << i << " " << i+delta << endl;
//        delta += 2;
//    }
//
//
 
    return 0;
}




Measured memory_bytes: 3576
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2005,M=4e6+5;
bitset<M>vis;int a[N],n,sum,res;
int main(){
	scanf("%d",&n);
	vis[0]=1;
	fp(i,1,n)scanf("%d",&a[i]),sum+=a[i],vis|=vis<<a[i];
	res=(sum+1)>>1;
	fp(i,res,sum)if(vis[i])return printf("%d\n",i),0;
	puts("QAQ");
	return 0;
} 

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string x,y; cin >> x >>y;
    if(x[0]==y[2]&&x[1]==y[1]&&x[2]==y[0])cout << "YES" << endl;
    else cout << "NO" << endl; return 0;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll H,W;
  cin>>H>>W;
  VEC2(v,H,W);
  FOR(i,0,H) FOR(j,0,W) cin>>v[i][j];
  FOR(i,0,H) FOR(j,0,W) v[i][j]=v[i][j]%2;

  ll flag=0;
  ll prei=0,prej=0;
  ll res=0;


  FOR(i,0,H){

    if(i%2==0){
      FOR(j,0,W){
        if(flag==1){
          //cout<<prei+1<<" "<<prej+1<<" "<<i+1<<" "<<j+1<<endl;
          res++;
          if(v[i][j]==1)flag=0;
        }
        else{
          if(v[i][j]==1)flag=1;
        }
      prei=i;
      prej=j;
      }
    }
    else{
      FORr(j,W-1,-1){
        if(flag==1){
          //cout<<prei+1<<" "<<prej+1<<" "<<i+1<<" "<<j+1<<endl;
          res++;
          if(v[i][j]==1)flag=0;
        }
        else{
          if(v[i][j]==1)flag=1;
        }
      prei=i;
      prej=j;
      }
    }

  }
  prei=0;
  prej=0;
  flag=0;

  cout<<res<<endl;
  FOR(i,0,H){

    if(i%2==0){
      FOR(j,0,W){
        if(flag==1){
          cout<<prei+1<<" "<<prej+1<<" "<<i+1<<" "<<j+1<<endl;
          if(v[i][j]==1)flag=0;
        }
        else{
          if(v[i][j]==1)flag=1;
        }
      prei=i;
      prej=j;
      }
    }
    else{
      FORr(j,W-1,-1){
        if(flag==1){
          cout<<prei+1<<" "<<prej+1<<" "<<i+1<<" "<<j+1<<endl;
          if(v[i][j]==1)flag=0;
        }
        else{
          if(v[i][j]==1)flag=1;
        }
      prei=i;
      prej=j;
      }
    }
  }


}


Measured memory_bytes: 4096
#include<stdio.h>
int A[100][100];
int visit[100];
void MinimumSpanningTree(int);
 
main(){
  int n, i, j;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &A[i][j]);
    }
  }
  MinimumSpanningTree(n);
  return 0;
}
 
void MinimumSpanningTree(int n){
  int i, j, k=1, X[100], minCost, min, sum=0;
   
  X[0] = 0;
  visit[0] = 1;
  for(i = 1; i < n; i++){
    visit[i] = 0;
  }
  while(1){
    minCost = 2001;
    for(i = 0; i < k; i++){
      for(j = 0; j < n; j++){
    if(A[X[i]][j] < minCost && A[X[i]][j] != -1 && visit[j] != 1){
      minCost = A[X[i]][j];
      min = j;
    }
      }
    }
    if(k != n){
      X[k] = min;
      visit[min] = 1;
      sum += minCost;
      k++;
    }
    else break;
  }
  printf("%d\n", sum);
}

Measured memory_bytes: 640
from collections import deque
H, W = map(int, input().split())

grid_array = [[0] * (W+2) for _ in range(H+2)]


white_count = 0
for i in range(1, H+1):
    grid = input()
    for j, x in enumerate(grid):
        if x == ".":
            grid_array[i][j+1] = 1
            white_count += 1

used_array = [[0] * (W+2) for _ in range(H+2)]

INF = 10 ** 5

distance_array = [[INF] * (W+2) for _ in range(H+2)]

tile_deque = deque()
tile_deque.append((1, 1))
used_array[1][1] = 1
distance_array[1][1] = 1
while len(tile_deque):
    i, j = tile_deque.popleft()
    # print(i,j)
    if used_array[i-1][j] == 0 and grid_array[i-1][j] == 1:
        used_array[i-1][j] = 1
        tile_deque.append((i-1, j))
        distance_array[i-1][j] = min(distance_array[i-1]
                                     [j], distance_array[i][j]+1)
    if used_array[i+1][j] == 0 and grid_array[i+1][j] == 1:
        used_array[i+1][j] = 1
        tile_deque.append((i+1, j))
        distance_array[i+1][j] = min(distance_array[i+1]
                                     [j], distance_array[i][j]+1)
    if used_array[i][j-1] == 0 and grid_array[i][j-1] == 1:
        used_array[i][j-1] = 1
        tile_deque.append((i, j-1))
        distance_array[i][j-1] = min(distance_array[i]
                                     [j-1], distance_array[i][j]+1)
    if used_array[i][j+1] == 0 and grid_array[i][j+1] == 1:
        used_array[i][j+1] = 1
        tile_deque.append((i, j+1))
        distance_array[i][j+1] = min(distance_array[i]
                                     [j+1], distance_array[i][j]+1)
# print(distance_array)
if distance_array[H][W] == INF:
    print(-1)
else:
    print(white_count-distance_array[H][W])

Measured memory_bytes: 40688
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

class Node{
public:
    int parent, rank;
    Node(int i): parent(i), rank(0){}
};

bool sortFunc(const vector<int>& A, const vector<int>& B){
    return A[2] < B[2];
}

int find(vector<Node>& nodes, const int& x){
    if(nodes[x].parent != x){
        int p = find(nodes, nodes[x].parent);
        nodes[x].parent = p;
    }
    return nodes[x].parent;
}

void unite(vector<Node>& nodes, const int& x, const int& y){
    int xp = find(nodes, x), yp = find(nodes, y);
    if(nodes[xp].rank > nodes[yp].rank){
        nodes[yp].parent = xp;
    }
    else if(nodes[yp].rank > nodes[xp].rank){
        nodes[xp].parent = yp;
    }
    else{
        nodes[xp].rank++;
        nodes[yp].parent = xp;
    }
}
int main(){
    int v, e, s, t, w;
    vector<Node> nodes;
    vector<vector<int>> edges;
    scanf("%d %d", &v, &e);
    for(int i = 0; i < v; i++){
        nodes.push_back(Node(i));
    }
    for(int i = 0; i < e; i++){
        scanf("%d %d %d", &s, &t, &w);
        edges.push_back(vector<int>{s, t, w});
    }
    sort(edges.begin(), edges.end(), sortFunc);
    int sum = 0;
    for(vector<int> edge: edges){
        if(find(nodes, edge[0]) == find(nodes, edge[1])) continue;
        sum += edge[2];
        unite(nodes, edge[0], edge[1]);
    }
    printf("%d\n", sum);
}



Measured memory_bytes: 7944
import bisect
import collections
import math
N = int(input())

if N == 1:
    print(0)
    exit()


def trial_division(n):
    # 素因数を格納するリスト
    factor = []
    # 2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    # リストが空ならそれは素数
    if not factor:
        return [n]
    else:
        if n != 1:
            factor.append(n)
        return factor


C = collections.Counter(trial_division(N))
# print(C)

L = [1]
for i in range(2, 1000):
    L.append(L[-1]+i)
# print(L)


ans = 0
for V in C.values():
    ans += bisect.bisect_right(L, V)
print(ans)


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

int main()
{
	long int a, b;
	while (cin >> a >> b)
	{
		if (a < b) swap(a, b);
		//?????§??¬?´???°
		for (int i = 1; i <= a; i++)
		{
			if (a % i == 0 && b % (a / i) == 0)
			{
				cout << a / i << " ";
				break;
			}
		}
		//????°???¬?????°
		for (int i = 1; i <= b; i++)
		{
			if ((a * i) % b == 0)
			{
				cout << a * i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1160
n=int(input())
s=[list(input()),list(input())]
a=1
if n>1:
 for i in range(n-1):
  if s[0][i]==s[0][i+1]:
   if i>0:
    if s[0][i-1]==s[1][i-1]:
      a*=2
    else:
      a*=3
   else:
      a*=6
 for i in range(n):
  if s[0][i]==s[1][i]:
   if i>0:
     if s[0][i-1]==s[1][i-1]:
       a*=2
   else:
     a*=3
  a%=1000000007
else:
  a=3
print(a)

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

int main(){
	string str, s;

	while( getline(cin,str) ){
		bool flag = false;
		s = "";
		for(int i=0 ; i<str.size() ; i++){
			if( str[i] == ' ' || str[i] == '.' || str[i] == ',' ){
				if( s.size() >= 3 && s.size() <= 6 ){
					if(flag){
						cout << " " << s ;
					}else{
						flag = true;
						cout << s;
					}
				}
				s = "";
			}else{
				s += str[i];
			}
		}
		cout << endl;
	}
	return 0;
}

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


int main(){
	while(1){
		int n,h,w;
		cin>>n;
		if(n==0) break;
		cin>>h>>w;
		vvi a(h,vi(w));
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			a[x-1][y-1]++;
		}
		int H,W;
		cin>>H>>W;
		int res=0;
		for(int i=0;i<h-H+1;i++) for(int j=0;j<w-W+1;j++){
			int tmp=0;
			for(int k=0;k<H;k++) for(int l=0;l<W;l++) if(a[i+k][j+l]) tmp++;
			res=max(res,tmp);
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3104
N = int(input())

ok = False
for i in range(1, 10):
    is_dividable = N % i is 0
    is_less_9 = N / i <= 9
    if is_dividable and is_less_9:
        ok = True
        break

answer = 'Yes' if is_dividable else 'No'

print(answer)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline void read(int &x){
  char c=nc(),b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}

const int N=10005;
const int M=500005;

struct edge{
  int u,v,next;
}G[M<<1];
int head[N],inum;
inline void add(int u,int v,int p){
  G[p].u=u; G[p].v=v; G[p].next=head[u]; head[u]=p;
}

int Q[5000005],l,r;
int ins[N];

int *F,idx[N];
inline bool cmp(int x,int y){
  return F[x]<F[y];
}

int n,m;
#define V G[p].v
inline void SPFA(int *f){
  l=r=-1;
  F=f; for (int i=1;i<=n;i++) idx[i]=i;
  sort(idx+1,idx+n+1,cmp); 
  for (int i=1;i<=n;i++) Q[++r]=idx[i],ins[idx[i]]=1;
  while (l<r){
    int u=Q[++l]; ins[u]=0;
    for (int p=head[u];p;p=G[p].next)
      if (f[V]>f[u]+1){
	f[V]=f[u]+1;
	if (!ins[V])
	  Q[++r]=V,ins[V]=1;
      }
  }
}
int fat[N];
int a[5][N];

int f[1<<3][N];

int main(){
  int iu,iv;
  read(n); for (int i=0;i<3;i++) read(*a[i]);
  for (int i=1;i<=n;i++) fat[i]=i;
  for (int i=0;i<3;i++){
    for (int j=1;j<=*a[i];j++)
      read(a[i][j]);
    sort(a[i]+1,a[i]+*a[i]+1);
    for (int j=2;j<=*a[i];j++)
      fat[a[i][j]]=a[i][1];
  }
  read(m);
  for (int i=1;i<=m;i++)
    read(iu),read(iv),add(fat[iu],fat[iv],++inum),add(fat[iv],fat[iu],++inum);
  memset(f,0x3f,sizeof(f));
  for (int i=0;i<3;i++)
    f[1<<i][a[i][1]]=0;
  for (int i=1;i<(1<<3);i++){
    for (int j=1;j<=n;j++)
      for (int k=(i-1)&i;k;k=(--k)&i)
	f[i][j]=min(f[i][j],f[k][j]+f[i^k][j]);
    SPFA(f[i]);
  }
  int ans=1<<30,idx;
  for (int i=1;i<=n;i++)
    if (f[7][i]<ans)
      ans=f[7][i],idx=i;
  printf("%d %d\n",ans,idx);
  return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    string a, b, c;
    cin >> a >> b >> c;
    int ans = INF;
    ans = min(ans, calc(a, b, c));
    ans = min(ans, calc(a, c, b));
    ans = min(ans, calc(b, a, c));
    ans = min(ans, calc(b, c, a));
    ans = min(ans, calc(c, a, b));
    ans = min(ans, calc(c, b, a));
    cout << ans << endl;
  }
  vector<int> check(string a, string b) {
    int la = a.length();
    int lb = b.length();
    vector<int> ret(la + 1);
    for (int d = 0; d <= la; ++d) {
      bool ok = true;
      for (int i = 0; i < min(lb, la - d); ++i) {
        if (b[i] == '?') continue;
        if (a[d + i] == '?') continue;
        if (b[i] != a[d + i]) ok = false;
      }
      ret[d] = ok;
    }
    return ret;
  }
  int calc(string a, string b, string c) {
    int la = a.length();
    int lb = b.length();
    int lc = c.length();
    int ret = INF;
    auto ab = check(a, b);
    auto bc = check(b, c);
    auto ac = check(a, c);
    for (int d1 = 0; d1 <= la; ++d1) {
      for (int d2 = 0; d2 <= max(lb, la - d1); ++d2) {
        if (ab[d1] && bc[min(lb, d2)] && ac[min(la, d1 + d2)]) {
          ret = min(ret, max({la, d1 + lb, d1 + d2 + lc}));
        }
      }
    }
    return ret;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (1e9 + 7)
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        cin >> n;

        if (n % 2 == 1) {
            puts("0");
            return 0;
        }
        long ans = n / 10;
        for (long pot = 50; pot <= 1e18; pot *= 5) {
            ans += n / pot;
        }
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 3724
#include <stdio.h>

int main(void)
{
    int a, b, answer;
    char op;

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

        if(op != '?'){

            if(op == '+'){
                answer = a + b;
            }
            if(op == '-'){
                answer = a - b;
            }
            if(op == '*'){
                answer = a * b;
            }
            if(op == '/'){
                answer = a / b;
            }
        }
        else {
            break;
        }
        printf("%d\n", answer);
    }
    return 0;
}

Measured memory_bytes: 600
w = str(input())
w = list(w)

flag = True
for c in [chr(i) for i in range(97, 97+26)]:
    count = 0
    for i in range(len(w)):
        if w[i] == c:
            count += 1
    if count % 2 == 0:
        pass
    else:
        flag = False

if flag == True:
    print('Yes')
else:
    print('No')
    


Measured memory_bytes: 3060
import java.util.*;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int sum=0;
  int no_fruits = sc.nextInt();
  int[] price = new int[n];
  for(int i=0; i<n; i++)
    price[i] = sc.nextInt();
  Arrays.sort(price);
  for(int i=0; i<no_fruits; i++){
    sum += price[i];
  }
  System.out.print(sum);
}
}

Measured memory_bytes: 38544
import numpy as np


def main():
    n = [int(x) for x in input()]
    K = int(input())
    dp = np.zeros((len(n)+1, 2, 5), dtype=int)

    if len(n) < K:
        print(0)
        return

    dp[0, 0, 0] = 1

    for i in range(len(n)):
        for k in range(K+1):
            # use 0
            if n[i] == 0:
                dp[i+1, 0, k] += dp[i, 0, k]
                dp[i+1, 1, k] += dp[i, 1, k]
            else:
                dp[i+1, 1, k] += dp[i, 0, k] + dp[i, 1, k]
            # use 1~9
            for x in range(1, 10):
                if x < n[i]:
                    # always smaller
                    dp[i+1, 1, k+1] += dp[i, 0, k] + dp[i, 1, k]
                elif x == n[i]:
                    dp[i+1, 0, k+1] += dp[i, 0, k]
                    dp[i+1, 1, k+1] += dp[i, 1, k]
                else:
                    dp[i+1, 1, k+1] += dp[i, 1, k]
    print(dp[len(n), 0, K] + dp[len(n), 1, K])


if __name__ == '__main__':
    main()

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

const int MX = 100000;
int n, a[MX];

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

  cin >> n;
  rep(i, n) cin >> a[i];
  int ans = 0;

  rep(i, n) {
    if (i == a[a[i] - 1] - 1) ans++;
  }
  cout << ans / 2 << '\n';
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main (void){
	int n, i, q;
	
	scanf("%d", &n);
	int S[n];
	
	for(i=0; i<n; i++){
		scanf(" %d", &S[i]);
		//printf("S%d\n", S[i]);
	}
	
	
	scanf("%d", &q);
	int T[q];
	
	for(i=0; i<q; i++){
		scanf(" %d", &T[i]);
		//printf("T%d\n", T[i]);
	}
	
	int k=0, ii, A[q], z;
	
	for(i=0; i<q; i++){//T
		for(ii=0; ii<n; ii++){//S
			if(T[i]==S[ii]){
				A[k]=S[ii];
				k++;
			//	printf("k++%d\n", k);
				for(z=0; z<k-1; z++){
					if(A[z]==S[ii]){
						//printf("A[z]==S[ii] %d %d\n", A[z], S[ii]);
					//	printf("k%d\n", k);
						k-=1;
					//	printf("k %d\n", k);
					}
				}
				
			}
		}
	}
	
	printf("%d\n", k);
	/*for(i=0; i<k-1; i++){
		printf("%d ", A[i]);
	}
	printf("%d", A[k]);
	*/
	
	
	return 0;
}


Measured memory_bytes: 2092
import java.util.*;
public class Main {
  	public static void main(String[] args) {
//		2xNのマス目
//		1,2,3,4..
//		5,6,7,8..
//		スタートは(1, 1)


		Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
//      (2,N)
      	ArrayList<Integer> masu1 = new ArrayList<Integer>();
      	ArrayList<Integer> masu2 = new ArrayList<Integer>();
      	for(int i = 0; i < N; i++) {
      		 masu1.add(sc.nextInt());
      	}

      	for(int i = 0; i < N; i++) {
     		 masu2.add(sc.nextInt());
     	}
    	ArrayList<Integer> ans = new ArrayList<Integer>();
      	for (int i = 1; i < N; i++) {
      		int total = 0;
      		int count = i;
      		while (count != 0) {
      			total += masu1.get(count - 1);
      			count--;
      		}
      		for (int j = N; j >= i; j--) {
      			total += masu2.get(j - 1);
      		}
      		ans.add(total);
      	}
      	int total = 0;
      	for(int i = 0; i < N; i++) {
    		 total += masu1.get(i);
    	}
      	total += masu2.get(N-1);
      	ans.add(total);

      	System.out.println(Collections.max(ans));
	}
}


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

#define int long long
#define x first
#define y second
#define sz(x) ((int)x.size())

const int oo = 1e18;

int n, a, b, c, d;

map<int, int> dp;

int f(int x) {
	if(x == 0) return x;
	if(dp.find(x) != dp.end()) return dp[x];
	dp[x] = +oo;
	int DP = +oo;
	if(+oo / d >= x) {
		DP = min(DP, x * d);
	}
	if(x % 5LL == 0) {
		if(+oo / d >= 4LL * (x / 5LL)) DP = min(DP, (4LL*(x/5LL))*d + f(x/5LL));
		DP = min(DP, c + f(x / 5LL));
	}
	else {
		int y = 5LL * (x / 5LL);
		int z = y + 5LL;
		if(y == 0) DP = min(DP, (x - y) * d);
		DP = min(DP, (x - y) * d + c + f(y / 5LL));
		if(+oo / d >= 4LL*(y/5LL)) DP = min(DP, (x - y) * d + (4LL*(y/5LL))*d + f(y/5LL));
		DP = min(DP, (z - x) * d + c + f(z / 5LL));
		if(+oo / d >= 4LL*(z/5LL)) DP = min(DP, (z - x) * d + (4LL*(z/5LL))*d + f(z/5LL));
	}
	if(x % 2LL == 0) {
		if(+oo / d >= (x / 2LL)) DP = min(DP, (x / 2LL) * d + f(x / 2LL));
		DP = min(DP, a + f(x / 2LL));
	}
	else {
		int y = 2LL * (x / 2LL);
		int z = y + 2LL;
		if(y == 0) DP = min(DP, (x - y) * d);
		DP = min(DP, (x - y) * d + a + f(y / 2LL));
		if(+oo / d >= y / 2LL) DP = min(DP, (x - y) * d + (y / 2LL) * d + f(y / 2LL));
		DP = min(DP, (z - x) * d + a + f(z / 2LL));
		if(+oo / d >= z / 2LL) DP = min(DP, (z - x) * d + (z / 2LL) * d + f(z / 2LL));
	}
	if(x % 3LL == 0) {
		if(+oo/d >= 2LL*(x/3LL)) DP = min(DP, (2LL*(x/3LL))*d+f(x/3LL));
		DP = min(DP, b + f(x / 3LL));
	}
	else {
		int y = 3LL * (x / 3LL);
		int z = y + 3LL;
		if(y == 0) DP = min(DP, (x - y) * d);
		DP = min(DP, (x - y) * d + b + f(y / 3LL));
		if(+oo/d >= 2LL*(y/3LL)) DP = min(DP, (x - y) * d + (2LL*(y/3LL)) * d + f(y/3LL));
		DP = min(DP, (z - x) * d + b + f(z / 3LL));
		if(+oo/d >= 2LL*(z/3LL)) DP = min(DP, (z - x) * d + (2LL*(z/3LL)) * d + f(z/3LL));
	}
//	cout << x << " " << DP << endl;
	return dp[x] = DP;
}

void solve() {
	dp.clear();
	cout << f(n) << endl;
}

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

	int nb_test_cases;
	cin >> nb_test_cases;
	for(int iTest = 1; iTest <= nb_test_cases; iTest++) {
		cin >> n >> a >> b >> c >> d;
		solve();
	}
	
	return 0;
}





































Measured memory_bytes: 4368
#include<cstdio>
#include<vector>

using namespace std;

class ExhaustiveSearch
{
public:
	void solve(int n, int A[], int q, int M[])
	{
		for (int i = 0; i < q; i++)
		{
			if (search(n, A, 0, M[i]))
				printf("yes\n");
			else
				printf("no\n");
		}
	}

	bool search(int n, int A[], int i, int m)
	{
		if (m == 0)
			return true;
		else if (i >= n)
			return false;

		return (search(n, A, i + 1, m) || search(n, A, i + 1, m - A[i]));
	}
};

int main()
{
	int n, tmp;
	scanf("%d", &n);
	vector<int> A;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &tmp);
		A.push_back(tmp);
	}
	int q;
	scanf("%d", &q);
	vector<int> M;
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &tmp);
		M.push_back(tmp);
	}

	 ExhaustiveSearch es;
	es.solve(n, A.data(), q, M.data());
}



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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;

using namespace std;

void print(int a[],int s,int e){for(int i=s;i<=e;i++)cout<<a[i]<<" ";cout<<"\n";}
void print(vector<int> &v,int s,int e){for(int i=s;i<=e;i++)cout<<v[i]<<" ";cout<<"\n";}
void print(vector<int> &v){for(int x:v)cout<<x<<" ";cout<<"\n";}

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*b;x%=m;return x;}

int a,b,h;

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    cin>>a>>b>>h;
    cout<<(a*h) + ((b-a)*h)/2;

    return 0;
}


Measured memory_bytes: 764
a='light ',b='heavy',c='middle',d='welter',require("fs").readFileSync("/dev/stdin","utf8").split(/\s/).map(function(i){i?console.log(i>91?b:i>81?a+b:i>75?c:i>69?a+c:i>64?d:i>60?a+d:i>57?'light':i>54?'feather':i>51?'bantam':(i>48?'':a)+'fly'):0})

Measured memory_bytes: 7648
from itertools import combinations

def resolve():
    N, M = map(int, input().split())
    balls = [2]*N + [1]*M
    ans = 0
    for x, y in combinations(balls, 2):
        if (x+y)%2 == 0:
            ans += 1
    return print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;
const int Max = 1e4 + 5;
int n, x, y, ans[Max];

int main() {
    scanf("%d %d %d", &n, &x, &y);
    for (int i = 1; i <= n - 1; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dis = j - i;
            dis = min(dis, abs(i - x) + abs(j - y) + 1);
            dis = min(dis, abs(j - x) + abs(i - y) + 1);
            ans[dis]++;
        }
    }
    for (int i = 1; i <= n - 1; i++)
        printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 128
//Why 860?
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(v) ((int)v.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(x) cout << #x << " = " << x << endl
#define FER(i,x,y) for(int (i)=(x);(i)<(y); (i) ++)
#define IFR(i,x,y) for(int (i)=(x);(i)>=(y); (i) --)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define N 101
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef ll T;

int main(){
	fastio;
	int n, h, w; cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    int main() {
   
     int n;
     
     cin >> n;
     
     int a[4][13] = { {0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,0,0,0,0,0,0,0,0,0} };
     
     for(int i = 0; i < n; i++){
        char s;
        int k;
        cin >> s >> k;
        
     	if(s=='S')  a[0][k-1]++;
     	else if(s=='H')	a[1][k-1]++;
     	else if(s=='C')	a[2][k-1]++;
     	else         	a[3][k-1]++;
     }
     
     for(int i = 0; i < 4; i++){
     	for(int j = 0; j < 13; j++){
     		if(a[i][j]!=0){
     		 	continue;
     		} else{
     			if(i==0)  printf("%s %d\n","S",j+1);
     	        else if(i==1)	printf("%s %d\n","H",j+1);
     	        else if(i==2)	printf("%s %d\n","C",j+1);
     	        else         	printf("%s %d\n","D",j+1);
     		}
     	}
     }
     	
     
     return 0;
    }


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using  P=pair<int,int>;
int main(){
  int N,T,dp[3020][6020],maxvalue=0,a,b;
  cin>>N>>T;
  vector<P> vec(0);
  for(int i=0;i<N;i++){
    cin>>a>>b;
    vec.push_back(make_pair(a,b));//a(first)は所要時間,b(second)は価値
  }
  //所要時間順にソート
  sort(vec.begin(),vec.end());
  //(1+(rock^価値)*x^(所要時間))の累積の考えて指数について制限をかけて考える
  //係数についてはrockの指数部分について見る。
  //形式的冪級数展開を行う(T+max(所要時間)まで考える)
  //計算量はO(N*(T+max(所要時間)))<=O(1.8*10^7)なので間に合う！
  for(int h=0;h<N;h++){
    //先に0乗の係数は1にしておく
    dp[h][0]=1;
  }
  for(int i=1;i<=N;i++){
    for(int j=0;j<T;j++){
      if(dp[i-1][j]!=0){//多項式をかける前のj乗の係数が0で無いなら
        //多項式のうちxの指数乗の方について、係数をまずは計算
        dp[i][j+vec.at(i-1).first]+=dp[i-1][j]+vec.at(i-1).second;
        //(jが0の時だけ処理(j=0の係数の1が加算されてしまうため))
        if(j==0){dp[i][j+vec.at(i-1).first]--;}
        //(j+vec.at(i-1).first)乗の係数はかける前の係数とかけて計算して出てきた二つのうち大きい方を採用
        dp[i][j+vec.at(i-1).first]=max(dp[i][j+vec.at(i-1).first],dp[i-1][j+vec.at(i-1).first]);
        //j乗の係数も二つのうち大きい方を採用
        dp[i][j]=max(dp[i][j],dp[i-1][j]);
      }
      //最大価値を更新
      maxvalue=max(maxvalue,dp[i][j]);
      maxvalue=max(maxvalue,dp[i][j+vec.at(i-1).first]);
    }
  }
  cout<<maxvalue<<endl;
}

Measured memory_bytes: 64688
#include <stdio.h>
#include <stdlib.h>

int stack[200];
int top = 0;

void push(int);
int pop();

int main() {
    char input[4];
    int a, b;

    while (scanf("%s", input) != EOF) {
        if (input[0] == '+') {
            push(pop() + pop());
            continue;
        }
        if (input[0] == '-') {
            a = pop();
            b = pop();
            push(b - a);
            continue;
        }
        if(input[0] == '*') {
            push(pop() * pop());
            continue;
        }
        push(atoi(input));
    }
    printf("%d\n", pop());
}

void push(int n) {
    stack[top++] = n;
}

int pop() {
    return stack[--top];
}



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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<ll> S(N);
    ll sum=0;
    for(int i=0;i<N;i++){
        cin>>S[i];
        sum+=S[i];
    }
    sum/=2;
    ll a=0;
    for(int i=0;i<N;i++){
        if(i%2==0) a+=S[i];
        else a-=S[i];
    }
    cout<<a;
    ll b;
    for(int i=0;i<N-1;i++){
        b=S[i]*2-a;
        cout<<" "<<b;
        a=b;
    }
    cout<<endl;
}



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



int main(){
    int a, b, c, x;
    cin >> a >> b >> c;
    int M = max(a, max(b, c));
    int r = (a + b + c) % 2;
    if (M % 2 == r) x = M;
    else x = M + 1;

    cout << (3 * x - (a + b + c)) / 2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#include <numeric>
#include <stdio.h>
#include<cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  if(n % 2 == 1) {
    cout << (n / 2) +1 << endl;
  } else {
    cout << n /2 << endl; 
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b;

int main(){
  cin >> a;
  if(a>=1200) cout << "ARC" << endl;
  else cout << "ABC" << endl;

  
  return 0;
}



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

#define int long long

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

signed main() {
    int appear[200001] = {};
    int N, K, kinds = 0;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if (appear[A] == 0) {
            kinds++;
        }
        appear[A]++;
    }
    sort(appear, appear + 200001);
    int ans = 0;
    for (int i = 0, ind = 0; i < kinds - K; i++, ind++) {
        ans += appear[ind];
        if (ans == 0) {
            i--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  char s[4];
  int i,j;
  int count=0;
  scanf ("%s",&s);
  for(i=0;i<4;i++){
    for(j=0;j<4;j++){
      if(s[i]==s[j]){
        count++;
      }
    }
  }
  if(count!=8){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n;
    t = 1;
    while(t--) {
     cin >> n;
     cout << n / 3 << endl;
    }
    return 0;
}


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

int main(){
	int ax, ay;
	char f[12][12];
	bool flag = false;

	for(int y=0 ; y<12 ; y++){
		for(int x=0 ; x<12 ; x++){
			f[y][x] = 0;
		}
	}

	while( 1 ){
		for(int i=0 ; i<8 ; i++) {
			if( scanf("%s", f[i]) == EOF ){
				flag = true;
				break;
			}
		}
		if(flag) break;

		for(int i=0 ; i<64 ; i++){
			if(f[i/8][i%8]=='1'){
				ax = i%8;
				ay = i/8;
				break;
			}
		}
		if( f[ay+1][ax]=='1' && f[ay][ax+1]=='1' && f[ay+1][ax+1]=='1' ){
			printf("A\n");
		}else if( f[ay+1][ax]=='1' && f[ay+2][ax]=='1' && f[ay+3][ax]=='1' ){
			printf("B\n");
		}else if( f[ay][ax+1]=='1' && f[ay][ax+2]=='1' && f[ay][ax+3]=='1' ){
			printf("C\n");
		}else if( f[ay][ax+1]=='1' && f[ay+1][ax+1]=='1' && f[ay+1][ax+2]=='1' ){
			printf("E\n");
		}else if( f[ay+1][ax]=='1' && f[ay+1][ax+1]=='1' && f[ay+2][ax+1]=='1' ){
			printf("F\n");
		}else if( f[ay][ax+1]=='1' && f[ay+1][ax]=='1' && f[ay+1][ax-1]=='1' ){
			printf("G\n");
		}else if( f[ay+2][ax-1]=='1' && f[ay+1][ax]=='1' && f[ay+1][ax-1]=='1' ){
			printf("D\n");
		}
	}
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;
#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define tr(c,i) 	for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) 	((c).find(x) != (c).end())

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

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

	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n-1; i++)
	{
		cin>>a[i];
	}
	ll sum=a[0];
	for(ll i=0; i<n-2; i++)
	{
		if(a[i] > a[i+1])
			sum+=a[i+1];
		else sum+=a[i];
	}
	sum+= a[n-2];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
// abc144_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> F[i];

    sort(ALL(A));
    sort(ALL(F), greater<ll>());

    ll ok = 1e12+1;
    ll ng = -1;
    while (ok - ng > 1){
        ll x = (ok + ng) / 2;

        ll tmp = 0;
        REP(i, N){
            tmp += max(A[i] - (x / F[i]), 0ll);
        }
        if (tmp <= K){
            ok = x;
        } else {
            ng = x;
        }
    }

    print(ok);

    return 0;
}


Measured memory_bytes: 3456
N = int(input())
 
result = 0
for i in range(1, int(N**0.5)+1):
  # 偽物が通ってしまう．sample 2 の時，999999ずれる
  if (N - i) % i == 0:
    temp = (N - i) // i
    if temp != 0 and N // temp == N % temp:
      result += temp
      
print(int(result))

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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll N, M;
    cin >> N >> M;
    vector<ll> H;
    vector<int> Ans(N, 1);
    rep(i, N){
        ll h;
        cin >> h;
        H.push_back(h);
    }
    rep(i, M){
        ll a, b;
        cin >> a >> b;
        ll ha, hb;
        ha = H.at(a-1);
        hb = H.at(b-1);
        if(ha<hb) Ans.at(a-1) = 0;
        if(ha>hb) Ans.at(b-1) = 0;
        if(ha==hb){
            Ans.at(a-1) = 0;
            Ans.at(b-1) = 0;
        }
    }
    out(accumulate(all(Ans), 0));
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 4644