akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	if (S.length() > K)
	{
		for (auto i = 0; i < K; ++i)
		{
			cout << S[i];
		}
		cout << "..." << endl;
	}
	else
	{
		cout << S << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
  int n, d, a, xma = 0, xmi = INT_MAX, hma = 0;
  ll o = 0;
  cin >> n >> d >> a;
  vector<pair<int, int>> xh(n);
  for(int i = 0; i < n; i++) {
    cin >> xh.at(i).first >> xh.at(i).second;
    xma = max(xma, xh.at(i).first);
    xmi = min(xmi, xh.at(i).first);
    hma = max(hma, xh.at(i).second);
  }
  if(d * 2 >= xma - xmi)
    cout << (hma + a - 1) / a << endl;
  else {
    sort(xh.begin(), xh.end());
    for(int i = 0; i < n; i++) {
      o += (xh.at(i).second + a - 1) / a;
      int j;
      for(j = i + 1; j < n; j++) {
        if(xh.at(j).first > xh.at(i).first + 2 * d) {
          j = -j;
          break;
        }
        if(xh.at(j).second > (xh.at(i).second + a - 1) / a * a) {
          for(int k = j; k < n; k++) {
            if(xh.at(k).first <= xh.at(i).first + 2 * d)
              xh.at(k).second -= (xh.at(i).second + a - 1) / a * a;
            else
              break;
          }
          j = 500000 + j;
          break;
        }
      }
      if(j < 0)
        i = -j - 1;
      if(j > 500000)
        i = j - 500001;
      if(j == n)
        break;
    }
    cout << o << endl;
  }
}

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

int main(void){
  int n;
  cin >> n;
  if(n%2 == 0) printf("%.8f\n", 0.5);
  else printf("%.8f\n", 1-((((double)n-1)/2)/(double)n));
  return 0;
}


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

int main(){
 int N;
  cin>>N;
  string s;
  cin>>s;
  int t=1;
  if(N%2==0){
    for(int i=0;i<N/2;i++){
      if(s.at(i)!=s.at(i+N/2)){
        t=0;
      }
    }
  }
  else{
    t=0;
  }
  if(t==1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
    
}


Measured memory_bytes: 256
def compute_depth(node: int, depth: int) -> None:
    global trees
    trees[node][1] = depth
    for child in trees[node][3]:
        compute_depth(child, depth + 1)


if __name__ == "__main__":
    node_num = int(input())
    trees = {idx: [-1, 0, "", [0]] for idx in range(node_num)}  # parent, depth, node_type, children

    for _ in range(0, node_num):
        node, _, *children = map(lambda x: int(x), input().split())
        trees[node][3] = children
        for child in children:
            trees[child][0] = node  # Add parent information to each child.

    for node, values in sorted(trees.items(), key=lambda x: x[1][0]):
        parent = values[0]
        children = values[3]
        if -1 == parent:
            trees[node][2] = "root"
            compute_depth(node, 0)
        else:
            # depth = trees[trees[node][0]][1] + 1  # Parents' depth + 1
            # trees[node][1] = depth
            if [] == children:
                trees[node][2] = "leaf"
            else:
                trees[node][2] = "internal node"

    for node, values in trees.items():
        parent = values[0]
        depth = values[1]
        node_type = values[2]
        children = values[3]
        print(f"node {node}: parent = {parent}, depth = {depth}, {node_type}, {children}")



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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
using ll = long long;
struct edge {
    int to, d, e;
};
vector<edge> G[101];
int dp[101][101];
int N, M, L;
void init() {
    REP(i, N + 1) {
        G[i].clear();
        REP(j, L + 1) { dp[i][j] = 1e9; }
    }
    dp[0][L] = 0;
}

using arr3 = array<int, 3>;
bool solve() {
    cin >> N >> M >> L;
    if (N == 0) return false;
    init();

    REP(i, M) {
        int u, v, d, e;
        cin >> u >> v >> d >> e;
        u--, v--;
        G[u].push_back({v, d, e});
        G[v].push_back({u, d, e});
    }

    priority_queue<arr3, vector<arr3>, greater<arr3>> que;
    que.push({0, 0, L});
    while (!que.empty()) {
        arr3 arr = que.top();
        que.pop();
        int res = arr[0], n = arr[1], rem = arr[2];
        if (res > dp[n][rem]) continue;
        for (auto e : G[n]) {
            //護衛を雇う
            if (rem >= e.d) {
                if (dp[n][rem] < dp[e.to][rem - e.d]) {
                    dp[e.to][rem - e.d] = dp[n][rem];
                    que.push({dp[e.to][rem - e.d], e.to, rem - e.d});
                }
            }
            //雇わない
            if (dp[n][rem] + e.e < dp[e.to][rem]) {
                dp[e.to][rem] = dp[n][rem] + e.e;
                que.push({dp[e.to][rem], e.to, rem});
            }
        }
    }
    int ans = 1e9;
    REP(i, L + 1) {
        // cout << i << ": " << dp[N - 1][i] << endl;
        ans = min(ans, dp[N - 1][i]);
    }
    cout << ans << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 4448
#include<bits/stdc++.h>
#define nl                 "\n"
#define ll                 long long
#define pb                 push_back
#define pf                 push_front
#define np                 next_permutation
#define pp                 prev_permutation
#define sz(x)              x.size()
#define sqr(x)             ((x)*(x))
#define pi                 acos(-1)
#define setprecision(x)    fixed<<setprecision((int)(x))
#define mem1(x)            memset(x,0,sizeof(x))
#define mem2(x)            memset(x,-1,sizeof(x))
#define all(x)             (x).begin(),(x).end()
#define rev(x)             reverse(all(x))
#define iota(x,a)          iota(all(x),a)
#define sorta(x)           sort(all(x))
#define sortd(x)           sort(all(x),greater<int>())
#define csort(x,c)         sort(all(x),c)
#define rsort(x)           sort(x.rbegin(),x.rend())
#define faster_io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define count_time         cerr<<nl<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<nl;
#define all_ele(x)         for(auto i:(x)){cout<<i<<' ';}cout<<nl;
#define multiple_test      int t; cin>>t; while(t--){solve();}
#define multiple_test2     int t;cin>>t;for(int i=1; i<=t; i++){cout<<"Case #"<<i<<": "<<test()<<nl;}
#define single_test        solve();
using namespace std;
//vector<vector<int>>p(sz,vector<int>(sz,val));
/*
ll test()
{
    return value;
}
*/
void solve()
{
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=k; i<n; i++)
    {
        if(a[i]>a[i-k])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
}
int main()
{
    //faster_io //multiple_test2
    //multiple_test
    single_test
    //count_time
    return 0;
}




Measured memory_bytes: 4048
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n;
    cin >> n;
    cout << "ai1333";
    rep(i,n/100)cout << "3";
    cout << endl;
}


Measured memory_bytes: 3092
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 c = sc.next();
      String a1 = a.substring(a.length()-1,a.length());
      String b1 = b.substring(0,1);
      String b2 = b.substring(b.length()-1,b.length());
      String c1 = c.substring(0,1);
      if(a1.equals(b1)&&b2.equals(c1))System.out.println("YES");
      else System.out.println("NO");
    }
}

