akhauriyash/Code-Regression huggingface dataset:
<?php
// Your code here!
 //配列を作る
    fscanf(STDIN,"%d",$x);
    $info = array();
    for($i=0;$i<$x;$i++){
        fscanf(STDIN,"%d %d %d %d",$tou,$kai,$ban,$num);
        if(!isset($info[$tou][$kai][$ban])){
            $info[$tou][$kai][$ban] = $num;
        }else{
            $info[$tou][$kai][$ban] += $num;
        }
    }
    
    
    //何棟かのループ
    for($j=1;$j<=4;$j++){
        //何階かのループ
        for($m=1;$m<=3;$m++){
            //何番目の部屋かのループ
            for($n=1;$n<=10;$n++){
                echo " ";
                if(empty($info[$j][$m][$n])){
                    echo 0;
                }else{
                    print_r($info[$j][$m][$n]);
                }
                
            }
            echo "\n";
        }
        if($j<4){
            echo "####################\n";
        }
    }
?>


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

string s, p;

int main(){
	cin >> s >> p;
	s += s;
	bool f = false;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < p.size(); j++) {
			if (p[j] != s[i + j]) {
				break;
			}
			if (j == p.size() - 1) {
				cout << "Yes" << endl;
				f = true;
				break;
			}
		}
		if (f) {
			break;
		}
	}
	if (!f) {
		cout << "No" << endl;
	}

	return 0;
}

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

int main()
{
    int N, D, A;
    cin >> N >> D >> A;
    vector<pair<int, int>> XH(N, make_pair(0, 0));
    for (int i = 0; i < N; i++)
    {
        cin >> XH.at(i).first >> XH.at(i).second;
    }

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

    int64_t res = 0;
    int64_t acc = 0;
    queue<pair<int, int64_t>> q;
    for (int i = 0; i < N; i++)
    {
        int Xi = XH.at(i).first, Hi = XH.at(i).second;
        while (!q.empty() && q.front().first < Xi)
        {
            auto f = q.front();
            acc -= f.second;
            q.pop();
        }
        Hi -= acc;
        
        if (Hi > 0)
        {
            int64_t count = (Hi + A - 1) / A;
            res += count;

            int64_t damage = A * count;
            Hi -= damage;
            acc += damage;
            q.push(make_pair(Xi + 2 * D, damage));
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,k,a[N],bit[N],ans=0;
vector<ll> sum;
void update(ll x)
{
	x++;
	while(x<=n)
	{
		bit[x]++;
		x+=(x&(-x));
	}
	return;
}
ll getans(ll x)
{
	ll ret=0;
	x++;
	while(x>0)
	{
		ret+=bit[x];
		x-=(x&(-x));
	}
	return ret;
}
int main(){
	ll i,x=0,pos;
	cin>>n>>k;
	memset(bit,0,sizeof(bit));
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]-=k;
		x+=a[i];
		sum.push_back(x);
	}
	sort(sum.begin(),sum.end());
	sum.erase(unique(sum.begin(),sum.end()),sum.end());
	x=0;
	for(i=0;i<=n;i++)
	{
		pos=lower_bound(sum.begin(),sum.end(),x)-sum.begin();
		x+=a[i];
		ans+=getans(pos);
		update(pos);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6004
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int f;
  cin>>f;
  cout<<(f-30)/2<<'\n';
  return(0);
}



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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a = inf,b = inf,c;
  rep(i,3){
  cin >> c;
  a = min(a,c);
  }
  rep(i,2){
    cin >> c;
    b = min(b,c);
  }
  cout << a + b - 50 << endl;
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    ll N , A , B;
    cin >> N >> A >> B;
    ll C = A * (N - 1) + B;
    ll D = B * (N - 1) + A;
    if(D - C + 1 <= 0){
        cout << 0 << endl;
    }
    else{
        cout << D - C + 1 << endl;
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC145E()
{
	int N, T;
	cin >> N >> T;
	vi A(N), B(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i] >> B[i];
	}

	vvi values(N, vi(T + 1));
	vvi values2(N, vi(T + 1));

	for (int j = A[0]; j < T; ++j)
	{
		values[0][j] = B[0];
	}
	for (int j = 0; j < min(T,A[0]); ++j)
	{
		values2[0][j] = B[0];
	}
	for (int i = 1; i < N; ++i)
	{
		for (int j = 0; j < T; ++j)
		{

			if (j - A[i] >= 0)
			{
				int x = values[i - 1][j];
				int y = values[i - 1][j - A[i]] + B[i];
				values[i][j] = max(x, y);
				if (x > y)
				{
					values2[i][j] = max(values2[i - 1][j], B[i]);
				}
				else if(x < y)
				{
					values2[i][j] = values2[i - 1][j - A[i]];
				}
				else
				{
					values2[i][j] = max(max(values2[i - 1][j], B[i]), values2[i-1][j-A[i]]);
				}

			}
			else
			{
				values[i][j] = values[i - 1][j];
				values2[i][j] = max(values2[i - 1][j], B[i]);
			}
		}
	}
	int ans = values[N - 1][T - 1] + values2[N - 1][T - 1];
	cout << ans << endl;
}
int main()
{
	ABC145E();
	return 0;
}


Measured memory_bytes: 70784
#include <cstdio>
#include <algorithm>

int main()
{
	int x = 0, y = 0;
	int temp;
	int count;
	while (scanf("%d %d", &x, &y) != EOF) {
		if (x == 0 && y == 0) {
			break;
		}

		temp = 0;

		if (x < y) {
			temp = x;
			x = y;
			y = temp;
		}

		for (count = 0; y != 0; count++) {
			x = x % y;
			temp = x;
			x = y;
			y = temp;
		}

		printf("%d %d\n", x, count);

	}
	return 0;
}

Measured memory_bytes: 2740
import math
a, b, x = map(int, input().split())
if (a**2)*b/2 < x:
    p = 2*b -(2*x)/(a**2)
    q = a
    print(90-math.degrees(math.atan2(a, 2*b -(2*x)/(a**2))))
elif (a**2)*b/2 == x:
    p = 1
    q = 1
    print(90/2)
else:
    c = 2*x/(a*b)
    
    print(90-math.degrees(math.atan2(c, b)))

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

int main(){
  int n;
  while(cin >> n){
    unsigned long ans[100][200]={};
    int tmp;
    cin >> tmp;
    ++ans[0][tmp];
    for(int i=1; i<n-1; ++i){
      cin >> tmp;
      for(int j=0; j<200; ++j){
        if(ans[i-1][j]>0){
          if(j+tmp<=20)ans[i][j+tmp]+=ans[i-1][j];
          if(j-tmp>=0)ans[i][j-tmp]+=ans[i-1][j];;
        }
      }
    }
    cin >> tmp;
    cout << ans[n-2][tmp] << endl;
  }
}



Measured memory_bytes: 3276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(a*b%2 == 0 ? "Even" : "Odd");
	}

}


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

