akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int i; (i = int.Parse(Console.ReadLine())) != 0;) {
                var data = new Dictionary<int, int>();
                int f, s, b, l = f = s = b = 0;
                for(int m = 0; m < i; ++m) {
                    var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    var time = 0;
                    for(int n = 1; n <= 8; ++n) {
                        time += input[n] * ((n & 1) == 1 ? 60 : 1);
                    }
                    data[input[0]] = time;
                    if(m <= 1) {
                        if(m == 0) {
                            f = s = b = l = input[0];
                        }
                        else { 
                            if (data[f] > time) {
                                f = b = input[0];
                            }
                            else {
                                s = l = input[0];
                            }
                        }
                    }
                    else {
                        if(time < data[s]) {
                            s = input[0];
                        }
                        if(time < data[f]) {
                            s = f;
                            f = input[0];
                        }
                        if(time > data[b]) {
                            b = input[0];
                        }
                        if(time > data[l]) {
                            b = l;
                            l = input[0];
                        }
                    }
                }
                Console.WriteLine("{0}{3}{1}{3}{2}", f, s, b, System.Environment.NewLine);
            }
        }
    }
}

Measured memory_bytes: 6868
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main(){
	int *a=new int[1000000];
	int *b=new int[1000000];
	for(int i=0;i<1000000;i++){
		a[i]=100000;
		b[i]=100000;
	}
	for(int i=1;i<pow(6000000,0.4)+5;i++){
		int aa=(i*(i+1)*(i+2))/6;
		if(aa<1000000){
			a[aa]=1;
		}
	}
	a[0]=0;
	a[2]=2;
	a[3]=3;
	for(int i=4;i<1000000;i++){
		if(a[i]==1){
			for(int j=1;j<=1000000/i+2;j++){
				for(int k=0;k<2*i;k++){
					if(j*i+k<1000000){
						a[j*i+k]=min(a[j*i+k],j+a[k]);
					}
				}
			}
		}
	}
	for(int i=0;i<pow(6000000,0.4)/4+5;i++){
		int bb=((4*i+1)*(4*i+2)*(4*i+3))/6;
		if(bb<1000000){
			b[bb]=1;
		}
	}
	b[0]=0;
	for(int i=2;i<35;i++){
		b[i]=i;
	}
	for(int i=4;i<1000000;i++){
		if(b[i]==1){
			for(int j=1;j<=1000000/i+2;j++){
				for(int k=0;k<3*i;k++){
					if(j*i+k<1000000){
						b[j*i+k]=min(b[j*i+k],j+b[k]);
					}
				}
			}
		}
	}
	int n;
	while(cin>>n){
		if(n==0) break;
		cout<<a[n]<<" "<<b[n]<<endl;
	}
    return 0;
    delete[] a;
    delete[] b;
}

Measured memory_bytes: 8992
#include<stdio.h>

int main(){

int i,n,a[10000];

scanf("%d",&n);


for(i=0;i<n;i++){

scanf("%d",&a[i]);

}

int min=a[0],max=a[0];

long long int sum =0;

for(i=0;i<n;i++){

if(a[i]<min){

min=a[i];

}else if(a[i]>max){

max=a[i];

}

sum+=a[i];

}

printf("%d %d %lld\n",min,max,sum);

return 0;

}

Measured memory_bytes: 636
h, w = map(int, input().split())
l = []
for i in range(h):
  a = str(input())
  if a == '.'*w:
    continue
  l.append(a)

skip = []
for i in range(w):
  for j in range(len(l)):
    if l[j][i] == '#':
      break
  else:
    skip.append(i)

skip = set(skip)
l_ = [0]*len(l)
for i in range(len(l)):
  temp = ''
  for j in range(w):
    if j not in skip:
      temp += l[i][j]
  l_[i] = temp
  
for i in range(len(l_)):
  print(l_[i])

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int getDigit10(ll i){
    int cnt = 0;
    while(i > 0){i/=10;++cnt;}
    return cnt;
}

int main(){
    ll N;cin >> N;
    int ans = getDigit10(N);
    for(ll i = 1;i <= int(sqrt(N));++i){
        if(N%i != 0)continue;
        ll j = N / i;
        if(ans > getDigit10(j))
            ans = getDigit10(j);
    }

    cout << ans;
}


Measured memory_bytes: 256
def caddi2018b_b():
    n, h, w = map(int, input().split())
    boards = [list(map(int, input().split())) for _ in range(n)]
    ans = 0

    for i in range(n):
        if boards[i][0] >= h and boards[i][1]>=w:
            ans += 1
    print(ans)


caddi2018b_b()

Measured memory_bytes: 3316
N,A,B = map(int, input().split())

if A == 0:
    print(0)
