akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int> 
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    } 
} 

bool cmp(vector<int> a,vector<int> b){
    return a.at(1)>b.at(1);
}

signed main() {
    int i;
    int N,M;
    cin>>N>>M;
    vin A(N);
    vector<vector<int> > BC(M,vector<int>(2));
    rep(0,N){
        cin>>A.at(i);
    }
    rep(0,M){
        cin>>BC.at(i).at(0)>>BC.at(i).at(1);
    }

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

    vin tmp(0);
    int cnt=0;
    
    for(int i=0;i<M;i++){
        for(int j=0;j<BC.at(i).at(0);j++){
            tmp.push_back(BC.at(i).at(1));
            cnt++;
            if(cnt>N) break;
        }
        if(cnt>N) break;
    }
    
    int m;
    if(tmp.size()>N){
        m=N;
    }
    else{
        m=tmp.size();
    }

    rep(0,m){
        if(A.at(i)<tmp.at(i)){
            A.at(i)=tmp.at(i);
        }
        else{
            break;
        }
    }

    cout<<accumulate(A.begin(),A.end(),0LL)<<endl;
    // rep(0,N){
    //     cout<<A.at(i)<<" ";
    // }
    // cout<<endl;
return 0;
}

Measured memory_bytes: 7672
const main = (input: string) => {
  const lines = input.trim().split("\n")
  const [N, M] = lines[0].split(" ").map(str => parseInt(str))
  const checkList: [number, string][] = lines.slice(1).map(line => {
    const [s, c] = line.split(' ');
    return [parseInt(s) - 1, c];
  });

  for (let i = 0; i < Math.pow(10, N); i++) {
    const strNum = i.toString();

    if (strNum.length === N && checkList.every(sc => strNum[sc[0]] === sc[1])) {
      console.log(strNum)
      process.exit(0);
    }
  }
  console.log(-1);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7756
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 入力を取得
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if(a==b && a==c){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    // 出力
    // System.out.println(Math.min(count[0],count[1]) *2);
  }
}

