akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string S=Console.ReadLine();
      int N=S.Length;
      bool flg=false;
      string S2=S.Substring(2,N-3);
      if(S.Substring(0,1)!="A"){
        flg=true;
      }else if(CountChar(S2,'C')!=1){
        flg=true;
      }else{
        if(CountChar(S,'C')>2){
          flg=true;
        }
        string S3=S.Replace("A","a");
        string S4=S3.Replace("C","c");
        string S4ToLower=S4.ToLower();
        if(S4ToLower!=S4){
          flg=true;
        }
      }
        if(flg){
          Console.WriteLine("WA");
        }else{
            Console.WriteLine("AC");
          }
     
  }
     public static int CountChar(string s, char c) {
    return s.Length - s.Replace(c.ToString(), "").Length;
    }
    
  }

}


Measured memory_bytes: 26016
function gcd() {
    var f = (a, b) => b ? f(b, a % b) : a
    var ans = arguments[0]
    for (var i = 1; i < arguments.length; i++) {
        ans = f(ans, arguments[i]); 
    }
    return ans 
}

function main(input){

    num = parseInt(input);
    out = 0;

    for(i=1;i<=num;i++){
        for(j=1;j<=num;j++){
            for(k=1;k<=num;k++){
                out=out+gcd(i,j,k);
            }
        }
    }

    console.log(out);

}

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

Measured memory_bytes: 34700
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string S[150];
	map<string,bool> alre;
	bool ans=1;
	scan(N);
	rep(i,N){
		scan(S[i]);
		if(i>0){
			if(alre[S[i]]!=0||S[i][0]!=S[i-1].back()) ans=0;
			else alre[S[i]]=1;
		}
		else alre[S[i]]=1;
	}
	if(ans) prin("Yes");
	else prin("No");
	return 0;
}


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



int MOD=1000000007;
int main(void){
	int A,B,C;
	cin >> A >> B >> C;
	if(A+B+C>=22) cout << "bust" << endl;
	else cout << "win" << endl;
}


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

template <typename T> T mod_sub (T a, T b, T m);

int main() {
	uint32_t N, K;
	cin >> N >> K;
	
	vector<uint64_t> dp(K+1);
	dp[0] = 1;
	
	uint32_t tmax = 0;
	uint64_t mod = pow(10, 9) + 7;
	
	for(uint32_t i=0; i<N; i++) {
		uint32_t a;
		cin >> a;
	
		tmax = min(tmax + a, K);
		
		deque<uint64_t> dq;
		uint64_t tsum = 0;
		
		for(uint32_t j=0; j<=K && j<=tmax; j++) {
			tsum = (tsum + dp[j]) % mod;

			if(dq.size() > a) {
				tsum = mod_sub(tsum, dq.front(), mod);
				dq.pop_front();
			}
			
			dq.emplace_back(dp[j]);
			dp[j] = tsum;
		}
	}
		
	cout << dp[K];
	return 0;
}

template <typename T> T mod_sub (T a, T b, T m) {
	return (a == b) ? 0 : (a > b) ? (a - b) % m : m + a - b;
}

Measured memory_bytes: 1904
n,a,b,c,d,=map(int,input().split())
path=list(input())

rock=0
blank=0
for i in range(a,c):
    if path[i-1]=='#' and path[i]=='#':
        rock=1
for i in range(b,d):
    if path[i-1]=='#' and path[i]=='#':
        rock=1

for i in range(max(a,b),min(c,d)+1):
    if path[i-2]=='.' and path[i-1]=='.' and path[i]=='.':
        blank=1

