akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int A, B, T;
	cin >> A >> B >> T;
	double time = A;
	int ans = 0;
	while (T + 0.5 > time)
	{
		time += A;
		ans += B;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define el "\n" ;
int main(){
    ll N ,W ;
    cin >> N >> W ;
    vector<ll> w(100005) ; 
    vector<ll> v(100005) ;
    vector<ll> dp(100005 , -1 ) ;
    for(ll i = 0 ; i < N ; i++){
        cin >> w[i] >> v[i] ;
    }
    for( ll i = 0 ; i  < N ; i++){
        for( ll j = W ; j >= w[i] ; j-- ){
            dp[j] = max(dp[j] , dp[j - w[i]]  + v[i]) ;
        }
    }
    cout << dp[W] + 1 << el ;
    return 0 ;
}

Measured memory_bytes: 5624
L, R = map(int, input().split())

if (R - L) >= 2019:
    print(0)
    exit()

L, R = L % 2019, R % 2019

if L >= R:
    R += 2019

ans = float('inf')

for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % 2019)
print(ans)


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

#define MAXN 100005

int n;
int dp[MAXN][3];
int a[MAXN];
int b[MAXN];
int c[MAXN];

int solve(int x, int s){
    if (x >= n) return 0;
    if (dp[x][s] != 0) return dp[x][s];
    else if (x > 0){
        if (s == 0){
            return dp[x][s] = max(b[x]+solve(x+1,1),c[x]+solve(x+1,2));
        } else if (s == 1){
            return dp[x][s] = max(a[x]+solve(x+1,0),c[x]+solve(x+1,2));
        } else {
            return dp[x][s] = max(a[x]+solve(x+1,0),b[x]+solve(x+1,1));
        }
    } else {
        return max(max(a[0]+solve(1,0),b[0]+solve(1,1)),c[0]+solve(1,2));
    }
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    cout << solve(0,0) << endl;
    return 0;
}


Measured memory_bytes: 7296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {
            string[] str = Console.ReadLine().Split(' ');
            float t = int.Parse(str[0]);
            float x = int.Parse(str[1]);
            Console.WriteLine(t / x);



        }
    }
}


Measured memory_bytes: 13140
def main110():
    N, M, X, Y = (int(x) for x in input().split())

    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    if min(b) - max(a) >= 1:
        if max(a)+1 > X and max(a)+1 > Y:
            print("War")
        elif min(b) < X and min(b) < Y:
            print("War")
        elif max(a)+1 == X or min(b) == Y:
            print("War")
        else:
            print("No War")
    else:
        print("War")

main110()

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

#define int long long

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

int A, B, C;

signed main() {
    cin >> A >> B >> C;
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    int sum = A + B + C;
    int A_diff = abs(A - (sum - A) / 2);
    int B_diff = abs(B - (sum - B) / 2);
    int ans_A = 1, ans_B = 1;
    while (A_diff != 0 && A_diff % 2 == 0) {
        A_diff /= 2;
        ans_A++;
    }
    while (B_diff != 0 && B_diff % 2 == 0) {
        B_diff /= 2;
        ans_B++;
    }
    if (A_diff == 0) {
        ans_A = LLONG_MAX;
    }
    if (B_diff == 0) {
        ans_B = LLONG_MAX;
    }
    int ans = min(ans_A, ans_B);
    if (ans == LLONG_MAX) {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,j;
    int n,m;
    int x,sum=0;
    
    scanf("%d %d",&n,&m);
    int A[n][m];
    int b[m];
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(j=0;j<m;j++) scanf("%d",&b[j]);
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            x=A[i][j]*b[j];
            sum=sum+x;
        }
        printf("%d\n",sum);
        sum=0;
    }
    return 0;
}



Measured memory_bytes: 2104
//Built by Sabuj Jana(greenindia) from Jadavpur University,Kolkata,India 
// God is Great------------/////\\\\\\\--------------------------------
 #include <bits/stdc++.h>
 using namespace std;
 #define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 #define endl "\n"
 //~ #define INF LLONG_MAX
 #define pb push_back
 #define mp make_pair
 const int INF= 1e9+5;
 typedef vector<int> vi;
 typedef long long ll;
 
 	 
 int main() {
  
    crap;
                  
     int n;cin>>n;
     vi vec(n);
     for(int& x: vec)
		cin>>x;
		
	vi dp(n,INF);
	dp[0]=0;
	for(int i=0; i<n; i++){
		
		for(int j: {i+1,i+2}){
			
			dp[j]=min(dp[j], dp[i]+ abs(vec[i]-vec[j]));
			
		}
		
		
	}
     
      cout<<dp[n-1];
    return 0;
 }