# elif N <= A:
#     print(N)
# elif N < (A+B):
#     print(A)
elif N < (A+B):
    print(min(A,N))
else:
    div = int(N/(A+B))
    quob = min(N%(A+B),A)
    ans = div*A+quob
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    ll n,k;
    cin >> n >> k;
    vector<ll> h;
    REP(i,0,n){
        ll tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    ll ans = LLONG_MAX;

    //処理
    SRT(h);
    REP(i,0,n-k+1){
        chmin(ans,h[i+k-1]-h[i]);
    }

    //出力
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 1400
class unionfind():
    def __init__(self,n):
        self.par = [i for i in range(n+1)]

    def root(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self,x,y):
        rx = self.root(x)
        ry = self.root(y)
        if rx!=ry:
            self.par[max(rx,ry)] = min(rx,ry)
            
    def same(self,x,y):
        rx = self.root(x)
        ry = self.root(y)
        if rx==ry:
            return True
        else:
            return False


def main():
    n,m = map(int,input().split())
    p = [int(i) for i in input().split()]
    ans = 0
    uf = unionfind(n)
    for i in range(m):
        x,y  = map(int,input().split())
        uf.unite(x,y)
        
    for i in range(1,n+1):
        uf.root(i)
        
    for i in range(n):
        if p[i] == i+1:#ループのindexと頂点ナンバーに1の差があるから
            ans += 1
        else:
            if uf.same(p[i],p[p[i]-1])==True:
                ans += 1
            else:
                continue
    print(ans)
main()

Measured memory_bytes: 20528
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

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


int main(int argc, char *argv[])
{
	ll a, b;
	cin >> a >> b;
	
	cout << a * b / gcd(max(a, b), min(a, b)) << endl;
	return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "4 3 1", "1 2", "2 3", "3 4", "2 3" ].parse.expand.solve == "1 2 2 1" );
	assert( [ "4 2 2", "1 2", "2 3", "1 4", "2 3" ].parse.expand.solve == "1 2 2 1" );
	assert( [ "7 4 4", "1 2", "2 3", "2 5", "6 7", "3 5", "4 5", "3 4", "6 7" ].parse.expand.solve == "1 1 2 1 2 2 2" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nkl = input.front.split.to!( long[] );
	auto pqs = new long[ 2 ][ nkl[ 1 ] ];
	foreach( ref pq; pqs )
	{
		input.popFront;
		pq = input.front.split.to!( long[] );
		pq[] -= 1;
	}
	auto rss = new long[ 2 ][ nkl[ 2 ] ];
	foreach( ref rs; rss )
	{
		input.popFront;
		rs = input.front.split.to!( long[] );
		rs[] -= 1;
	}
	return tuple( nkl[ 0 ], pqs, rss );
}

auto solve( long n, long[ 2 ][] pqs, long[ 2 ][] rss )
{
	// 道路グループを判定
	auto uft_a = UnionFindTree( n );
	foreach( pq; pqs )
	{
		uft_a.unite( pq[ 0 ], pq[ 1 ] );
	}
	
	// 鉄道グループを判定
	auto uft_b = UnionFindTree( n );
	foreach( rs; rss )
	{
		uft_b.unite( rs[ 0 ], rs[ 1 ] );
	}
	
	// 道路グループの根と鉄道グループの根のペアを作成して同じペアをカウント（＝道路と鉄道の両方で接続されている都市の数）
	auto ps = new long[ 2 ][ n ];
	long[ long[ 2 ] ] cs;
	foreach( i, ref p; ps )
	{
		p = [ uft_a.root( i ), uft_b.root( i ) ];
		cs[ p ]++;
	}
	auto anss = new long[ n ];
	foreach( ref ans, p; lockstep( anss, ps ) )
	{
		ans = cs[ p ];
	}
	return anss.to!( string[] ).join( " " );
}

// UnionFind木
struct UnionFindTree
{
	private long[] ps;
	private long[] rs;
	
	public this( long n )
	{
		ps.length = n;
		ps[] = -1;
		rs.length = n;
	}
	
	public long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	public bool same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	public void unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( rs[ i ] < rs[ j ] )
		{
			ps[ j ] += ps[ i ];
			ps[ i ] = j;
		}
		else
		{
			ps[ i ] += ps[ j ];
			ps[ j ] = i;
			if( rs[ i ] == rs[ j ] ) rs[ i ]++;
		}
	}
}


Measured memory_bytes: 43132
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    string res = "";
    if (a > b)
    {
        for (int i = 0; i < a; i++)
        {
            res += to_string(b);
        }
    }
    else
    {
        for (int i = 0; i < b; i++)
        {
            res += to_string(a);
        }
    }
    cout << res << endl;
}


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