int main() {
	double a, b, c, d, e, f, p, q, x, y;
	while (cin >> a >> b >> c >> d >> e >> f) {
		p = (c * e - f * b) / (a * e - d * b);
		q = (c - a * p) / b;
		x = round(1000 * p) / 1000;
		y = round(1000 * q) / 1000;
		if (x == 0) x = 0;
		if (y == 0) y = 0; //-0.000??¨??¨???????????????????????¢
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 1248
n,k=map(int,input().split())
mod=10**9+7

#x**t%mod
def pow(x,t):
    if t==0:
        return 1
    a=pow(x,t>>1)
    return a*a*(x**(t&1))%mod

#n!%mod
fact=[0]*(n+1)
fact[0]=1
for i in range(1,n+1):
    fact[i]=fact[i-1]*i
    fact[i]%=mod

#1/n!%mod
ifact=[0]*(n+1)
ifact[n]=pow(fact[n],mod-2)
for i in range(n,0,-1):
    ifact[i-1]=ifact[i]*i
    ifact[i-1]%=mod


def nCr(n,r):
    if r<0 or r>n:
        return 0
    return fact[n]*ifact[r]*ifact[n-r]%mod


for i in range(1,k+1):
  ans=nCr(k-1,i-1)*nCr(n-k+1,i)
  ans%=mod
  print(ans)


Measured memory_bytes: 3444
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    S = [str(sys.stdin.readline().rstrip()) for _ in range(N)]
    M = int(sys.stdin.readline().rstrip())
    T = [str(sys.stdin.readline().rstrip()) for _ in range(M)]
    target = set(S)

    ret = 0
    for s in target:
        tmp = S.count(s) - T.count(s)
        if ret < tmp:
            ret = tmp

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes";
    }else{
        cout << "No";
    }
    

}


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