Measured memory_bytes: 1024
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let number: u64 = read();
    // 初期の最小値として非常に大きな値を指定する
    let mut min_number_of_trials: u64 = 10u64.pow(12);

    // 探索範囲は対称性からsqrt(N)までで良い。
    for i in 1..(number as f64).sqrt() as u64 + 1
    {
        // 割り切れる値を発見したら、試行回数が最小値であるかどうか調べ、最小値であればアップデートする。
        if number % i == 0
        {
            let now_number_of_trials = (number / i) + i - 2;
            if now_number_of_trials < min_number_of_trials
            {
                min_number_of_trials = now_number_of_trials;
            }
        }
    }

    println!("{}", min_number_of_trials);
}


Measured memory_bytes: 4352
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j,l,p=-1,max=0,s=0,q=-1;
cin>>n;int a[n];
for(i=0;i<n;i++)
{max=0;
	for(j=0;j<3;j++)
	{
		cin>>a[j];
		if(a[j]>max)
		{max=a[j];p=j;
		}
		
	}
	cout<<"p"<<p<<" q:"<<q<<"\n";
	if(i==0)
	{s=s+max;q=p;
	}
	else if(q!=p)
	{
		s=s+max;q=p;
	}
	else
	{
		
		l=lower_bound(a,a+3+1,max)-a;
	
		l=l-1;	q=l;
		if(l<0)
		l=0;
		s+=a[l];
	}
}
cout<<s;
return 0;
}
*/

#include<bits/stdc++.h>
using namespace std;
int a[100001][3];int n,i,j,l,max1=0,temp,k,c,dp[100001][3];
int f(int i,int j)
{if(i==n || j>3 || j<0 )
return 0;
if(dp[i][j]!=-1)
return dp[i][j];
	if(j==0)
	{
		c=max(f(i+1,j+1)+a[i][j],f(i+1,j+2)+a[i][j]);
	}
else if(j==1)
	{
		c=max(f(i+1,j-1)+a[i][j],f(i+1,j+1)+a[i][j]);
	}
	else if(j==2)
	{
		c=max(f(i+1,j-1)+a[i][j],f(i+1,j-2)+a[i][j]);
	}
	return dp[i][j]=c;
}
int main()
{
memset(dp,-1,sizeof(dp));
cin>>n;
for(i=0;i<n;i++)
{for(j=0;j<3;j++)
cin>>a[i][j];
}
for(k=0;k<3;k++)
{c=0;
	temp=f(0,k);
	if(temp>max1)
	max1=temp;
}
cout<<max1;
return 0;
}

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

int ten[20][20];

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;

	ll cnt = 0;
	REP(i, n) {
		double x; cin >> x;
		ll tmp = x * 1e9 + 0.1;
		int two = 0;
		int five = 0;
		while (tmp % 2 == 0) {
			tmp /= 2;
			two++;
		}
		while (tmp % 5 == 0) {
			tmp /= 5;
			five++;
		}
		if (two > 18) two = 18;
		if (five > 18) five = 18;
		for (int j = 18 - two; j <= 18; j++)
			for (int k = 18 - five; k <= 18; k++)
				cnt += ten[j][k];
		ten[two][five]++;
	}

	cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a[1000][3],ans[1000];
int main()
{
    int N;
    while(scanf("%d",&N)==1)
    {
        for(int i = 0; i < N-1; i++)
        {
            scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
            ans[i] = a[i][1]+a[i][0];
            for(int j = 0; j < i; j++)
            {
                if(ans[j]<a[i][1])
                    ans[j]=ans[i];
                else
                {
                    int ge2 = (a[i][2]-(ans[j]-a[i][1])%a[i][2])%a[i][2];
                    ans[j] = ans[j] + ge2 +a[i][0];
                }

            }
        }
        for(int i = 0; i < N-1; i++)
        {
            printf("%d\n",ans[i]);
        }
        printf("%d\n",0);
    }

    return 0;
}


Measured memory_bytes: 256
n_box, n_move = map(int,input().split())
num_balls = [1] * n_box
can_red = [0] * n_box
can_red[0] = 1
for i in range(n_move):
    From, to = map(int,input().split())
    From -= 1
    to -= 1
    if can_red[From] == 1:
        if num_balls[From] == 1:
            can_red[From] = 0
            can_red[to] = 1
        else:
            can_red[to] = 1
    num_balls[From] -= 1
    num_balls[to] += 1

ans = 0
for i in range(n_box):
    if can_red[i] == 1:
        ans += 1
print(ans)



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