Measured memory_bytes: 23764
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

while True:
    A, B, C = map(int, raw_input().split())
    if A + B + C == 0:
        break
    lst = []
    for i in range(10001):
        if (C + A * i) % B == 0:
            num = (C + A * i) / B
            lst.append((i + num, A * i + B * num, i))
        if (C - A * i) % B == 0:
            num = (C - A * i) / B
            if num < 0:
                num *= -1
            lst.append((i + num, A * i + B * num, i))
    lst.sort()
    print str(lst[0][2]) + ' ' + str(lst[0][0] - lst[0][2])


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

int abb(int s){
  if(s >= 0){
    return (s - 0);
  }
  if(s < 0){
    return (0 - s);
  }
}


int main(void){
  int L, N, pie, x, y; 
  
  x = 10000;
  cin >> N >> L;
  vector<int> apple(N + 1);
  
  for(int i =1;i <= N;i++){
    apple.at(i) = L + i - 1;
  }
  //０に近い甘さを求める
  for(int i = 1;i <= N;i++){
  	if(abb(apple.at(i)) < x){
    	x = abb(apple.at(i));
        y = apple.at(i);
    }
  }
  /////////////////////pie計算
  for(int i =1;i <= N;i++){
  	pie += apple.at(i);
  }
  
  pie -= y;
  /////////////////////
  cout << pie << endl;
  return 0;
}
  
  
  
    

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<long> h(n);
  for(int i=0;i<n;i++) cin >> h[i];
  vector<bool> v(n,true);
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    if(h[a-1]>h[b-1]) v[b-1]=false;
    else if(h[a-1]<h[b-1]) v[a-1]=false;
    else{
      v[a-1]=false;
      v[b-1]=false;
    }
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(v[i]==true) cnt++;
  }
  cout << cnt;
}


Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <limits>

const int INF = std::numeric_limits<int>::max();

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

    std::vector<int> dp(N + 1, INF);
    dp[N] = 0;
    for (int i = 0; i < M; ++i) {
        int c;
        std::cin >> c;
        for (int n = N; n - c >= 0; --n) {
            dp[n - c] = std::min(dp[n - c], dp[n] + 1);
        }
    }

    std::cout << dp[0] << std::endl;
    return 0;
}