int main() {
  long n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(long i=0;i<n;i++) cin >> s[i];
  sort(s.begin(),s.end());
  for(long i=0;i<n;i++) cout << s[i];
  cout << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a, b, c, d;
  int ans;
  cin >> a >> b >> c >> d;
  if(b <= c ||  d <= a){
    //cout << 0 << endl;
    ans = 0;
  }else{
    // c < b
    if(a < c && c < b && b < d){
      ans = b - c;
    }else if(a < c && d <= b){
      ans = d - c;
    }else if( c <= a && d < b){
      ans = d - a;
    }else{
      ans = b - a;
    }

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


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

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

    long long sum=0;
    for(int i=1;i<=N;i++){
        if(i % 5 != 0 && i % 3 != 0){
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int total = K;
  for (int i = 1; i < N; i++) {
    total *= (K - 1);
  }
  
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll a,b;
    cin >> a >> b;
    ll ans=0;
    ans = a*b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
gets
as = gets.split.map &:to_i

colors = []
kinds = 0
as.each do |a|
  if a <= 399
    colors[0] = true
  elsif a <= 799
    colors[1] = true
  elsif a <= 1199
    colors[2] = true
  elsif a <= 1599
    colors[3] = true
  elsif a <= 1999
    colors[4] = true
  elsif a <= 2399
    colors[5] = true
  elsif a <= 2799
    colors[6] = true
  elsif a <= 3199
    colors[7] = true
  else
    kinds += 1
  end
end

min = colors.count(true)
max = min + kinds
min = [min, 1].max
print min, ' ', max


Measured memory_bytes: 1788
#include <stdio.h>

typedef struct{
    int parent;
    int left;
    int right;
}Tree;

Tree t[100000];
int num,depth[100000],height[100000];

void print(int);
void setDep(int,int);
int setHei(int);
int getSib(int);

int main(){
    int v,k,l,r,c,i,root = 0;

    scanf("%d",&num);
    for(i = 0; i< num; i++){
        t[i].parent = -1;
        t[i].left = -1;
        t[i].right = -1;
    }
    
    for(i = 0; i< num; i++){
        scanf("%d %d %d",&v,&l,&r);
        
        t[v].left = l;
        t[v].right = r;
        
        if(l != -1)t[l].parent = v;
        if(r != -1)t[r].parent = v;
    }
    
    for(i = 0; i < num; i++){
        if(t[i].parent == -1)root = i;
    }
    
    setDep(root,0);
    setHei(root);
    
    for(i = 0; i< num; i++)print(i);
    return 0;
}


void print(int u){
    
    int i,c;
    printf("node %d: parent = %d, sibling = %d, ",u,t[u].parent,getSib(u));
    int degree = 0;
    if(t[u].left != -1) degree++;
    if(t[u].right != -1) degree++;
    printf("degree = %d, depth = %d, height = %d, ",degree,depth[u],height[u]);
    
    if(t[u].parent == -1) printf("root\n");
    else if(t[u].left == -1 && t[u].right == -1) printf("leaf\n");
    else printf("internal node\n");
}

void setDep(int u,int p){
    
    if(u == -1) return;
    depth[u] = p;
    setDep(t[u].right,p+1);
    setDep(t[u].left,p+1);
    
}

int setHei(int u){
    int h1 = 0,h2 = 0,h;
    
    if(t[u].left != -1){
        h1 = setHei(t[u].left)+1;
    }
    if(t[u].right != -1){
        h2 = setHei(t[u].right)+1;
    }
    if(h1 > h2) height[u] =h1;
    else height[u] = h2;
    
    return height[u];
}

int getSib(int u){
    
    if(t[u].parent == -1) return -1;
    if(t[t[u].parent].left != u && t[t[u].parent].left != -1) return t[t[u].parent].left;
    if(t[t[u].parent].right != u && t[t[u].parent].right != -1) return t[t[u].parent].right;
    
    return -1;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
long long n, k;
vi x, y, vx, vy;

int main(){
    cin >> n >> k;
    x = vi(n);
    y = vi(n);
    rep(i, n){
        cin >> x[i] >> y[i];
        vx.push_back(x[i]);
        vy.push_back(y[i]);
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());
    long long ans = 1LL * (vx[n - 1] - vx[0]) * (vy[n - 1] - vy[0]);
    rep(xi, n)loop(xj, xi + 1, n)rep(yi, n)loop(yj, yi + 1, n){
        long long ue = vy[yj], sita = vy[yi], migi = vx[xj], hidari = vx[xi];
        int cnt = 0;
        rep(i, n)
            if(sita <= y[i] && y[i] <= ue && hidari <= x[i] && x[i] <= migi)
                cnt++;
        if(cnt >= k)
            ans = min(ans, 1LL * (ue - sita) * (migi - hidari));
    }
    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);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();

        long max = b*d;
        max = Math.max(max, a*c);
        max = Math.max(max, a*d);
        max = Math.max(max, b*c);

        System.out.println(max);
    }
}

Measured memory_bytes: 35764
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String K = sc.next();

        long longA = Long.parseLong(A);
        long longB = Long.parseLong(B);
        long longK = Long.parseLong(K);

        if (longK >= longA) {
            longK = longK - longA;
            longA = 0;
        } else {
            longA = longA - longK;
            longK = 0;
        }

        if (longK >= longB) {
            longK = longK - longB;
            longB = 0;
        } else {
            longB = longB - longK;
            longK = 0;
        }

        System.out.println(longA + " " + longB);
    }
}


Measured memory_bytes: 21716
#include <stdio.h>

int main( void ) 
{
	int b[101];
	int a[101][101];
	int c[101];
	int n,m;
	int i,j;

	scanf( "%d%d", &n, &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++ ) {
		c[i]=0;
		for( j=0; j<m; j++ ) {
			c[i]+=a[i][j]*b[j];
		}
	}
	for( i=0; i<n; i++ ) {
		printf( "%d\n", c[i] );
	}

	return 0;
}

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

constexpr ll INF = ll(1e+18) + 1;

int main(){
    int n, ans, ctr = 0;
    vector<int> a;
    int buf, idx = 1;
    bool *flag; //falseで初期化、参照したらtrue

    cin >> n;
    a.push_back(-1);
    rep(i, n){
        cin >> buf;
        a.push_back(buf);
    }
    flag = new bool[n + 1];
    rep(i, n+1) {flag[i] = false;}
    
    while (flag[idx] == false && idx != 2) {
        flag[idx] = true;
        idx = a[idx];
        ctr++;
    };
    (ctr > 0 && idx == 2) ? ans = ctr : ans = -1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
n = int(input())
t, x, y = 0, 0, 0
flag = 0
for i in range(n):
    t_in, x_in, y_in = map(int, input().split())
    time_dis = t_in - t
    move_dis = abs(x_in-x) + abs(y_in-y)
    if time_dis < move_dis:
        flag = -1
    elif abs(move_dis - time_dis) % 2 == 1:
        flag = -1
    else:
        t, x, y = t_in, x_in, y_in

if flag == -1:
    print("No")
else:
    print("Yes")


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

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;
const int modulo = 1e9 + 7;
template<typename T>
inline T sum(const T& a, const T& b) { return T((a % modulo + b % modulo) % modulo); }
template<typename T>
inline T mul(const T& a, const T& b) { return T((1LL * (a % (1LL * modulo)) * (b % (1LL * modulo))) % (1LL * modulo)); }
string to_string(string a) { return "\"" + a + "\""; }
#ifdef __LOCAL_DEBUG
#define debug(args...) { string __out = #args; replace(__out.begin(), __out.end(), ',', ' '); stringstream __out_ss(__out);\
istream_iterator<string> __it(__out_ss); _debug(__it, args); }
void _debug(istream_iterator<string> it) { }
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T a, Args... args){ cerr << *it << " = " << to_string(a) << '\n'; _debug(++it, args...); }
#else
#define debug(...)
#endif