if rock==0 and ((a-b)*(c-d)>0 or (blank==1 and (a-b)*(c-d)<0)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61680
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



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



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

using namespace std;

int main()
{
    int a, b ,c,d;
    cin>>a>>b>>c>>d;
    int f  = 2;
    for (int i = 0;; i++)
    {
        if (i%2==0)
        {
            c = c-b;
            if (c<=0)
            {
                f = 1;
                break;
            }
        }
        else{
            a = a-d;
            if (a<=0)
            {
                f=0;
                break;
            }
        }
    }
    if (f==1)
    {
        cout<<"Yes"<<"\n";
    }
    else{
        cout<<"No"<<"\n";
    }
    
}

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

using namespace std;
using lint = long long;

template<class T>
T GCD(T n, T m) {
    return m ? GCD(m, n % m) : n;
}

int main() {
    lint N, M;
    string s, t;
    cin >> N >> M >> s >> t;

    lint g = GCD(N, M);
    lint res = N / g * M;
    N /= g, M /= g;
    bool ok = true;
    for (lint i = 0; i < g; ++i) {
        if (s[i * N] != t[i * M]) ok = false;
    }

    if (ok) {
        cout << res << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
using namespace std;
int g[100][100];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<100;i++)
		for(int j=0;j<100;j++)
			g[i][j]=99999999;
	for(int i=0;i<a;i++)
		g[i][i]=0;
	for(int i=0;i<a;i++){
		int b,c;
		scanf("%d%d",&b,&c);
		for(int j=0;j<c;j++){
			int d;
			scanf("%d",&d);
			g[b-1][d-1]=1;
		}
	}
	for(int k=0;k<a;k++)
		for(int i=0;i<a;i++)
			for(int j=0;j<a;j++)
				g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	scanf("%d",&a);
	while(a--){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		r=min(r,10000);
		
		if(r<=g[p-1][q-1])printf("NA\n");
		else printf("%d\n",g[p-1][q-1]+1);
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string S;

  for(int i = 0; i < W+2; i++){
    cout << '#';
  }
  cout << "\n";

  for(int i = 0; i < H; i++){
    cin >> S;
    cout << '#' << S << "#" << endl;
  }
  
  for(int i = 0; i < W+2; i++){
    cout << '#';
  }
  cout << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
long double dis(pair<int,int>p,pair<int,int>q){
    long double d=((p.first-q.first)*(p.first-q.first))+((p.second-q.second)*(p.second-q.second));
    return sqrt(d);
}
int main()
{
   
    double n;
    cin>>n;
    vector<pair<int,int>>p;
    int x,y;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        p.push_back(make_pair(x,y));
        
    }
    long double ans=0.0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
             ans+=dis(p[i],p[j])*(double)2;
             //cout<<ans<<" ";
        }
    }
    cout<<setprecision(10)<<ans/n<<endl;
    return 0;

} 

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print(*a, **dict(file=sys.stderr, **kw))

N, T = inm()
A = inl()
assert N > 1
assert len(A) == N


def solve():
    lmin = [None] * N
    lmin[0] = A[0]
    for i in range(1, N):
        lmin[i] = min(lmin[i - 1], A[i])

    rmax = [None] * N
    rmax[N - 1] = A[N - 1]
    for i in range(N - 2, -1, -1):
        rmax[i] = max(rmax[i + 1], A[i])

    gap = -1
    gmin = set()
    for i in range(N - 1):
        g = rmax[i + 1] - lmin[i]
        if g <= 0:
            continue
        if g > gap:
            gap = g
            gmin = {lmin[i]}
            # debug(f"{gap=}: {rmax[i+1]} - {lmin[i]}")
        elif g == gap and lmin[i] not in gmin:
            gmin.add(lmin[i])
    buy = len(gmin)
    assert buy > 0
    return buy


print(solve())


Measured memory_bytes: 19636
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,x,k=0,count=0;
    unordered_map<int,int> mp;
    cin>>n>>m>>x;
    int a[m];
    for (int i = 0; i <m; ++i)
    {
    	cin>>a[i];
    	mp[a[i]]=1;
    }
    
    for (int i=x; i<=n; ++i)
    {
    	if(mp.find(i)!=mp.end()){
    		k++;
    	}
    }

    for (int i =x; i>=0; i--)
    {
    	if(mp.find(i)!=mp.end()){
    		count++;
    	}
    }
    cout<<min(count,k)<<endl;
    return 0;
  }

Measured memory_bytes: 3544
n = int(input())
a = [n]
i = 1
flg = 0
while flg == 0:
  if n % 2 == 0:
    n = n // 2
  else:
    n = 3 * n + 1
  if n in a:
    flg = 1
  else:
    a.append(n)
  i += 1
print(i)

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

using namespace std;

const int maxn = 1e5 + 100;
int s[500];
int t[50];

