akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	int n, m, X, Y, in;
	vi x, y;
	cin >> n >> m >> X >> Y;
	rep(i, n) {
		cin >> in;
		x.push_back(in);
	}
	rep(i, n) {
		cin >> in;
		y.push_back(in);
	}
	int xp = *max_element(all(x));
	int yp = *min_element(all(y));
	bool ans = false;
	range(i, xp + 1, yp + 1) {
		if (X<i&&i<=Y)ans = true;
	}
	cout << (ans ? "No War" : "War") << endl;


}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)

	first := n[0]
	last := n[3]

	if (n[1] == first && n[2] == first) || (n[1] == last && n[2] == last) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

Measured memory_bytes: 512
#include<stdio.h>
void func(int,int);
int n,m,max,cnt;
int a[100][100];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(void)
{
	int i,j;
	while(1)	{	
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)	break;
		max=0;
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				a[i][j]=0;
			}
		}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				scanf("%d",&a[i][j]);
			}
		}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				if(a[i][j]==1){
					cnt=1;
					func(i,j);
					a[i][j]=1;
				}	
			}
		}	
		printf("%d\n",max);
	}	
	return 0;
}
void func(int y,int x)
{
	int i,j,xx,yy;
	//printf("%d %d\n",y,x);
	a[y][x]=0;
	if(max<cnt) max=cnt;	
	for(i=0;i<4;i++){
		xx=x+dx[i]; yy=y+dy[i];
		if(xx<=n&&yy<=m&&xx>=0&&yy>=0&&a[yy][xx]==1){
			cnt++; func(yy,xx);
			a[yy][xx]=1; cnt--;
		}
	}
}

Measured memory_bytes: 2612
import java.util.*;

public class Main{
	
	private static final Scanner scan = new Scanner(System.in)
							.useDelimiter("[,\\s]+");

	public static void main(String[] args){

		while(scan.hasNext()){
			double[] x = new double[4];
			double[] y = new double[4];
			for(int i = 0; i < 4; i++){
				x[i] = scan.nextDouble();
				y[i] = scan.nextDouble();
			}
			boolean flag = isIntersect(x[0], y[0], x[2], y[2], x[1], y[1], x[3], y[3])
			 && isIntersect(x[1], y[1], x[3], y[3], x[0], y[0], x[2], y[2]);
			System.out.printf("%s\n", flag? "YES" : "NO");
		}
	}

	public static boolean isIntersect(double x1, double y1, double x2, double y2,
					 double x3, double y3, double x4, double y4){
		boolean result = false;
		double tb = (x1-x2)*(y3 -y1)+(y1-y2)*(x1- x3);
		double td = (x1-x2)*(y4 -y1)+(y1-y2)*(x1- x4);
		if(tb*td < 0){
			result = true;
		}
		return result;
	}
} 

Measured memory_bytes: 28480
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <stdio.h>
//end of libraries ;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define INF 3999999999999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
string s , s1;
int main(){
fcin;
	cin >> s >> s1;
	string s2 ="";
	for(int i = 0 ; i < s1.length()-1 ; i++){
		s2 += s1[i];
	}
	if(s==s2) cout<<"Yes\n";
	else cout<<"No\n";

}

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

int main(void){
    int N;
    cin >> N;
    char S;
    for(int i{0}; i<N; ++i){
        cin >> S;
        if(S=='Y'){
            cout << "Four" << endl;
            return(0);
        }
    }
    cout << "Three" << endl;
}


Measured memory_bytes: 256
n, x, y = map(int, input().split())
cnt_dist = [0] * (n - 1)
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        dist = min(j - i, abs(x - i) + 1 + abs(j - y))
        cnt_dist[dist - 1] += 1
print(*cnt_dist, sep='\n')

Measured memory_bytes: 3444
// lannisters don't act like fools
#include <bits/stdc++.h>
using namespace std;
#define yah_faster_baby ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


void solve() {

    int n;
    cin >> n;
    long long a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    long long int sum = a[n - 1];
    int count = n - 2;
    for (int i = n - 2; i >= 0, count > 0; i--) {
        if (count >= 2) {
            sum += (2 * a[i]);
            count -= 2;
        }
        else if (count >= 1) {
            sum += (a[i]);
            break;
        }
    }
    cout << sum << endl;
}