Measured memory_bytes: 3152
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<stack>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
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; }
const int MAX = 3000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
void COMint(){ //前処理
    fac[0]=fac[1]=1; //階乗
    finv[0]=finv[1]=1; //階乗の逆元
    inv[1]=1; //逆元

    for(int i=2;i<MAX;i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD % i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}
ll COM(int n, int k){ //二項係数の計算
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD; // n! * (k!)^-1 * ((n-k)!)^-1
}
int main(){
    int a,b; cin >> a >>b;
    for(int i=b-a+1;i<=b+a-1;i++){
        cout << i << " ";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int mapa[100101];
int mapb[100101];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int mapa[100001]={0};
    int mapb[100001]={0};
    int a,num;
    scanf("%d",&a);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&num);
        if(i%2==0)
            mapa[num]++;
        else
            mapb[num]++;
    }
    int maxa=0,maxb=0,t1=0,t2=0;
    for(int i=0;i<100001;i++)
    {
        if(mapa[i]>=maxa)
        {
            t1=i;
            maxa=mapa[i];
        }
    }
    for(int i=0;i<100001;i++)
    {
        if(mapb[i]>=maxb)
        {
            t2=i;
            maxb=mapb[i];
        }
    }
    sort(mapa,mapa+100001,cmp);
    sort(mapb,mapb+100001,cmp);
//    for(int i=0;i<10;i++)
//        printf("%d ",mapa[i]);
//    printf("\n");
//    for(int i=0;i<10;i++)
//        printf("%d ",mapb[i]);
//        printf("\n");
    if(t2==t1)
    {
        int res=max(mapa[0]+mapb[1],mapa[1]+mapb[0]);
        printf("%d\n",a-res);
    }
    else
        printf("%d\n",a-mapa[0]-mapb[0]);
    return 0;
}


Measured memory_bytes: 1024
min, max, sum = 1000000, -1000000, 0
n = input()
n = int(n)
string = input()
numbers = list(map(int, string.split(' ')))
for i in range(n):
    if numbers[i] < min:
        min = numbers[i]
    if numbers[i] > max:
        max = numbers[i]
    sum = sum + numbers[i]
print(min, max, sum)


Measured memory_bytes: 6556
a,b,c,d=map(int,input().split())
if a==b and b==c and c==d:
    print('yes')
elif a==b and c==d:
    print('yes')
elif a==c and b==d:
    print('yes')
elif a==d and b==c:
    print('yes')
else:
    print('no')


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

using namespace std;

int main(){
    int mn = -1,mx = -1;
    int n;
    cin>>n;
    int a[n];
    for (int i = 0;i<n;i++)cin>>a[i];
    int ans = 0 ;
    for (int i = 0;i<n;i++) {
        if (i == 0)ans += abs(a[i]);
        else ans += abs(a[i] - a[i - 1]);
    }
    ans += abs(a[n - 1]);
    for (int i = 0;i<n;i++) {
        if (i == 0)cout<<ans - abs(a[i]) - abs(a[i] - a[i+1]) + abs(a[i+1])<<endl;
        else if (i == n-1)cout<<ans - abs(a[i]) - abs(a[i] - a[i - 1]) + abs(a[i-1])<<endl;
        else cout<<ans - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1])<<endl;
    }
    return 0;
}



Measured memory_bytes: 1664
n,a,b = map(int, input().split())
s = input()
MAX = a+b
foreign = 0
total = 0
for i in s:
  if i == "a":
    if total < MAX:
      print("Yes")
      total += 1
    else:
      print("No")
  elif i == "b":
    if total < MAX and foreign < b:
      print("Yes")
      total += 1
      foreign += 1
    else:
      print("No")
  else:
    print("No")

Measured memory_bytes: 4016
/*
    LEARNING DP:    FROG 2
        + Frog need to reach stone N
        + Can jump to Stone i + 1 or i + 2 when the Frog is on Stone i
        + Cost |hi - hj|
        => Imagine if the frog were at stone i + 1 or i + 2
        What is the minium cost to reach on Stone i.

        + DIFFERENT FROM FROG 1:
            + i + 1, i + 2, i + k
            => Image if the frog were at stone i + 1 or i + 2 ... i + k
            Or what if we've already known the minium cost at i - 1, i - 2 .. i - k.
            we now can calculate the solution for stone i
    PRE DP:
        +FIRST STATE: i = 0 => cost = 0
    TIME COMPLEXITY:
        + O(n * k)
*/
#include <bits/stdc++.h>
using namespace std;

#define DB(_x)      cout << #_x << " is " << (_x) << "\n";
#define FOR(_a,_b)  for (_a = 0; _a < _b; ++_a)
//#define IOFILE

using LL = long long;
using LD = long double;
using VI = vector<int>;
using PI = pair<int,int>;

void Excalibur(){
    int n, k;
    while (cin >> n >> k){
        VI a(n);
        for (auto &x: a) cin >> x;

        VI dp(n, 1e9);
        int i, j;
        dp[0] = 0;
        FOR (i,n){
            FOR (j, k+1){
                if (i-j >= 0) dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
            }
        }

        cout << dp[n-1] << "\n";
    }
}

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

#ifdef  IOFILE
    freopen("INPUT.in", "r", stdin);
    freopen("OUTPUT.out", "w", stdout);
#endif

Excalibur();
return 0;}


Measured memory_bytes: 1024
a = input()
b = [int(x) for x in a]
c = []
d = " +-"

for x in [1,-1]:
    for y in [1,-1]:
        for z in [1,-1]:
            if b[0]+x*b[1]+y*b[2]+z*b[3] == 7:
                c.append(""+str(b[0])+d[x]+str(b[1])+d[y]+str(b[2])+d[z]+str(b[3])+"=7")
print(c[0])

Measured memory_bytes: 3064
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

