akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var A = ReadInts().ToList();
            var B = ReadInts().ToList();
            var C = ReadInts().ToList();
            A.RemoveAt(0);
            B.RemoveAt(0);
            C.RemoveAt(0);
            var ans = 0;
            for (int i = 0; i < C.Count; i++)
            {
                if (A.Contains(C[i]))
                {
                    if (B.Contains(C[i]))
                    {
                        ans++;
                    }
                }
                else
                {
                    ans++;
                }
            }
            WriteLine(ans);

        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b = LI()
if a != b:
    print(max(a, b)*2-1)
else:
    print(a+b)

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



int main(){
	char x;
	cin >> x;
	int i = (int)x;
	if(i>=97 && i <= 122) cout << "a" << endl;
	else cout << "A" << endl;
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M;
  cin>>N>>M;
  vector<ll>A(N);
  vector<pair<ll,ll>>B(M);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<M;i++)cin>>B[i].second>>B[i].first;
  sort(rng(A));
  sort(rng(B));
  reverse(rng(B));
  vector<ll>sum(N+1);
  sum[0]=0;
  for(int i=1;i<=N;i++)sum[i]=sum[i-1]+A[i-1];
  int l=0;
  ll ans=sum[N];
  for(int i=0;i<M;i++){
    int p=lower_bound(A.begin()+l,A.end(),B[i].first)-A.begin();
    int d=min(p-l,(int)B[i].second);
    ans-=sum[l+d]-sum[l];
    ans+=B[i].first*(d);
    l=l+d;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3456
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>
#include <array>

typedef long long ll;

int main(int argc, char *argv[])
{
    ll a, b, n;
    ll ans = std::numeric_limits<ll>::min();

    std::cin >> a >> b >> n;

    for (ll x = (n < b)?(n):(b - 1); x <= n; x += b) {
        ll p = (a * x) / b - a * (x / b);
        ans = std::max(ans, p);
        
        break;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  ll N, X;
  cin >> N >> X;
  vector<ll> Pati(N + 1), Maisuu(N + 1);
  Pati[0] = 1, Maisuu[0] = 1;
  for (int i = 1; i <= N; i++) {
    Pati[i] = 2 * Pati[i - 1] + 1;
    Maisuu[i] = 2 * Maisuu[i - 1] + 3;
  }
  ll ans = 0;
  for (int i = N; i >= 0; i--) {
    X--;
    if (X >= 0 && i == 0) {
      ans++;
      break;
    }
    if (i == 0) break;
    if (X >= Maisuu[i - 1]) {
      ans += Pati[i - 1];
      X -= Maisuu[i - 1];
    } else {
      continue;
    }
    X--;
    if (X >= 0) ans++;
    if (X >= Maisuu[i - 1]) {
      ans += Pati[i - 1];
      X -= Maisuu[i - 1];
      X--;
    } else {
      continue;
    }
  }
  cout << ans << endl;
}

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

string t;

int main() {
  cin >> t;
  long long res = 0, n = t.size();
  for (int i = 0; i < n; ++i)
    if (t[i] == '?') t[i] = 'D';
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3748
x = list(map(int, input().split()))
a = x[0]
b = x[1]
c = x[2]
d = x[3]

ac = a*c
ad = a*d
bc = b*c
bd = b*d

max = ac
if max<ad:
  max = ad
if max<bc:
  max = bc
if max<bd:
  max = bd
      
print(max)
    



Measured memory_bytes: 9080
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<string>
using namespace std;

int main() 
{ 
  int a, b;
  cin >> a >>b;
  if((a+b)%2!=0) cout << "IMPOSSIBLE";
  else cout << (int)(a+b)/2;
  
  return 0; 
} 

Measured memory_bytes: 256
N=int(input())
S=[input() for _ in range(N)]

S_d={}
A=[]

for i in range(N):
    if S[i] not in S_d.keys():
        S_d[S[i]]=1
    else:
        S_d[S[i]]+=1

max_co=max(S_d.values())

for j in S_d.keys():
    if S_d[j]==max_co:
        A.append(j)

B=sorted(A)

for k in B:
    print(k)

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

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

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000000LL

using namespace std;

int main(){
  ll n,k;cin>>n>>k;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(), a.end());

  ll l=-INF;
  ll r = INF;
  while(l+1<r){
    ll x = (l+r)/2;

    ll count=0;
    rep(i, n){
      if(a[i] < 0){

        ll l=-1, r=n;
        while(r>l+1){
          ll m = (l+r)/2;
          // バグらせポイント
          if(a[m]*a[i] < x) r=m;
          else l=m;
        }
        // バグらせポイント
        count += n-r;

      }else{

        ll l=-1, r=n;
        while(r>l+1){
          ll m = (l+r)/2;
          if(a[m]*a[i]<x) l=m;
          else r=m;
        }
        count += r;

      }
      if(a[i]*a[i]<x)count--;

//cout<<a[i]<<' '<<count<<endl;

    }
    if(count/2<k) l=x;
    else r=x;
//cout<<'*'<<count<<' '<<x<<endl;
  }

  cout<<l;

  return 0;
}

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

int main(){

  int alf[27]={};
  string S;
  getline(cin, S);

  for(int i=0; i<S.size(); i++){
    alf[S[i]-'a']++;
  }

  for(int i=0; i<27; i++){
    if(alf[i] > 1){
      cout << "no" << endl;
      return 0;
    }
  }

  cout << "yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll X;
  cin >> X;
  ll ans = 360 / __gcd(X, 360ll);
  cout << ans << "\n";
}


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

int main() {
  string s;
  cin >> s;
  if(s == "SSS") {
    cout << 0;
  }else if(s == "RRS" || s == "SRR") {
    cout << 2;
  }else if(s == "RRR") {
    cout << 3;
  }else {
    cout << 1;
  }
}

Measured memory_bytes: 3596
N = int(input())
data = list(map(int, input().split(' ')))
sorteddata = sorted(data)

c1 = sorteddata[N // 2]
c2 = sorteddata[N // 2 - 1]

for i in range(N):
    if (data[i] < c1):
        print(c1)
    else:
        print(c2)

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

int main(){
	int d,n;
	cin>>d>>n;
  cout.precision(10);
	if(n<100) cout << pow(100,d)*n << endl;
	else cout << pow(100,d)*101 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int H, W;
char field[105][105];

class Dinic {
  int MAX_V;
  ll INF;
  struct edge{ ll to, cap, rev, icap, flow; };

  vector< vector<edge> > G;
  vector<int> level; //sからの距離
  vector<int> iter; //どこまで調べたか

  void max_flow_bfs(int s){
    fill(level.begin(), level.end(), -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
      int v = que.front(); que.pop();
      for(int i=0; i<G[v].size(); i++){
        edge &e = G[v][i];
        if(e.cap>0 && level[e.to]<0){
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
  }
  ll max_flow_dfs(int v, int t, ll f){
    if(v==t) return f;
    for(int &i=iter[v]; i<G[v].size(); i++){
      edge &e = G[v][i];
      if(e.cap>0 && level[v]<level[e.to]){
        ll d = max_flow_dfs(e.to, t, min(f, e.cap));
        if(d>0){
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          e.flow += d;
          return d;
        }
      }
    }
    return 0;
  }

public:
  Dinic(int N):MAX_V(N),G(N),level(N),iter(N){
    INF = 9999999999999LL;
  }

  void add_edge(int from, int to, ll cap){
    G[from].push_back((edge){to, cap, (int)G[to].size(), cap, 0});
    G[to].push_back((edge){from, 0, (int)G[from].size()-1, 0, 0});
  }

  ll get_flow(int from, int to){ //untried
    rep(i,G[from].size()){
      if(G[from][i].to == to){
        return G[from][i].flow;
      }
    }
    return -1;
  }
  
  ll max_flow(int s, int t){
    ll flow = 0;
    while(true){
      max_flow_bfs(s);
      if(level[t]<0) return flow;
      fill(iter.begin(), iter.end(), 0);
      ll f;
      while((f = max_flow_dfs(s, t, INF))>0){
        flow += f;
      }
    }
  }
  
};

int main(){
  cin >> H >> W;
  rep(i,H){
    string str;
    cin >> str;
    rep(j,W){
      field[i][j] = str[j];
    }
  }

  Dinic dinic(20005);
  int s_id = -1;
  int t_id = -1;

  rep(i,H){
    rep(j,W){
      if(field[i][j] == 'S'){
        s_id = i*W+j;
        field[i][j] = 'o';
      }
      if(field[i][j] == 'T'){
        t_id = i*W+j;
        field[i][j] = 'o';
      }
    }
  }

  int sy = s_id/W, sx = s_id%W;
  int ty = t_id/W, tx = t_id%W;
  if(sy == ty || sx == tx){
    cout << -1 << endl;
    return 0;
  }

  ll INF = 9999999999999LL;
  rep(i,H){
    rep(j,W){
      if(field[i][j] == 'o'){
        dinic.add_edge(i*W+j, i*W+j+10001, 1);
        rep(k,W){
          if(k!=j && field[i][k] == 'o'){
            //cout << i << " " << j << " -> " << i << " " << k << endl;
            dinic.add_edge(i*W+j+10001, i*W+k,INF);
          }
        }
        rep(k,H){
          if(k!=i && field[k][j] == 'o'){
            //cout << i << " " << j << " -> " << k << " " << j << endl;
            dinic.add_edge(i*W+j+10001, k*W+j,INF);
          }
        }
      }
    }
  }

  cout << dinic.max_flow(s_id+10001, t_id) << endl;
  
  return 0;
}



Measured memory_bytes: 206720
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a*b % 2 == 0)
	{
		cout << "Even" << endl;
	}
	else
	{
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll N;
  cin >> N;
  map<string, int> str;
  rep(i,N){
    string s;
    cin >> s;
    str[s]++;
  }
  int max = 0;
  for(auto &x : str){
    if(max < x.second){
      max = x.second;
    }
  }
  for(auto &x : str){
    if(x.second == max){
      cout << x.first << endl;
    }
  }

}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n, m;
  cin >> n >> m;
  int s = 0;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    s += x;
  }
  if (s <= n) {
    cout << n - s << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    int tmp = n / (a + b);
    ans += tmp * a;
    n -= tmp * (a + b);
    ans += min(n, a);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  cin>>n;
  vector<ll>v(n,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  vector<ll>v2=v;
  sort(v2.begin(),v2.end());
  for(ll i=0;i<n;i++){
    if(v[i]!=v2[i])ans++;
  }
  if(ans==0||ans==2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 888
n = int(input())
dic = {}
key = ''
for i in range(n):
  key = input()
  if (key in dic.keys())==True:
    dic[key] += 1
  else:
    dic[key] = 1
m = int(input())
for i in range(m):
  key = input()
  if (key in dic.keys())==True:
    dic[key] -= 1
  else:
    dic[key] = -1
print(max(max(dic.values()),0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int color[10];

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

    int n;
    cin >> n;

    int more = 0;
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        if( 1 <= a && a < 400 ) ++color[1];
        if( 400 <= a && a < 800 ) ++color[2];
        if( 800 <= a && a < 1200 ) ++color[3];
        if( 1200 <= a && a < 1600 ) ++color[4];
        if( 1600 <= a && a < 2000 ) ++color[5];
        if( 2000 <= a && a < 2400 ) ++color[6];
        if( 2400 <= a && a < 2800 ) ++color[7];
        if( 2800 <= a && a < 3200 ) ++color[8];
        if( 3200 <= a ) ++more;

    }
    int kind = 0;
    int z_cnt = 0;
    for( int i = 1; i <= 8; ++i ) {
        if( color[i] ) ++kind;
        else ++z_cnt;

    }
    int mn, mx;
    if( kind == 0 ) mn = 1;
    else mn = kind;
    mx = kind + more;

    cout << mn << " " << mx << endl;

    return 0;
}



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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 5000, MAX_K = 5000, INF = 1e9;
int N, K;
ll a[MAX_N];
ll dp[MAX_N+1][MAX_K+1];

int main() {
  cin >> N >> K;
  rep(i,N) cin >> a[i];
  sort(a, a+N);
  reverse(a, a+N);

  for (int j = 0; j <= K; ++j) dp[0][j] = j;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= K; ++j) {
      dp[i][j] = dp[i-1][j];
      if (j - a[i-1] >= 0) dp[i][j] = min(dp[i][j], dp[i-1][j-a[i-1]]);
    }
  }

  int need = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < K; ++j) {
      if (a[i-1] - dp[i-1][j] >= K - j) {
        need = i; break;
      }
    }
  }

  cout << N - need << endl;
  
  return 0;
}


Measured memory_bytes: 195712
n,m = map(int,input().split())
ans = [1]*(n+1)
for i in range(m):
    a = int(input())
    ans[a] = 0
    
for i in range(2,n+1):
    if ans[i]==0:
        continue
    else:
        ans[i] = ans[i-2] + ans[i-1]
print(ans[n]%(10**9+7))

Measured memory_bytes: 470264
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int A, B, C;
    cin>>A>>B>>C;
    if(A+B>=C)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

ll n;
ll ans = 0;

void dfs(ll x, int a, int b, int c) {
	if (x > n)return;
	if (a && b && c)ans++;
	dfs(10 * x + 3, 1, b, c);
	dfs(10 * x + 5, a, 1, c);
	dfs(10 * x + 7, a, b, 1);
}

int main() {
	int n;
	cin >> n;
	if (n == 4 || n == 6 || n == 9 || n == 10 || n == 14 || n == 21 || n == 22 || n == 25 || n == 26)cout << 2 << endl;
	else if (n == 8 || n == 12 || n == 18 || n == 20 || n == 27)cout << 5 << endl;
	else if (n == 16)cout << 14 << endl;
	else if (n == 24)cout << 15 << endl;
	else if (n == 28 || n == 30)cout << 4 << endl;
	else if (n == 32)cout << 51 << endl;
	else cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int long a ,b;
cin>>a>>b;
int long long lcm,hcf=0;
for(int i=2;i<=min(a,b);i++)
{
    if(a%i==0 && b%i==0)
      hcf=i;
}
if(hcf==0)
hcf=1;
lcm=a*b/hcf;
cout<<lcm;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	uint64_t a, b;
	cin >> a >> b;

	uint64_t aa = a, bb = b;

	while( aa != bb )
	{
		if( aa < bb )	aa += a;
		else			bb += b;
	}

	cout << aa << endl;

	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a=[int(aa)-1 for aa in input().split() ]

now=0

been = [0]*n
been[0]=1
for i in range(n):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        t_stack=sum(been)
        break

start=now

been = [0]*n
been[now]=1
for i in range(n):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        period=sum(been)
        break

        
if k<=t_stack:
    now=0
    for i in range(k):
        now=a[now]
    print(now+1)
    
else:
    n_itr = (k-t_stack+period)%period
    now=start
    for i in range(n_itr):
        now=a[now]
    print(now+1)

Measured memory_bytes: 92360
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int width, height;

	//標準入力
	cin >> width >> height;

	//面積
	int area = width * height;

	//週の長さ
	int totalLength = (width + height) * 2;

	//
	cout << to_string(area) + " " + to_string(totalLength) << endl;

	return 0;
    
}


Measured memory_bytes: 3244
h,w=map(int,input().split())
a=[list(map(int,input().split()))for i in range(h)]
b=[list(map(int,input().split()))for i in range(h)]
s=[0]*w
s[0]=p=1<<6400
for i in range(h):
    for j in range(w):
        d=abs(a[i][j]-b[i][j])
        if j>0:
            s[j]|=s[j-1]
        s[j]=(s[j]<<d)|(s[j]>>d)
t=s[-1]
for i in range(6401):
    if t&(p<<i) or t&(p>>i):
        print(i)
        break

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int a[N];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  sort(a+1,a+1+n);
  if(unique(a+1,a+1+n)-a-1!=n)cout<<"NO\n";
  else cout<<"YES\n";
  return 0;
}

Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    char[] forecast = sc.next().toCharArray();
    char[] real = sc.next().toCharArray();
    int count = 0;
    for (int i = 0; i < forecast.length; i++) {
      if (forecast[i] == real[i]) {
        count++;
      }
    }
    pw.println(count);
  }
}


Measured memory_bytes: 22608
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvl vector<vector<ll>>
#define v(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

//-I/usr/local/include
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<1000, std::int64_t>> fl_1000;
typedef mp::cpp_dec_float_100 fl;
/*
  mp::sqrt(x)

*/
int main(int argc, char const *argv[]) {
  fl_1000 n, m;std::cin >> n >> m;
  vector<fl_1000> a((int)n);
  fl_1000 s = 0;
  re(i, n){
    std::cin >> a[i];
    s += a[i];
  }
  ll c = 0;
  s /= m*4;
  re(i, n) if(a[i]>=s)c++;
  std::cout << (c>=m?"Yes":"No") << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,i;
    cin>>n>>k;
    ll a[n+1];
    for(i=1;i<=n;i++)
    cin>>a[i];
    if(k<=n)
    {
        ll place;
        ll start=1;
        while(k>0)
        {
            place=a[start];
            k--;
            start=place;
        }
        cout<<start;
    }
    else
    {
        ll place;
        ll start=1;
        ll num=n,val;
        vector<int>v;
        map<int,int>mp;
        ll i=1,idx;
        ll arr[n+1];
        memset(arr,0,sizeof(arr));
        while(num>0)
        {
            place=a[start];
            if(mp.find(start)!=mp.end())
            {
                val=start;
                idx=mp[start];
                break;
            }
            v.pb(start);
            mp[start]=i;
            i++;
            num--;
            start=place;
        }
        ll size=i-idx,k1,j;
        for(i=0;i<v.size();i++)
        {
            if(v[i]==val)
            {
                j=i;
                break;
            }
        }
        k1=j;
        for(i=j;i<v.size();i++)
        {
            arr[k1%size]=v[i];
            // cout<<v[i]<<" "<<k1<<endl;
            k1++;
        }
        ll m=k%size;
        cout<<arr[m]<<endl;
    }
    return 0;
}

Measured memory_bytes: 14280
#include<iostream>

using namespace std;

int main(){
  int n, q, a[100009];
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  cin >> q;
  int cnt =0, x;
  for(int i=0;i<q;i++){
    cin >> x;
    for(int j=0;j<n;j++){
      if(a[j] == x){
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3100
// ARC076 F Exhausted?

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

// ******************************************************************
// Segment Tree with Lazy Propagation
// Increment modification on range, queries for maximum / minimum on range.
// ******************************************************************
template<typename T>
class SegTreeLazy{
    size_t n;
    int h;
    vector<T> data;
    vector<T> lazy;
    const T identity_element = -2e9;  // for max
    //const T identity_element = 2e9;  // for min
    static T combine(T L, T R){
        return max(L, R);
        // return min(L, R);
    }
    void apply(size_t i, T v){
        data[i] += v;
        if (i < n) lazy[i] += v;
    }
    void build(size_t i){      // update all the parents of node i.
        while (i > 1) i >>= 1, data[i] = combine(data[i*2], data[i*2+1]) + lazy[i];
    }
    void push(size_t p){       // propagates the changes from the root to node p.
        for (int s = h; s > 0; --s){
            size_t i = p >> s;
            if (lazy[i] != 0){
                apply(i*2, lazy[i]);
                apply(i*2+1, lazy[i]);
                lazy[i] = 0;
            }
        }
    }
    int calc_h(size_t nn){
        int hh = 1;
        for (; nn > 1; ++hh, nn >>= 1);
        return hh;
    }
public:
    SegTreeLazy(size_t _n): n(_n), h(calc_h(n)), data(vector<T>(2 * n, 0)), lazy(vector<T>(n, 0)){}
    SegTreeLazy(const vector<T> &src): n(src.size()), h(calc_h(n)), data(vector<T>(2 * n, 0)), lazy(vector<T>(n, 0)){
        for (int i = 0; i != n; ++i) data[n + i] = src[i];
        for (int i = n - 1; i != 0; --i) data[i] = combine(data[i*2], data[i*2+1]);
    }
    void inc(size_t L, size_t R, T v){  // add v to range [L, R)
        L += n;
        R += n;
        size_t L0 = L;
        size_t R0 = R;
        for (; L < R; L >>= 1, R >>= 1){
            if (L & 1) apply(L++, v);
            if (R & 1) apply(--R, v);
        }
        build(L0);
        build(R0 - 1);
    }
    T query(size_t L, size_t R){
        L += n;
        R += n;
        push(L);
        push(R - 1);
        T ret = identity_element;
        for (; L < R; L >>= 1, R >>= 1){
            if (L & 1) ret = combine(ret, data[L++]);
            if (R & 1) ret = combine(data[--R], ret);
        }
        return ret;
    }
};



int solve(int N, int M, const vector<pair<int, int>> & LRs){
    vector<vector<int>> Rs(M + 1, vector<int>());
    for (const auto &LR : LRs) Rs[LR.first].push_back(LR.second);
    vector<int> initial_values(M + 2, 0);
    for (int i = 0; i <= M + 1; ++i) initial_values[i] = i - M - 1;
    SegTreeLazy<int> seg(initial_values);
    int ans = 0;
    for (int L = 0; L <= M; ++L){
        for (auto R : Rs[L]){
            seg.inc(0, R + 1, 1);
        }
        ans = max(ans, seg.query(0, M + 2) - L);
    }
    ans = max(ans, N - M);
    return ans;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> LRs(N);
    for (auto & LR : LRs) cin >> LR.first >> LR.second;
    cout << solve(N, M, LRs) << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> red, green, plain;
  rep(i, a) {
    int t; cin >> t;
    red.push_back(t);
  }
  rep(i, b) {
    int t; cin >> t;
    green.push_back(t);
  }
  rep(i, c) {
    int t; cin >> t;
    plain.push_back(t);
  }

  sort(red.begin(), red.end(), greater<int>());
  sort(green.begin(), green.end(), greater<int>());
  sort(plain.begin(), plain.end());

  vector<int> apples(a + b + c);
  copy(red.begin(), red.begin() + x, apples.begin());
  copy(green.begin(), green.begin() + y, back_inserter(apples));
  copy(plain.begin(), plain.end(), back_inserter(apples));
  sort(apples.begin(), apples.end(), greater<int>());
  
  ll ans = 0;
  rep(i, x + y) {
    ans += apples[i];
  }
  cout << ans;
}


Measured memory_bytes: 3960
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    if (n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const ll INF = 1e18 + 10;

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x( (x%mod + mod) % mod ) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ( (x += a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ( ( x += mod - a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        ( x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int N, K;
vector<int> G[200005];
vector<int> child[200005];
mint res = 1;

void dfs0(int v, int p) {
    for (auto u : G[v]) {
            if (u == p) continue;
            child[v].push_back(u);
            dfs0(u,v);
    }
}

void dfs1(int v) {
    rep(i,child[v].size()) {
        res *= mint(K- 1 - (int)(v != 0) -i);
        dfs1(child[v][i]);
    }
}

int main() {
    cin >> N >> K;
    rep(i,N-1) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs0(0, -1);
    dfs1(0);
    cout << res*mint(K) << endl;
}

Measured memory_bytes: 25108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	bool bFumiyasui;
	string S;
	char ch;

	cin >> S;
	
	bFumiyasui = true;
	for (int i = 0; i < S.length(); i++) {
		ch = S[i];
		if ((i % 2) != 0) {
			if (!((ch == 'L')||(ch == 'U')||(ch == 'D'))) {
				bFumiyasui = false;
				break;
			}
		} else {
			if (!((ch == 'R')||(ch == 'U')||(ch == 'D'))) {
				bFumiyasui = false;
				break;
			}
		}
	}

	if (bFumiyasui) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}



Measured memory_bytes: 256
S = input()
q = int(input())
head = ""
tail = ""
rev_cnt = 1
for ind in range(q):
    cur_list = list(input().split())
    #print(cur_list)
    if int(cur_list[0]) == 1:
        rev_cnt *= -1
    else:
        f = int(cur_list[1])
        c = cur_list[2]
        if f == 1:
            if rev_cnt == 1:
                head += c
            else:
                tail += c
        elif f == 2:
            if rev_cnt == 1:
                tail += c
            else:
                head += c
            
S = head[::-1] + S + tail   
if rev_cnt == -1:
    S = S[::-1]
    
print("".join(S))

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

vector<int> adj[200005];
vector<long long> adj1[200005];


int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int n;
		scanf("%d",&n);
		for(int i=0;i<n-1;i++){
			int u,v;
			long long c;
			scanf("%d %d %lld",&u,&v,&c);
			adj[u].push_back(v);
			adj[v].push_back(u);
			adj1[u].push_back(c);
			adj1[v].push_back(c);
		}
		int q,k;
		scanf("%d %d",&q,&k);
		set<pair<long long,int> > pq;
		static long long dis[200005];
		static bool vis[200005];
		memset(vis,false,sizeof(vis));
		pq.insert(make_pair(0ll,k));
		while(pq.size()){
			pair<long long,int> tmp = *pq.begin();
			pq.erase(pq.begin());
			int cur = tmp.second;
			if(vis[cur]){
				continue;
			}
			vis[cur] = true;
			dis[cur] = tmp.first;
			for(int i=0;i<adj[cur].size();i++){
				if(vis[adj[cur][i]] == false){
					pq.insert(make_pair(dis[cur]+adj1[cur][i],adj[cur][i]));
				}
			}
		}
		while(q--){
			int x,y;
			scanf("%d %d",&x,&y);
			printf("%lld\n",dis[x] + dis[y]);
		}
	}
	return 0;	
}

Measured memory_bytes: 25456
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
#define SORT(a) sort(a,a+sizeof(a)/sizeof(a[0]))
using namespace std;

int main(){
  int N,C,K;
  cin >> N >> C >> K;
  int T[N];
  REP(i,N){
    cin >> T[i];
  }
  SORT(T);
  int ret = 0, f = 0;
  while(f < N){
    int b = f;
    while(b < N && T[b] <= T[f] + K && b < f + C){ b++; }
    if(b != f){ ret++; f = b; }
  }
  cout << ret << endl;
}

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

int main(){
  int N;
  string S;
  set<string> ans;
  scanf("%d", &N);
  
  for (int i = 0; i < N; i++){
    cin >> S;
    ans.insert(S);
    }
  printf("%d\n", ans.size());
}

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

using namespace std;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N 100010
ll n,f[N],g[N];
vector<ll> e[N];
void dfs(ll x,ll from){
 ll sf=1,sa=1;
 for(auto y:e[x])if(y!=from){
     dfs(y,x);
     sf=sf*f[y]%mod;
     sa=sa*(f[y]+g[y])%mod;
 }
 f[x]=sa,g[x]=sf;
}
int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
     ll a,b;cin>>a>>b;
     e[a].push_back(b);
     e[b].push_back(a);
    }
    dfs(1,0);
    cout<<(f[1]+g[1])%mod<<endl;
 return 0;   
}

Measured memory_bytes: 14208
#include<bits/stdc++.h>
#define maxn 1005
#define ll long long
using namespace std;
ll dp[maxn],n,a[maxn],anss,l[maxn],r[maxn],id,ans[maxn],tail;
int main()
{
	scanf("%lld",&n);
	dp[0]=-0x3f3f3f3f;
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]),dp[i]=a[i];
	for(int i=1;i<=n;++i) 
	for(int j=1;j<i;++j) 
	{
		if((i-j)%2==0)
		if(dp[j]+a[i]>dp[i]) dp[i]=max(dp[i],dp[j]+a[i]),l[i]=j;
	}
	for(int i=1;i<=n;++i) if(dp[i]>dp[id]) id=i;
	cout<<dp[id]<<endl;
	for(int i=n;i>id;--i) ans[++tail]=i;
	while(l[id]!=0){
		int mid=(id+l[id])>>1;
		for(int i=mid;i>l[id];--i)
		ans[++tail]=i;
		id=l[id];
	}
	for(int i=1;i<id;++i) ans[++tail]=1;
	printf("%lld\n",tail);
	for(int i=1;i<=tail;++i) printf("%lld\n",ans[i]);
	
	return 0;
}

Measured memory_bytes: 256
# ARC064C - Boxes and Candies (ABC048C)
def main():
    n, x = map(int, input().split())
    A = list(map(int, input().split()))

    # modify A[0] if >x
    ans = 0 if A[0] < x else A[0] - x
    A[0] = min(A[0], x)
    
    prv = A[0]
    for i in range(1, n):
        dif = prv + A[i] - x
        if dif > 0:
            A[i] -= dif
            ans += dif
        prv = A[i]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14052
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second
#define NMAX 100005
#define INF 1000000007

long long ans, val;

int main (){
    
    scanf("%lld",&val);
    ans = (val / 11) * 2;
    if(val % 11 == 0)
        ans += 0;
    else if(val % 11 <= 6)
        ans++;
    else
        ans += 2;
    printf("%lld\n", ans);
    
    return 0;
}

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

int main() {
	int n ; 
	cin>>n;
	int t = n ;
	vector<long long > prefix (n+1,0);
	vector<vector<long long> > dp(n,vector<long long>(n,100000000000000000) );
	for(int i = 0 ; i < n ; i++){
		int temp;
		cin>>temp;
		prefix[i+1] = prefix[i] + temp;
		dp[i][i] = 0;
	}
	t--;
	for(int i = 1 ; i < n ; i++){
		for(int  j = 0 ; j < t ; j++){
			int row = j;
			int col = j+i;
			for(int k = 1 ; col - k >= row ; k++ ){
			dp[row][col]=min(dp[row][col-k]+dp[col-k+1][col]+prefix[col+1]-prefix[row] ,dp[row][col]);	
			}
		}
		t--;
	}
	cout<<dp[0][n-1]<<endl;
	return 0 ;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  vector<int> bit(32,-1);
  vector<LL> l(32,0),r(32,0);
  l[0]=0;
  r[0]=1;
  for(int i=1;i<32;i++){
    if(i%2){
      l[i]=l[i-1]-(1<<i);
      r[i]=r[i-1];
    }else{
      l[i]=l[i-1];
      r[i]=r[i-1]+(1<<i);
    }
    // cout << l[i] << " " << r[i] << endl;
  }
  for(int i=31;i>=1;i--){
    if(l[i-1]<=n-(1<<i)*(1-2*(i%2))&&n-(1<<i)*(1-2*(i%2))<=r[i-1]){
      bit[i]=1;
      n-=(1<<i)*(1-2*(i%2));
    }else{
      bit[i]=0;
    }
    // cout << bit[i] << endl;
    // cout << n << endl;
  }
  if(n%2) bit[0]=1;
  else bit[0]=0;
  bool ok=false;
  for(int i=31;i>=0;i--){
    if(bit[i]==1){
      ok=true;
    }
    if(ok) cout << bit[i];
  }
  cout << endl;
  return 0;
}


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

vector<int> vi[100010];
bool inq[100010]={false};
int pre[100010]={0};
int n;
void init(){
    for(int i=1;i<=n;i++){
        pre[i]=i;
    }
}


void BFS(int idx){
    queue<int> q;
    q.push(1);
    inq[1]=true;
    while(!q.empty()){
        int top=q.front();
        //inq[top]=true;
        q.pop();
        for(int i=0;i<vi[top].size();i++){
            if(inq[vi[top][i]]==false){
                pre[vi[top][i]]=top;
                q.push(vi[top][i]);
                inq[vi[top][i]]=true;
            }
        }
    }
}

int main(){
   int m;
   scanf("%d%d",&n,&m);
   init();
   for(int i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    vi[a].push_back(b);
    vi[b].push_back(a);
   }
   BFS(1);
   bool flag=true;
    for(int i=2;i<=n;i++){
        if(pre[i]==i){
            flag=false;
            break;
        }
    }
    if(!flag){
        printf("No");
    }else{
        printf("Yes\n");
        for(int i=2;i<=n;i++){
            printf("%d\n",pre[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 10696
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>

#define ll long long int
#define llu unsigned long long int
#define N 100001
using namespace std;

vector<vector<int>> dp(N,vector<int>(3,-1));
int fun(vector<vector<int>> &v, int i,int x) {
	if(i==0){
	return 0;
	}
	if(dp[i][x]==-1)
	switch(x){
			case 0: dp[i][x]=max(fun(v,i-1,1)+v[i][1],fun(v,i-1,2)+v[i][2]);
			break;
			case 1: dp[i][x]=max(fun(v,i-1,0)+v[i][0],fun(v,i-1,2)+v[i][2]);
			break;
			case 2: dp[i][x]= max(fun(v,i-1,0)+v[i][0],fun(v,i-1,1)+v[i][1]);
			break;
		}
	return dp[i][x];
}

int main(){
int n;
cin>>n;
vector<vector<int>> v(n+1,vector<int>(3));
for(int i=1;i<=n;i++){
	cin>>v[i][0]>>v[i][1]>>v[i][2];
}
cout<<max(max(fun(v,n,0),fun(v,n,1)),fun(v,n,2))<<"\n";
// dp[0][0]=0;
// for(int i=1;i<=n;i++){
// 	cout<<dp[i][0]-dp[i-1][0]<<" ";
// }


return 0;
}

Measured memory_bytes: 17408
///ShzFahad
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    ld k;
    cin >> n;
    k = ceil(n/1000.0)*1000;
    cout << k-n << endl;


}



Measured memory_bytes: 3784
#include <stdio.h>

int main()
{
  int a, b, k;
  int i, count = 0;

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

  for (i = (a < b ? a : b); count != k; i--) {
    if (a % i == 0 && b % i == 0) {
      count++;
    }
  }

  printf("%d\n", i + 1);

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	static String remove(String s, int x, int y) {
		return s.substring(0, x) + s.substring(y + 1);
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		boolean keyence = s.equals("keyence");
		for(int i = 0; i < s.length(); i++) {
			for(int j = i; j < s.length(); j++) {
				if(remove(s, i, j).equals("keyence")) keyence = true;
			}
		}
		System.out.println(keyence ? "YES" : "NO");
	}
}


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

int n,m,q;
vector<int>a,b,c,d;
int ans = 0;
void dfs(vector<int> A){
    if(A.size() == n+1){
        int now = 0;
        rep(i,q){
            if(A[b[i]]-A[a[i]] == c[i]) now += d[i];
        }
        ans = max(now,ans);
        return;
    } 
    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
}
int main(){
    
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,y;cin>>n>>m>>x>>y;
  vector<int>a(n+1),b(m+1);
  for(int i=0;i<n;i++)cin>>a.at(i);
  for(int i=0;i<m;i++)cin>>b.at(i);
  a.at(n)=x;b.at(m)=y;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(a.at(n)<b.at(0)||a.at(0)>b.at(m))cout<<"No War"<<endl;
  else cout<<"War"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX_V 1000000
int prime[MAX_V+1];
int main(){
    int i, k, n;
    
    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1;
    }
    for(i = 2; i * i <= MAX_V; i++){
        if(prime[i]){
            for(k = 2*i;k <= MAX_V; k += i){
                prime[k] = 0;
            }
        }
    }
    while(scanf("%d", &n) != EOF){
        if(n==0) break;
        for(i = n; i >=2; i--){
            if(prime[i - 2]&& prime[i]/*&&p1<i*/){
                printf("%d %d\n", i - 2, i);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 5596
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int W, H; readf("%d %d\n", &W, &H);
    auto F = new int[][](H, W);
    int Y, X; // 福袋の座標
    foreach (i; 0 .. H) {
        string s = readln.chomp;
        foreach (j; 0 .. W) {
            if (s[j] == '.') {
                F[i][j] = 0;
            } else if (s[j] == '#') {
                F[i][j] = int.max;
            } else { assert(s[j] == 't');
                F[i][j] = 0;
                Y = i; X = j;
            }
        }
    }
    int N; readf("%d\n", &N);
    foreach (int i; 1 .. N + 1) {
        int x, y; readf("%d %d\n", &x, &y);
        F[y][x] = i;
    }

    bool bfs(int t) {
        struct P { int y, x; }
        DList!P Q;
        Q.insert(P(0, 0));
        auto used = new bool[][](H, W);
        while (!Q.empty) {
            static const dy = [0, 1, 0, -1],
                         dx = [1, 0, -1, 0];
            P p = Q.front; Q.removeFront;
            foreach (i; 0 .. 4) {
                int ny = p.y + dy[i],
                    nx = p.x + dx[i];
                if (ny < 0 || ny >= H) continue;
                if (nx < 0 || nx >= W) continue;
                if (F[ny][nx] > t) continue;
                if (used[ny][nx]) continue;
                if (ny == Y && nx == X) {
                    return true;
                }
                used[ny][nx] = true;
                Q.insert(P(ny, nx));
            }
        }
        return false;
    }

    if (bfs(0)) {
        writeln(0);
    } else if (!bfs(N)) {
        writeln(-1);
    } else {
        int lb = 0, ub = N;
        while (lb + 1 < ub) {
            int mid = (lb + ub) / 2;
            if (bfs(mid)) {
                ub = mid;
            } else {
                lb = mid;
            }
        }
        writeln(ub);
    }
}

Measured memory_bytes: 56916
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

int main(void) {
    // insert code here...
    int W,H;
    cin >> W >> H;
    int x,y;
    cin >> x >> y;
    
    double menseki = double(W)*double(H)/(double)2;
    cout <<setprecision(11) << menseki<<" ";
    if (x+x==W && y+y==H) cout <<1<<endl;
    else {cout << 0<<endl;}
}

Measured memory_bytes: 256
n, m, L = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
c = [[sum(ak * bk for ak, bk in zip(ai,bj)) for bj in zip(*b)] for ai in a]
for ci in c:
    print(*ci)



Measured memory_bytes: 6992
n = int(input())
a = [int(i) for i in input().split(" ")]

count = 0
for i in range(n):
    minv = a[i]
    mini = i
    for j in range(i+1, n, 1):
        if minv > a[j]:
            minv = a[j]
            mini = j
    if i != mini:
        a[i], a[mini] = a[mini], a[i]
        count += 1
print(" ".join([str(i) for i in a]))
print(count)


Measured memory_bytes: 5608
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
int main(){
	int n,t;
	while(cin>>t>>n,n||t){
		int in[200][200]={0};
		int a,b;
		rep(i,n){
			cin>>a>>b;
			in[a+100][b+100]=-1;
		}
		cin>>a>>b;
		a+=100;b+=100;
		vi x(1,a),y(1,b);
		int dx[]={0,0,1,-1,1,-1};
		int dy[]={-1,1,0,0,1,-1};
		in[a][b]=1;
		while(t--){
			vi tx,ty;
			rep(i,x.size())rep(j,6){
				int xx=x[i]+dx[j],yy=y[i]+dy[j];
				if(!in[xx][yy]){
					in[xx][yy]=1;
					tx.pb(xx);
					ty.pb(yy);
				}
			}
			x=tx;y=ty;
		}
		int co=0;
		rep(i,200)rep(j,200)if(in[i][j]==1)co++;
		cout<<co<<endl;
	}
}

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

using namespace std;
const int N=150000;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL);
	int i,n,A,B,C,a[N],b[N],c[N];
	cin>>n;
	cin>>a[0]>>b[0]>>c[0];
	for(i=1;i<n;++i){
		cin>>A>>B>>C;
		a[i]=max(b[i-1],c[i-1])+A;
		b[i]=max(a[i-1],c[i-1])+B;
		c[i]=max(b[i-1],a[i-1])+C;
		
	}
	cout<<max(a[n-1],max(b[n-1],c[n-1]));
}

Measured memory_bytes: 4760