using ll=long long;
const int SIZE=1000000;
int main(){
    ll a,b;
    cin>>a>>b;
    if(b%a==0){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=1;i<SIZE;i++){
        ll N=a*i;
        ll m=N/b;
        if(m==0) continue;
        ll k=(N-m*b)/a;
        ll donyoku=N-m*b-a*k+m+k;
        ll ans=i;
        if(ans<donyoku){
            cout<<N<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

long long gcd(long long a, long long b);
long long lcm(long long a, long long b);

long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}

void solve(int N, vector<long long> A);

void solve(int N, vector<long long> A) {
  vector<long long> L(N + 1);
  vector<long long> R(N + 1);
  L[0] = 0;
  R[N] = 0;
  for (int i = 0; i < N; i++) {
    L[i + 1] = gcd(L[i], A[i]);
  }
  for (int i = N - 1; i >= 0; i--) {
    R[i] = gcd(R[i + 1], A[i]);
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, gcd(L[i], R[i + 1]));
  }
  printf("%lld\n", ans);
}

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  solve(N, A);
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;


int main() {
    int n;
    cin>>n;
    Graph G(n);
    for(int i=0;i<n;i++){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++){
            int x;
            cin>>x;
            G[u-1].push_back(x-1);
        }
    }

    queue<int>que;
    vector<int>dist(n, -1);
    dist[0]=0;

    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int nv : G[v]){
            if(dist[nv]!=-1)continue;
            que.push(nv);
            dist[nv]=dist[v]+1;
        }
    }

    for(int i=0;i<n;i++){
        cout<<i+1<<" "<<dist[i]<<endl;
    }



    return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define ll long long
#define PI pair<ll,int>
#define mo 1000000007
#define N 100005
using namespace std;
ll ds[N],dt[N],ways[N],wayt[N];
struct edge {
	int to,next,v;
} e[N*4];
int head[N],vis[N];
int n,m,s,t,tot,ans;
priority_queue<PI > q;
inline char gc() {
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read() {
	int x = 0;
	char ch = gc();
	bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a) {
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a) {
	if(a<0) {
		a=-a;
		putchar('-');
	}
	write(a);
	puts("");
}
void add(int x,int y,int v) {
	e[++tot]=(edge){
		y,head[x],v
	};
	head[x]=tot;
}
void dijkstra(int S,ll *dis,ll *way) {
	for(int i=1; i<=n; i++){dis[i]=1e18; vis[i]=way[i]=0;}
	dis[S]=0;
	way[S]=1;
	while(!q.empty())q.pop();
	q.push(PI(0,S));
	while (!q.empty()) {
		int x=q.top().second;
		q.pop();
		if (vis[x]) continue;
		vis[x]=1;
		for (int i=head[x]; i; i=e[i].next) {
			ll tmp=dis[x]+e[i].v;
			if (dis[e[i].to]>tmp) {
				dis[e[i].to]=tmp;
				way[e[i].to]=0;
				q.push(PI(-tmp,e[i].to));
			}
			if (dis[e[i].to]==tmp)way[e[i].to]=(way[e[i].to]+way[x])%mo;
		}
	}
}
int main() {
	n=read();
	m=read();
	s=read();
	t=read();
	for (int i=1; i<=m; i++) {
		int x=read(),y=read(),z=read();
		add(x,y,z);
		add(y,x,z);
	}
	dijkstra(s,ds,ways);
	ans=(long long)ways[t]*ways[t]%mo;
	dijkstra(t,dt,wayt);
	for (int i=1; i<=n; i++)
		if (ds[i]*2==ds[t]&&ds[i]+dt[i]==ds[t])
			ans=(ans+mo-(long long)ways[i]*ways[i]%mo*wayt[i]%mo*wayt[i]%mo)%mo;
	for (int x=1; x<=n; x++)
		for (int i=head[x]; i; i=e[i].next)
			if (ds[x]+e[i].v+dt[e[i].to]==ds[t])
				if (ds[x]*2<ds[t]&&dt[e[i].to]*2<ds[t])
					ans=(ans+mo-(long long)ways[x]*wayt[e[i].to]%mo*ways[x]%mo*wayt[e[i].to]%mo)%mo;
	writeln(ans);
}

Measured memory_bytes: 10996
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  
 ll n,i,j=0,sm1=0;
 string s;
 cin>>s;
 n=s.size();
 if(s.size()==1)cout<<-1<<' '<<-1;
 
 else if(s.size()==2)
 {if(s[0]==s[1])cout<<1<<' '<<2;
  else cout<<-1<<' '<<-1;
 }
 
 else 
 {
     for(i=0;i<n-3;i++)
     {map<char,int>m;
         for(j=i;j<=i+2;j++)
         { m[s[j]]++;
             if(m[s[j]]>=2)
             {
                 cout<<i+1<<' '<<j+1;return 0;
             }
         }
     }
     cout<<-1<<' '<<-1;
 }

}

Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <math.h>