const int maxn = 1e5 + 100;
vector<int> cities;
vector<int> prefec[maxn];
map<int, int> look;
int main(){
	FIO
	
	int n, m;cin >> n >> m;
	for(int i = 0; i < m; i++){
		int p, y;cin >> p >> y;
		prefec[p].emplace_back(y);
		cities.emplace_back(y);
		look[y] = p;
	}
	for(int i = 0; i < maxn; i++)sort(prefec[i].begin(), prefec[i].end());
	for(auto i:cities){
		int belong = look[i];
		string pref = to_string(look[i]);
		while(pref.size() != 6)pref = '0' + pref;
		int pos = lower_bound(prefec[belong].begin(), prefec[belong].end(), i) - prefec[belong].begin() + 1;
		string suff = to_string(pos);
		while(suff.size() != 6)suff = '0' + suff;
		cout << pref + suff << "\n";
	}
	return 0;
}


Measured memory_bytes: 12152
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

const i64 MOD = 998244353;

i64 pow(i64 a, i64 n)
{
  i64 ret = 1;
  while (n)
  {
    if (n % 2 == 1)
      ret = ret * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return ret;
}

int main()
{
  i64 n;
  cin >> n;
  vector<i64> d(n);
  for (i64 i = 0; i < n; i++)
    cin >> d[i];
  i64 dep = 0;
  vector<i64> cnt(n);
  for (i64 i = 0; i < n; i++)
  {
    cnt[d[i]]++;
    dep = max(dep, d[i] + 1);
  }
  if (d[0] != 0 || cnt[0] != 1)
  {
    cout << 0 << endl;
    return 0;
  }
  i64 ans = 1;
  for (i64 i = 2; i < dep; i++)
    ans = ans * pow(cnt[i - 1], cnt[i]) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    vector<ll> p(A),q(B),r(C);
    rep(i,A) cin>>p.at(i);
    rep(i,B) cin>>q.at(i);
    rep(i,C) cin>>r.at(i);
    sort(ALLOF(p));
    sort(ALLOF(q));
    sort(ALLOF(r));
    reverse(ALLOF(p));
    reverse(ALLOF(q));
    reverse(ALLOF(r));
    
    vector<ll> ansap(0);
    rep(i,X) ansap.push_back(p.at(i));
    rep(i,Y) ansap.push_back(q.at(i));
    sort(ALLOF(ansap));
    
    ll maxchange=min(X+Y,C);
    rep(i,maxchange){
        ansap.at(i)=max(ansap.at(i),r.at(i));
    }
    ll ans=0;
    rep(i,ansap.size()) ans+=ansap.at(i);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4724
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  char op;
  cin >> A >> op >> B;

  if (op == '+') {
    cout << A + B << endl;
  } else if (op == '-') {
    cout << A - B << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <cmath>

using namespace std;
const int maxn = 10005;

void solve(const int& n) {
    std::array<int, maxn> res{};
    int nsq = floor(sqrt(n));
    for (int i = nsq; i >= 1; i --) {
        for (int j = nsq; j >= 1; j --) {
            for (int k = nsq; k >= 1; k --) {
                int s = pow(i, 2) + pow(j, 2) + pow(k, 2) + i*j + i*k + j*k;
                if (s < maxn)
                    res[s] += 1;
            }
        }
    }
    for (int i = 1; i <= n; i ++) {
        cout << res[i] << endl;
    }
}

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

    return 0;
}

Measured memory_bytes: 3676
n = int(input())

a = [int(input()) for i in range(n)]
a_max = max(a)
a2 = a[:]
a2.remove(a_max)
a_second_max = max(a2)

for i in range(n):
    if a[i] == a_max:
        print(a_second_max)
    else:
        print(a_max)

Measured memory_bytes: 14080
#include <iostream>
#include <complex>

using namespace std;

typedef complex<double> P;

#define EPS (1.0e-11)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

double cross(P a, P b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}


int main()
{
    double x[4], y[4];
    char comma;

    while (cin >> x[0] >> comma >> y[0]) {
        bool clock;

        for (int i = 1; i < 4; i++) 
            cin >> comma >> x[i] >> comma >> y[i];

        if (cross(P(x[1] - x[0], y[1] - y[0]), 
                  P(x[2] - x[0], y[2] - y[0])) > EPS)
            clock = true;
        else
            clock = false;

        bool flag = true;
        for (int i = 1; i < 4; i++) {
            if (clock) {
                if (cross(P(x[(i + 1) % 4] - x[i], y[(i + 1) % 4] - y[i]), 
                          P(x[(i + 2) % 4] - x[i], y[(i + 2) % 4] - y[i])) < -EPS) {
                    flag = false;
                    break;
                }
            }
            else {
                if (cross(P(x[(i + 1) % 4] - x[i], y[(i + 1) % 4] - y[i]), 
                          P(x[(i + 2) % 4] - x[i], y[(i + 2) % 4] - y[i])) > EPS) {
                    flag = false;
                    break;
                }
            }
        }
        if (flag)
            cout << "YES" << endl;
        else 
            cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1216
from sys import stdin

N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

count = 0

for i in range(N):
    tmp = Base_10_to_n(a[i], 2)[::-1]
    for j in range(len(tmp)):
        if tmp[j] == '0':
            count += 1
        else:
            break

print(count)


Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010;
int n;
long long c,mx,x[maxn],v[maxn],a[maxn],b[maxn];
int main()
{
	cin>>n>>c;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>v[i];
		a[i]=a[i-1]+x[i-1]-x[i]+v[i];
	}
	x[n+1]=c;
	for(ll i=n;i>=1;i--)b[i]=b[i+1]+x[i]-x[i+1]+v[i];
	for(int i=2;i<=n;i++)a[i]=max(a[i],a[i-1]);
	for(int i=n-1;i>=1;i--)b[i]=max(b[i],b[i+1]);
	for(int i=1;i<=n;i++)
	{
		mx=max(mx,a[i]),mx=max(mx,b[i]);
		mx=max(mx,a[i]-x[i]+b[i+1]);
		mx=max(mx,b[i]-(c-x[i])+a[i-1]);
	}
	printf("%lld\n",mx);
	return 0;
}

Measured memory_bytes: 3328
h, w = map(int, input().split())
s = [input() for _ in range(h)]
ans = 'Yes'
x = [[-1, 0], [0, -1], [1, 0], [0, 1]]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            flag = 1
            for k in x:
                if 0 <= i + k[0] < h and 0 <= j + k[1] < w and s[i + k[0]][j + k[1]] == '#':
                    flag = 0
            if flag:
                ans = 'No'
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
string st;
char ch[100000+10];
long long len;
int main()
{
	cin>>st;
	len=st.size();
	for(int i=0;i<st.size();i++)
	{
		ch[len-i-1]=st[i];
		if(st[i]=='b')ch[len-i-1]='d';
		if(st[i]=='d')ch[len-i-1]='b';
		if(st[i]=='p')ch[len-i-1]='q';
		if(st[i]=='q')ch[len-i-1]='p';
	}
	for(int i=0;i<len;i++)
		if(ch[i]!=st[i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] dif = new int[n];
		long asum = 0;
		long bsum = 0;
		for(int i = 0; i < n; i++) {
			int tmpa = ni();
			a[i] = tmpa;
			asum += tmpa;
		}
		for(int i = 0; i < n; i++) {
			int tmpb = ni();
			b[i] = tmpb;
			bsum += tmpb;
			dif[i] = a[i] - b[i];
		}
		
		int result = 0;
		long csum = asum - bsum;
		
		if(asum < bsum) {
			result = -1;
		} else {
			Arrays.sort(dif);
			for(int i = 0; i < n; i++) {
				if(dif[i] < 0) {
					result++;
				} else if(dif[i] == 0){
					continue;
				} else {
					if(dif[i] <= csum) {
						csum -= dif[i];
					} else {
						result++;
					}
				}
			}
		}		
		System.out.println(result);		
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 43784
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int min = 1000000000;
    int target = 0;
    int an = a[n - 1];
    int h = an / 2;
    for (int i = n - 2; i >= 0; i--) {
      if (min > Math.abs(h - a[i])) {
        min = Math.abs(h - a[i]);
        target = a[i];
      }
    }
    System.out.println(String.format("%d %d", an, target));
  }
}


Measured memory_bytes: 51968
#include <iostream>
#include <vector>
#include <cstring>
#include <cmath>
using namespace std;

#define ROOT 1000010 //10^12ツづ個閉スツ陛サツ債ェ + 10

typedef unsigned long long ll;

bool flg[ROOT+1];
vector<ll> p,v;

ll solve(int idx,vector<ll> val){
	if(idx == v.size()){
		ll res = 1;
		for(int i=0;i<v.size();i++){
			if(val[i] == v[i]){
				res *= v[i] + 1;
			}
		}
		return res;
	}

	ll res = 0;
	for(int i=0;i<=v[idx];i++){
		val.push_back(i);
		res += solve(idx+1,val);
		val.pop_back();
	}

	return res;
}

int main(void){
	memset(flg,true,sizeof(flg));
	flg[0] = flg[1] = false;
	for(int i=2;i<=ROOT;i++){
		if(flg[i]){
			for(int j=i+i;j<=ROOT;j+=i){
				flg[j] = false;
			}
		}
	}
	for(int i=0;i<=ROOT;i++){
		if(flg[i]) p.push_back(i);
	}

	ll L;
	while(cin>>L,L){
		v.clear();
		ll l = L;
		int idx = 0;

		while(l != 1 && p[idx] * p[idx] <= l){
			int cnt = 0;
			while(l % p[idx] == 0){
				l /= p[idx];
				cnt++;
			}
			idx++;
			if(cnt != 0) v.push_back(cnt);
		}
		if(l != 1) v.push_back(1);

		cout<<(solve(0,vector<ll>())+1)/2<<endl;
	}

	return 0;
}

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

pair<int,int> merge(pair<int,int> l,pair<int,int> r){return {l.first,r.second};}

int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> xy(m);
  for(int i=0;i<m;i++) {
    cin>>xy[i].first>>xy[i].second;
    xy[i].second--;
  }

  sort(xy.begin(),xy.end());
  vector<pair<int,int>> range(n);
  for(int i=0;i<n;i++) range[i]={i,i};
  
  for(int i=0;i<m;i++){
    range[xy[i].second]=range[xy[i].second+1]=merge(range[xy[i].second],range[xy[i].second+1]);
  }

  for(int i=0;i<n;i++){
    cout<<range[i].second-range[i].first+1;
    if(i!=n-1) cout<<" ";
    else cout<<endl;
  }
				   
  return 0;
}

Measured memory_bytes: 5216
r, c = [int(i) for i in input().split()]
array = []

for i in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    array.append(row)
    print(*row)

last_array = []
for i in range(c+1):
    total = 0
    for a in array:
        total += a[i]
    last_array.append(total)
print(*last_array)

Measured memory_bytes: 7752
n,m = map(int,input().split())
inf = 10 ** 18
cost = [inf for _ in range(2**n)]
cost[0] = 0
for _ in range(m):
  a,b = map(int,input().split())
  c = list(map(int,input().split()))
  key = 0
  for i in range(b):
    key += 2 ** (c[i]-1)
  #print(key)
  for t in range(2**n):
    cost[t|key] = min(cost[t|key],cost[t]+a)
#print(cost)
ans = cost[-1]
if ans < inf:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 47576
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++){
    cin >> p[i];
  }
  int count = 0;
  bool flg = true;
  for (int i = 0; i < N; i++){
    if (p[i] == i + 1 && flg){
      count++;
      flg = false;
    } else if (!flg){
      flg = true;
    }
  }
  cout << count;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;

    int diff;
    if (A > B){
        diff = A - B;
    }else{
        diff = B - A;
    }
    if((diff % 2) == 1){
        cout << "IMPOSSIBLE" << endl;
    }else{
        int K;
        if (A > B){
            K = B + (diff / 2);
        }else{
            K = A + (diff / 2);
        }
    cout << K << endl;
    }
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

void eratosthenes(int n, vector<bool> &isPrime){
    isPrime.resize(n+1, true);
    rep(i, 2){
        isPrime[i] = false;
    }
    for(int i = 2 ; i * i <= n ; i++){
        if(isPrime[i]){
            for(int j = i ; i * j <= n ; j++){
                isPrime[i * j] = false;
            }
        }
    }
    return;
}

int main(){
    vector<bool> isPrime;
    eratosthenes(250000, isPrime);
    vector<int> sum(250000);
    sum[0] = 0;
    REP(i, 1, 250000){
        sum[i] = sum[i - 1] + isPrime[i];
    }
    int n;
    while(cin >> n, n){
        cout << sum[n * 2] - sum[n] << endl;
    }
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

using ii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;

class C1DReversi {
public:
	void solve(std::istream &in, std::ostream &out) {
		string s;
		in >> s;
		vector<char> ans;
		for (int i = 0; i < (int) s.size(); i++) {
			if (ans.empty()) ans.push_back(s[i]);
			else if (ans.back() == s[i]) continue;
			else ans.push_back(s[i]);
		}
		out << (int) ans.size() - 1 << '\n';
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	C1DReversi solver;
	std::istream &in(std::cin);
	std::ostream &out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int ans = 1200000;
    for (int i = 0; i <  (1 << 12); i++) { // 組み合わせ
        bitset<12> s(i);
        int sum_C = 0;
        vector<int> sum_A(M) ;
        for (int j = 0; j < N; j++) {
            if (s.test(j)) {
                sum_C += C[j];
                for (int k = 0; k < M; k++) {
                    sum_A[k] += A[j][k];
                }
            }
        }

        int judge = 0;
        for (int k = 0; k < M; k++) {
            if (sum_A[k] < X) {
                judge++;
            }
        }
        if (judge == 0) {
            ans = min(ans, sum_C);
        }
    }

    int sum_all_C = 0;
    for (int i = 0; i < N; i++) {
        sum_all_C += C[i];
    }

    if (ans <= sum_all_C) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
    
    
    
    
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
#define rep(i,N) for (int (i) = 0; (i) < (N); (i)++)

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	
	int A, B; std::cin >> A >> B;
	std::string S; std::cin >> S;
	bool flag = true;
	rep(i, S.size()) {
		if (i == A && S[i] != '-')flag = false;
		if (i != A && S[i] == '-')flag = false;
	}

	std::cout << (flag ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
S = input()
N = int(input())

T1_m = 0
T1_s = 0
rev = 0

myDict = {"fr" : "", "fl" : ""}

for indx in range(N):
    que = input().split()

    if len(que) == 1:
        T1_m += 1
        T1_s += 1
    else:
        F = int(que[1])
        C = str(que[2])

        if T1_s % 2 == 1:
            rev += 1
        
        T1_s = 0
        
        if rev % 2 == 0:
            if F == 1:
                myDict["fl"] = myDict["fl"] + C
            else:
                myDict["fr"] = myDict["fr"] + C
        else:
            if F == 2:
                myDict["fl"] = myDict["fl"] + C
            else:
                myDict["fr"] = myDict["fr"] + C
        
if T1_s % 2 == 1:
    rev += 1

if T1_m % 2 == 1:
    S = S[::-1]

if rev % 2 == 0:
    print(myDict["fl"][::-1] + S + myDict["fr"])
else:
    print(myDict["fr"][::-1] + S + myDict["fl"])

Measured memory_bytes: 4580
n=int(input())
ac =0
wa=0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == "AC":
        ac +=1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1
print("AC"+" "+"x"+" "+str(ac))
print("WA "+"x "+str(wa))
print("TLE "+"x "+str(tle))
print("RE "+"x "+str(re))

Measured memory_bytes: 69852
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n, k, l,p,q,r,s;
	std::cin >> n >> k >> l;
	int i, j; 
	vector<int> G1[200000],G2[200000];
	for (i = 0; i < k; i++) {
		std::cin >> p >> q; p--; q--; G1[p].push_back(q); G1[q].push_back(p);
	}
	for (i = 0; i < l; i++) {
		std::cin >> r >> s; r--; s--; G2[r].push_back(s); G2[s].push_back(r);
	}
	int can1[200000] = {}; int can2[200000] = {}; int mem1=1; int mem2=1;
	for (i = 0; i < n; i++) {
		if (can1[i] == 0) {
			can1[i] = mem1;
			vector<int> q;
			q.push_back(i);
			while (!q.empty()) {
				int x = q[0]; q.erase(q.begin());
				int len = G1[x].size();
				for (j = 0; j < len; j++) {
					if (can1[G1[x][j]] == 0) {
						q.push_back(G1[x][j]); can1[G1[x][j]] = mem1;
					}
				}
			}
			mem1++;
		}
		if (can2[i] == 0) {
			can2[i] = mem2;
			vector<int> q;
			q.push_back(i);
			while (!q.empty()) {
				int x = q[0]; q.erase(q.begin());
				int len = G2[x].size();
				for (j = 0; j < len; j++) {
					if (can2[G2[x][j]] == 0) {
						q.push_back(G2[x][j]); can2[G2[x][j]] = mem2;
					}
				}
			}
			mem2++;
		}
	}
	map<P, int> mp;
	for (i = 0; i < n; i++) {
		mp[{can1[i], can2[i]}]++;
	}
	for (i = 0; i < n; i++) {
		cout << mp[{can1[i], can2[i]}] << " ";
	}
	cout << endl;
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

long long evaluate(string a){

    long long cur = 0, tot = 0;

    for(auto i : a){
        if(i == '+'){
            tot += cur;
            cur = 0;
        } else {
            cur = cur * 10 + (i - '0');
        }
    }

    return tot + cur;

}

long long helper(int pos, string a){
    if(pos == a.size())
        return evaluate(a);
    string b = a.substr(0, pos) + "+" + a.substr(pos, a.size());
    return helper(pos + 1, a) + helper(pos + 2, b);
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string a;
    cin >> a;

    cout << helper(1, a);

    return 0;
}


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

int main() {
 
int N;
cin >>N;
 vector<int> A(N),B(N);
 for(int i=0; i<N; i++){cin>>A[i]; B[i]=A[i];}
sort(A.begin(),A.end());
  if(A[N-1]==A[N-2]){for(int i=0;i<N;i++)cout<<A[N-1]<<endl;}
  else for(int i=0;i<N; i++){if(B[i]==A[N-1])cout<<A[N-2]<<endl;
                             else cout<<A[N-1]<<endl;}
}


Measured memory_bytes: 3200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {

        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

            in.readLine();
            List<String> arr = Arrays.stream(in.readLine().split(" "))
                    .collect(Collectors.toList());
            Collections.reverse(arr);

            System.out.println(String.join(" ", arr));
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.exit(0);
    }
}



Measured memory_bytes: 30896
ABK=list(map(int,input().strip().split()))

A=ABK[0]
B=ABK[1]
K=ABK[2]

if K>=(A+B):
	A=0
	B=0
elif K>=A:
	B=B-(K-A)
	A=0
elif K<A:
	A=A-K
	B=B

print(A,B)

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while (1) {
    if (c - b <= 0) {
      cout << "Yes" << endl;
      return 0;
    } else if (a - d <= 0) {
      cout << "No" << endl;
      return 0;
    } else {
      a -= d;
      c -= b;
    }
  }
}

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

int main() {
    int A[9], N;
    bool X[9] = {false};
    for(int i = 0; i < 9; ++i) cin >> A[i];
    cin >> N;
    
    int b[N];
    for(int i = 0; i < N; ++i) cin >> b[i];

    //
    for(int i = 0; i < 9; ++i){
        for(int j = 0; j < N; ++j){
            if(A[i] == b[j]) X[i] = true;
        }
    }

    //
    if(X[0]&&X[1]&&X[2]
     ||X[3]&&X[4]&&X[5]
     ||X[6]&&X[7]&&X[8]
     ||X[0]&&X[3]&&X[6]
     ||X[1]&&X[4]&&X[7]
     ||X[2]&&X[5]&&X[8]
     ||X[0]&&X[4]&&X[8]
     ||X[2]&&X[4]&&X[6]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,l;
  cin >> n >> m >> l;

//行列Aをつくる
  int a[100][100];
  for(int i=0; i<n; i++)
    for(int j=0; j<m; j++) cin >> a[i][j];

//行列Bをつくる
  int b[100][100];
  for(int i=0; i<m; i++)
    for(int j=0; j<l; j++) cin >> b[i][j];

//行列Cをつくる
  long long c[100][100] = {};
  for(int i=0; i<n; i++)
    for(int j=0; j<l; j++)
      for(int k=0; k<m; k++) c[i][j] += a[i][k] * b[k][j];

  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
	if(j) cout<< " ";
	cout << c[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    vector<int> v(n),c(n);

    rep(i,n)cin >> v[i];
    rep(i,n) cin >> c[i];

    rep(i,n) v[i] = v[i] - c[i];

    int ans=0;
    rep(i,n){
        if(v[i]>0){
            ans += v[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MOD=1e9+7;
int n,k,a[110],dp[110][100010];
int main() {
	scanf("%d%d",&n,&k);
	int i,j;
	for(i=0;i<=k;i++)dp[0][i]=1;
	for(i=1;i<=n;i++) {
		scanf("%d",a+i);
		for(j=0;j<=k;j++) {
			dp[i][j]=dp[i-1][j];
			if(j>=a[i]+1) dp[i][j]=(dp[i][j]+MOD-dp[i-1][j-a[i]-1])%MOD;
			//printf("dp[%d][%d]:%d\n",i,j,dp[i][j]);
		}
		for(j=1;j<=k;j++) dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
	}
	printf("%d",(dp[n][k]+MOD-dp[n][k-1])%MOD);
	return 0;
}

Measured memory_bytes: 41216
#include<iostream>
using namespace std;
int main() {
    int E,Y;
    cin >> E >> Y;
    switch(E) {
        case 0:
        if(Y<1912)cout << "M" << Y-1867 << endl;
        else if(Y<1926)cout << "T" << Y-1911 << endl;
        else if(Y<1989)cout << "S" << Y-1925 << endl;
        else cout << "H" << Y-1988 << endl;
        break;
        case 1:
        cout << Y+1867 << endl;
        break;
        case 2:
        cout << Y+1911 << endl;
        break;
        case 3:
        cout << Y+1925 << endl;
        break;
        case 4:
        cout << Y+1988 << endl;
        break;
    }
}


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

int main () {
  int N;
  cin >> N;
  vector <double> num(N);
  for (int i = 0; i < N; i++) cin >> num.at(i);
  double ans = 0;
  for (int i = 0; i < N; i++) ans += 1/num.at(i);
  cout << fixed << setprecision(6);
  cout << 1/ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
if(K%2 != 0):
    odd = (N // K)**3 # 選び方はa,b,cそれぞれN//K個ある
    print(int(odd))
else:
    c= N//(K/2)
    d= N//K
    e=c-d
    print(int(e**3 + d**3))


Measured memory_bytes: 3060
def main():
    word = list(input())
    word_set = list(set(word))
    # word = input()

    for str in word_set:
        if word.count(str) % 2 == 1:
            print('No')
            return

    # for str in word:
    #     if word.count(str) % 2 == 1:
    #         print('No')
    #         return

    print('Yes')


if __name__ == "__main__":

    main()


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

lli dp [100100];
bool vis[100100];

vector<lli> G[100100];

lli func(lli now){
	if(vis[now])return dp[now];

	vis[now]=true;
	multiset<lli> s;

	for(auto e:G[now]){
		s.insert(func(e));
	}

	lli cnt = 0;
	for(auto e:s){
		if(e>cnt)cnt = e;
		cnt++;
	}

	return dp[now] = cnt;
}

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

	REP(i,1,n){
		lli a;
		cin>>a;
		a--;
		G[a].push_back(i);
	}

	cout<<func(0)<<endl;
	
}

Measured memory_bytes: 17536
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,r; cin>>n>>r;
    cout<<((n<10)?r+100*(10-n):r)<<endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

vector<pair<int64, int>> Factorize(int64 x) {
  vector<pair<int64, int>> r;
  for (int d = 2; d * d <= x; d++) {
    int c = 0;
    while (x % d == 0) {
      x /= d;
      c++;
    }
    if (c > 0) {
      r.push_back({d, c});
    }
  }
  if (x > 0) r.push_back({x, 1});
  return r;
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  const int MAX_X = 1000000;
  vector<int> cs(MAX_X + 1);
  for (int64 x : xs) {
    auto pairs = Factorize(x);
    for (const auto& pair : pairs) {
      UpdateMax(cs[pair.first], pair.second);
    }
  }

  FiniteField lcm = 1;
  for (int i = 1; i <= MAX_X; i++) {
    lcm *= Power(i, cs[i]);
  }
  FiniteField ans = 0;
  for (int64 x : xs) {
    ans += lcm / x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(){
	int N,K,a,count=0;
	int c,tmp;
	scanf("%d",&N);
	scanf("%d",&K);
	for(c=0;c<N;c++){
		scanf("%d",&tmp);
	}
	while(N!=0){
		a=N%K;
		N=N/K;
		count=N+count;
		N=N+a;
		if(N<K){
			break;
		}
	}
	
	if(a==0){
		printf("%d",count);
	}else{
		printf("%d",count+1);
	}
	
	return 0;
	
}



Measured memory_bytes: 128