Measured memory_bytes: 22100
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n;
string a;
int main()
{
	int i;
	cin >> a;
	if (a.size() >= 4 && a[0] == 'Y' && a[1] == 'A' && a[2] == 'K' && a[3] == 'I') {
		cout << "Yes";
	} else {
		cout << "No";
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string str;
  cin >> str;
  if(str == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(str == "Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s,t;
    int a=0;
    t="CODEFESTIVAL2016";
    cin>>s;
    for(int i=0;i<16;i++){
        if(s[i]!=t[i])a++;
        
    }
    cout<<a<<endl;
    return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<bool> ac(N);
    vector<int> cnt(N);
    for(int i=0; i<M; i++){
        int p;  string S;
        cin >> p >> S;
        p--;
        if(ac[p]) continue;

        if(S == "AC") ac[p] = true;
        if(S == "WA" && !ac[p]){
            cnt[p]++;
        }
    }

    int accepted = 0;
    int wrong = 0;
    for(int i=0; i<N; i++){
        if(ac[i]){
            accepted++;
            wrong+=cnt[i];
        }
    }
    cout << accepted << " " << wrong << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
  int n, d[50];
  int i, j;
  int total;
  scanf("%d", &n);
  total=0;
  scanf("%d", &d[0]);
  for(i=1; i<n; i++){
    scanf("%d", &d[i]);
    for(j=0; j<i; j++){
      total += d[j] * d[i];
    }
  }
  printf("%d\n", total);
  return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main() {
    input!(n: u64, m: u64);
    println!(
        "{}",
        if n == 1 && m == 1 {
            1
        } else if n == 1 {
            m - 2
        } else if m == 1 {
            n - 2
        } else {
            (m - 2) * (n - 2)
        }
    );
}


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

using namespace std;

int main()
{

  int sx, sy, tx, ty;
  vector<char> S;

  cin >> sx >> sy >> tx >> ty;

  int dx , dy;
  dx = tx-sx;
  dy = ty-sy;

  for ( int i = 0; i < dx; ++i ) S.push_back('R');
  for ( int i = 0; i < dy; ++i ) S.push_back('U');

  for ( int i = 0; i < dx; ++i ) S.push_back('L');
  for ( int i = 0; i < dy; ++i ) S.push_back('D');

  S.push_back('D');
  for ( int i = 0; i < dx; ++i ) S.push_back('R');
  S.push_back('R');
  S.push_back('U');
  for ( int i = 0; i < dy; ++i ) S.push_back('U');
  S.push_back('L');

  S.push_back('U');
  for ( int i = 0; i < dx; ++i ) S.push_back('L');
  S.push_back('L');
  S.push_back('D');
  for ( int i = 0; i < dy; ++i ) S.push_back('D');
  S.push_back('R');

  for ( int i = 0; i < S.size(); ++i ) cout << S[i]; cout << "\n";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();
        int num = Integer.parseInt(line);

        ArrayList<String> list = new ArrayList<String>();

        for (int i = 0; i < num; i++) {
            list.add(br.readLine());
        }


        findCard("S", list);
        findCard("H", list);
        findCard("C", list);
        findCard("D", list);

    }

    static void findCard(String mark, ArrayList list){
    	for (int i = 1; i <= 13; i++) {
            if(list.contains(mark + " " + i) == false){
                System.out.println(mark + " " + i);
            }
        }
    }

}

Measured memory_bytes: 24180
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int R;
int G;
int B;
int N;
int main(){
  int i;
  int res = 0;
  rd(R);
  rd(G);
  rd(B);
  rd(N);
  for(i=(0);i<(N+1);i+=(R)){
    int j;
    for(j=(0);j<(N+1-i);j+=(G)){
      if((N-i-j)%B==0){
        res++;
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// int R, G, B, N;
// {
//   int res = 0;
//   rd(R,G,B,N);
//   rep(i,0,N+1,R) rep(j,0,N+1-i,G) if((N-i-j)%B==0) res++;
//   wt(res);
// }


Measured memory_bytes: 256
n = int(input())
red=[list(map(int, input().split())) for _ in range(n)]
blue=[list(map(int, input().split())) for _ in range(n)]

ans = 0
red.sort()
blue.sort()
usedred = [0]*n
usedblue = [0]*n
for i, (a, b) in enumerate(blue):
    if not(usedblue): continue
    maxy = -1
    maxj = 0
    for j, (c, d) in enumerate(red):
        if c < a:
            if d < b and d > maxy and not(usedred[j]):
                maxy = d
                maxj = j
        else:
            break
    if maxy >= 0:
        usedblue[i] = 1 
        usedred[maxj] = 1
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int dif(vector<string> s,vector<string> t){
	int n = s.size();
	int res = 0;
	rep(i, n)
	{
		rep(j,n){
			if(s[i][j] != t[i][j])
				res++;
		}
	}
	return res;
}

vector<string> r(vector<string> s){
	int n = s.size();
	vector<string> temp(n, string(n, '0'));
	rep(i, n)
	{
		rep(j,n){
			temp[j][n - i - 1] = s[i][j];
		}
	}
	return temp;
}
vector<string> l(vector<string> s){
	int n = s.size();
	vector<string> temp(n, string(n, '0'));
	rep(i, n)
	{
		rep(j,n){
			temp[n-j-1][i] = s[i][j];
		}
	}
	return temp;
}

int main(){
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int score = 0;
	rep(i, n - 1) if (s[i] == s[i + 1]) score++;
	cout << min(score + 2 * k, n - 1) << endl;

	return 0;
}

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

int main() {
    int a,b,c,k,ans;
    cin >> a >> b >> c >> k;
    ans = 0;
    while( a >= b){
        ans += 1;
        b *= 2;
    }
    while ( b >= c){
        ans += 1;
        c *= 2;
    }
    if(ans <= k){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
# coding: utf-8
# Your code here!A=int(input())

H,W,D=[int(i) for i in input().split()]
#AA=[]
KAZU=[0]*(H*W+1)
#print(KAZU)
for i in range(H):
#    AA=[int(i) for i in input().split()]
#    A.append(AA)
#    AA=[int(i) for i in input().split()]
    for (j, a) in enumerate(input().split()):
#        print(j,a)
        KAZU[int(a)] = [i,j] 

def cost(x, y):
    return abs(KAZU[x][0] -KAZU[y][0]) + abs(KAZU[x][1] -KAZU[y][1])

COSTMAT=[0]*(H*W+1)
for i in range(H*W+1):
    if i > D:
        COSTMAT[i] = COSTMAT[i-D]+cost(i,i-D)
    else:
        COSTMAT[i] = 0
    
    


#print(KAZU)
Q=int(input())
for i in range(Q):
    l,r=[int(i) for i in input().split()]
    print(COSTMAT[r]-COSTMAT[l])
    




    


Measured memory_bytes: 17088
/*
author:Manson
date:7.7.2018
theme:
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1005;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	set<string>se;
	string s1;
	cin>>s1;
	se.insert(s1);
	char ch = s1[s1.length()-1];
	for(int i =1;i <n;i++){
		cin>>s1;
		if(s1[0] != ch){
			cout<<"No"<<endl;
			return 0;
		}
		ch = s1[s1.length()-1];
		se.insert(s1);	
	}
	if(se.size()!=n){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
//Author:- S_Aditya
//Date created:- 24 February 2019

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=4e2+4;

ll dp[N][N],a[N];

int main()                  
{
    int n;
    
    scn(n);
    
    rep(i,0,n)
    lscn(a[i]);
    
    //dp[i][j] tells the optimum merging cost for the segment [i,j].
    //dp[i][i]=0, no cost of merging
    
    for(int len=2;len<=n;len++)
    {
        for(int i=0;i+len-1<n;i++)
        {
            int j=i+len-1;
            
            dp[i][j]=1e18;
            
            ll sum=0;
            
            for(int k=i;k<=j;k++)
            sum+=a[k];
            
            for(int k=i;k<j;k++)
            {
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum);
            }
        }
    }
    
    ll ans=dp[0][n-1];
    
    printf("%lld",ans);
} 


Measured memory_bytes: 1536
#include<stdio.h>

int main()
{
	double max=0.0,min,h;
	int n=0;

	while(scanf("%lf",&h)!=EOF)
	{
		if(!n)
			min=h;
		if(max<h)
			max=h;
		if(min>h)
			min=h;
		n++;
	}

	printf("%lf\n",max-min);
	return 0;
}

Measured memory_bytes: 648
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

import sys
input=sys.stdin.readline
n=I()
a=L()
suma=sum(a)
dic={}
for i in a:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1
q=I()
for i in range(q):
    b,c=L()
    if b not in dic:
        print(suma)
        continue
    if c not in dic:
        suma-=b*dic[b]
        dic[c]=dic[b]
        suma+=c*dic[c]
        del dic[b]
    else:
        suma-=b*dic[b]
        suma+=c*dic[b]
        dic[c]+=dic[b]
        del dic[b]
    print(suma)

Measured memory_bytes: 20700
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k;
ll a[MAXN];
int b[MAXN];
double E[MAXN];
ll sumb[MAXN],sumbi[MAXN],sumbi2[MAXN];
ll get_sum(int l,int r)
{
    return sumb[r]-sumb[l-1];
}
ll get_sumb(int l,int r)
{
    return sumbi[r]-sumbi[l-1];
}
ll get_sumb2(int l,int r)
{
    return sumbi2[r]-sumbi2[l-1];
}
ll get_res(int l,int r)
{
    return get_sumb(l,r)-(l-1)*get_sum(l,r);
}
ll calc(int l,int r)
{
    int len=r-l-2;
    return (1LL*r*r-r)*get_sum(l+1,r-1)-(2*r-1)*get_sumb(l+1,r-1)+get_sumb2(l+1,r-1);
}
double get_ans(int l,int r)
{
    ll dif=a[r]-a[l];
    double x=(dif-2*((r-l)*get_sum(l+1,r-1)-get_res(l+1,r-1)))/(double)(r-l);
    return a[l]*(r-l)+x*(r-l-1)*(r-l)/2+calc(l,r);
}
vector<int> v;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++) scanf("%d",&b[i]);
    int id=-1; ll val=-1;
    for(int i=1;i<=n;i++) if(a[i]>val) {val=a[i]; id=i;}
    rotate(a+1,a+id,a+n+1); rotate(b+1,b+id,b+n+1);
    a[n+1]=a[1]; b[n+1]=b[1];
    for(int i=1;i<=n+1;i++)
    {
        sumb[i]=sumb[i-1]+b[i];
        sumbi[i]=sumbi[i-1]+1LL*i*b[i];
        sumbi2[i]=sumbi2[i-1]+1LL*i*i*b[i];
    }
    v.push_back(1);
    for(int i=2;i<=n+1;i++)
    {
        while(v.size()>=2&&get_ans(v[v.size()-2],v.back())+get_ans(v.back(),i)<get_ans(v[v.size()-2],i)) v.pop_back();
        v.push_back(i);
    }
    double ans=0.0;
    for(int i=1;i<(int)v.size();i++) ans+=get_ans(v[i-1],v[i]);
    E[1]=E[n+1]=a[1];
    printf("%.10f\n",ans/(double)n);
    return 0;
}

Measured memory_bytes: 11172
n,d = map(int,input().split())
def lens(a,b):
    s = 0
    for i,j in zip(a,b):
        s+=(i-j)**2
    return s**0.5
c = []
ans = 0
for _ in range(n):
    c.append(list(map(int,input().split())))
for i in range(n):
    for j in range(i):
        l = lens(c[i],c[j])
        if l == int(l):
            ans+=1
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;


vector<string> split(const string &s, char c = ' '){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}


int main(){
	map<int,int> m;
	set<int> s1, s2;
	string s;
	bool f = true;
	while(getline(cin,s)){
		if(s ==""){
			f = false;
			continue;
		}
		vector<string> v = split(s,',');
		int a = atoi(v[0].c_str());
		m[a]++;
		if(f) s1.insert(a);
		else s2.insert(a);
	}

	for(auto it = m.begin(); it != m.end(); it++){
		if(s1.count(it -> fi) && s2.count(it -> fi)) cout<<it->fi<<" "<<it->se<<endl;
	}
}

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

int main(void){
    int A, B, C, D, num1, num2, result;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    
    if(A > B){
        num1 = B;
    }else{
        num1 = A;
    }
    if(C > D){
        num2 = D;
    }else{
        num2 = C;
    }
    result = num1 + num2;
    printf("%d\n", result);
    exit(0);
}

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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  X -= Z;
  cout << X / (Y + Z) << endl;
}

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

int main()
{
  char a,b;
  cin >>a >> b;
  
  int p=0,q;
  if (a=='H')p=1;
  if (a=='D')p=-1;
  
  if (b=='H')q=1;
  if (b=='D')q=-1;
  
  
  if (p*q > 0){
  	cout << "H";
  }else{
    cout << "D";
  }
    return 0;
}






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

int main(){
    int ans[100000]={0};
    int n;
    cin>>n;
    ans[n]=1;
    for(int i=2;i<100000;i++){
        if(n%2==0){
            if(ans[n/2]==1){
                cout<<i<<endl;
                break;
            }else {
                ans[n/2]++;
                n=n/2;
            }
        }else{
            if(ans[(3*n)+1]==1){
                cout<<i<<endl;
                break;
            }else{
                ans[(3*n)+1]++;
                n=(3*n)+1;
            }
        }
    }
}

Measured memory_bytes: 640
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
def zoro(items):
    return items[0] == items[1]
for a, b, c in zip(d[:], d[1:], d[2:]):
    if zoro(a) and zoro(b) and zoro(c):
        print('Yes')
        exit(0)
print('No')
    


Measured memory_bytes: 9152
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

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

    ll res = 0;
    for (int i = 0; i < N-1; i++){
	ll psum = a[i]+a[i+1];
	if (a[i] > x){
	    res += (a[i]-x)+a[i+1];
	    a[i] = x;
	    a[i+1] = 0;
	} else if (psum > x){
	    res += psum-x;
	    a[i+1] -= psum-x;
	}
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
import collections

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

c = collections.Counter()

ans = 0
s = 0
c[0] += 1
for a in A:
    s += a
    s %= M
    ans += c[s]
    c[s] += 1

print(ans)


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

int main(void){
    int n,a;
    std::cin >> n >> a;

    int box = n%500;
    if(n <= a || box <= a){
        std::cout << "Yes";
        return 0;
    }

    else std::cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N,T;
	scanf("%d %d",&N,&T);

	int* table = new int[T+1];
	for(int i = 0; i <= T; i++)table[i] = 0;

	int left,right;
	for(int i = 0; i < N; i++){
		scanf("%d %d",&left,&right);
		table[left]++;
		table[right]--;
	}

	for(int i = 1; i <= T; i++)table[i] += table[i-1];

	int maximum = 0;
	for(int i = 0; i <= T; i++)maximum = max(maximum,table[i]);

	printf("%d\n",maximum);

	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=pow(2,31)-1;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;using namespace std;
void segment_tree(){
	int a,b;
	cin>>a>>b;
	{
		int c=1;
		while(1){
			c*=2;
			if(a<c){a=c;break;}
		}
	}
	vi in(a*2,inf);
	while(b--){
		int c,d,e;
		cin>>c>>d>>e;
		if(c==0){
			d+=a;
			in[d]=e;
			while(d!=1){
				d/=2;
				in[d]=min(in[2*d],in[2*d+1]);
			}
		}else{
			int mi=inf;
			vi q;
			q.pb(0);
			q.pb(a-1);
			q.pb(1);
			while(q.size()){
				int w=q.back();
				q.pop_back();
				int y=q.back();
				q.pop_back();
				int x=q.back();
				q.pop_back();
				if(y<d||e<x)continue;
				if(d<=x&&y<=e){mi=min(in[w],mi);continue;}
				int tmp=(x+y+1)/2;
				q.pb(x);q.pb(tmp-1);q.pb(w*2);
				q.pb(tmp);q.pb(y);q.pb(w*2+1);
			}
			cout<<mi<<endl;
		}
	}
}
void heihou_bunnkatu(){http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A
	int a,b;
	cin>>a>>b;
	vi in(a,inf);
	#define B 200
	vi t(a/B+1,inf);
	while(in.size()%B)in.pb(inf);
	while(b--){
		int c,d,e;
		cin>>c>>d>>e;
		if(c==0){
			in[d]=e;
			int q=d/B;
			t[q]=inf;
			rep(i,B)t[q]=min(t[q],in[q*B+i]);
		}else{
			int mi=inf;
			e++;
			while(d<e){
				if(d%B==0&&d+B<=e){
					d+=B-1;
					mi=min(mi,t[d/B]);
				}else mi=min(mi,in[d]);
				d++;
			}
			cout<<mi<<endl;
		}
	}
}
int main(){
	segment_tree();
}

Measured memory_bytes: 2060
n,m = map(int,input().split())
x = [int(x) for x in input().split()]
x.sort()

if n > m:
    print(0)
else:
    ans = []
    for i in range(m-1):
        ans.append(x[i+1] - x[i])
    ans.sort()
    print(sum(ans[0:(m-n)]))


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

using namespace std;

typedef long long LL;

const int N = 110;

int main()
{
    string s;
    cin >> s;

    int res = 0x3f3f3f3f;
    for(int i = 2; i < s.size(); i++)
    {
        int x = (s[i - 2] - '0') * 100 + (s[i - 1] - '0') * 10 + s[i] - '0';
        if(abs(x - 753) < res) res = abs(x - 753);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


class CombMod:

    def __init__(self, N, MOD=10**9 + 7):

        N = N + 1
        inv = [0] * N
        fact = [0] * N
        fact_inv = [0] * N

        inv[0] = 0
        inv[1] = 1
        for n in range(2, N):
            q, r = divmod(MOD, n)
            inv[n] = inv[r] * (-q) % MOD

        fact[0] = 1
        for n in range(1, N):
            fact[n] = n * fact[n - 1] % MOD

        fact_inv[0] = 1
        for n in range(1, N):
            fact_inv[n] = fact_inv[n - 1] * inv[n] % MOD

        self.fact = fact
        self.fact_inv = fact_inv
        self.inv = inv

    def comb(self, n, r, mod=10**9 + 7):
        return self.fact[n] * self.fact_inv[r] % mod * self.fact_inv[n - r] % mod

    def perm(self, n, r, mod=10**9 + 7):
        return self.fact[n] * self.fact_inv[n - r] % mod


def main():

    N, M = in_nn()
    mod = 10**9 + 7
    c = CombMod(M)

    ans = 0
    for i in range(N + 1):
        t = c.comb(N, i)

        t *= (-1)**(i % 2)
        t %= mod

        t *= c.perm(M, i)
        t %= mod

        t *= c.perm(M - i, N - i)
        t %= mod

        t *= c.perm(M - i, N - i)
        t %= mod

        ans += t
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 82528
use std::io::*;
use std::str::FromStr;
//標準入力(s)
//let s:Vec<char> = read_s::<String>().chars().collect();
fn read_s<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let mut s:Vec<char>= read_s::<String>().chars().collect();;
    let mut j:bool = true;

    let mut count=0;
    if s[0]!='A'{j=false} else {s[0]='a'};
    for i in 2..(s.len()-1){
        if s[i]=='C'{
            count += 1;
            s[i] = 'c';
        }
    }
    if count !=1{j=false};
    let mut tj = true;
    for c in s {
        if c < 'a' || 'z' < c {
            tj = false;
        }
    }
    if j {if !tj {j = tj}};
    if j {println!("AC")} else {println!("WA")};
}


Measured memory_bytes: 4352
#include<stdio.h>

#define MAX 1000000

int parent(int);
int left(int);
int right(int);
void buildMaxHeap(void);
void maxHeapify(int);

int Heap;
int A[MAX + 1];

int main(){
    
  int i;

  scanf("%d",&Heap);
  for(i=1;i <=Heap; i++) {
      scanf("%d",&A[i]);
}

for(i=Heap/2;i>=1;i--) {maxHeapify(i);
}

for(i=1;i<=Heap;i++){
  printf(" %d",A[i]);
}
    printf("\n");

  return 0;
}

int parent(int x){
  return x/2;
}

int left(int y){
  return 2*y;
}

int right(int z){
  return 2*z+1;
}

void maxHeapify(int i){
  int l,r,largest,temch;

  l=left(i);
  r=right(i);

  if(l<=Heap && A[l]>A[i]) largest = l;
  else largest = i;
  if(r<=Heap && A[r] > A[largest]) {
largest = r;
}

  if(largest != i){
    temch = A[i];
    A[i] = A[largest];
    A[largest] = temch;
    maxHeapify(largest);
  }
}

void buildMaxHeap(void){
int i;
  for(i=Heap/2;i>1;i--) {
maxHeapify(i);
}
}



Measured memory_bytes: 3692
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		//String s = sc.next();
		/*
		List<Integer> list = new ArrayList<>();
		for(int i=0;i<n;i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);*/
		int[] x = new int[n];


		for(int i=0;i<n;i++) {
			x[i] = sc.nextInt();
		}

		//boolean flag = true;
		int currentBest = 300000000;

		for(int i=0;i<n-k+1;i++) {
			if(x[i+k-1]<=0) {
				if(currentBest>Math.abs(x[i])) {
					currentBest = Math.abs(x[i]);
				}
			}else {
				if(x[i]>=0) {
					if(currentBest>Math.abs(x[i+k-1])) {
						currentBest = Math.abs(x[i+k-1]);
					}
				}else {
					int a = Math.max(Math.abs(x[i]), Math.abs(x[i+k-1]));
					a += Math.min(Math.abs(x[i]), Math.abs(x[i+k-1]))*2;
					if(currentBest>a) {
						currentBest = a;
					}
				}
			}



		}
		System.out.println(currentBest);
	}
	/*
	static boolean check(int t,int x,int y) {
		if(Math.abs(x)+Math.abs(y)>t)return false;
		if((Math.abs(x)+Math.abs(y)-t)%2==0) {
			return true;
		}else {
			return false;
		}

	}
	*/
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (a-c)*(b-d) << endl;
}

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


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

#define int long long
#define f first

#define s second
using namespace std;

template<typename T> using vc = vector<T>;
using pii=pair<int, int>;

void xmax(int & a, int b){
    a=max(a, b);
}
void xmin(int& a, int b){
    a=min(a, b);
}

void print(vc <int> & a, string s){
    cerr << s << " : ";
    for (int i=0; i<a.size(); i++){
        cerr <<a[i] << " ";
    }
    cerr << endl;
}

int mod = 1e9+7;
int pow (int a, int exp){
    if (exp == 0) return 1;
    if (exp%2 == 0) return pow(a*a%mod, exp/2);
    return a*pow(a, exp-1)%mod;
}
int inv (int a){
    return pow(a, mod -2);
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LOCAL_RUN
    freopen("input.txt", "r", stdin);
    int ttt;
    cin >> ttt;
    while(ttt--){
    #endif // LOCAL_RUN
    int n, k;
    cin >> n >> k;
    k = min(n-1, k);
    vc <int> n_fac (n+1);
    vc <int> n1_fac (n);
    vc <int> fac (n+1);
    fac[0]=1;
    for (int i=1; i<=n; i++){
        fac[i] = (i*fac[i-1])%mod;
    }
    for (int i=0; i<=n; i++){
        n_fac[i] = (fac[n] * inv((fac[i]*fac[n-i])%mod))%mod;
    }
    for (int i=0; i<=n-1; i++){
        n1_fac[i] = (fac[n-1] * inv((fac[i]*fac[n-i-1])%mod))%mod;
    }
    int sum = 0;
    for (int i=0; i<=k; i++){
        int add = n_fac[i]*n1_fac[i]%mod;
        sum=(sum+add)%mod;
    }
    cout << sum << "\n";

    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
}


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

int main () {
  long long N, K;
  cin >> N >> K;
  
  if (K % 2 == 1) {
    
    // Kの倍数でしか無い
    long long sub = N / K;
    cout << sub * sub * sub << endl;  
  }  
  else {
    long long answer = 0;

    // Kの倍数の時
    long long sub = N / K;
    answer = answer + sub * sub * sub;
    
    // Kが倍数で無い時
    if (N >= K) {
      N = N - K / 2;
      sub = N / K + 1;
    }
    else {
      if (N == K/2) {
        sub = 1;  
      }    
      else {
        sub = 0;  
      }
    }
    answer = answer + sub * sub * sub;
    
    cout << answer << endl;   
  }
}

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

int main() {
	// your code goes here
	long long x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	long long a=x/d;
	//cout<<a<<" #"<<"\n";
	if(x==d && k%2==0){
		cout<<x;
		return 0;
	}
	if(a==d && k%2!=0){
		cout<<0;
		return 0;
	}
	if(k<=a){
		cout<<x-k*d<<"\n";
	}
	else{
		long long b=x-a*d;
		b=abs(b);
		long long e=k-a;
		long long c=d-b;
		if(e%2==0){
			cout<<b;
		}
	//	cout<<b<<" %"<<"\n";
	else cout<<c;
		
	//	cout<<c<<"^"<<"\n"
	}
	return 0;
}

Measured memory_bytes: 3628
s=input()

s=list(s)

for i in range(1,len(s)):
    if i==1:
        if s[i] == s[i-1]:
            print(i,i+1)
            exit()
    elif s[i] == s[i-1]:
        print(i,i+1)
        exit()
    elif s[i] == s[i-2]:
        print(i-1,i+1)
        exit()
print(-1, -1)

Measured memory_bytes: 49520
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int dp[2003];
int n , m;

int alpha(int cur)
{
	if(cur <= 0)return cur==0;
	int &abs = dp[cur];
	if(abs != -1)return abs;
	int ans = 0;
	loop(i,3,2001)
	{
		ans += alpha(cur - i);
		ans %= M;
	}

	return abs = ans%M;
}

void solve()
{
	int n;
	cin >> n;
	mset(dp , -1);
	int ans = alpha(n);

	cout << ans;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)

int main() {
	int N, D, ans = 0;
	cin >> N >> D;
	int i, j, k;
	int x[10][10];

	rep(i, N) {
		rep(j, D) {
			cin >> x[i][j];
		}
	}
	rep(i, N) {
		rep(j, i)//j<i　ダブルカウントしないように
		{
			int s = 0;
			int t = 0;
			rep(k, D) {
				int s = x[i][k] - x[j][k];
				t += s * s;
			}
			if (ceil(sqrt(t)) == floor(sqrt(t)))
			{
				ans++;
			}
		}	
	}
	cout << ans << endl;
	return 0;
}

                


Measured memory_bytes: 256
// Problem : C - Longest Path
// Contest : Virtual Judge - Sheet 2# ( DP Basics , styles ( 0/1 , Knapsack , LIS , LCS ,CC )
// URL : https://vjudge.net/contest/362954#problem/C
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 1e5 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
vector<vector<int>>g;
int mem[N];
int dfs(int node) {
	int& ret = mem[node];
	if (~ret)return ret;
	ret = 0;
	for (int nxt : g[node]) {
		ret = max(ret,dfs(nxt)+1);
	}
	return ret;
}
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	clr(mem, -1);
	int n, m;
	cin >> n >> m;
	g = vector<vector<int>>(n + 1);
	for (int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		g[u].push_back(v);
	}
	int ans = 0;
	
	for (int i = 1; i <= n; i++) {
		ans = max(ans, dfs(i));
	}
	cout << ans;

}


Measured memory_bytes: 11120
from collections import deque


def marge_ponds(lx, area_of_pond):
    global ponds
    if ponds and ponds[-1][0] > lx:
        return marge_ponds(lx, area_of_pond + ponds.pop()[1])
    return area_of_pond


terrains = input().strip()
x, last_x, ponds = 0, deque(), deque()

for terrain in terrains:
    if terrain == '\\':
        last_x.append(x)
    elif terrain == '/':
        if last_x:
            lx = last_x.pop()
            ponds.append((lx, marge_ponds(lx, x - lx)))
    x += 1

print(sum(pond[1] for pond in ponds))
ponds.appendleft((0, len(ponds)))
print(' '.join(map(str, [pond[1] for pond in ponds])))

Measured memory_bytes: 8416
module AOJ_Volume0104;

import std.stdio,std.string,std.conv;

int main()
{
	string f[101];
	while(true)
	{
		string[] s = readln.chomp.split(" ");
		int n = s[0].to!int;
		int m = s[1].to!int;

		if(n == 0 && m == 0) break;

		foreach(i;0..n)
		{
			f[i] = readln.chomp;
		}

		int memo[101][101];
		foreach(i;0..101)
		{
			foreach(j;0..101)
			{
				memo[i][j] = 0;
			}
		}

		int i=0,j=0;
		while(f[i][j] != '.' && memo[i][j] == 0)
		{
			memo[i][j]++;

			if(f[i][j] == '>')
			{
				j++;
			}
			else if(f[i][j] == '<')
			{
				j--;
			}
			else if(f[i][j] == 'v')
			{
				i++;
			}
			else if(f[i][j] == '^')
			{
				i--;
			}
		}

		if(memo[i][j] == 0)
		{
			writeln(j," ",i);
		}
		else
		{
			"LOOP".writeln;
		}
	}
	return 0;
}

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

string operator*(string s, int n){
    if(n==0) return "";
    if(n==1) return s;
    return s+s*(n-1);
}

int main(){
    int N;
    string s,r="";
    cin >> N >> s;

    int a=0;
    for(int i=0;i<N;i++){
        r=r+s[i];
        if(s[i]=='(') a++;
        else a--;

        if(a<0){
            a=0;
            r="("+r;
        }
    }
    string cket=")";
    cout << (r+cket*a) << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 * src.cpp
 *
 *  Created on: 2016/07/26
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=10;

int n;
int d[MAX_N],v[MAX_N];

typedef long long ll;

ll g[MAX_N];

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

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

int main(){
	do{
		cin>>n;
		if (n){
			REP(i,n){
				cin>>d[i]>>v[i];
			}
			REP(i,n-1){
				ll a,b;
				a=d[0]*v[i+1];
				b=d[i+1]*v[0];
				g[i]=b/gcd(a,b);
			}
			for (int i=n-3;i>=0;i--){
				g[i]=lcm(g[i],g[i+1]);
			}
			cout<<g[0]<<endl;
			FOR(i,1,n){
				cout<<d[0]*v[i]*g[0]/v[0]/d[i]<<endl;
			}
		}
	}while(n);
	return 0;
}

Measured memory_bytes: 1156
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<queue>
using namespace std;

int main(void)
{
	int d,t,s;
	scanf("%d %d %d",&d,&t,&s);
	if(t*s>=d)	printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1664
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<LL, LL> LLLL;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	vector<LL> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	vector<LLLL> v;
	for (int i = 0; i < m; ++i) {
		LL b, c;
		cin >> b >> c;
		v.push_back(LLLL(c, b));
	}
	sort(v.rbegin(), v.rend());
	LL ans = 0;
	int ap = 0, vp = 0;
	while (n > 0) {
		if (vp < (int)v.size() && v[vp].second == 0) {
			++vp;
		}
		if (vp < (int)v.size() && v[vp].second > 0 && v[vp].first > a[ap]) {
			ans += v[vp].first;
			v[vp].second--;
		} else {
			ans += a[ap++];
		}
		--n;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3188
a,b = map(int,input().split())

c = a*2
d = a*4
if d < b:
  print('No')
elif c == b:
    print('Yes')
elif c <= b:
     if (b-c)%2 ==0:
        print('Yes')
     else:
        print('No')
else:
     print('No')

Measured memory_bytes: 9180
#include <stdio.h>

const int dir[][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};

void explode(char field[10][10], int px, int py) {
    int i, j, x, y;
    field[py][px] = '0';
    for (i = 0; i < 4; i++) {
        for (j = 1; j <= 3; j++) {
            x = px + j * dir[i][0];
            y = py + j * dir[i][1];
            if (x < 1 || 8 < x || y < 1 || 8 < y) break;
            if (field[y][x] == '1') explode(field, x, y);
        }
    }
}

int main(void) {
    char field[10][10];
    int N, n, i, sx, sy;

    gets(field[0]);
    sscanf(field[0], "%d", &N);

    for (n = 1; n <= N; n++) {
        for (i = 0; i <= 8; i++) {
            gets(&(field[i][1]));
        }
        gets(field[0]);
        sscanf(field[0], "%d", &sx);
        gets(field[0]);
        sscanf(field[0], "%d", &sy);

        explode(field, sx, sy);

        printf("Data %d:\n", n);
        for (i = 1; i <= 8; i++) {
            puts(&(field[i][1]));
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<cstring>

int n, m;
int dp[1001];

int main()
{
	while( std::cin >> n >> m, n | m )
	{
		memset( dp, 0, sizeof( dp ) );
	
		dp[1] = 0;
		for( int i = 2; i <= n; ++i )
			dp[i] = ( dp[i-1] + m ) % i;

		std::cout << dp[n] + 1 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define ll long long
#define rep(i, a) for(ll i=0; i<a; i++)
#define rep1(i, a, b) for(ll i=a; i<b; i++)
using namespace std;
typedef vector<ll> vi;
typedef vector<vi> vvi;

double fun(int n, int x, vector<vector<double>> &dp, vector<double> &p){
    if(x>n)
        return 0;
    if(n==1 && x==1)
        return dp[n][x]=p[n-1];
    if(n==1 && x==0)
        return dp[n][x]=1-p[n-1];
    if(dp[n][x]==-1)
        dp[n][x] =  fun(n-1, x, dp, p)*(1-p[n-1]) + fun(n-1, x-1, dp, p)*p[n-1];
    return dp[n][x];
}

int main(){
    int n;
    cin>>n;
    vector<double> p(n);
    vector<vector<double>> dp(n+1, vector<double> (n+1, -1));
    rep(i, n)
        cin>>p[i];
    rep(i, n+1)
        rep(j, n+1)
            dp[i][j]=-1;
    double ans = 0;
    rep1(i, 1, n+1)
        rep(j, i+1)
            fun(i, j, dp, p);
    // rep(i, n+1){
    //     rep(j, n+1)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    rep1(j, n/2+1, n+1)
        ans+=dp[n][j];
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}

Measured memory_bytes: 70656
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>

#define rep(i,n) for(int i = 0; i < n; i++)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

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

constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

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

  int n;
  cin >> n;

  vector<int> csum(n+1, 0);
  rep(i,n) {
    int w;
    cin >> w;
    csum[i+1] = csum[i]+w;
  }

  int res = inf;
  rep(i,n) {
    chmin(res, abs(csum[n]-csum[i]*2));
  }

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

Measured memory_bytes: 3656
s = gets.chomp
frag = "AC"
if s[0] != "A"
  frag = "WA"
end
count = 0;cp = nil
2.upto(s.length-2) do |i|
  if s[i] == "C"
    count += 1
    cp = i
  end
end
if count != 1
  frag = "WA"
end
s[0] = "a"
if cp != nil
  s[cp] = "c"
end
if s != s.downcase
  frag = "WA"
end
puts frag 


Measured memory_bytes: 1788
#include <stdio.h>

int main()
{

int a[10000], min, max, n, i;
long long sum = 0;
scanf("%d", &n);
for(i = 0; i < n; i++){
scanf("%d", &a[i]);
sum += a[i];
}
max = min = a[0];
for(i = 1; i < n; i++){
if(a[i] > max)max = a[i];
if(a[i] < min)min = a[i];
}
printf("%d %d %lld\n", min, max, sum);

return 0;
}




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

int main() {
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i <= x + k - 1; i++) {
    if (i != x + k - 1) {
      cout << i << " ";
    }
    else {
      cout << i;
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  int min=h[n-1]-h[0];
  for(int i=0;i<n-k+1;i++){
    if(h[k+i-1]-h[i]<min){
      min=h[k+i-1]-h[i];
    }
  }
  cout<<min<<endl;
}

Measured memory_bytes: 768
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int min=n;
    for(int i=1;i<n;i++){
      min=Math.min(calc(i)+calc(n-i),min);
    }
    System.out.println(min);
  }
  static int calc(int a){
    int res=0;
    while(a>0){
      res+=a%10;
      a/=10;
    }
    return res;
  }
}

Measured memory_bytes: 22612
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

dydx4 = ((-1,0),(0,-1),(0,1),(1,0))
h,w = map(int,input().split())
S = [input() for i in range(h)]
dp = [[inf]*w for i in range(h)]
if S[0][0] == "#": dp[0][0] = 1
else: dp[0][0] = 0
for i in range(h):
  for j in range(w):
    if i-1 >= 0:
      if S[i-1][j] == "." and S[i][j] == "#":
        dp[i][j] = min(dp[i][j],dp[i-1][j] + 1)
      else:
        dp[i][j] = min(dp[i][j],dp[i-1][j])

    if j-1 >= 0:
      if S[i][j-1] == "." and S[i][j] == "#":
        dp[i][j] = min(dp[i][j],dp[i][j-1] + 1)
      else:
        dp[i][j] = min(dp[i][j],dp[i][j-1])
print(dp[h-1][w-1])

Measured memory_bytes: 44016