using P = pair<int,int>;
int main(void) {
    int N,maxa = 0;
    int code = 0;
    int pos = 0;
    cin >> N;

    vector<int> a(N);
//    random_device rd;
//    mt19937 mt(rd());
//    uniform_int_distribution<int> d(-1000000,1000000);
    for(int i=0;i<N;i++) {
//        a[i] = d(mt);
        cin >> a[i];
        if(maxa < abs(a[i])) {
            maxa = abs(a[i]);
            code = a[i] > 0 ? 1 : -1;
            pos = i;
        }
    }

    // ＋かーに統一してしまう。
    // +の場合左から前を足していく
    // -の場合右から前を足していく
    if(code == 0) {
        cout << "0\n";
    } else if(code > 0) {
        vector<P> ans;
        for(int i=0;i<N;i++) {
            if(i==pos) continue;
            if(a[i] < 0) {
                a[i]+= a[pos];
                ans.push_back(make_pair(pos+1,i+1));
            }
        }

        for(int i=1;i<N;i++) {
            if(a[i-1] > a[i]) {
                ans.push_back(make_pair(i,i+1));
                a[i] += a[i-1];
            }
        }

        cout << ans.size() << endl;
        for(int i=0;i<ans.size();i++) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    } else {
        vector<P> ans;
        for(int i=0;i<N;i++) {
            if(i==pos) continue;
            if(a[i] > 0) {
                a[i]+= a[pos];
                ans.push_back(make_pair(pos+1,i+1));
            }
        }

        for(int i=N-2;i>=0;i--) {
            if(a[i+1] < a[i]) {
                ans.push_back(make_pair(i+2,i+1));
                a[i] += a[i+1];
            }
        }

        cout << ans.size() << endl;
        for(int i=0;i<ans.size();i++) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
    return 0;
}


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

vector < int > adj[sz];
int dis[sz];
bool vis[sz];
stack < int > st;
void dfs(int s){
    vis[s] = true;
    int len = adj[s].size();
    for(int i=0;i<len;i++){
        int v = adj[s][i];
        if(vis[v] == false)
            dfs(v);
    }
    st.push(s);
}
int calc(){
    int mx = 0;
    while(!st.empty()){
        int u = st.top();
        st.pop();
        int len = adj[u].size();
        for(int i = 0 ; i < len ; i++){
            int v = adj[u][i];
            if(dis[v] == 0)dis[v] = dis[u] + 1;
            else dis[v] = max(dis[v],dis[u]+1);
            mx = max(mx,dis[v]);
        }
    }
    return mx;
}
int main(){
    //freopen("test.txt","r",stdin);
    int i , j , n , x , y , m;
    cin>>n>>m;
    while(m--){
        cin>>x>>y;
        adj[x].push_back(y);
    }
    int mx = 0;
    for(i=1;i<=n;i++)
        if(!vis[i])dfs(i);
    cout<<calc()<<endl;
    return 0;
}


Measured memory_bytes: 8704
#include <stdio.h>

void calc(double matrix[],double ans[]){
	double det = matrix[0]*matrix[3]-matrix[1]*matrix[2];
	double tmp[4] = {matrix[3], -matrix[1],-matrix[2],matrix[0]};
	double atmp[2] = {ans[0], ans[1]};
	ans[0] = (atmp[0]*tmp[0]+atmp[1]*tmp[1])/det+0.000;
	ans[1] = (atmp[0]*tmp[2]+atmp[1]*tmp[3])/det+0.000;
	int a = ans[0]*1000;
	ans[0] = (double)a/1000;
	a = ans[1]*1000;
	ans[1] = (double)a/1000;
	return;
}

int main(){
	double m[4];
	double a[2];
	while(scanf("%lf %lf %lf %lf %lf %lf", &m[0],&m[1],&a[0],&m[2],&m[3],&a[1])!=EOF){
		calc(m, a);
		printf("%.3f %.3f\n", a[0], a[1]);
	}
	return 0;
}

Measured memory_bytes: 652
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split()) ;a-=1;b-=1
    G[a].append([b,c])
    G[b].append([a,c])
q,k=map(int,input().split());k-=1

queue= deque([ [k,l[0],l[1]] for l in G[k] ] )
# print(queue)
dist=[-1]*n ; dist[k]=0
while queue:
    pre, now, kati = queue.pop()
    # print(pre,now)
    dist[now]= dist[pre]+kati
    for to,katin in G[now]:
        if to!= pre:
            queue.appendleft([now,to,katin ])

for i in range(q):
    a,b=map(int,input().split())
    a-=1;b-=1
    print(dist[a]+dist[b])


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