ll c[7], n;

ll brute_force() {
  ll f[7] = {0}, ans = 0;
  f[1] = n;
  c[6] = n;
  while (f[6] < n) {
    for (int i = 6; i >= 2; --i) {
      int tmp = min(f[i] + f[i - 1], c[i]);
      f[i - 1] -= tmp - f[i];
      f[i] = tmp;
    }
    ans++;
    for (int i = 1; i <= 6; ++i)
      cout << f[i] << " \n"[i == 6];
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= 5; ++i)
    cin >> c[i];
  int j = 1;
  for (int i = 1; i <= 5; ++i)
    if (c[i] < c[j])
      j = i;
  cout << (n + c[j] - 1) / c[j] + 4 << '\n';
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


S = ST()

cnt = np.zeros(2019)
cnt[0] = 1
res = 0
tmp = 1
for s in S[::-1]:
    res += int(s) * tmp
    res %= 2019
    cnt[res] += 1
    tmp *= 10
    tmp %= 2019

ans = 0
for c in cnt[cnt >= 2]:
    ans += c * (c - 1) // 2

print(int(ans))


Measured memory_bytes: 27308
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.Bits ((.&.), xor)
import qualified Data.Vector.Storable as V
import qualified Data.ByteString.Char8 as B

data Dat = Dat Int Int Int (V.Vector Int) Int

shaku (Dat b e x va n)
    | e >= n        = Nothing
    | x .&. ve == 0 = Just(e-b+1, Dat  b   (e+1) (x `xor` ve) va n)
    | otherwise     = Just(0,     Dat (b+1) e    (x `xor` vb) va n)
    where
        vb = va V.! b
        ve = va V.! e

main = do
    _ <- getLine
    as <- V.unfoldr (B.readInt.B.dropWhile (==' ')) <$> B.getLine
    print $ V.foldl1' (+) $ V.unfoldr shaku $ Dat 0 0 0 as (V.length as)

Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
main(){
  string s;
  cin>>s;
  for(int bit=0;bit<8;++bit){
    bitset<3> b(bit);
    int r=s[0]-'0';
    if(b[0])r+=s[1]-'0';
    else r-=s[1]-'0';
    if(b[1])r+=s[2]-'0';
    else r-=s[2]-'0';
    if(b[2])r+=s[3]-'0';
    else r-=s[3]-'0';
    if(r==7){
      cout<<s[0];
      cout<<(b[0]?'+':'-');
      cout<<s[1];
      cout<<(b[1]?'+':'-');
      cout<<s[2];
      cout<<(b[2]?'+':'-');
      cout<<s[3];
      cout<<"=7"<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cmath>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
const double EPS = 1e-10;
struct Vec2 {
  double x;
  double y;

  Vec2() : x(0.0),y(0.0){} 
  Vec2(double _x,double _y) :x(_x),y(_y){}  
  
  Vec2 operator+(const Vec2& other) const { return { x + other.x , y + other.y }; }
  Vec2 operator-(const Vec2& other) const { return { x - other.x , y - other.y }; }
  bool operator==(const Vec2& other) const { return (abs(x - other.x) < EPS && abs(y - other.y) < EPS ); }
  
  double dot(const Vec2& other) const { return x * other.x + y * other.y; }
  double cross(const Vec2& other) const { return x * other.y - y * other.x; }
  double length() const { return sqrt(x * x + y * y); }
};
// A とB のなす角θ cosθ, sinθ を返す
double Cos(const Vec2 A, const Vec2 B) { return A.dot(B) / (A.length()*B.length()); }
double Sin(const Vec2 A, const Vec2 B) { return A.cross(B) / (A.length()*B.length()); }

// 線分AとBの作る三角形の面積
double Area(const Vec2 A, const Vec2 B) {
  return A.cross(B) / 2;
}

int main()
{
  int n; cin >> n;
  vector<double> x(n),y(n);
  rep(i,n) {
    cin >> x[i] >> y[i];
  }
  double res = 0;
  Vec2 O(x[0], y[0]);
  rep1(i,n-2) {
    res += Area(Vec2(x[i], y[i]) - O, Vec2(x[i+1], y[i+1]) - O);
  }
  printf("%.1f\n", res);
  return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=1e6+5;
int prime[N],ct[N];


void solve()
{
       
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 memset(prime,0,sizeof(prime));
 memset(ct,0,sizeof(ct));
 for(int i=2;i<N;i++)
 {
    for(int j=1;j*i<N;j++)
    {
        if(prime[j*i]==0)
        {
            prime[j*i]=i;
        }
    }
 }

 int n,x,y=-1,f=1;
 cin>>n;
 for(int i=1;i<=n;i++)
 {
    cin>>x;
    if(i==1)
        y=x;
    else
        y=__gcd(y,x);
  
    while(x!=1)
    {
        int z=prime[x];
        if(ct[z])
        {
            f=0;
            break;
        }
        ct[z]=1;
        while(x%z==0)
        x/=z;
    }
 }
 if(f)
 {
    cout<<"pairwise coprime\n";
 }
 else if(y==1)
 {
    cout<<"setwise coprime\n";
 }
 else
 {
    cout<<"not coprime\n";
 }



}

Measured memory_bytes: 19260
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

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

	int sigma = 0;
	set<int> setScore;
	for (int n = 0; n < N; n++) {
		int score = 0;
		cin >> score;
		setScore.insert(score);
		sigma += score;
	}

	if (sigma % 10 != 0) {
		cout << sigma << endl;
		return 0;
	}

	set<int>::iterator itr = setScore.begin();
	while (itr != setScore.end()) {
		if (*itr % 10 != 0) {
			sigma -= *itr; 
			cout << sigma << endl;
			return 0;
		}
		itr++;
	}

	cout << 0 << endl;

	return 0;
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -fsanitize=signed-integer-overflow -fno-sanitize-recover=all -o template template.cpp

string divide[4] = {"maerd", "remaerd", "esare", "resare"};

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

	//s is reversed
	reverse(s.begin(), s.end());

	bool can = true;
	for(int i = 0, i_len = s.size(); i < i_len;){
		bool can2 = false;
		for(int j = 0, j_len = 4; j < j_len; ++j){
			string d = divide[j];
			if(s.substr(i,d.size()) == d){
				can2 =true;
				i += d.size();
			}
		}
		if(!can2){
			can = false;
			break;
		}
	}
	if(can) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  char a;
  cin >> a;
  bool flag = true;
  rep(i,3){
    char b;
    cin >> b;
    if(b == a) flag = false;
    a = b;
  }
  if(flag){
    cout << "Good" <<endl;
  }else{
    cout << "Bad" <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000
#define mod 1000000007
const int N = 200010;
int n , m , a;
vector< int > v1 , v2 , v3 , v4;

void answer(){
	for(int i = 0 ;i < (int)v3.size();i++){
		if(i) putchar(' ');
		printf("%d",v3[i]);
	}
	printf("\n%d\n",(int)v4.size());
	for(int i = 0 ;i < (int)v4.size();i++){
		if(i) putchar(' ');
		printf("%d",v4[i]);
	}
	puts("");
	exit(0);
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i = 0 ;i < m;i++){
		scanf("%d",&a);
		if(a & 1)
			v1.push_back(a);
		else
			v2.push_back(a);
	}
	if((int)v1.size() == 0){
		v3 = v2;
		v4.push_back(1);
		for(int i = 0 ;i < (int)v2.size();i++){
			if(i == (int)v2.size() - 1){
				v4.push_back(v2[i] - 1);
			}
			else
				v4.push_back(v2[i]);
		}
		answer();
	}
	else if((int)v1.size() == 1){
		v3 = v2;
		v3.push_back(v1[0]);
		if((int)v3.size() == 1 && n == 1){
			v4.push_back(1);
			answer();
		}
		v4.push_back(1);
		for(int i = 0 ;i < (int)v3.size();i++){
			if(i == (int)v3.size() - 1){
				if(v3[i] != 1) v4.push_back(v3[i] - 1);
			}
			else
				v4.push_back(v3[i]);
		}
		answer();
	}
	else if((int)v1.size() == 2){
		v3.push_back(v1[0]);
		for(int i = 0 ;i < (int)v2.size();i++) v3.push_back(v2[i]);
		v3.push_back(v1[1]);
		for(int i = 0 ;i < (int)v3.size();i++){
			if(i == 0)
				v4.push_back(v3[i] + 1);
			else if(i == (int)v3.size() - 1){
				if(v3[i] != 1)
					v4.push_back(v3[i] - 1);
			}
			else
				v4.push_back(v3[i]);
		}
		answer();
	}
	else
		puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int main(){
  long long H,N;
  long long A[100000];
  long long sum = 0;
  
  cin >> H >> N;
  
  for(int i = 0;i < N;i++){
    cin >> A[i];
    sum += A[i];
  }
  
  if(sum < H){
    cout << "No";
  }else{
    cout << "Yes";
  }
}

Measured memory_bytes: 1024
def conv_bin(i, digit):
    if i & 1 << digit:
        return "+"
    else:
        return "-"

if __name__ == "__main__":
    abcd = input()
    bin_pattern_digit = len(abcd) - 1

    # パターン数分ループ。2進数3桁(1「+」2「+」3「+」4や1「-」2「-」3「+」4)なので8回
    for i in range(1 << bin_pattern_digit):
        # 初期値:一番左の桁の値。
        result = int(abcd[0:1])
        # パターン数(2進数)の桁数ループ。2進数3桁(001や111)なので3回。
        for j in range(bin_pattern_digit):

            # if文の条件「bin_pattern_digit - j -1」について
            # ビット全探索対象の変数「abcd」は文字列だが、ループ変数「j」は数値。なので、
            # 「i % 1 << j」すると、文字列は先頭(一番左)から、数値は末尾(一番右)から数えてしまう。
            # 全網羅的な処理なら問題ないが、本問題の様に順番が大事な問題は想定通りの結果にならない。
            # 対応は以下の2つ。
            #   対応1.ビット演算子を右シフトに反転「i & 1000(対象桁数分0を追加) >> j」
            #   対応2.ビット演算子はそのままで、引数を反転「i & 1 << (MAX - j - i)」
            #   ->対応1は文字列は先頭(一番左)から、数値は末尾(一番右)から数えてしまう。
            #   全網羅的な処理なら問題ないが、本問題の様に順番が大事な問題は想定通りの結果にならない。

            # +の場合
            # if i & 1 << (bin_pattern_digit - j -　1 ):
            if i & 1 << bin_pattern_digit - 1 >> j:
                # 例：パターン1234の1「+」2の場合：i=0の時に+2(abcd[1:2])する必要がある。
                result += int(abcd[j + 1])
            # -の場合
            else:
                # 例：パターン1234の3「-」4の場合：i=2の時に-4(abcd[3:4])する必要がある。
                result -= int(abcd[j + 1])

        # 合計が7なら終了
        if result == 7:
            break

    # 注意：
    # bit変数(i)の結果を確認する場合、文字列とスライスの併用(str(bit(i[0:1])))は使えない。
    # 数値と同じで、先頭0は消される = 桁数が可変であるため。
    # i & 1 << 0  # 1桁目が真か確認。
    # i & 1 << 1  # 2桁目が真か確認。
    # -dev-
    print(abcd[0:1] + conv_bin(i, 2) + abcd[1:2] + conv_bin(i, 1) + abcd[2:3] + conv_bin(i, 0) + abcd[3:4] + "=7")



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,sum=0,mi=MAX;
    cin>>n;
    ll a[n+1];
    for(i=1;i<=n;i++){
        cin>>a[i];
        mi=min(mi,a[i]);
        if(mi==a[i]){
            sum++;
        }
    }
    cout<<sum;
}

Measured memory_bytes: 1792
class Queue:
    def __init__(self, n):
        self.A = [0 for i in range(n)]
        self.head = 0
        self.tail = 0
        self.len = n

    def is_empty(self):
        return self.head == self.tail

    def is_full(self):
        return (self.tail + 1) % self.len == self.head

    def enqueue(self, x):
        if not self.is_full():
            self.A[self.tail] = x
            self.tail += 1
            if self.tail == self.len:
                self.tail = 0

    def dequeue(self):
        if not self.is_empty():
            x = self.A[self.head]
            self.head += 1
            if self.head == self.len:
                self.head = 0
            return x


class Task:
    def __init__(self, name, time):
        self.name = name
        self.time = time


if __name__ == '__main__':
    Q = Queue(100005)
    n, q = map(int, raw_input().split())
    for i in range(n):
        l = raw_input().split()
        t = Task(l[0], int(l[1]))
        Q.enqueue(t)

    cnt = 0
    while not Q.is_empty():
        t = Q.dequeue()
        if t.time > q:
            cnt += q
            t.time -= q
            Q.enqueue(t)
        else:
            cnt += t.time
            print t.name, cnt

    pass


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int ah[300001];
Int aw[300001];

int main() {
    Int h, w, m;
    cin >> h >> w >> m;
    vector<pair<Int, Int>> bom(m);
    for (Int i = 0; i < m; i++) {
        cin >> bom[i].first >> bom[i].second;
        bom[i].first--, bom[i].second--;
    }
    for (Int i = 0; i < m; i++) {
        ah[bom[i].first]++;
        aw[bom[i].second]++;
    }
    Int h_ma = 0;
    for (Int i = 0; i < h; i++) {
        h_ma = max(h_ma, ah[i]);
    }
    Int w_ma = 0;
    for (Int i = 0; i < w; i++) {
        w_ma = max(w_ma, aw[i]);
    }
    set<Int> h_st, w_st;
    for (Int i = 0; i < h; i++) {
        if (h_ma == ah[i]) {
            h_st.insert(i);
        }
    }
    for (Int i = 0; i < w; i++) {
        if (w_ma == aw[i]) {
            w_st.insert(i);
        }
    }
    Int cnt = 0;
    for (Int i = 0; i < m; i++) {
        if (h_st.find(bom[i].first) != h_st.end() and w_st.find(bom[i].second) != w_st.end()) {
            cnt++;
        }
    }
    Int hs = h_st.size();
    Int ws = w_st.size();
    print(hs * ws == cnt ? h_ma + w_ma - 1 : h_ma + w_ma);
    return 0;
}


Measured memory_bytes: 40724
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

long int combination(long int n, long int r);

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

long int combination(long int n, long int r)
{
	if(r>n-r) r = n-r;
	if(r == 0) return 1;
	else if(r == 1) return n;
	return (combination(n-1, r) + combination(n-1, r-1));
	//大きくなるとき
	/*
	long int tmp1, tmp2, tmp3;
	tmp1 = combination(n-1, r);
	if(tmp1>=MOD) tmp1 = tmp1%MOD;
	tmp2 = combination(n-1, r-1);
	if(tmp2>=MOD) tmp2 = tmp2%MOD;
	tmp3 = tmp1+tmp2;
	if(tmp3>=MOD) tmp3 = tmp3%MOD;
	return (tmp3);
	*/
}


int main(){
	int h, w;
	scanf("%d%d", &h, &w);
	char tehon[h+2][w+2];
	int count=0;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			scanf(" %c", &tehon[i][j]);
			//count++; printf("%d:(%d, %d) %c\n", count, i, j, tehon[i][j]);
		}
	}

	int ok=1;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			if(tehon[i][j] == '#'){
				if((tehon[i+1][j]=='.') && (tehon[i][j+1]=='.') && (tehon[i-1][j]=='.') && (tehon[i][j-1]=='.')){
					ok = -1;
				}
			}
		}
	}
	if(ok==1) printf("Yes\n");
	else printf("No\n");
		
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

vector<int> to[200005];
  vector<int> pls(200005);
  vector<int> ans(200005);

void dfs(int v, int p=-1) {
  if(p==-1){
    ans[v]=pls[0];
  } else{
    ans[v]=pls[v]+ans[p];
  }
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u,v);
  }
}