int main() {
    yah_faster_baby
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif // ONLINE_JUDGE
    solve();
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int a,b;cin>>a>>b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

int josephus(int n,int k){
	if(n == 1)return 0;
	else return (josephus(n-1,k) + k) % n;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,k,m;
	while(cin >> n >> k >> m,n){
		cout <<  (josephus(n - 1,k) + m) % n + 1<< endl;
	}
  return 0;
}

Measured memory_bytes: 3272
h,w,k=map(int,input().split())
s=[]
Sh=[0]*h
Sw=[0]*w
cnt=[]
Th=[]
Tw=[]
for i in range(h):
    s.append(input())

for i in range(h):
    cnt.append(s[i].count('#'))

for i in range(w):
    c=0
    for j in range(h):
        if s[j][i]=='#':
            c+=1
    cnt.append(c)
#cntの1~hは　行　の#の個数。h+1~wは　列　の#の個数

#関数の定義
def cheak(s,i,j):
    if s[i][j]=='#':
        return 1
    else:
        return 0

def rech(k):
    totalh=0
    if k==h:
        for i in range(h):
            if Sh[i]==1:
                totalh+=cnt[i]
        #print(Sh, totalh)
        th=Sh.copy()
        Th.append(th)
        Th.append(totalh)
        return
    rech(k+1)
    Sh[k]=1
    rech(k+1)
    Sh[k]=0

def recw(k):
    totalw=0
    if k==w:
        for i in range(w):
            if Sw[i]==1:
                totalw+=cnt[h+i]
        #print(Sw, totalw)
        tw=Sw.copy()
        Tw.append(tw)
        Tw.append(totalw)
        return
    recw(k+1)
    Sw[k]=1
    recw(k+1)
    Sw[k]=0

total=sum(cnt[0:h])
ans=0
'''
for i in range(h):
    for j in range(w):
        if total-(cnt[i]+cnt[h+j]-cheak(s,i,j))==k:
            ans+=1
'''
rech(0)
recw(0)
#print(Th)
#print(Tw)

for i in range(2**h):
    for j in range(2**w):
        cheaktotal=0
        for p in range(h):
            for q in range(w):
                if Th[2*i][p]==1 and Tw[2*j][q]==1:
                    cheaktotal+=cheak(s,p,q)
        if total-Th[2*i+1]-Tw[2*j+1]+cheaktotal==k:
            ans+=1
print(ans)


Measured memory_bytes: 9196
<?php
fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));

$ans = 0;

for ($i= 1; $i < $N; $i++) {
    if ($a[$i - 1] == $a[$i]) {
        $ans++;
        $i++;
    }
}

echo $ans . PHP_EOL;


Measured memory_bytes: 4856
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A, B, M; cin >> A >> B >> M;
    vector<int> a(A, 0);
    vector<int> b(B, 0);
    int tmp_a = 10e9 + 1, tmp_b = 10e9 + 1;
    for (int i = 0; i < A; ++i) {
        cin >> a[i];
        tmp_a = min(tmp_a, a[i]);
    }
    for (int i = 0; i < B; ++i) {
        cin >> b[i];
        tmp_b = min(tmp_b, b[i]);
    }
    int ans = tmp_a + tmp_b;
    for (int i = 0; i < M; ++i) {
        int x, y, z; cin >> x >> y >> z;
        if (ans > (a[x - 1] + b[y - 1]) - z) ans = (a[x - 1] + b[y - 1]) - z;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 4004
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

const int N = 1e5;
ll x[N], y[N];

int used[N];

// 数え上げ用
map<ll, set<pair<ll, int>>> x2yC;
map<ll, set<pair<ll, int>>> y2xC;
// 遷移用
map<ll, set<pair<ll, int>>> x2y;
map<ll, set<pair<ll, int>>> y2x;

ll d;

template<class S, class T, class U>
void update(S &x2y, T &y, U &v, ll val, int i) {
  auto &s = x2y[val];
  auto fir = s.lower_bound(make_pair(y[i] - d, 0));
  auto las = fir;
  while(las != s.end() && las->first <= y[i] + d) {
    if(used[las->second] == 0) v.emplace_back(las->second);
    used[las->second] = 1;
    ++las;
  }
  s.erase(fir, las);
}

const ll linf = 1e18;
const int inf = 1e9;

template<class S, class T>
void mycopy(S &x2y, T &x2yC) {
  for(auto &p : x2y) {
    auto &s = x2yC[p.first];
    int i = 0;
    for(auto &e : p.second) {
      s.emplace(e.first, i++);
    }
    s.emplace(linf, i);
  }
}

template<class S, class T>
inline int cnt(S &x2yC, T &y, ll val, int i) {
  auto &s = x2yC[val];
  return s.upper_bound(make_pair(y[i] + d, inf))->second - s.lower_bound(make_pair(y[i] - d, 0))->second;
}

set<pair<ll, ll>> pts;

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

  int a, b;
  cin >> a >> b;
  a--; b--;

  for(int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    x[i] = u + v;
    y[i] = u - v;
    x2y[x[i]].emplace(y[i], i);
    y2x[y[i]].emplace(x[i], i);
    pts.emplace(x[i], y[i]);
  }

  mycopy(x2y, x2yC);
  mycopy(y2x, y2xC);

  d = max(abs(x[a] - x[b]), abs(y[a] - y[b]));
  vector<int> v;
  v.emplace_back(a);
  v.emplace_back(b);
  used[a] = used[b] = 1;

  ll ans = 0;

  while(v.size()) {
    int i = v.back();
    v.pop_back();
    update(x2y, y, v, x[i] + d, i);
    update(x2y, y, v, x[i] - d, i);
    update(y2x, x, v, y[i] + d, i);
    update(y2x, x, v, y[i] - d, i);
    ans += cnt(x2yC, y, x[i] + d, i);
    ans += cnt(x2yC, y, x[i] - d, i);
    ans += cnt(y2xC, x, y[i] + d, i);
    ans += cnt(y2xC, x, y[i] - d, i);
    for(int j = -d; j <= d; j += d * 2) for(int k = -d; k <= d; k += d * 2)
    ans -= pts.count(make_pair(x[i] + j, y[i] + k));
  }

  assert(ans % 2 == 0);
  cout << ans / 2 << endl;
  return 0;
}