int main(){
    int N, M;
    cin >> N >> M;

    vector<int> X(M);
    vector<bool> s(M, false);
    for(int i = 0; i < M; ++i){
        cin >> X[i];
    }

    if(N >= M){
        cout << "0" << endl;
        return 0;
    }

    sort(begin(X), end(X));

    vector<pair<int, int>> d(M-1);
    for(int i = 0; i < M-1; ++i){
        d[i].first = X[i+1]-X[i];
        d[i].second = i+1;
    }

    sort(begin(d), end(d));
    reverse(begin(d), end(d));

    --N;
    s[0] = true;
    for(int i = 0; i < M-1 && N > 0; ++i, --N){
        s[d[i].second] = true;
    }

    int ans = 0;
    for(int i = 1; i < M; ++i){
        if(!s[i]) ans += X[i]-X[i-1];
    }
    cout << ans << endl;
}

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

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  
  if(a%b==0){
   cout<<"NO"<<endl; 
  }else{
   int i,ans;
   for(i=1;i<=b;i++){
     ans=a*i-c;
     if(ans%b==0){
      cout<<"YES"<<endl;
 	  break;
     }
   }
   if(i==b+1)cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MX=3*1e5+100;
const long long INF = 1e18;
ll N, M, k;
ll arr[MX];
// UNRESTORABLE
int main()
{
    string s, t, ans;
    cin>>s>>t;
    int last=-1;
    for(int i=0;i<s.size();i++)
    {
        bool ok=1;
        if(s[i] != t[0] && s[i] != '?') continue;
        int j=0;
        for(int j=0;j<t.size();j++)
        {
            if(i+j >= s.size()) {ok=0; break;}
            if(s[i+j] != t[j] && s[i+j] !='?') ok=0;
        }
        if(ok) last=i;
    }
    if(last == -1)
    {
        cout<<"UNRESTORABLE";

    }
    else
    {
            int m=t.size(), i=0;
        while(m) s[last++]=t[i++], m--;
        for(int i=0;i<s.size();i++)
        {
            if(s[i] =='?') s[i]='a';
        cout<<s[i];
        }
    }
}


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

#define MAX 200001
#define VAL_MAX 10000

int main() {
	int n = 0;
	scanf("%d", &n);
	int *A = new int[n+1];
	int count[VAL_MAX+1] = { 0 };
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
		count[A[i]]++;
	}
	// ??¨???
	for (int i = 1; i < VAL_MAX+1; i++) {
		count[i] += count[i - 1];
	}
	// sort
	int *out = new int[n + 1];
	for (int i = n - 1; 0 <= i; i--) {
		// out[c[a[i]]] ???????´?
		out[count[A[i]]] = A[i];
		count[A[i]]--;
	}

	for (int i = 1; i <= n; i++) {
		if (i-1) printf(" ");
		printf("%d", out[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 18368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(int q, int h, int s, int d, int n) {
    int min_unit = min({4*q, 2*h, s});
    int min_unit2 = min(2*min_unit, d);
    long long ret = 0;
    ret += (static_cast<long long> (n/2)) * min_unit2;
    ret += n%2 == 1 ? min_unit : 0;
    std::cout << ret << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int q, h, s, d, n;

    gettimeofday(&start,NULL);

    std::cin >> q >> h >> s >> d >> n;
    solve(q, h, s, d, n);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>A(n); 
	vector<ll>sum(n + 1);
	
	rep(i, n) {
		scanf("%d", &A[i]);
		A[i] -= (i + 1);
	}
	sort(all(A));
	sum[0] = 0;
	ll Sum = 0;
	rep(i, n) {
		Sum += A[i];
		sum[i+1] = Sum;
	}
	ll ans = 1e20;
	FOR(ite, 0, n) {
		ll tmp = (ll)(n - 2 * ite)*A[ite]*(-1) + (sum[n] - 2 * sum[ite]);
		ans = min(ans, tmp);
		if (ans < tmp) {
			break;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){

    int N;

    scanf("%d", &N);

    long long f[N+1], s[N+1], t[N+1];

    for(int i = 1; i <= N; i++){
        f[i] = 1;
        s[i] = 0;
        t[i] = 0;
    }

    long long a[N+1], b[N+1], c[N+1];

    for(int i = 1; i <= N; i++){
        scanf("%lld", &a[i]);
    }
    for(int i = 1; i <= N; i++){
        scanf("%lld", &b[i]);
    }
    for(int i = 1; i <= N; i++){
        scanf("%lld", &c[i]);
    }

    mergeSort(a, 1, N+1);
    mergeSort(b, 1, N+1);
    mergeSort(c, 1, N+1);

    int x = 1, y = 1;

    while(1){
        if(x > N){
            s[y+1] = s[y];
            y++;
        }else if(a[x] < b[y]){
            s[y] += f[x];
            x++;
        }else{
            s[y+1] = s[y];
            y++;
        }
        if(y > N){
            break;
        }
    }

    x = 1, y = 1;

    while(1){
        if(x > N){
            t[y+1] = t[y];
            y++;
        }else if(b[x] < c[y]){
            t[y] += s[x];
            x++;
        }else{
            t[y+1] = t[y];
            y++;
        }
        if(y > N){
            break;
        }
    }

    long long ans = 0;

    for(int i = 1; i <= N; i++){
        ans += t[i];
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 6868
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long N, M, count=0;
	cin >> N;
	vector<long long> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	M = vec.at(0);
	for (int i = 0; i < N; i++) {
		if (vec.at(i) < M) {
			count += M - vec.at(i);
		}
		else if (vec.at(i) > M) {
			M = vec.at(i);
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 4772
#include<stdio.h>

int main(void) {

	int a, b;

	scanf("%d", &a);
	scanf("%d", &b);

	if (a == 1 && b == 2) {
		printf("3\n");
	}
	else if (a == 2 && b == 3) {
		printf("1\n");
	}
	else if (a == 3 && b == 1) {
		printf("2\n");
	}
	else if (a == 2 && b == 1) {
		printf("3\n");
	}
	else if (a == 3 && b == 2) {
		printf("1\n");
	}
	else if (a == 1 && b == 3) {
		printf("2\n");
	}



	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    double x1,y1,x2,y2,x3,y3,xp,yp;
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
        if(((x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)>0)&&((x3-x2)*(y3-yp)-(y3-y2)*(x3-xp)>0)&&((x1-x3)*(y1-yp)-(y1-y3)*(x1-xp)>0)){
            printf("YES\n");
        }else if(((x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)<0)&&((x3-x2)*(y3-yp)-(y3-y2)*(x3-xp)<0)&&((x1-x3)*(y1-yp)-(y1-y3)*(x1-xp)<0)){
            printf("YES\n");
        }else{
            printf("NO\n");
        }

    }
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,A;
ll i, j, k;
int main(){
    scanf("%lld%lld", &N,&A);
    printf("%lld", (N * 3 + A) / 2);

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(S: str):
    tmp = S[0]
    counter = 0
    for s in S:
        if tmp != s:
            counter += 1
        tmp = s
    print(counter)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5472
import math
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if n == 1:
    print(0)
else:

    l = factorization(n)



    if all(l[i][1] == 1 for i in range(len(l))):
        ans = len(l)
    else:
        ans = 0
        for i in range(len(l)):
            if l[i][1] == 1:
                ans += 1
            else:
                ans += int(( -1 + math.sqrt(1 + 8 * l[i][1]) ) / 2)
    print(ans)


Measured memory_bytes: 9504
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let n = cin.next_usize();
    let mut t = (0..n).map(|_| cin.next_f64()).collect::<Vec<_>>();
    let mut v = (0..n).map(|_| cin.next_f64()).collect::<Vec<_>>();
    t.push(1.0);
    v.push(0.0);

    let mut ans: f64 = 0.0;
    let mut cur_v: f64 = 0.0;
    for i in 0..n {
        let mut acc_t = v[i] - cur_v;
        let mut dec_t = t[i];
        let mut sum_t = t[i];
        for j in i + 1..t.len() {
            if dec_t > sum_t - (v[i] - v[j]) {
                dec_t = sum_t - (v[i] - v[j]);
            }
            sum_t += t[j];
        }
        if acc_t > dec_t {
            acc_t = (acc_t + dec_t) / 2.0;
            dec_t = acc_t;
        }
        if acc_t > t[i] {
            acc_t = t[i];
            dec_t = acc_t;
        }
        ans += cur_v * acc_t + acc_t * acc_t / 2.0;
        cur_v += acc_t;
        ans += cur_v * (dec_t - acc_t);
        ans += cur_v * (t[i] - dec_t) - (t[i] - dec_t) * (t[i] - dec_t) / 2.0;
        cur_v -= (t[i] - dec_t);
    }

    println!("{:.9}", ans);
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }

    #[allow(dead_code)]
    fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)]
    fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)]
    fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)]
    fn next_f64(&mut self) -> f64 { self.next_generics::<f64>() }
    #[allow(dead_code)]
    fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)]
    fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}

Measured memory_bytes: 4352
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a,b,c,ans;
    sfl(a),sfl(b),sfl(c);
    ans = a/b;
    if( ans*b != a ) ans++;
    ans = ans*c;
    pfl(ans);
    return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())S
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    char a;
    cin >> a;
    if(a=='A')pr('T');
    else if(a=='C')pr('G');
    else if(a=='G')pr('C');
    else if(a=='T')pr('A');
}