int main(){
  int n, q;
  cin >> n >> q;
  rep(i,n-1) {
      int a, b;
      cin >> a >> b;
      --a; --b;
      to[a].push_back(b);
      to[b].push_back(a);
    }
  rep(i, q){
    int p, x;
    cin >> p >> x;
    p--;
    pls[p]+=x;
  }
  dfs(0);
  rep(i, n){
    cout << ans[i] << endl;
  }
  return 0;
}


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

signed main() {
    int k,a,b;
    cin>>k>>a>>b;
    FOR(i, a, b+1) {
        if(i%k==0) {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

void pok() {
  std::cout << "Yes" << std::endl;
}
void png() {
  std::cout << "No" << std::endl;
}

int main() {
  int a, b; std::cin >> a >> b;
  if ((a==2)||(b==2)) png();
  else pok();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,x,mx=INT_MAX;
    cin>>n>>x;
    while(n--){
        int a,b;
        cin>>a>>b;
        if(b<=x)
            mx=min(mx,a);
    }
    if(mx==INT_MAX)
        cout<<"TLE"<<endl;
    else
        cout<<mx<<endl;

    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second


int main() {
	string s;
	cin>>s;
	string ss = s;
	reverse(s.begin(), s.end());
	int n = s.length();
	string s1 = s.substr(0,(n-1)/2);
	string ss1 = s1;
	string s2 = s.substr((n+2)/2,n-((n+3)/2)+1);
	string ss2 = s2;
	reverse(s1.begin(), s1.end());
	reverse(s2.begin(), s2.end());
	//cout<<ss1<<" "<<ss2<<" ";
	if(s==ss && s1==ss1 && s2==ss2){
		cout<<"Yes";
	}
	else cout<<"No";

	
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cassert>
#include <deque>
#include <iostream>
#include <iomanip>
#include <istream>
#include <iterator>
#include <map>
#include <math.h>
#include <memory>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 4000000000000000000LL
#define INF 1000000000
#define EPS 1e-12
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))
#define bits(a) __builtin_popcountll(a)

using namespace std;

int arr[100005], n;

void solve() {
  LL curr = 2, maxi = 3;
  for (int i = n - 2; i >= 0; i--) {
    LL nxt = (curr + arr[i] - 1) / arr[i];
    nxt *= arr[i];
    if (nxt > maxi) {
      cout << -1;
      return;
    }
    curr = nxt;
    maxi = maxi / arr[i];
    maxi = maxi * arr[i] + arr[i] - 1;
  }
  cout << curr << " " << maxi;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  if (arr[n - 1] != 2) {
    cout << -1;
    return 0;
  }
  solve();
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long int
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+9;
const ll MOD=998244353;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int a[MAX];
int b[MAX];
multiset<int>st[MAX] , mx;
int main() 
{

	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n;
    char c;
    cin>>c;
    if(c>='A' && c<='Z')
      cout<<'A';
    else
      cout<<'a';

}

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

int main(){
    string s;
    cin >> s;
    stack<char> st;
    rep(i, s.length()) {
        if ( st.empty() ) {
            st.push(s[i]);
        }
        else if ( st.top() == '0' && s[i] == '1' ) {
            st.pop();
        }
        else if ( st.top() == '1' && s[i] == '0' ) {
            st.pop();
        }
        else {
            st.push(s[i]);
        }
    }
    cout << s.length() - st.size() << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>

long long a,b,x;
long long s,e;
int main(){
	scanf("%lld%lld%lld",&a,&b,&x);
	if(a%x==0)s=a/x;
	else s=a/x+1;
	e=b/x;
	printf("%lld",e-s+1);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, ans=0;
	vector<int> v, w(3);

	cin>> n;
	v.resize(n);

	rep(i, n) cin >> v[i];
	sort(v.begin(), v.end());

	rep(i, n){
		rep(j, n){
			rep(k, n){
				if(v[i]==v[j] || v[i]==v[k] || v[j]==v[k]) break;
				w[0]=v[i];
				w[1]=v[j];
				w[2]=v[k];
				sort(w.begin(), w.end());
				if(w[0]+w[1]>w[2]) ans++;
			}
		}
	}

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

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int N;
int main() {
    cin >> N;
    if(N>=1000) {
        cout << "ABD";
    }else
        cout << "ABC";

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n, k, q = gets.split.map(&:to_i)
a = Array.new(q)
for i in 0..(q-1)
  a[i] = gets.to_i
end

ans = Array.new(n+1, 0)
for i in 0..(q-1)
  ans[a[i]] += 1
end

for i in 1..n
  if k - q + ans[i] > 0
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 3964
#include<iostream>
#include<iomanip>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<ctype.h>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<utility>
#define For(a,b) for(int i=(a);i<(b);i++)
#define Rep(n) for(int i=0; i<(n); ++i)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
//----------program from here----------

int main(){
    int ans=0,N=0;
    cin >> N;
    int H[N];
    Rep(N) cin >> H[i];
    for(int i=0;i<N;++i){
        bool flag=true;
        for(int j=0;j<i;++j){
            if(H[i]<H[j]) flag=false;
        }
        if(flag) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import itertools

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n,m,r = map(int,input().split()) #n:頂点数  w:辺の数
arr=list(map(int,input().split()))

d = [[float("inf")]*n for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x,y,z = map(int,input().split())
    x-=1
    y-=1
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０

table=warshall_floyd(d)

ans=float('inf')
for lst in itertools.permutations(arr,r):
  cnt=0
  for i in range(r-1):
    cnt+=table[lst[i]-1][lst[i+1]-1]

  ans=min(ans,cnt)


print(ans)

Measured memory_bytes: 75404
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
if(!(s.at(0)==s.at(1)) && !(s.at(1)==s.at(2)) && !(s.at(0)==s.at(2)))cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
pattern = []
8.times { pattern << gets.chomp }

puts 90
0.upto(7) do |i|
  7.downto(0) do |j|
    print pattern[j][i]
    puts "" if j.zero?
  end
end

puts 180
pattern.reverse.each { |p| puts p.reverse }

puts 270
7.downto(0) do |i|
  0.upto(7) do |j|
    print pattern[j][i]
    puts "" if j == 7
  end
end

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> da(n);
    for(int i=0;i<n;i++){
        cin >> da[i];
    }
    int m;
    cin >> m;
    vector<int> di(m);
    for(int i=0;i<m;i++){
        cin >> di[i];
    }
    int ans=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            if(da[j]==di[i]){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int a,b,c;

int main()
{
    vector<int> vec;
    rep(i,1,3)
    {
        cin >> a;
        vec.push_back(a);
    }

    sort(vec.begin(),vec.end());
    int kind = 3;
    rep(i,1,2)
    {
        if(vec[i - 1] == vec[i])
        {
            kind--;
        }
    }
    cout << kind << endl;
}

Measured memory_bytes: 256