int main() {
    long long n, m;
    long long a, b;

    cin >> n >> m;
    if (n % 3 == 0 || m % 3 == 0) {
        cout << 0 << endl;
    } else {
        if (n % 2 == 0 || m % 2 == 0) {
            if (n % 2 == 0) {
                a = n;
                b = m;
            } else {
                a = m;
                b = n;
            }
            if (n % 2 == 0 && m % 2 == 0) {
                a = min(n, m);
                b = max(n, m);
            }
            long long temp = a / 2;
            long long ans = 999999999999999999;
            for (int i = 1; i < b; i++) {
                ans = min(ans, abs(i * temp - (b - i) * a));
            }
            ans = min(ans,min(m,n));
            cout << ans << endl;

        } else {
            a = m + n;
            b = max(m, n);
            a = a - b;
            long long temp = a / 2;
            long long ans = 999999999999999999;
            for (int i = 1; i < b; i++) {
                long long aa = i * temp;
                long long bb = i * (temp + 1);
                long long cc = a * (b - i);
                ans = min(ans, max(aa, max(bb, cc)) - min(aa, min(bb, cc)));
            }
            ans = min(ans,min(m,n));

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

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String in = br.readLine();
        int n = in.length();
        String t1 = new StringBuilder(in).reverse().toString();
        
        String s1 = in.substring(0,(n-1)/2);
        String t2 = new StringBuffer(s1).reverse().toString();
        
        String s2 = in.substring((n+3)/2-1, n);
        String t3 = new StringBuffer(s2).reverse().toString();
        
        System.out.println(s1.equals(t2)&&s2.equals(t3)&&in.equals(t1) ? "Yes" : "No");
    }
}

Measured memory_bytes: 22612
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using lb = long double;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SI(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define debugV(x) for(int i=0;i<((ll)(x).size());i++)cerr << #x <<"at:"<<i<< ": " << x[i] << "\n"//手動デバッグ 
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
//------------------------------------------------------------





//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    string s,t;cin>>s>>t;
    ll ans=INF;
    if(s.size()-t.size()==0){
        ans=0;
        rep(i,s.size()){
            if(s[i]!=t[i])ans++;
        }
        O(ans);
        return 0;
    }
    rep(i,s.size()-t.size()){
        ll tmp=0;
        rep(j,t.size()){
            if(s[j+i]!=t[j])tmp++;
        }
        ans=min(ans,tmp);
    }
    O(ans);
    
    
    
    
//------------------------------------------------------------
	return 0;
}


Measured memory_bytes: 3656
import java.util.*;

class Main{
	public static void main(String args[]){
		Solve s = new Solve();
		s.solve();
	}
}

class Solve{
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()){
			int n = in.nextInt();
			if(n == 0) return;
			
			boolean f = true, l = true, r = true;
			int ans = 0;

			for(int i = 0; i < n; i++){
				String s = in.next();
				if(s.charAt(0) == 'l') l = !l;
				else r = !r;
				if((l == r) && (l != f)){
					ans++;
					f = l;
				}
			}

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

Measured memory_bytes: 36868
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define debug(x) cout<<x<<endl
#define int long long 
const int mod=1000000007;
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}
inline int read() {int num=0, w=0;char ch=0;while (!isdigit(ch)) {w|=ch=='-';ch = getchar();}while (isdigit(ch)) {num = (num<<3) + (num<<1) + (ch^48);ch = getchar();}return w? -num: num;}
// cin.tie(0);
// ios::sync_with_stdio(false);
// head
// long long *long long 		**
//all 
int a[1200000];
signed main()
{
	int n,k=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		a[i]=read();
	}
	for(int i=0;i<n-k;i++){
		if(a[i]<a[i+k]){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 5208
#include<iostream>


int main(){
  int a,b,c,i,n;
  std::cin>>n;
  for(i=0;i<n;i++){
    std::cin>>a;
    std::cin>>b;
    std::cin>>c;
    if      (a*a==b*b+c*c) {std::cout<<"YES"<<std::endl;}
    else if(b*b==a*a+c*c) {std::cout<<"YES"<<std::endl;}
    else if(c*c==a*a+b*b) {std::cout<<"YES"<<std::endl;}
    else std::cout<<"NO"<<std::endl;
    }

	
	return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] p = new int[M];
		String[] S = new String[M];
		for(int i = 0;i < M;i++){
			p[i] = sc.nextInt();
			S[i] = sc.next();
		}
		sc.close();

		int[] WA = new int[105000];
		boolean[] AC = new boolean[105000];
		int WAnum = 0;
		int ACnum = 0;
		for(int i = 0;i < N;i++){
			WA[i+1] = 0;
			AC[i+1] = false;
		}
		for(int i = 0;i < M;i++){
			if(AC[p[i]])continue;
			if(S[i].equals("AC")){
				AC[p[i]] = true;
				ACnum++;
				WAnum += WA[p[i]];
			}else if(S[i].equals("WA")){
				WA[p[i]]++;
			}
		}
		System.out.println(ACnum + " " + WAnum);
	}
}

Measured memory_bytes: 72240
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

const int MAXN = (int)1e6;
int x, y;
ll fact[MAXN + 5], inv[MAXN + 5];
const ll mod = (ll)1e9 + 7;

ll power(ll x, ll y){
	ll ret = 1;
	while(y){
		if(y & 1){
			ret = (ret * x) % mod;
		}
		x = (x * x) % mod;
		y >>= 1;
	}
	return ret;
}

ll mod_inv(ll x){
	return power(x, mod - 2);
}

ll povrh(ll x, ll y){
	ll gore = fact[x];
	ll dole = (inv[y] * inv[x - y]) % mod;
	//cout << 1 << endl;
	ll ret = (gore * dole) % mod;
	return ret;
}

void initstuff(){
	fact[0] = 1;
	for(ll i = 1 ; i <= MAXN ; ++i){
		fact[i] = (fact[i - 1] * i) % mod;
	}
	inv[0] = 1;
	for(int i = 1 ; i <= MAXN ; ++i){
		inv[i] = mod_inv(fact[i]);
	}
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
initstuff();
cin >> x >> y;
int sve = x + y;
if(sve % 3){
	cout << 0 << endl;
	return 0;
}
sve /= 3;
x -= sve;
y -= sve;
if(x < 0 || y < 0 || x > sve || y > sve){
	cout << 0 << endl;
	return 0;
}
ll sol = povrh(sve, y);
cout << sol << endl;

return 0;
}



Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
//#include<stdlib.h>
using namespace std;
int main() {
	int a = 0, n; bool c=true;
	string s;
	cin >> n;
	for (int t = 0; t < n; t++) 
	{
		cin >> s;
		if (s == "A") { a++; }
		else { a--; }
		if (a < 0) { c = false; break; }
	}
	if (a != 0) { c = false; }
	if (c) { cout << "YES"<<endl; }
	else { cout << "NO"<<endl; }
	return 0;
}


Measured memory_bytes: 3152
N = int(input())
S = str(input())
_sum = 0
visited = set()
_sum_visited = set()
max_size = len(set(S))


for n in range(N-1):
  if S[n] in S[n+1:] and (S[n] not in visited):
    _sum += 1
  
  elif S[n] in visited and (S[n] not in S[n+1:]):
    _sum -= 1
  
  visited.add(S[n])
  _sum_visited.add(_sum)
  last_size = len(set(S[n+1]))
  ans = max(_sum_visited)
  if ans == max_size:
    break
    
print(max(_sum_visited))

Measured memory_bytes: 9212
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int X,N;
  cin>>X>>N;
  int p[N];
  REP(i,N)cin>>p[i];
  int ans=-1;
  int score=999;
  REP(i,102){
    bool f=false;
    REP(j,N)if(i==p[j])f=true;
    if(f)continue;
    int temp=max(X-i,i-X);
    if(temp<score){
      score=temp;
      ans=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3624
public class Main {
    public static void main(String[] args) {

        // ??????????????????????????????.
        // ?????????????????????????????? 2 ??????????????????.
        java.util.Scanner sc = new java.util.Scanner(System.in);
        String s = sc.next();
        String p = sc.next();

        // ????????°??¶???????????? s ?????????????????? p ????????????????????????.
        boolean tf = false;
        String x = "";
        for (int i = 0; i < s.length(); i ++) {
            x = "";
            for (int j = 0; j < p.length(); j ++) { x += s.charAt((i + j) % s.length()); }
            if (x.equals(p)) { tf = true; }
        }
        if (tf == true) { System.out.println("Yes"); }
        else { System.out.println("No"); }
    }
}

Measured memory_bytes: 32272
from collections import defaultdict
import bisect
def solve():
    s = input()
    t = input()
    d = defaultdict(list)
    st_s = set(s)

    for i in range(len(s)):
        d[s[i]].append(i)
    
    round = 0
    prev = -1
    for i in range(len(t)):
        if not t[i] in st_s:
            print(-1)
            return
        now = getNextIdx(prev,d[t[i]])
        if now <= prev:
            round += 1
        
        prev = now
    
    print(prev + round*len(s) + 1)

def getNextIdx(prev,idx_list):
    ret_idx = bisect.bisect_right(idx_list, prev)
    if ret_idx == len(idx_list):
        return idx_list[0]

    return idx_list[ret_idx]

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7924
#!/usr/bin/env python3

N = int(input().split()[0])


def get_divisor(n: int) -> list:
    d_list = []
    for i in range(1, int(n ** (1 / 2)) + 1):
        if n % i == 0:
            a = int(n / i)
            d_list.append((i, a))
    return d_list


min_d = float("inf")

for d_set in get_divisor(N):
    x, y = d_set
    min_d = min(abs(1 - x) + abs(1 - y), min_d)

ans = min_d
print(ans)


Measured memory_bytes: 3432
#include <iostream>

using namespace std;

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

int field[20][20];

int dfs(int W, int H, int x, int y, int step, int limit){
	if(++step > limit){ return limit; }
	for(int i = 0; i < 4; ++i){
		int fx = x + dx[i], fy = y + dy[i];
		if(fx < 0 || fx >= W || fy < 0 || fy >= H){ continue; }
		while(!(fx < 0 || fx >= W || fy < 0 || fy >= H)){
			if(field[fy][fx] < 0){ return step; }
			if(field[fy][fx] > 0){
				fx -= dx[i]; fy -= dy[i];
				break;
			}
			fx += dx[i]; fy += dy[i];
		}
		if(fx < 0 || fx >= W || fy < 0 || fy >= H){ continue; }
		if(fx == x && fy == y){ continue; }
		field[fy + dy[i]][fx + dx[i]] = 0;
		limit = min(limit, dfs(W, H, fx, fy, step, limit));
		field[fy + dy[i]][fx + dx[i]] = 1;
	}
	return limit;
}

int main(){
	while(true){
		int w, h;
		cin >> w >> h;
		if(w == 0 && h == 0){ break; }
		int x = 0, y = 0;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				cin >> field[i][j];
				if(field[i][j] == 2){
					x = j; y = i;
					field[i][j] = 0;
				}else if(field[i][j] == 3){
					field[i][j] = -1;
				}
			}
		}
		int answer = dfs(w, h, x, y, 0, 11);
		if(answer >= 11){ answer = -1; }
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char C;
  cin >> C;
  
  if (C == 'a' || C == 'i' || C == 'u' || C == 'e' || C == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> x(n), y(n);
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
        a[i] = x[i] + y[i];
        b[i] = x[i] - y[i];
    }
    sort(all(a));
    sort(all(b));
    cout << max(a[n - 1] - a[0], b[n - 1] - b[0]) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 9532
#include <bits/stdc++.h>
#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 endl    '\n'
#define INF 2e9
#define int ll
#define vi          vector<int>
#define de          deque<int>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()//全範囲指定を簡略化
typedef long long ll;
using namespace std;
//配列の要素数は　sizeof(ar)/sizeof(ar[0]) で求める

string S;
int N, cnt;

signed main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  

int main() {
	string s1, s2,ans;
	int n;
	cin >> n >> s1 >> s2;
	for (int i = 0; i < n; i++) {
		ans += s1[i];
		ans += s2[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    long[] a=new long[n];
   double l=0,sum=0;
    for(int i=0;i<n;i++) {
    	a[i]=sc.nextLong();
    	sum+=a[i];
    }
    for(int i=0;i<n;i++) {
    	if(l<sum/2) {
    		l+=a[i];
    	}
    	if(l==sum/2){
    		System.out.println("0");
    		break;
    	}
    	if(l>sum/2){
    		System.out.println((long)Math.min(Math.abs(2*l-sum), Math.abs(2*(l-a[i])-sum)));
    		break;
    	}
    }
  }
}


Measured memory_bytes: 95852
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])

const p = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = () => {
  let count = 0
  for (let i = 1; i < n - 1; i++) {
    const sorted = [p[i - 1], p[i], p[i + 1]].sort((a, b) => a - b)
    if (sorted[1] === p[i]) {
      count++
    }
  }

  console.log(count)
}

ans()


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int n;
  while (cin >> n) {
    cout << (n / 10 == 9 || n % 10 == 9 ? "Yes" : "No") << endl;
  }
  
  return 0;
}


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

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

    ll n; cin >> n;
    vector<ll> a(n,0); for(ll i=0;i<n;i++) cin >> a[i];
    ll sum = 0; sum = accumulate(a.begin(), a.end(), 0LL);
    ll q; cin >> q;
    vector<ll> b(q,0), c(q,0); for (ll i=0;i<q;i++) cin >> b[i] >> c[i];

    vector<ll> dp(1000000, 0);
    for (ll i=0;i<n;i++) {
        dp[a[i]] += 1;
    }

    ll ans = sum;
    for (ll i=0;i<q;i++) {
        ans = ans - (b[i] * dp[b[i]]) + (c[i] * dp[b[i]]);
        dp[c[i]] = dp[c[i]] + dp[b[i]];
        dp[b[i]] = 0;
        cout << ans << endl;
    }
   

    return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int r,g,b,n;
int ans = 0;
vector<pair<int, int> >ans_pair;
bool rec(int i, int R, int G, int B)
{
    if(i == n )
    {
        rep(i,ans_pair.size())
        {
            if(R == ans_pair[i].first && G == ans_pair[i].second) return false;
        }
        ans++;
        ans_pair.push_back(make_pair(R,G));
        return true;
    }
    else if(i > n) return false;
    rec(i+r,R+1,G,B);
    rec(i+g,R,G+1,B);
    rec(i+b,R,G,B+1);
    return true;
}


int main()
{
    cin >> r >> g >> b >> n;
    //rec(0,0,0,0);
    for(int R = 0;R < n+1;R += r)
    {
        for(int G = 0;G + R < n+1;G += g)
        {
            if((n-G-R)%b == 0) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    ll L, R;
    cin >> L >> R;
    const long div = 2019;
    // 2019の倍数が間にあれば0になる
    if(R / div - L / div > 0) cout << 0 << endl;
    // かけると2019の倍数になるかもしれない
    // 2019を超える可能性があるかどうかの判定
    else
    {
        ll _min = INF;
        for(size_t i=L%div;i<R%div; i++)
        {
            for(size_t j=(L+1)%div;j<=R%div; j++)
            {
                _min = min(_min, (ll)(i*j)%div);
            }
        }
        cout << _min << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2);
		return (tmp * tmp) % MOD;
	}
	return (a * mod_pow(a, n - 1)) % MOD;
}

vector<ll> fact;
vector<ll> inv_fact;

void comb_init(int n) {
	fact.resize(n + 1);
	inv_fact.resize(n + 1);
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv_fact[i] = (inv_fact[i - 1] * mod_pow(i, MOD - 2)) % MOD;
	}
}

ll comb(int n, int k) {
	if (n < k) return 0;
	ll ret = fact[n];
	(ret *= inv_fact[k]) %= MOD;
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}
ll p[200001], q[200001];
int main() {
	int B, W;
	cin >> B >> W;
	comb_init(B + W);
	ll x = mod_pow(2, MOD - 2);
	for (int i = B; i < B + W; i++) {
		p[i] = p[i - 1];
		(p[i] += (comb(i - 1, B - 1)*mod_pow(x, i)) % MOD) %= MOD;
	}
	for (int i = W; i < B + W; i++) {
		q[i] = q[i - 1];
		(q[i] += (comb(i - 1, W - 1)*mod_pow(x, i)) % MOD) %= MOD;
	}
	for (int i = 0; i < B + W; i++) {
		ll ans = (1 + (MOD - p[i]) + q[i]) % MOD;
		(ans *= x) %= MOD;
		cout << ans << endl;
	}
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
typedef vector<ull> vec;
typedef vector<vec> mat;
typedef pair<int,ull> P;
#define N 4
ull po[N*N+10];
ull m2i(mat m){
  int res=0;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      res+=m[i][j]*po[i*N+j];
  return res;
}
mat i2m(ull x){
  mat res(N,vec(N));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      if(i==N-1&&j==N-1) res[i][j]=x/po[i*N+j];
      else res[i][j]=(x%po[i*N+j+1])/po[i*N+j];
  return res;
}
int dist(mat m){
  int res=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(!m[i][j]) continue;
      int k=m[i][j]-1;
      int y=k/N,x=k%N;
      res+=abs(i-y)+abs(j-x);
    }    
  }
  return res;
}
signed main(){
  po[0]=1;
  for(int i=0;i<N*N;i++) po[i+1]=po[i]*(N*N);
  mat p(N,vec(N));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      cin>>p[i][j];
  mat e(p);
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      e[i][j]=i*N+j+1;
  e[N-1][N-1]=0;
  ull ans=m2i(e);
  //cout<<ans<<endl;
  priority_queue<P,vector<P>,greater<P> > q;
  map<ull,int> m;
  q.push(P(dist(p),m2i(p)));
  m[m2i(p)]=0;
  int ax[]={1,0,-1,0};
  int ay[]={0,1,0,-1};
  while(!q.empty()){
    P y=q.top();q.pop();
    ull x=y.second;
    if(x==ans) break;
    p=i2m(x);
    int zy,zx;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
	if(p[i][j]==0) zy=i,zx=j;
    //cout<<zy<<" "<<zx<<endl;
    for(int k=0;k<4;k++){
      int ny=zy+ay[k],nx=zx+ax[k];
      if(ny<0||N<=ny||nx<0||N<=nx) continue;
      swap(p[zy][zx],p[ny][nx]);
      ull t=m2i(p);
      //cout<<t<<endl;
      if(!m.count(t)||m[x]+1<m[t]){
	m[t]=m[x]+1;
	//if(t==ans) break;
	q.push(P(m[t]+dist(p),t));
      }
      swap(p[zy][zx],p[ny][nx]);
    }
  }
  cout<<m[ans]<<endl;
  return 0;
}

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

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