Measured memory_bytes: 113664
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 2333333
const int MOD=1e9+7;
ll fac[SZ],rfac[SZ];
ll qp(ll a,ll b)
{
	ll x=1; a%=MOD;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
int C(int a,int b)
{
	if(b>a||b<0) return 0;
	return fac[a]*rfac[b]%MOD*rfac[a-b]%MOD;
}
int main()
{
	fac[0]=1;
	for(int i=1;i<SZ;++i) fac[i]=fac[i-1]*i%MOD;
	rfac[SZ-1]=qp(fac[SZ-1],MOD-2);
	for(int i=SZ-1;i;--i) rfac[i-1]=rfac[i]*i%MOD;
	ll ans=0; int n; cin>>n;
	for(int i=0;i<n-1;++i)
	{
		int b=n-1-i,a=n-1-b;
		ans+=(C(a+b,b)-C(a-1,b))%MOD*fac[i]%MOD*fac[n-1-i];
		ans%=MOD;
	}
	ans=(ans%MOD+MOD)%MOD;
	cout<<ans<<"\n";
}


Measured memory_bytes: 36736
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <vector>
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 10005;
const double pi = acos(-1.0);

int n,m,x;
int a[maxn][maxn];
int p[maxn];
int num[maxn];
int ans = INF;

void dfs(int s, int price)
{
    if(s == n + 1)
    {
        for(int i = 1; i <= m; i ++)
            if(p[i] < x)
                return ;
        ans = min(ans, price);
        return ;
    }
    dfs(s + 1, price);
    for(int i = 1; i <= m; i ++)
        p[i] += a[s][i];
    dfs(s + 1, price + num[s]);
    for(int i = 1; i <= m; i ++)
        p[i] -= a[s][i];
}

int main()
{
    while(cin >> n >> m >> x)
    {

        for(int i = 1; i <= n; i ++)
        {
            cin >> num[i];
            for(int j = 1; j <= m; j ++)
                cin >> a[i][j];
        }
        dfs(1,0);
        if(ans > 1e9)
            cout << -1 << endl;
        else 
            cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3664
#include<iostream>
#include<stdlib.h>
#define D(x) cout<<"D:"<<#x<<'='<<x<<endl;
using namespace std;
typedef long long ll;
inline ll next(void)
{
	ll k;
	cin>>k;
	return k;
}
ll num[5][5];
bool t[5][5];
int main(void)
{
//	freopen("$.in", "r", stdin);
//	freopen("$.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	char *str = (char*)malloc(10*sizeof(char));
	str = "No";
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			cin>>num[i][j];
	while(cin>>n)
		for(int i = 0; i < 3; i++)
			for(int j = 0; j < 3; j++)
				if (num[i][j] == n) t[i][j] = 1;
	for(int i = 0; i < 3; i++)
		if ((t[i][0] && t[i][1] && t[i][2]) || (t[0][i] && t[1][i] && t[2][i])) str = "Yes";
	if ((t[0][0] && t[1][1] && t[2][2]) || (t[0][2] && t[1][1] && t[2][0])) str = "Yes"; 
	cout<<str<<endl; 
	return 0;
}


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

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        int pi;
        cin >> pi;
        p[i] = pi;
    }
    p.push_back(0);
    for (int i = 0; i < n; i++) {
        if (p[i] == i+1) {
            ans++;
            if (p[i+1] == i+2) {
                i++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INL inline
#define REG register
#define DB double
#define LDB long double
#define ULL unsigned long long
#define LL long long

#define RPT(i,x,y) for (REG int i=(x);i<(y);i++)
#define DRPT(i,x,y) for (REG int i=(x);i>(y);i--)
#define MST(a,b) memset((a),(b),sizeof(a))
#define MRK() cout<<"Mark"<<endl;
#define WRT(x) cout<<#x<<" = "<<(x)<<endl;

#define MAXN 10000
#define MAXM 10000
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5

#define _ 0
using namespace std;

int n;
int a[210000];
int s[210000];
int cnt;
int main()
{
	cin>>n;
	RPT(i,1,n+1)
		scanf("%d",&a[i]);
	DRPT(i,n,0)
	{
		int tmp=0;
		for (int j=2*i;j<=n;j+=i)
			tmp+=s[j];
		if (tmp%2==a[i])
			s[i]=0;
		else
		{
			s[i]=1;
			cnt++;
		}
	}
	cout<<cnt<<endl;
	RPT(i,1,n+1)
		if (s[i])
			printf("%d ",i);
	return ~~(0^_^0);
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

ll f(ll a){
  if(a%2 == 1) return 0;
  ll cnt = 0;
  cnt += 1 + f(a/2);
  return cnt;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<ll> A;
  REP(i, N){
    ll tmp; cin >> tmp;
    if(tmp%2 == 0){
      A.push_back(tmp);
    }
  }
  ll ans = 0;
  REP(i, A.size()){
    ans += f(A[i]);
  }
  cout << ans << endl;
}

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

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


int main(void){
	int w, h, n, i;
	scanf("%d%d%d", &w, &h, &n);
	int l = 0, r = w, t = h, b = 0;
	rep(i, n){
		int x, y, a;
		scanf("%d%d%d", &x, &y, &a);
		if(a == 1)l = max(l, x);
		else if(a == 2)r = min(r, x);
		else if(a == 3)b = max(b, y);
		else t = min(t, y);
	}
	if(b >= t || l >= r) puts("0");
	else printf("%d\n", max(0, (t - b) * (r - l)));
	
	return 0;
}

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

import static java.lang.Integer.parseInt;

/**
 * Entrance Examination
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int m, nmin, nmax;
			m = parseInt(st.nextToken());
			nmin = parseInt(st.nextToken());
			nmax = parseInt(st.nextToken());
			if ((m | nmin | nmax) == 0) break;

			int[] ns = new int[m];
			for (int i = 0; i < m; i++) {
				ns[i] = parseInt(br.readLine());
			}

			int max = -1, n = nmin;
			for (int i = nmin - 1; i < nmax; i++) {
				int gap = ns[i] - ns[i + 1];
				if (max <= gap) {
					max = gap;
					n = i + 1;
				}
			}
			System.out.println(n);
		} //end while
	} //end main
}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n;
    cin >> n;
    map<string, int> s;
    REP(i, 0, n) {
        string x;
        cin >> x;
        auto it = s.find(x);
        if (it == s.end())
            s.insert(make_pair(x, 1));
        else
            it->second++;
    }
    lli m;
    cin >> m;
    REP(i, 0, m) {
        string x;
        cin >> x;
        auto it = s.find(x);
        if (it != s.end())
            it->second--;
    }
    int ans = 0;
    REPIT(it, s) {
        ans = max(it->second, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n;
ll cnt=0;
ll r,g,b;
string s;

int main() {
    ios::sync_with_stdio(false);
    cin>>n>>s;
   for(int i=0;i<n;++i){
       for(int j=i+1;j<n;++j){
           int k=j+(j-i);
           if(k>n-1) continue;
           if(s[i]!=s[j] && s[j]!=s[k] && s[i]!=s[k]) cnt++;
       }
   }

   for(int i=0;i<n;++i){
       if(s[i]=='R') r++;
       else if(s[i]=='G') g++;
       else b++;
   }
   printf("%lld\n",r*g*b-cnt);


    return 0;
}

Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n; cin >> n;
  	int a[n]; for(int i=0;i<n;i++) cin>>a[i];
  	int ans=0,move=1;
  	while(true){
      ans++;
      if(a[move-1]==2) break;
      else move=a[move-1];
      if(ans>n) {ans=-1;break;} 
    }
  	cout<< ans << endl;
    return 0;
}

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

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

Measured memory_bytes: 624
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main( void )
{
  int d,n=0;
  map<int,int> m;
  while( 1 ){
    cin>>d;
    if( cin.eof() ) break;
    if( m.find( d ) == m.end() ) m[d]=0;
    m[d]++;
  }
  for( map<int,int>::iterator it = m.begin(); it != m.end(); ++it )
    if( it->second > n ) n = it->second;
  for( map<int,int>::iterator it = m.begin(); it != m.end(); ++it )
    if( it->second == n ) cout << it->first << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
#define ALL(a)  (a).begin(),(a).end()
//小数点の表し方 cout << fixed << setprecision(5);


int main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a),q(b),r(c),s;
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
    for(int i=0;i<b;i++){
        cin >> q[i];
    }
    for(int i=0;i<c;i++){
        cin >> r[i];
    }
    sort(ALL(p),greater<int>());
    sort(ALL(q),greater<int>());
    //sort(ALL(r),greater<int>());
    for(int i=0;i<x;i++){
        r.push_back(p[i]);
    }
    for(int i=0;i<y;i++){
        r.push_back(q[i]);
    }
    sort(ALL(r),greater<int>());
    ll ans = 0;
    for(int i=0;i<x+y;i++){
        ans += r[i];
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2552
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(x==0 && y==0){break;}
            if(x>y){
                int tmp = x;
                x = y;
                y = tmp;
            }
            System.out.println(x + " " + y);
        }
    }
}


Measured memory_bytes: 36040
S = input()
N = len(S)

result = [0] * N

k = 0

for i in range(N):
    if S[i] == 'R':
        j = 1
        k += 1
        if S[i+1] == 'L':
            result[i] += k//2 + k%2
            result[i+1] += k // 2
            k = 0
        while S[i+j] == 'L':
            if j % 2 == 0:
                result[i] += 1
            else:
                result[i+1] += 1
            j += 1
            if i + j == N:
                break


for i in result:
    print(i, end = ' ')


Measured memory_bytes: 4848
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n == 1) System.out.println("Hello World");
    if (n == 2) {
      int a = sc.nextInt(); int b = sc.nextInt(); 
      System.out.println(a+b);
    }
  }
}

Measured memory_bytes: 21716
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))


class BPostdocs {
public:
    void solve(std::istream &in, std::ostream &out) {
      string t;
      in >> t;
      REP(i, t.length()) {
        if (t[i] == '?') {
          t[i] = 'D';
        }
      }
      out << t << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  BPostdocs solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a,d,res;
map<int,vector<pair<int,int> > >mp;
int pre(int x){//the number of d's in the prefix x numbers
	return x*(x-1)/2;
}
int suf(int x){//the number of d's in the suffix x numbers
	return (2*n-1-x)*x/2;
}
vector<pair<int,int> >v;
signed main(){
	scanf("%lld%lld%lld",&n,&a,&d);
	if(d==0){
		if(!a)puts("1");
		else printf("%lld\n",n+1);
		return 0;
	}
	if(d<0)a+=(n-1)*d,d=-d;
	for(int i=0;i<=n;i++){
		int j=n-i;
		int base=a*(i-j);
		int up=suf(i)-pre(j);
		int dw=pre(i)-suf(j);
		base+=dw*d;
		int id=base%(2*d);
		if(id<0)id+=2*d;
		int x=(base-id)/(2*d),y=x+(up-dw)/2;
		mp[id].push_back(make_pair(x,y));
	}
	for(map<int,vector<pair<int,int> > >::iterator it=mp.begin();it!=mp.end();it++){
		v=it->second;
		sort(v.begin(),v.end());
		int rb=-1e18;
		for(int i=0;i<v.size();i++){
			rb=max(rb,v[i].first);
			res+=max(0ll,v[i].second-rb+1);
			rb=max(rb,v[i].second+1);
		}
	}
	printf("%lld\n",res);
	return 0;
} 

Measured memory_bytes: 22144
code=[*97..122].each_with_object([]){|c,h|h.push c.chr}
x = gets.to_i
ans=[]
(1..11).each do |i|
    break if x<=0
    q=x.divmod(26)
    x=q[0]
    x-=1 if q[1]==0
    ans.push code[q[1]-1]
end
puts ans.reverse.join

Measured memory_bytes: 14312
#include<bits/stdc++.h>
#define LL long long
#define MOD (LL)1000000007
#define pi acos(-1.0)
#define ULL unsigned long long
#define mem_1(str) memset(str,-1,sizeof(str))
#define mem0(str) memset(str,0,sizeof(str))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define INF 999999999
using namespace std;
int main()
{
	int n;
	int num2=0,sum=0,minn=10000;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a); 
		sum+=a;
		if(a%10==0) num2++;
		else minn=min(minn,a);
	}
	if(num2==n)
	{
		printf("0\n");
	}
	else
	{
		if(sum%10!=0)
		{
			printf("%d\n",sum); 
		}
		else
		{
			printf("%d\n",sum-minn);
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+7;
int n;const int mod=1e9+7;
ll quickmod(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y&1)
		{
			ans*=x;ans%=mod;
		}
		x*=x;x%=mod;y>>=1;
	}
	return ans;
}
int main()
{
	ll x,y;cin>>x>>y;
	if((x+y)%3!=0)
	{
		cout<<0<<endl;
		return 0;
	}
	else
	{
		ll tmp=(x+y)/3;
		ll num=y-tmp;
		if(num<0||num>tmp)
		{
			cout<<0<<endl;
			return 0;
		}
		//cout<<num<<" "<<tmp<<endl;
		ll ans=1;
		for(int i=tmp;i>=tmp-num+1;i--)
		{
			ans*=i;ans%=mod;
		}
		for(int i=num;i>=1;i--)
		{
			ans*=quickmod(i,mod-2);ans%=mod;
		}
		cout<<ans<<endl;
	}
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
vector<int>n;
long long dp[10009][2][109];

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

  int l=s.size();
  for(int i=0;i<l;i++){
    n.push_back(s[i]-'0');
  }

  dp[0][0][0]=1;
  for(int i=0;i<l;i++){
    for(int smaller=0;smaller<2;smaller++){
      for(int j=0;j<d;j++){
        for(int x=0;x<=(smaller?9:n[i]);x++){
          dp[i+1][smaller||x<n[i]][(j+x)%d] += dp[i][smaller][j];
          dp[i+1][smaller||x<n[i]][(j+x)%d] %= mod;
        }
      }
    }
  }

  cout<<(dp[l][0][0]+dp[l][1][0]-1+mod)%mod<<endl;

  return(0);
}


Measured memory_bytes: 17408
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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


int main()
{
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    REP(i, N-1){
        int A, B;
        cin >> A >> B;
        --A, --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    int K;
    cin >> K;
    vector<int> ans(N, -1);
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
    REP(i, K){
        int V, P;
        cin >> V >> P;
        --V;
        ans[V] = P;
        q.push({P, V});
    }

    while(!q.empty()){
        auto tmp = q.top(); q.pop();
        int val = tmp.first;
        int pos = tmp.second;
        for(int v: G[pos]){
            if(ans[v] == -1){
                ans[v] = val+1;
                q.push({ans[v], v});
            }else{
                if(abs(ans[v]-val) != 1){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    REP(i, N) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 8320
#include <iostream>

using namespace std;

const int NMAX=100;
int n,a,b;

int main(){

    cin >> n >> a >> b;
    if((b-a)%2==1){
        cout << "Borys\n";
    }
    else{
        cout << "Alice\n";
    }
    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    if (s.size() + 1 != t.size()) {
        cout << "No" << endl;
        return 0;
    }
    if (t.substr(0, s.size()) != s) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


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

long long int N, A[100010];
int main() {
    scanf("%lld", &N);
    long long int sum = 0, div = N*(N+1)/2;
    for(int i=0; i<N; i++) {
        scanf("%lld", &A[i]);
        sum += A[i];
    }

    bool ok = (sum % div == 0);
    long long int sum_op = sum / div;
    for(int i=0; i<N; i++) {
        long long int val = A[i] - A[(i+1)%N] + sum_op;
        ok &= (val >= 0 && val % N == 0);
    }
    printf("%s\n", ok ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 896
N = int(input())
Alist = []
Blist = []
cost = 0
for i in range(N):
    A, B = map(int, input().split())
    Alist.append(A)
    Blist.append(B)
    
k = zip(Blist, Alist)
q = sorted(k)
for i in range(N):
    cost += q[i][1]
    if cost > q[i][0]:
        print("No")
        break
    if i == N-1:
        print("Yes")

Measured memory_bytes: 32516
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, W;
int x[1000];
int sum[1001];
int memo[1001][1001];
int CASE;
int dfs(int idx, int e){
  int& res = memo[idx][e];
  if(~res) return res;
  int s = sum[idx] - sum[idx - e];
  if(idx == N){
    return max(0, s - W);
  }
  res = dfs(idx + 1, e + 1);
  res = min(res, abs(s + x[idx] - W) + dfs(idx + 1, 0));
  return res;
}

int main(){
  CASE = 1;
  while(cin>>N>>W && N){
    printf("Case %d: ", CASE++);
    memset(sum, 0, sizeof(sum));
    memset(memo, -1, sizeof(memo));
    REP(i, N) cin>>x[i];
    REP(i, N) sum[i + 1] = sum[i] + x[i];
    cout<<dfs(0, 0)<<endl;
  }
  return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    char c;
    cin >> c;

    for(auto i : {'a', 'e', 'i', 'o', 'u'})
        if(c == i) {
            cout << "vowel" << endl;
            return 0;
        }
    cout << "consonant" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int N, Odd = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
        Odd += A.at(i) % 2;
    }
    if (Odd % 2 == 0){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

#define MAX 1001

int c[MAX][MAX];
int m,n;

void LCRLength(char *X,char *Y){
  int i,j;

  m=strlen(X);
  n=strlen(Y);

  for(i=1;i<=m;i++) c[i][0]=0;
  for(j=0;j<=n;j++) c[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
}

int main(){
  int q,i;
  char X[MAX],Y[MAX];

  scanf("%d",&q);

  for(i=1;i<=q;i++){
    scanf("%s",X);
    scanf("%s",Y);
    LCRLength(X,Y);
    printf("%d\n",c[m][n]);
  }

  return 0;
}

Measured memory_bytes: 4524
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iterator>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define VE vector<int>
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int N;
  int A[100000];
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  sort(A,A+N);
  if(A[N-1]-A[0]>1){
    Yes(0);
  }else if(A[N-1]-A[0]==1){
    int S=count(A,A+N,A[0]);
    if(S<A[N-1]&&2*(A[N-1]-S)<=N-S){
      Yes(1);
    }else{
      Yes(0);
    }
  }else{
    int num=A[0];
    if(num==N-1){
      Yes(1);
    }else{
      if(num*2<=N){
        Yes(1);
      }else{
        Yes(0);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 640
s = input()
x,y = map(int,input().split())

x_mov = []
y_mov = []

s += "T"
flag = 'x'
mov = 0
for c in s:
    if c=='F':
        mov += 1
    elif flag == 'x':
        flag = 'y'
        x_mov.append(mov)
        mov = 0
    else:
        flag = 'x'
        y_mov.append(mov)
        mov = 0

def get_pos(pos,mov_set):
    for i in mov_set:
        new_pos = set()
        for j in pos:
            new_pos.add(j+i)
            new_pos.add(j-i)
        pos = new_pos
    return pos

if s[0] =="T":
    x_pos = get_pos([0],x_mov)
else:
    x_pos = get_pos([x_mov[0]],x_mov[1:])
y_pos = get_pos([0],y_mov)

print("Yes" if x in x_pos and y in y_pos else "No")

Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdio.h>
using namespace std;
 
int main(){
    int N,X,i,K=0,ans=1;
    cin >> N >> X;
    int L[N];
    for(i=0; i<N; i++){
        cin >> L[i];
        K+=L[i];
        if(K>X){
            break;
        }
        ans++;
    }
    cout << ans;
    return 0;
}

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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	REP(i, h) cin >> a[i];
	
	bool f = true;
	while(f){
		f = false;
		REP(i, h){
			bool flg = true;
			REP(j, w){
				if(a[i][0] != a[i][j] || a[i][j] == '#') {
					flg = false;
					break;
				}
			}
			if(flg){
				for(int j = i; j < h - 1; ++j){
					a[j] = a[j + 1];
				}
				--h;
				f = true;
			}
		}
		
		REP(i, w){
			bool flg = true;
			REP(j, h){
				if(a[0][i] != a[j][i] || a[j][i] == '#') {
					flg = false;
					break;
				}
			}
			if(flg){
				for(int j = 0; j < h; ++j){
					for(int k = i; k < w - 1; ++k){
						a[j][k] = a[j][k + 1];
					}
				}
				--w;
				f = true;
			}
		}
	}
	
	REP(i, h){
		REP(j, w){
			cout << a[i][j];
		}
		cout << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
while True:
    n = int(raw_input())
    if n == 0:
        break
    R = sorted([map(int,raw_input().split()) for _ in xrange(n)],
                key = lambda x:sum(60*m+s for m,s in zip(x[1::2],x[2::2])))
    print "\n".join(map(str,[R[0][0],R[1][0],R[-2][0]]))

Measured memory_bytes: 5548
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
using namespace std;

int main(){
    string S;
    string T;
    cin >> S;
    cin >> T;

    bool restorable = true;
    if(T.size() > S.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for(int i = S.size() - T.size(); i >= 0; i--){
        restorable = true;
        for(int j = 0; j < T.size(); j++){
            if(S[i + j] != '?' && S[i+j] != T[j]){
                restorable = false;
                break;
            }
        }
        if(restorable){
            S.replace(i, T.size(), T);
            for(int j = 0; j < S.size(); j++){
                if(S[j] == '?'){
                    S[j] = 'a';
                }   
            }
            break;
        }
    }

    if(!restorable){
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << S << endl;
    }

    return 0;
}

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> e(n + 1);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<bool> vis(n);
  vector<int> p1, p2;
  function<void(int)> dfs = [&](int v) {
    vis[v] = true;
    p1.push_back(v);
    for (int i : e[v]) {
      if (!vis[i]) {
        dfs(i);
        break;
      }
    }
  };
  dfs(1);
  swap(p1, p2);
  dfs(1);
  reverse(p1.begin(), p1.end());
  p1.pop_back();
  p1.insert(p1.end(), p2.begin(), p2.end());
  cout << p1.size() << endl;
  for (int i : p1) {
    cout << i << ' ';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 10104
#include<iostream>
#include<cstdio>
#include<stdlib.h>

using namespace std;
  typedef struct xy{
    int x;
    int y;
    int sum;
  }xys;
int main(){
  int h,w,d,tmp;
  cin>>h>>w>>d;
  xys a[h*w];
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      cin>>tmp;
      a[tmp].x=i;
      a[tmp].y=j;
    }
  }
  for(int j=1;j<h*w+1;j++){
    if(j>d)a[j].sum=a[j-d].sum
               +abs(a[j-d].x-a[j].x)+abs(a[j-d].y-a[j].y);
    else a[j].sum=a[j].x+a[j].y;
    /* cout<<j<<":"<< a[j].sum<<"$"<<a[j].x<<"$"<<a[j].y
        <<"#"<<abs(a[j-d].x-a[j].x)<<"#"
        <<abs(a[j-d].y-a[j].y)<<endl;*/
  }
  int q,l,r;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>l>>r;
    cout<<a[r].sum-a[l].sum<<endl;
  }
  return 0;
}


Measured memory_bytes: 2176
import scala.io.StdIn.readLine
import scala.math.{max,min}

object Main extends App {

  def getResult():Unit = {
    val Array(n,x) = readLine.split(" ").map(_.toInt)
    if( n!=0 || x!=0) {
      println( ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) => sum + max(min(n,(x-i+1)/2)- max(i+1,x-i-n),0)})
      getResult()
    }
  }

  getResult()
}

Measured memory_bytes: 44036
import java.util.Scanner;
public class Main {
     
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int L = 0;
        int R = 0;
        for(int i = 0; i < n; i++) {
            String s1 = stdIn.next();
            String s2 = stdIn.next();
             
            if(s1.compareTo(s2) == 0) {
                L++;
                R++;
            }
            else if(s1.compareTo(s2) < 0) {
                L += 3;
            }
            else {
                R += 3;
            }
        }
         
        System.out.println(R + " " + L);
    }
}