using namespace std;


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

	int n, m;
	cin >> n >> m;
	int *k = new int[m];
	vector<vector<int>> s;
	int *p = new int[m];
	int max = 1;
	for (int i = 0; i < n; i++)
		max *= 2;
	for (int i = 0; i < m; i++)
	{
		cin >> k[i];
		vector<int> ss;
		for (int j = 0; j < k[i]; j++)
		{
			int x;
			cin >> x;
			ss.emplace_back(x);
		}
		s.emplace_back(ss);
	}
	for (int i = 0; i < m; i++)
	{
		cin >> p[i];
	}

	int flag = 0;
	int pattern = 0;
	for (int i = 0; i < max; i++)
	{
		int onNum = 0;
		for (int j = 0; j < m; j++)
		{	// ビットonが点いているスイッチ
			int count = 0;
			for (int ii = 0; ii < k[j]; ii++)
			{
				int f = flag;

				if ((f >> (s[j][ii] - 1)) % 2 == 1)
				{
					count++;
				}
			}
			if (count % 2 != p[j])
				continue;
			onNum++;
		}
		if (onNum == m)
			pattern++;
		flag++;
	}
		
	cout << pattern << '\n';

	delete[] k;
	delete[] p;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int x;
  	string y;
  
  	cin >> x;
    
    switch (x) {
      case 1:
        y = "0";
        break;
      case 0:
        y = "1";
        break;
    }
  
  	cout << y << endl;
  
    return 0;
    }


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