Measured memory_bytes: 256
import kotlin.math.ceil
import kotlin.math.round
import kotlin.system.exitProcess

fun main(args: Array<String>) {
    abc173B(args)
}

fun abc173B(args: Array<String>) {
    val N = readLine()!!.toInt()

    var acCount = 0
    var waCount = 0
    var tleCount = 0
    var reCount = 0

    for (i in 0 until N) {
        val si = readLine()!!.toString()
        when(si) {
            "AC" -> acCount++
            "WA" -> waCount++
            "TLE" -> tleCount++
            "RE" -> reCount++
        }
    }

    println("AC x $acCount")
    println("WA x $waCount")
    println("TLE x $tleCount")
    println("RE x $reCount")
}


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

int main() {
  int a,b,c,d;
  cin >> a >>b >>c>>d;
  
  while(a>0&&c>0)
  {
	  c -= b;
	  if(c<=0)
	  {
		  cout << "Yes";
		  break;
	  }
	  a -= d;
	  if(a<=0)
	  {
		  cout << "No";
		  break;
	  }
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef set<int> S;

int getNum(string a){
  int res=0;
  for(int i=0;i<a.size();i++) res=res*10+a[i]-'0';
  return res;
}

map<string,P> val;
vector<string> el;
int n;

int calc(){
  stack <S> stk;
  for(int i=0;i<n;i++){
    string e=el[i];
    S t;
    if(isdigit(e[0]))t.insert(getNum(e));
    else if(isalpha(e[0])){
      int l=val[e].first,r=val[e].second;
      while(l<=r)t.insert(l++);
    }
    else {
      S B=stk.top();stk.pop();
      S A=stk.top();stk.pop();
      for(S::iterator i=A.begin();i!=A.end();i++)
	for(S::iterator j=B.begin();j!=B.end();j++){
	  int a=*i,b=*j,r;
	  if(e[0]=='+')r=(a+b)%256;
	  if(e[0]=='-')r=(a-b+256)%256;
	  if(e[0]=='*')r=(a*b)%256;
	  if(e[0]=='/'){
	    if(!b) return 0;
	    r=(a/b)%256;
	  }
	  t.insert(r);
	}
      
    }
    stk.push(t);
  }
  return 1;
}



int main(){
  int m;
  cin>>m;
  for(int i=0,a,b;i<m;i++){
    string t;
    cin>>t>>a>>b;
    val[t]=P(a,b);
  }
  cin>>n;
  el.resize(n);
  for(int i=0;i<n;i++) cin>>el[i];
  cout<<(calc()?"correct":"error")<<endl;
  return 0;
}

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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

void solve(long long K){
    ll res = 0;
    for(int i=1; i <= K; i++){
        for(int j=1; j <= K; j++){
            for(int k=1; k <= K; k++){
                res += __gcd(i, __gcd(j, k));
            }
        }
    }

    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>

using namespace std;

using vi = vector<int>;

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;

	vi v(n);
	for (int i = 0; i < n; ++i) cin >> v[i]; 

	vi c(n, 0);
	int bp = 0;
	for (int i = n; i > 0; --i) {
		int bolas = 0;
		for (int j = i; j <= n; j += i) {
			if(j == i) bolas += v[j - 1]; 
			else bolas += c[j - 1];
		}

		if ((bolas % 2) == 0) {}
		else {
			++bp;
			c[i - 1] = 1;
		}
	}

	cout << bp << '\n';
	if (bp > 0) {
		int bc = 0;
		for (int i = 0; i < c.size(); ++i) {
			if (c[i] == 1) {
				++bc;
				cout << i + 1;
				if (bc == bp) {
					cout << '\n';
					break;
				}
				else cout << ' ';
			}
		}
	}

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
    }

    vector<ll> s(N+1, 0);
    map<ll, ll> m;
    rep (i, N) {
        s[i+1] = s[i] + A[i];
    }

    rep (i, N+1) {
        m[s[i]]++;
    }

    ll ans = 0;
    for (auto it : m) {
        ans += it.second*(it.second-1)/2;
    }

    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

ll mod = 1000000007;
int main(){
  int n; cin >> n;
  vector <ll> a(n);
  rep(i, n){
    cin >> a[i];
    a[i]++;
  }
  vector <ll> num(n+1);
  num[0] = 3;
  ll ans = 1;
  rep(i, n){
    if (num[a[i]-1] < 0){
      cout << 0 << endl;
      return 0;
    }
    ans *= num[a[i]-1];
    ans %= mod;
    num[a[i]-1]--;
    num[a[i]]++;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 4836
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int n;
  while(cin>>n){
    vector<int> ar(n);
    int a=0,b=0;
    for(int i=0;i<n;++i) cin>>ar[i];
    sort(ar.begin(),ar.end());
    for(int i=0;i<n;++i){
      b+=ar[i];
      a+=b;
    }
    cout<<a<<endl;
  }
  return 0;
}

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

int main(){
    int n, sn=0;
    string str;

    cin >> n;
    str = to_string(n);
    for(int i = 0 ; i < str.length() ; i++){
        sn+= str[i] - '0';
    }
    if (n % sn == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, dp[2][4];
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N;
	int pre = 0, cur = 1;
	for(int i = 1, a, b, c;i<=N;i++){
		cin >> a >> b >> c;
		dp[cur][1] = max(dp[pre][2]+a, dp[pre][3]+a);
		dp[cur][2] = max(dp[pre][1]+b, dp[pre][3]+b);
		dp[cur][3] = max(dp[pre][1]+c, dp[pre][2]+c);
		swap(pre, cur);
	}
	cout << max(dp[pre][1], max(dp[pre][2], dp[pre][3])) << '\n';
	return 0;
}

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

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

	vector<int> v(n);
	vector<int> e(n);

	int a = 0;
	

	for (int i = 0; i < n; i++) {
			cin >> v.at(i) >> e.at(i);

			a += e.at(i) - v.at(i) +1;
			
		}
           cout << a  << endl;
	

	return 0;
}

Measured memory_bytes: 256
import math

P = 10**9 + 7
X, Y = map(int, input().split())
if (X + Y) % 3 > 0:
    print(0)
    exit()
n = (X + Y) // 3
x = X - n
y = Y - n
if 0 > x or 0 > y:
    print(0)
    exit()
fact = [0] * (x + y + 1)
inv = [0] * (x + y + 1)
fact_inv = [0] * (x + y + 1)
fact[0], fact[1] = 1, 1
inv[0], inv[1] = 0, 1
fact_inv[0], fact_inv[1] = 1, 1
for i in range(2, x + y + 1):
    fact[i] = (fact[i - 1] * i) % P
    inv[i] = (-inv[P % i] * (P // i)) % P
    fact_inv[i] = (fact_inv[i - 1] * inv[i]) % P
print((fact[x + y] * fact_inv[x] * fact_inv[y]) % P)


Measured memory_bytes: 82164
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll n, i, j, a, b, c, d;
	cin >> n >> a >> b >> c >> d; 
	string s;
	cin >> s;
	ll tmp = 0;
	fr(i, b-1, d)
	{
		if(s[i] == '.')
			tmp = 0;
		else
			tmp++;
		if(tmp == 2)
		{
			cout << "No";
			return 0;	
		}	
	}
	tmp = 0;
	fr(i,a-1,c)
	{
		if(s[i] == '.')
			tmp = 0;
		else
			tmp++;
		if(tmp == 2)
		{
			cout << "No";
			return 0;	
		}
	}
	if(c < d)
		cout << "Yes";
	else
	{
		ll y = 0;
		fr(i,b-1,d)
		{
			if((s[i] == '.')&&(s[i-1] == '.')&&(s[i+1] == '.'))
			{
				cout << "Yes";
				return 0;
			}
		}
		cout << "No";
	}
}


Measured memory_bytes: 592
local H, W = io.read("n", "n", "l")
local A = {}
for h=1,H do
  A[h] = {}
  for w=1,W do
    local a = io.read(1)
    A[h][w] = a
  end
  io.read("l")
end
local RH ={}
for h=1,H do
  local remove = true
  for w=1,W do
    if A[h][w] == '#' then
      remove = false
      break
    end
  end
  if remove then
    RH[h] = 1
  end
end
local RW = {}
for w=1,W do
  local remove = true
  for h=1,H do
    if A[h][w] == '#' then
      remove = false
      break
    end
  end
  if remove then
    RW[w] = 1
  end
end

for h=1,H do
  if not RH[h] then
    for w=1,W do
      if not RW[w] then
        io.write(A[h][w])
      end
    end
    print()
  end
end



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


//////////////////ここの値は必ず確認！！！！！////////////////////
//---------------------------------------------------------//
const int MOD = 1e9+7;
const int MAXR = 510000;
//---------------------------------------------------------//

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint com(ll n,ll k){
    if(k==0) return 1;
    if(n<k)return 0;
    if(n<0)return 0;
    if(k<0)return 0;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {
    com_init();
    ll N,K; cin >> N >> K;

    

    FOR(i,1,K+1){
        mint ans = 0;
        ans += com(K-1, K-i) * com(N-K-1, N-K-i-1);
        ans += com(K-1, K-i) * com(N-K-1, N-K-i) * 2;
        ans += com(K-1, K-i) * com(N-K-1, N-K-i+1);
        cout << ans << endl;
    }
    return 0;
}

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

void chmax(int& a, int b) {
  if (a < b) a = b;
}

int main() {
  string S;
  string T;
  cin >> S >> T;
  
  int dp[3010][3010] = {0};

  // dpの更新
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < T.size(); j++) {
      if (S[i] == T[j]) {
        chmax(dp[i+1][j+1], dp[i][j] + 1);
      } else {
        chmax(dp[i+1][j+1], dp[i+1][j]);
        chmax(dp[i+1][j+1], dp[i][j+1]);
      }
    } 
  }

  // 文字列の復元(dpルートの移動)
  int m, n;
  m = S.size(); n = T.size();
  
  string ans = "";

  while (m > 0 && n > 0) {
    if (dp[m][n] == dp[m-1][n]) {
      m--;
    } else if (dp[m][n] == dp[m][n-1]) {
      n--;
    } else {
      ans = S[m-1] + ans;
      m--; n--;
    }
  }

  cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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 DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	string s;
	cin >> s;
	rep(i,s.size())
	{
		cout << 'x';
	}
	cout << endl;
	return 0;
}

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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNextN();) {
			solver.readN(in.readLine());
		}
		for (; solver.hasNextM();) {
			solver.readM(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int M;
	int cntN;
	int cntM;
	int[] SX;
	int[] SY;
	int[] CX;
	int[] CY;

	public void init() {
		N = 0;
		M = 0;
		cntN = 1;
		cntM = 1;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		M = Integer.parseInt(strArr[1]);
		// System.out.println(N);
		SX = new int[N + 1];
		SY = new int[N + 1];
		CX = new int[M + 1];
		CY = new int[M + 1];
	}

	public boolean hasNextN() {
		return cntN <= N;
	}

	public void readN(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		SX[cntN] = Integer.parseInt(strArr[0]);
		SY[cntN] = Integer.parseInt(strArr[1]);
		cntN++;
	}

	public boolean hasNextM() {
		return cntM <= M;
	}

	public void readM(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		CX[cntM] = Integer.parseInt(strArr[0]);
		CY[cntM] = Integer.parseInt(strArr[1]);
		cntM++;
	}

	public void solve() {
		for (int i = 1; i <= N; i++) {
			int cp = 1;
			int d = Integer.MAX_VALUE;
			for (int j = 1; j <= M; j++) {
				int dx = SX[i] > CX[j] ? SX[i] - CX[j] : CX[j] - SX[i];
				int dy = SY[i] > CY[j] ? SY[i] - CY[j] : CY[j] - SY[i];
				// System.out.println(SX[i] + " " + CX[j] + " " + dx);
				if (d > dx + dy) {
					d = dx + dy;
					cp = j;
				}
			}
			System.out.println(cp);
		}
	}
}


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

const ll maxn=100+5, maxv=1e5+5, inf=0x3f3f3f3f3f3f3f3f;
ll N, W, v[maxn], w[maxn], dp[maxv];

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

    cin>>N>>W;
    rep(i,0,N) cin>>w[i]>>v[i];
    memset(dp, 0x3f, sizeof dp);
    dp[0]=0;
    rep(i,0,N) {
        for(ll j=maxv-1; j>=v[i]; j--) {
            dp[j]=min(dp[j], w[i]+dp[j-v[i]]);
        }
    }
    ll ans=-1;
    rep(i,0,maxv) if(dp[i]<=W) ans=i;
    cout<<ans<<"\n";

}


Measured memory_bytes: 1024
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    a, b, c = gets.chomp.split.map(&:to_i)

    if b - a == c - b
      puts "YES"
    else
      puts "NO"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2172
#include <stdio.h>

int main(void) {
	int a,i;
	scanf("%d",&a);
	int num[a];
	
	for(i=0;i<a;i++){
		scanf("%d",&num[(a-1)-i]);

	}
	for(i=0;i<a;i++){
		printf("%d",num[i]);
		if(i  != a-1){
			printf(" ");
		
		}
	}
		printf("\n");
	return 0;
}

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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;


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

	string S;
	cin >> S;
	if (S.size() < 4)
		cout << "No" << endl;
	else if (S.substr(0, 4) == "YAKI") {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int,input().split()))

L = []
flag = 1
while len(B):
    for i,b in enumerate(B[::-1]):
        if len(B)-i == b:
            L.append(b)
            B.pop(len(B)-i-1)
            break
    else:
        flag = 0
        break

if flag:
    for s in L[::-1]:
        print(s)
else:
    print(-1)

Measured memory_bytes: 3064