goke = 0
ans = 0

for i in range(len(a)):
    goke += a[i]

ave = goke / N

ans = 0
for i in range(len(a)):
    if abs(ave-a[ans]) > abs(ave - a[i]):
        ans = i


print(ans)

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

const int MAX_N	= 100;
int t[ MAX_N + 5 ];
int v[ MAX_N + 5 ];
int A[ MAX_N + 5 ];

int main()
{
int i;
int j;
int N;
int T;
int L;
int R;
int iSum;
int iTop;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;

	for( i = 0; i < N; i++ )
	{
		cin >> t[ i ];

		t[ i ] *= 2;
	}

	A[ 0 ] = 0;
	for( i = 0; i < N; i++ )
	{
		cin >> v[ i ];

		v[ i ] *= 2;
		A[ i ] = min( A[ i ], v[ i ] );
		A[ i + 1 ] = min( A[ i ] + t[ i ], v[ i ] );
	}

	A[ N ] = 0;
	for( i = N - 1; i > 0; i-- )
		A[ i ] = min( A[ i ], A[ i + 1 ] + t[ i ] );

	iSum = 0;
	for( i = 0; i < N; i++ )
	{
		iTop = ( A[ i ] + t[ i ] + A[ i + 1 ] ) / 2;
		R = ( A[ i ] + t[ i ] - A[ i + 1 ] ) / 2;
		L = t[ i ] - R;
		iSum += ( L * ( A[ i ] * 2 + L ) + R * ( A[ i + 1 ] * 2 + R ) ) / 2;
		if( iTop > v[ i ] )
		{
			iTop -= v[ i ];
			iSum -= iTop * iTop;
		}
	}

	i = iSum % 4;
	if( i == 0 )
		cout << iSum / 4 << endl;
	else if( i == 1 )
		cout << iSum / 4 << ".25" << endl;
	else if( i == 2 )
		cout << iSum / 4 << ".5" << endl;
	else if( i == 3 )
		cout << iSum / 4 << ".75" << endl;

	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <deque>

using namespace std;

int main(){
	while( 1 ){
		int sum = 0;
		int n, s;
		deque< int > scores;
		scanf( "%d", &n );
		if( !n ){ return 0; }
		for( int i = 0; i < n; i++ ){
			scanf( "%d", &s );
			scores.push_back( s );
		}
		sort( scores.begin(), scores.end() );
		for(deque<int>::iterator it = scores.begin() + 1; it + 1 != scores.end(); it++){
			sum += *it;
		}
		
		printf( "%d\n", sum / ( n - 2 ) );
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define LARGE 101
#define INF 2000000000

int main(){
	int i,j,N,W;
	int sum=0;
	int v[LARGE];
	int w[LARGE];
	int **dp;

	scanf("%d %d",&N,&W);
	
	for(i=1;i<=N;i++){
		scanf("%d %d",&v[i],&w[i]);
		sum+=v[i];
	}
	
	dp=malloc(sizeof(int*)*(N+1));
	for(i=0;i<=N;i++){
		dp[i]=malloc(sizeof(int)*(sum+1));
		for(j=0;j<=sum;j++)dp[i][j]=INF;
	}
	
	
	for(i=0;i<=N;i++)dp[i][0]=0;
	
	for(i=1;i<=N;i++){
		for(j=0;j<=sum;j++){
			if(dp[i-1][j]!=INF){
				dp[i][j]=MIN(dp[i-1][j],dp[i][j]);
				if(dp[i-1][j]+w[i]<=W)dp[i][j+v[i]]=MIN(dp[i][j+v[i]],dp[i-1][j]+w[i]);
			}
		}
	}
	
	for(i=sum;i>=0;i--){
		if(dp[N][i]!=INF){
			printf("%d\n",i);
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 5684
# Problem 
# Ruby 3rd Try
si = gets.chomp.split('')
apos = 0
zpos = si.size-1
0.upto(si.size-1){ |j|
    if si[j] == 'A'
        apos = j
        break
    end
}
(si.size-1).downto(0){ |j|
    if si[j] == 'Z'
        zpos = j
        break
    end
}
answer = (zpos-apos)+1
puts(answer)

Measured memory_bytes: 16764
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
scanf("%d/%d/%d",&x,&y,&z);
if(y<=4)cout <<"Heisei";
else cout << "TBD";
}



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

vector<int> graph[200100];
int n, m;

bool dfs(int from, bool flag){
    if(flag){
        for(auto e : graph[from]){
            if(e == n) return true;
        }
        return false;
    }
    bool ans = false;
    for(auto x : graph[from]){
        if(x == n) return true;
        ans |= dfs(x, true);
    }
    return ans;
}

int main() {
    cin >> n >> m;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        ///graph[b].push_back(a);
    }
    cout << (dfs(1, false) ? "POSSIBLE\n" : "IMPOSSIBLE\n");
}


Measured memory_bytes: 8576
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

struct con{
    ll t;
    ll c;
    ll s;
    con(ll i, ll j, ll k){
        t = i;
        c = j;
        s = k;
    }
};

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N, C;
    cin >> N >> C;
    vector<con> v;
    ll i, j, k;
    REP(l, N) {
        cin >> i >> j >> k;
        v.push_back(con(i, k, 1));
        v.push_back(con(j, k, -1));
    }

    sort(v.begin(), v.end(), [](con& a, con& b){
        if (a.c == b.c) return (a.t == b.t) ? (a.s > b.s) : (a.t < b.t);
        else return (a.c < b.c);
    });
    REP(i, v.size()){
        if (i < v.size() - 1 && v[i].t == v[i+1].t && v[i].c == v[i+1].c){
            v[i].s = 0;
            v[i+1].s=0;
        }else if (v[i].s == -1) v[i].t++;
    }
    sort(v.begin(), v.end(), [](con& a, con& b){
        return (a.t < b.t);
    });

    ll ans = 0, tmp = 0;
    REP(i, v.size()){
        tmp += v[i].s;
        if (i == v.size() - 1 || v[i].t != v[i+1].t) ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 8432
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=100;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}
int a,b;

int main()
{
	read(a),read(b);
	printf("%d\n",max(0,a-2*b));
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long>m(n);
    vector<long long>a(n);
    long long tmp, sum=0;
    for(int i=0; i<n; i++){
        cin >> tmp;
        m[i]=tmp;
        sum += tmp;
        a[i] = sum;
    }
    
    long long ans = 1e15;
    for(int i=0; i<n-1; i++){
        ans = min(ans, abs(a[i]-(sum-a[i])) );
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6404
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

ans = 1000
[a, b, c, d, e].permutation do |p|
  last = 0
  p.each_with_index do |t, i|
    if i == 4
      last += t
    else
      last += (t + 9) / 10 * 10
    end
  end
  ans = [ans, last].min
end
puts ans


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

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string a0;
    int l;
    vector<int> data;
    int ai, ij;
    int j;

    while (cin >> a0 >> l,l) {

        data.clear();

        while (true) {

            while(a0.size() != l)
                a0 = "0" + a0;

            data.push_back(stoi(a0));

            sort(a0.begin(),a0.end());

            string min = a0;
            string max = a0;
            reverse(max.begin(), max.end());

            int d = stoi(max) - stoi(min);

            auto itr = find(data.begin(), data.end(), d);
            j = distance(data.begin(), itr);

            if(j != data.size()) {
                ai = d;
                ij = data.size() - j;
                break;
            }

            a0 = to_string(d);

        }

        cout << j << " " << ai << " " << ij << endl;
    }

    return 0;

}

Measured memory_bytes: 3236
'use strict'
function Main(input) {
    input = input.split("\n")[0].split(' ').map(str => parseInt(str))

    const r = input[0]; const D = input[1]; const x_2000 = input[2]

    let val = x_2000
 
    for(let i = 0; i < 10; i++) {
       val = r * val - D
       console.log(val)
    }
   
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

signed main()
{
   int N; cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   sort(a.begin(),a.end());

   if(N%2==0){
      int ans=0;
      for(int i=0;i<N/2;i++){
         ans-=a[i]*2;
      }
      for(int i=N/2;i<N;i++){
         ans+=a[i]*2;
      }
      ans+=a[N/2-1];
      ans-=a[N/2];
      cout<<ans<<endl;
   }else{
      int ans1=0;
      for(int i=0;i<N/2;i++){
         ans1-=a[i]*2;
      }
      for(int i=N/2;i<N;i++){
         ans1+=a[i]*2;
      }
      ans1-=a[N/2];
      ans1-=a[N/2+1];

      int ans2=0;
      for(int i=0;i<N/2+1;i++){
         ans2-=a[i]*2;
      }
      for(int i=N/2+1;i<N;i++){
         ans2+=a[i]*2;
      }
      ans2+=a[N/2];
      ans2+=a[N/2-1];
      
      cout<<max(ans1,ans2)<<endl;
   }
}


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

map<ll,ll>f;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,b,x=0,y=0;
    cin>>a>>b;
    string s;
    x=__lg(b/a);
    cout<<x+1<<endl;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 2);
    A[0] = 0;
    rep(i, N) cin >> A[i + 1];
    A[N + 1] = 0;

    ll sum = 0;
    rep(i, N + 1) sum += abs(A[i + 1] - A[i]);

    rep(i, N) {
        int diff = abs(A[i + 2] - A[i]) - abs(A[i + 2] - A[i + 1]) - abs(A[i + 1] - A[i]);
        cout << sum + diff << endl;
    }
}


Measured memory_bytes: 1664
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
      	int hundred=N/100;
        int ten=(N-hundred*100)/10;
        int one=(N-hundred*100-ten*10);
        
      	if(one==7 || ten==7 || hundred==7){
        System.out.println("Yes");}
      	else{
        System.out.println("No");}
	}
}

Measured memory_bytes: 27080
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;

#define EPS (1e-3)

int n;
double a, b, c;
double x[32], y[32], z[32];

double getDist(int idx1, int idx2){
  return sqrt(
    pow(x[idx1] - x[idx2], 2) + 
    pow(y[idx1] - y[idx2], 2) +
    pow(z[idx1] - z[idx2], 2));
}

bool EQ(double val1, double val2){
  if(fabs(val1 - val2) < EPS){
    return true;
  }
  return false;
}

void solve(){
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j) continue;

      for(int k = 0; k < n; k++){
	if(i == k || j == k) continue;

	double A = getDist(i, j);
	double B = getDist(j, k);
	double C = getDist(k, i);
	double mul = a / A;

	A *= mul;
	B *= mul;
	C *= mul;

	if(EQ(A, a) && EQ(B, b) && EQ(C, c)){
	  cout << k + 1 << " " << i + 1 << " " << j + 1 << endl;
	  return;
	}
      }
    }
  }
}

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

  while(T--){
    cin >> a >> b >> c;
    cin >> n;

    for(int i = 0; i < n; i++){
      cin >> x[i] >> y[i] >> z[i];
    }

    solve();
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  vector<bool> row(H,false);
  vector<bool> col(W,false);

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(A.at(i).at(j)=='#'){
      	row.at(i)=true;
        col.at(j)=true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
     if(row.at(i)){
        for (int j = 0; j < W; j++) {     
            if(col.at(j)){
                cout << A.at(i).at(j); 
            }
         }
     cout << endl;
     }
  }
}

Measured memory_bytes: 256