Measured memory_bytes: 30072
#include<iostream>
#include<vector>
#include<algorithm>
int main(void){
    std::vector<int> v;
    int N,tmp,count=0,ans=0;
    std::cin>>N;
    while(std::cin>>tmp){
        v.push_back(tmp);
    }
    std::sort(v.begin(), v.end());
    tmp=-1;
    for(auto x:v){
        if(tmp!=x){
            ans+=count%2;
            tmp=x;
            count=1;
        }else{
            count++;
        }
    }
    ans+=count%2;
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
int main()
{
int n;
while(scanf("%d",&n)==1)
{
int a[n],i,max,sum=0;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
max=a[0];
for(i=1;i<n;i++)
{
if(max<a[i])
max=a[i];
}
for(i=0;i<n;i++)
sum+=a[i];
printf("%g",sum-max/2.0);
}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <string.h>
#include <set>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath> 
#include <queue> 
#include <stdlib.h>
#include <cstdio>
#include <cstdlib> 
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
using namespace std;  
int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	cout<<(x-a)%b; 
    return 0;  
}  

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

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

	vector<int> a(n), b(n), c(n-1);
	for(int &e : a)
		cin >> e;
	for(int &e : b)
		cin >> e;
	for(int &e : c)
		cin >> e;
	
	long long xD = 0;
	for(int i = 0;i < n-1;++i)
		if(a[i+1] - a[i] == 1)
			xD += (c[a[i]-1]);
	for(int i = 0;i < n;++i)
		xD += (b[a[i]-1]);

	cout << xD << '\n';
}