int main() {
  int h,w;
  cin >> h >> w;
  for ( int i=0; i<h; i++ ) {
    string s;
    cin >> s;
    cout << s << '\n';
    cout << s << '\n';
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;

int kaijo(int a){
  int i,ans=1;
  for(i=1;i<=a;i++){
  ans*=i;
  }
  return ans;
}

int mathC(int a,int b){

  int i,ans=1;
  if(b>a/2) b=a-b;
  for(i=1;i<=b;i++){
    ans*=(a-i+1);
    ans/=i;
  }
  
  return ans;
}

int max(int x[],int N){
  int i,max=x[0];
	for(i=1;i<N;i++){
      if(max<x[i]) max=x[i];
    }
  return max;
}

int min(int x[],int N){
  int i,min=x[0];
	for(i=1;i<N;i++){
      if(min>x[i]) min=x[i];
    }
  return min;
}

void solve(void){
	int a,b,c;
  string ans;
  cin >> a >> b>>c;
  
  if(a==b&&a==5&&c==7){
    ans="YES";
  }else if(a==c&&a==5&&b==7){
    ans="YES";
  }else if(b==c&&b==5&&a==7){
    ans="YES";
  }else{
  	ans="NO";
  }
  
  cout << ans <<endl;
  return;
}
int main(void){
  
	solve();
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
int main() {
	int n, m;
	bool a[500][500];
	while (cin >> n&&n!=0) {
		cin >> m;
		for (int i = 0; i < n; i++) fill(a[i], a[i] + n, false);
		set <int>d,f;
		for (int i = 0; i < m; i++) {
			int b,c;
			cin >> b >> c;
			if (b > c) swap(b, c);
			b--;
			c--;
			a[b][c] = true;
			a[c][b] = true;
			if (b == 0) {
				f.insert(c);
				d.insert(c);
			}
		}
		set<int>::iterator it = f.begin();
		while (it != f.end()) {
			for (int i = 1; i < n; i++) {
				if (a[(*it)][i]) {
					d.insert(i);
				}
			}
			it++;
		}
		cout << d.size() << endl;
	}
}

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

int main(void)
{
  int N, M;
  cin >> N >> M;
  int road[N];
  for (int i = 0; i < N; ++i) {
    road[i] = 0;
  }
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    road[a-1]++;
    road[b-1]++;
  }
  for (int i = 0; i < N; ++i) {
    cout << road[i] << endl;
  }
  return 0;
}


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

int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    ll t = min(a, k);
    a -= t;
    k -= t;
    b -= min(b, k);

    cout << a << ' ' << b << endl;

    return 0;
}

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

int main(void){
  int a[12] = {1,3,5,7,8,10,12,4,6,9,11,2};

  int x,y, b, c;
  scanf("%d", &x);
  scanf("%d", &y);

  if (x==y) {
    printf("Yes");
    return 0;
  }

  for (int i = 0; i < 12; i++) {
    if (a[i] == x) {
      b = i;
    }
    if (a[i] == y) {
      c = i;
    }
  }

  if ((b<=6 && c<=6) || (6<b && b<=10 && 6<c && c<=10)) {
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int all = 0;
  for ( int i = 0; i< N; i++){
    int from, to;
    cin >> from >> to;
    all += to - from + 1;
  }
  cout << all << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List

solve :: [String] -> [String]
solve [] = []
solve (ini:m:ls) =
    let (ns, ns') = splitAt (read m) ls in
    (foldl' shuffle ini $ map read ns) : solve ns'
    where
    shuffle :: String -> Int -> String
    shuffle s n =
        let (a,b) = splitAt n s in
        b ++ a

main =
    mapM_ putStrLn =<< solve . takeWhile (/= "-") . lines <$> getContents 


Measured memory_bytes: 3980
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<string>
#include<map>

using namespace std;


#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define pl_twin(x,y,z) for(int i=0;i<x;i++){cin>>y[i]>>z[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define st(s) size_t size = s.length()
#define prians(Answer) cout<<Answer<<"\n"
#define make_pair mp;
#define com_div(x,Co) for(int i=1;i<x+1;i++){if(x%i==0){Co++;}}
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef vector<pr> vpt;
typedef greater<int> gi;

int main()
{
    string s;
    cin>>s;
    size_t size=s.length();
    int ans=2;
    rep(i,size-1)
    {
        if(s[i]==s[i+1])
        ans=0;
    }
    if(ans!=0)
    ans=1;
    ans==1?cout<<"Good\n":cout<<"Bad\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using namespace std;
using u32 = unsigned;

int main() {
    u32 n;
    int ans = -INF;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(10));
    vector<vector<int>> v2(n, vector<int>(11));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> v[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 11; ++j) {
            cin >> v2[i][j];
        }
    }
    for (int i = 1; i < (1 << 10); ++i) {
        int pro = 0;
        vector<int> c(n, 0);
        c.assign(n, 0);
        for (int j = 0; j < 10; ++j) {
            if (i & (1<<j)) {
                for (int k = 0; k < n; ++k) {
                    if(v[k][j]==1) c[k]++;
                }
            }
        }
        for (int j = 0; j < n; ++j) {
            pro += v2[j][c[j]];
        }
        ans = max(ans, pro);
    }
    cout << ans << "\n";
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

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


//#define int ll

class CCatSnukeAndAVoyage {
public:
        set<int> s,ss,res;
void solve(std::istream& cin, std::ostream& cout) {
    int n, m;
    cin >> n >> m;
    _for(i,m){
        int a,b;
        cin >> a >> b;
        if(a == 1)s.insert(b);
        if (b == n)ss.insert(a);
    }
    set_intersection(all(s), all(ss),inserter(res,res.end()));
    if(res.empty())cout << "IMPOSSIBLE\n";
    else cout << "POSSIBLE\n";
}
};


#undef int
int main() {
	CCatSnukeAndAVoyage solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  map<int, int> a; rep(i,N) {int tmp; cin >> tmp; a[tmp]++;}
  string result = "No";
  if (a.size()==2) {
    auto it1 = a.begin(); int i1f = it1->first, i1s = it1->second;
    auto it2 = it1; it2++; int i2f = it2->first, i2s = it2->second;
    if (i2f-i1f==1) {
      if (i1s<=i1f && (N-i1s)/2+i1s>=i2f) result = "Yes";
    }
  }
  else if (a.size()==1) {
    int af = a.begin()->first;
    if (af==N-1||af<=N/2) result = "Yes";
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4992
@s = split(//, <>);

if(($s[0] == $s[1]) and ($s[1] == $s[2])){
}else{
	@cmp = ($s[0] , $s[0] , $s[0]);
	if(int(join("", @cmp)) < int(join("", @s))){
		@s = ($s[0] + 1, $s[0] + 1, $s[0] + 1);
	}else{
		@s = @cmp;
	}
}

printf join("", @s) . "\n";


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

int main() {
  int n; cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];

  cout << a[n-1];
  for (int i = n-3; i >= 0; i -= 2) cout << " " << a[i];
  for (int i = n%2; i < n; i += 2) cout << " " << a[i];
  cout << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int m,n;
    cin >>n>>m;
    std::vector<int> v(n);
    priority_queue<lli>pq;
    for (int i = 0; i < n; ++i)
    {
        /* code */cin>>v[i];
        pq.push(v[i]);
    }
    lli sum=0;
    while(m--){
        int temp=pq.top();
        pq.pop();
        pq.push(temp/2);
    }
    while(!pq.empty())
    {
        /* code */sum+=pq.top();
        pq.pop();
    }
    cout<<sum;
    
    return 0;
}


Measured memory_bytes: 4604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll H,W;
    cin>>H>>W;
    
    if(H==1 || W == 1){
        cout<<1;
    }
    else if(H%2 == 1 && W%2 == 1){
        cout<<(H*W+1)/2;
    }
    else cout<<H*W/2;
    return 0;
}

Measured memory_bytes: 256
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
ld dp[3005][3005];
void solve()
{
   ll n;
   cin>>n;
   ld pro[n+3];
   for(int i=1;i<=n;i++)
   { 
   	 cin>>pro[i];
   }
   dp[0][0]=1;
   for(int i=1;i<=n;i++)
   {
   	   dp[i][0]=(dp[i-1][0])*(1-pro[i]);
       for(int j=1;j<=i;j++)
       {
           dp[i][j]=dp[i-1][j]*(1-pro[i])+dp[i-1][j-1]*pro[i];
       }
   }
   ld ans=0;
   for(int i=n/2+1;i<=n;i++)
   {
   	  ans+=dp[n][i];
   }
   DEC(15);
   cout<<ans;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 85664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    string N;
    cin >> N;
    ll sum = 0;
    rep(i, N.size()){
        sum += N[i]-'0';
    }
    if(sum % 9 == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }

}


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

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

    vector<int> l(m), r(m);
    for (int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
    }

    int lmax = 0;
    int rmin = n;
    for (int i = 0; i < m; i++) {
        lmax = max(l[i], lmax);
        rmin = min(r[i], rmin);
    }

    int cnt = rmin - lmax + 1;
    if(cnt<0){
        cnt = 0;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  int t=1;
  //cin>>t;
    while(t--){
            int a,b,h=100,w=100;
    cin>>a>>b;
    string s[100];
    int i,j;
    fr(i,0,50)
    {
        fr(j,0,100)
        s[i]+='.';
    }
    fr(i,50,100)
        fr(j,0,100)
        s[i]+='#';
    a--;
    b--;
    j=0;
    i=51;
    while(a--)
    {
        s[i][j]='.';
        j+=2;
        if(j>98)
        {
            j=0;
            i+=2;
        }
    }
    j=0;
    i=0;
    while(b--)
    {
        s[i][j]='#';
        j+=2;
        if(j>98)
        {
            j=0;
            i+=2;
        }
    }
    cout<<h<<" "<<w<<"\n";
    fr(i,0,100)
    cout<<s[i]<<"\n";

  }
  return 0;
  }



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

int main() {
	string S;
	long K;
	cin >> S >> K;
	K--;

	for (int i = 0; i < K; i++)
	{
		if (S[i] != '1') {
			cout << S[i] << endl;
			return 0;
		}
	}
	
	cout << S[K] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int x[5];
    rep(i,5)cin >> x[i];
    rep(i,5){
        if(x[i]==0){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}



 

Measured memory_bytes: 3556
package main

import (
	. "fmt"
	"io"
	"os"
	"sort"
	"syscall"
)

type event struct{ p, i, d int }
type events []event

func (p events) Len() int           { return len(p) }
func (p events) Less(i, j int) bool { return p[i].p < p[j].p }
func (p events) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			syscall.Read(syscall.Stdin, buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	ri := func() (x int) {
		b := rc()
		for ; '0' > b || b > '9'; b = rc() {
		}
		for ; '0' <= b && b <= '9'; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	r, c, n := ri(), ri(), ri()
	border := func(x, y int) bool { return x == 0 || x == r || y == 0 || y == c }
	getP := func(x, y int) int {
		if y == 0 || x == r {
			return x + y
		}
		return 2*r + 2*c - x - y
	}
	es := events{}
	for i := 0; i < n; i++ {
		x1, y1, x2, y2 := ri(), ri(), ri(), ri()
		if border(x1, y1) && border(x2, y2) {
			p1, p2 := getP(x1, y1), getP(x2, y2)
			if p1 > p2 {
				p1, p2 = p2, p1
			}
			es = append(es, event{p1, i, 1}, event{p2, i, -1})
		}
	}
	sort.Sort(es)
	s := []int{}
	for _, e := range es {
		if e.d == 1 {
			s = append(s, e.i)
		} else {
			if s[len(s)-1] != e.i {
				Fprint(_w, "NO")
				return
			}
			s = s[:len(s)-1]
		}
	}
	Fprint(_w, "YES")
}

func main() { run(os.Stdin, os.Stdout) }


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
std::map<int,int> map;
int main() {
    std::cin >> N;
    REP(i, N) {
        int a;
        std::cin >> a;
        map[a]++;
    }

    int ans = 0;
    EACH(it, map) {
        int sum = 0;
        sum += map.count(it->fst - 1) > 0 ? map[it->fst - 1] : 0;
        sum += it -> snd;
        sum += map.count(it->fst + 1) > 0 ? map[it->fst + 1] : 0;

        ans = std::max(ans, sum);
    }
    std::cout << ans << std::endl;

}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

template<class Abel> struct unionfind {
    vector<int> par;
    vector<int> sizes;
    vector<Abel> wei;

    unionfind(int N, Abel uni = 0) : par(N), sizes(N, 1), wei(N, uni) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int parfind(int x) {
        if (par[x] == x)return x;
        int r = parfind(par[x]);
        wei[x] += wei[par[x]];
        return par[x] = r;
    }

    Abel weight(int x) {
        parfind(x);
        return wei[x];
    }

    void unite(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = parfind(x); y = parfind(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y), w = -w;
        par[y] = x;
        wei[y] = w;
        sizes[x] += sizes[y];
    }

    bool same(int x, int y) {
        return parfind(x) == parfind(y);
    }
    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
    int size(int x) {
        return sizes[parfind(x)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    unionfind<int> uf(N);
    for (int i = 0; i < M; ++i) {
        int L, R, D;
        cin >> L >> R >> D;
        --L, --R;
        if (uf.same(L, R)) {
            int diff = uf.diff(L, R);
            if (diff != D) {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            uf.unite(L, R, D);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
#define MAX 101
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];
void dijkstra()
{
    int minv;
    int d[MAX], color[MAX], p[MAX];
    for(int i=0; i<MAX; i++)
    {
        color[i] = WHITE;
        d[i] = INFTY;
        p[i] = -1;
    }
    d[0] = 0;
    color[0] = GRAY;
    while(1)
    {
        minv = INFTY;
        int u = -1;
        for(int i=0; i<n; i++)
        {
            if(minv > d[i] && color[i] != BLACK)//?????????????°??????????????????????
            {
                u = i;
                minv = d[i];
            }
        }
        if(u == -1)    break;
        color[u] = BLACK;
        for(int v=0; v<n; v++)
        {
            if(color[v] != BLACK && M[u][v] != -1)
            {
                if(d[u]+M[u][v] < d[v])
                {
                    d[v] = d[u] + M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    for(int i=0; i<n; i++)
    {
        cout << i << " " << d[i] << endl;
    }
}
int main()
{
    cin >> n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            M[i][j] = INFTY;
    }
    int k, c, u, v;
    for(int i=0; i<n; i++)
    {
        cin >> u >> k;
        for(int j=0; j<k; j++)
        {
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    dijkstra();
    return 0;
}

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

A=list(map(int,input().split()))
l=[3]+[0]*(10**6)

ans=1
for i in range(len(A)):
    ans*=l[A[i]]
    l[A[i]]-=1
    l[A[i]+1]+=1
    ans%=(10**9+7)
    
print(ans)

Measured memory_bytes: 23932
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    ll A;
    cin >> A;
    string S;
    cin >> S;
    int N = S.length() - 3;
    ll left = stol(S.substr(0, N));
    ll right = stol(S.substr(S.length() - 2, 2));
    ll ans = A * left;
    ll temp = A * right;
    temp /= 100;
    ans += temp;
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    map<string,int> mp;
    int n;
    cin >> n;
    REP(i,n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    if ( mp.count("AC") ) {
        cout << "AC x " << mp["AC"] << '\n'; 
    } else {
        cout << "AC x " << 0 << '\n'; 
    }
    if ( mp.count("WA") ) {
        cout << "WA x " << mp["WA"] << '\n'; 
    } else {
        cout << "WA x " << 0 << '\n'; 
    }
    if ( mp.count("TLE") ) {
        cout << "TLE x " << mp["TLE"] << '\n'; 
    } else {
        cout << "TLE x " << 0 << '\n'; 
    }

    if ( mp.count("RE") ) {
        cout << "RE x " << mp["RE"] << '\n'; 
    } else {
        cout << "RE x " << 0 << '\n'; 
    }


    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
 
int main(){
    int r, c;
    int a[101][101] = {};
    cin >> r >> c;
    
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin >> a[i][j];
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
            a[r][c] += a[i][j];
        }
    }
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c;j++){
            cout << a[i][j] << " ";
        }
        cout << a[i][c] << endl;
    }
}


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

bool comp(const std::string& lh, const std::string& rh) {
  for (int i = 0; i < lh.size() && i < rh.size(); i++) {
    if (lh[i] < rh[i]) {
      return true;
    } else if (lh[i] > rh[i]) {
      return false;
    }
  }
  return lh.size() < rh.size();
}

int main() {
  std::string s;
  int k;
  std::cin >> s >> k;

  std::set<char> set;
  for (const auto c : s) {
    set.insert(c);
  }

  auto itr = set.cbegin();

  while (true) {
    std::set<std::string> po;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == *itr) {
        for (int j = 1; j <= k && i + j <= s.size(); j++) {
          po.insert(s.substr(i, j));
        }
      }
    }
    if (k <= po.size()) {
      std::vector<std::string> n(po.cbegin(), po.cend());
      std::sort(n.begin(), n.end(), comp);
      std::cout << n[k - 1] << std::endl;
      return 0;
    } else {
      k -= po.size();
      itr++;
    }
  }
  return 0;
}


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


int main(void){
  double r; cin >> r;
  cout << 2*r*3.1415926535 << endl;
  return 0;
}


Measured memory_bytes: 3788
N = input()

keta = len(N)

#ans = [0] * ( keta + 1 )
N_list = [0] * (keta+1)
ans_num = 0

for i in reversed(range(keta)):
    N_list[keta-i-1] = int(N[i])

for i in range(keta+1):
    if N_list[i] == 5 and N_list[i+1] >= 5:
        #ans[i] = 0
        N_list[i+1] += 1
        ans_num += 10 - N_list[i]
    elif N_list[i] > 5:
        #ans[i] = 0
        N_list[i+1] += 1
        ans_num += 10 - N_list[i]
    else:
        #ans[i] =  N_list[i]
        ans_num += N_list[i]
#print(ans)
print(ans_num)

Measured memory_bytes: 60252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

ll binary_search2(ll min, ll max, ll i, ll j, vll &l) {
  if (min + 1 == max) { //解近傍の処理
    if (l[max] < l[i] + l[j]) return max;
    else return min;
  }

  ll med = (min + max) / 2;
  if (l[med] < l[i] + l[j]) return binary_search2(med, max, i, j, l);
  else return binary_search2(min, med, i, j, l);
}

int main() {
  ll n;
  cin >> n;
  vll l(n);
  for (ll i = 0; i < n; i++) cin >> l[i];
  sort(all(l));
  ll ans = 0;
  for (ll i = 0; i < n - 2; i++) {
    for (ll j = i + 1; j < n - 1; j++) {
      ll x;
      if (l[j + 1] >= l[i] + l[j]) continue;
      else if (l[n - 1] < l[i] + l[j]) x = n - 1;
      else x = binary_search2(j + 1, n - 1, i, j, l);
      ans += x - (j + 1) + 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int N,h,n,w;
main() {
	cin>>N;
	for(int h=1;h<=3500;h++) {
		for(int n=1;n<=3500;n++) {
			double w=n*h*N*1.0/(-1.0*((n+h)*N-4*n*h));
//			if(h==1&&n==2) cout<<w<<"\n";
			if(w<0.0) continue;
			if(fabs((int)w-w)<=1e-8) {
				printf("%lld %lld %lld",h,n,(int)w);
				return 0;
			}
		}
	} 
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, V = mapint()
B, W = mapint()
T = int(input())

if A==B:
    print('YES')
else:
    if V<=W:
        print('NO')
    else:
        if (V-W)*T>=abs(A-B):
            print('YES')
        else:
            print('NO')

Measured memory_bytes: 61964
#include"bits/stdc++.h"
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> a(m);
	vector<int> b(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		b[i]--;
		a[i]--;
     }
	vector<bool> good(n);
	for (int i = 0; i < n; i++) {
		good[i] = true;
	}
	for (int i = 0; i < m; i++) {
		if (h[b[i]] < h[a[i]]) {
			good[b[i]] = false;
		}
		if (h[b[i]] > h[a[i]]) {
			good[a[i]] = false;
		}
		if (h[b[i]] == h[a[i]]) {
			good[a[i]] = false;
			good[b[i]] = false;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (good[i] == true) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4580
//import java.util.InputMismatchException;
//import java.util.Scanner;
import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		//Scanner scan = new Scanner(System.in);
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String text = br.readLine();
		String[] word = text.split(" ", 0);
		int[] cun = new int[word.length];
		int max = 0;
		int maxA = 0;
		for(int i = 0 ; i < word.length ; i++){
			cun[i] = 0;
			for(int j = 0 ; j < word.length ; j++){
				if(i != j){
					if(word[i].equals(word[j])){
						cun[i]++;
					}
				}
			}
			if(max < cun[i]){
				max = cun[i];
				maxA = i;
			}
		}
		max = word[0].length();
		String maxT = word[0];
		for(int i = 1 ; i < word.length ; i++){
			if(max < word[i].length()){
				max = word[i].length();
				maxT = word[i];
			}
		}
		System.out.println(word[maxA] + " " + maxT);
	}
}

Measured memory_bytes: 24152
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

for i in reversed(range(1, 10)):
 	if is_integer_num(N/i) and N/i < 10:
 		print("Yes")
 		exit()

print("No")

Measured memory_bytes: 61676
#include<bits/stdc++.h>
using namespace std;
vector<long long>v;
main()
{
	long long t,ck=1;
	for(int i = 0;i < 3;i++)
	{
		scanf("%lld",&t);
		v.push_back(t);
		ck=min(ck,t%2);
	}
	sort(v.begin(),v.end());
	printf("%lld",(ck)*v[0]*v[1]);
}

Measured memory_bytes: 256