Measured memory_bytes: 3604
def C_WriteandErase(N, A):
    import collections
    count_dict = collections.Counter(A)  # 言った数字の出現回数
    ans = 0
    for k, v in count_dict.items():  # 数字kはv回出たことを意味する
        if v % 2 == 0:  # kが偶数回出たなら、kは紙に残らない
            pass
        else:
            ans += 1  # kが奇数回出たなら、その数字は残っている
    return ans

N = int(input())
A = [int(input()) for i in range(N)]
print(C_WriteandErase(N, A))

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

int main(){
  double a,an,sum;
  while(cin>>a){
    an=a*2;
    sum=0;
    for(int i=0;i<5;i++){
      sum+=a+an;
      a=an/3;
      an=a*2;
    }
    printf("%.8lf\n",sum);
  }
  return 0;
}

Measured memory_bytes: 3104
#include<stdio.h>
int main(){
  char s[10];
  char t[10];
  int i,a;
  scanf("%s",s);
  scanf("%s",t);
  a = 0;
for(i=0;i<3;i++){
  if(s[i] == t[i]) a++;
}
  printf("%d",a);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

//////////

signed main()
{
    fastio;
    int f[5]={};
    for(int i=0;i<6;++i)
    {
        int d;
        cin>>d;
        f[d]++;
    }
    if(f[1]==3||f[4]==3||f[3]==3||f[2]==3)
        cout<<"NO";
    else
        cout<<"YES";
}

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

const int ms = 1e5 + 30;

int n;
long long l;
char s[ms];
int trie[ms][2], z;
bool term[ms];

void add() {
  int cur = 0;
  for (int i = 0; s[i]; i++) {
    int id = s[i] - '0';
    if (trie[cur][id] == -1) {
      memset(trie[z], -1, sizeof trie[z]);
      trie[cur][id] = z++;
    }
    cur = trie[cur][id];
  }
  term[cur] = 1;
}

long long xr;

long long nimber(long long x) {
  long long ans = 1;
  if (x == 0) return 0;
  while ((x & 1) == 0) {
    ans <<= 1;
    x >>= 1;
  }
  return ans;
}

void search(int cur, int sz = 0) {
  if (term[cur]) return;
  for (int i = 0; i < 2; i++) {
    if (trie[cur][i] == -1) xr ^= nimber(l - sz);
    else search(trie[cur][i], sz + 1);
  }
}

int acc[100], mk[100], nim[100];

int main() {
  cin >> n >> l;
  memset(trie[0], -1, sizeof trie[0]);
  z = 1;
  for (int i = 0; i < n; i++) {
    scanf(" %s", s);
    add();
  }
  search(0);
  if (xr) puts("Alice");
  else puts("Bob");
  // cout << 0 << '\n';
  // int acc;
  // for (int x = 1; x < 20; x++) {
  //   memset(mk, 0, sizeof mk);
  //   acc = 0;
  //   mk[acc]++;
  //   for (int i = 1; i < x; i++) {
  //     acc ^= nim[x - i];
  //     mk[acc]++;
  //   }
  //   int n = 0;
  //   while (mk[n]) n++;
  //   nim[x] = n;
  //   cout << n << ' ' << x << '\n';
  // }
}

Measured memory_bytes: 5760