akhauriyash/Code-Regression huggingface dataset:
#include <iostream>                                             
#include <string>                                               
using namespace std;                                            
                                                                
int main() {                                                    
  int n;                                                        
  cin >> n;                                                     
  string Tcard, Hcard;                                          
  int Tpoint = 0, Hpoint = 0;                                   
  while (n--) {                                                 
    cin >> Tcard >> Hcard;                                      
    if (Tcard>Hcard) {                                          
      Tpoint += 3;                                              
    } else if (Tcard<Hcard) {                                   
      Hpoint += 3;                                              
    } else {                                                    
      Tpoint++;                                                 
      Hpoint++;                                                 
    }                                                           
  }                                                             
  cout << Tpoint << " " << Hpoint << endl;                      
  return 0;                                                     
}                                                               
                                                                
                                                                
                                                                
                                                                
                                   

Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
using namespace std;
long long a,b,c,d,e;
main(){
    cin>>a>>b>>c;
    if((a*b*c)%2==0){
        cout<<0<<endl;
        return 0;
    }
    d=min({a,b,c});
    e=max({a,b,c});
    cout<<d*(a+b+c-d-e)<<endl;
}

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

const ll mod = 1e9+7;

void add(ll& a, ll b) {
    a = (a+b) % mod;
}

int nth_bit(ll num, int n) {
    return (num >> n) & 1;
}

ll num[10][10], dp[101][10];

int main() {
    int H, W, K;
    cin >> H >> W >> K;

    for (int b=0; b<(1<<(W-1)); ++b) {
        bool ok = true;
        for (int i=0; i<W-2; ++i) {
            if (nth_bit(b, i) and nth_bit(b, i+1)) {
                ok = false;
                break;
            }
        }

        if (!ok) continue;

        vector<int> P(W);
        for (int i=0; i<W; ++i) P[i] = i;
        for (int i=0; i<W-1; ++i) {
            if (nth_bit(b, i)) swap(P[i], P[i+1]);
        }
        for (int i=0; i<W; ++i) num[i][P[i]]++;
    }

    dp[0][0] = 1;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            for (int k=0; k<W; ++k) {
                add(dp[i+1][k], dp[i][j] * num[j][k] % mod);
            }
        }
    }

    cout << dp[H][K-1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int x[] = new int[num];
		int y[] = new int[num];
		int h[] = new int[num];
		for(int i = 0; i < num; i ++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}

		int cX = 0;
		int cY = 0;
		int height = -1;
		boolean rightAns = false;
		end: for(cX = 0; cX <= 100; cX ++) {
			for(cY = 0; cY <= 100; cY ++) {
				height = h[0] == 0 ? -1 : h[0] + Math.abs(cX -x[0]) + Math.abs(cY -y[0]);
				rightAns = true;
				for(int i = 0; i < num; i ++) {
					int crtHeight = h[i] == 0 ? -1 : h[i] + Math.abs(cX -x[i]) + Math.abs(cY -y[i]);
					if(height == -1) {
						height = crtHeight;
					}else {
						if(height != crtHeight && crtHeight != -1) {
							rightAns = false;
							break;
						}
					}
				}
				if(rightAns) {
					for(int i = 0; i < num; i ++) {
						if(Math.max(height - Math.abs(cX -x[i]) - Math.abs(cY -y[i]), 0) != h[i]) {
							rightAns = false;
						}
					}
				}
				if(rightAns) {
					break end;
				}
			}
		}
		System.out.println(cX+" "+cY+" "+height);
	}
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
LL a[50], b[50];

bool solve(LL x) {
    forn(i, n) b[i] = a[i] + x;
    forn(i, n) x -= (b[i] + 1) / (n + 1);
    return x >= 0;
}

int main() {
    cin >> n;
    forn(i, n) cin >> a[i];
    LL lo = 0, hi = 1e18, mid;
    while (lo < hi) {
        mid = (lo + hi) >> 1;
        if (solve(mid)) {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }
    lo = max(0ll, lo - 1000);
    while (!solve(lo)) ++lo;
    cout << lo << endl;
    return 0;
}


Measured memory_bytes: 256
#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 n;
  cin >> n;
  int h[n+5];
  for(int i = 0;i<n;++i) cin >> h[i];
  
  int cnt = 0;
  for(int i = 0;i<n;){
    if(h[i]!=0){
      cnt++;
      for(int j = i;j<n;++j){
        if(h[j]!=0){
          h[j]--;
        }else break;
      }
    }
    if(h[i] == 0) ++i;    
  }
  cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    ll minv = min(X,Y),ans = 0;;
    if(A+B >= 2*C){
        ans += 2*C*minv;
    }else{
        ans += (A+B)*minv;
    }
    X -= minv;
    Y -= minv;
    if(A >= 2*C){
        ans += 2*C*X;
    }else{
        ans += A*X;
    }

    if(B >= 2*C){
        ans += 2*C*Y;
    }else{
        ans += B*Y;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

ll h,w,n,res[15];
set<pair<int,int>> s;

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>h>>w>>n;
	for(int i=0;i<n;++i){
		int x,y;
		cin>>x>>y;
		s.insert({x,y});
	}
	for(auto i:s){
		for(int x=max(1,i.fi-2);x<=i.fi;++x)
			for(int y=max(1,i.se-2);y<=i.se;++y){
				if(x+2>h||y+2>w) continue;
				int cnt=1;
				for(int tx=x;tx<=x+2;++tx) for(int ty=y;ty<=y+2;++ty) 
					if((tx!=i.fi||ty!=i.se)&&s.find({tx,ty})!=s.end()){
						++cnt;
					}
				++res[cnt];
			}
	}
	res[0]=(h-2)*(w-2);
	for(int i=1;i<=9;++i) res[i]/=i;
	res[0]-=accumulate(res+1,res+10,0LL);
	for(int i=0;i<=9;++i) cout<<res[i]<<'\n';
}

Measured memory_bytes: 4992
#include<stdio.h>

int main(void){
	int a[4];
	int b[4];
	int i,j,hit,blow;
	
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
		hit = 0;
		blow = 0;
		scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
		for(i=0;i<4;i++){
			if(a[i]==b[i])
			hit++;
			for(j=0;j<4;j++){
				if(i!=j&&a[i]==b[j])
				blow++;
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    cout << a[0]-a[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
A, B = [int(_) for _ in stdin.readline().rstrip().split()]
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
print(len(set(prime_factorize(A)) & set(prime_factorize(B)))+1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+7;
int h[N], dp[N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n,k; cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int i = 0; i < n; i++) dp[i] = 1e9+7;
    dp[0]=0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i+j < n) {
                dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
            }
        }
    }
    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 4392
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353;
#define pai 3.141592653589793238462643383279


  


int main(){
  int h, w, m; cin >> h >> w >> m; set<pair<int, int>>st;
   int tate[h]={}, yoko[w]={};
  rep(i, m){
    int x, y; cin >> x >> y; x--; y--;
    st.insert({x, y}); tate[x]++; yoko[y]++;
  }
  int matate=0, mayoko=0;
  rep(i, h){
    if(tate[i]>matate) matate=tate[i];
  }
  rep(i, w){
    if(yoko[i]>mayoko) mayoko=yoko[i];
  }
  vector<int> chta, chyo;
  rep(i, h){
    if(tate[i]==matate) chta.push_back(i);
  }
  rep(i, w){
    if(yoko[i]==mayoko) chyo.push_back(i);
  }
  bool can = false;
  for(auto i: chta){
    for(auto j: chyo){
      if(st.count({i, j})) continue;
      else{
        can = true; break;
      }
    }
  }
  if(can) cout << matate+mayoko << endl;
  else cout << matate+mayoko-1 << endl;
}
    

Measured memory_bytes: 23740
n,m = map(int,input().split())
s = input()[::-1]

#まず何手でクリアできるかを把握する
count = 1
inf = 10**10

#ゴールまでその地点から何手で到達できるかを記録する
length = [inf]*(n+1)
length[0] = 0
now = 0
flag = True

while flag:
    ok = 0
    for i in range(1,m+1):
        if s[now+i] == "1":
            continue
        length[now+i] = count
        ok = now+i
        if now+i == n:
            flag = False
            break
    if ok == 0:
        print(-1)
        exit()
    now = ok
    count += 1

count -= 2

#スタートからの軌跡を格納するリスト
li = []
length = length[::-1]
point = 0

for i,j in enumerate(length):
    if j == count:
        count -= 1
        li.append(point)
        point = 0
    point += 1

print(*li)

Measured memory_bytes: 10324
def solve(string):
    n, k, s = string.split()
    k = int(k)
    ans = change = 0
    for s0, s1 in zip(s, s[1:]):
        if s0 == s1:
            ans += 1
        else:
            change += 1
    return str(ans + min(2 * k, change))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


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

int main(){
  int n,ans;
  double t,a,h,div=99999.0;
  cin >> n ;
  cin >> t >> a;
  for(int i=0; i<n; i++){
    cin >> h;
    if( abs(t-h*0.006 - a) < div){
      ans = i+1;
      div = abs(t-h*0.006 - a);
    }
  }
  
  cout << ans << endl;
    
  return 0;
}

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

int main(){
    int H, W; cin >> H >> W;
    char s[H][W];
    for(int i = 0; i < H ; i++){
        for(int j = 0; j < W; j++){
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(s[i][j] == '#'){
                int cnt = 0;
                //cout << i << "  "<< j << endl;
                if(i != 0) cnt += s[i-1][j] == '#' ? 1 : 0;
                if(i != H - 1) cnt += s[i+1][j] == '#' ? 1 : 0;
                if(j != 0) cnt += s[i][j-1] == '#' ? 1 : 0;
                if(j != W - 1) cnt += s[i][j+1] == '#' ? 1 : 0;

                if(cnt == 0){
                    cout << "No" <<endl;
                    return 0;
                }
            }
        }
    }
    cout <<"Yes\n";
}

Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


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


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    judge = {"AC":0, "WA" : 0, "TLE" : 0, "RE" : 0}
    for _ in range(N):
        s = input()
        judge[s] += 1
    
    for x, y in judge.items():
        print(x, "x", y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    int n, m;   cin >> n >> m;
    
    vector<vector<ll>> light(m);
    REP(i, m){
        int k;  cin >> k;
        REP(j, k){
            int x;  cin >> x;
            x--;
            light[i].push_back(x);
        }
    }
    vector<ll> p(m);
    REP(i, m)   cin >> p[i];

    ll res=0;
    REP(i, 1<<n){
        vector<bool> sw(n, false);
        REP(bit, n){
            if(i & 1<<bit) sw[bit]=true;
        }
        
        bool flag=true;
        REP(j, m){
            int cnt=0;
            for(auto x: light[j]){
                if(sw[x]) cnt += 1;
            }
            if(cnt%2!=p[j]) flag = false;
            //cout << i << ' ' << cnt << endl;
        }
        if(flag) res += 1;

    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define INF 0x3fffffff
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 505
int ans[N][N];
signed main()
{
	int k=read();
	if(k<=500)
	{
		cout<<k<<endl;
		for(int i=1;i<=k;i++)
		{
			for(int j=1;j<=k;j++) printf("%d ",i);
			cout<<"\n";
		}
	}
	else
	{
		int n=500;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(i+j<=n+1) ans[i][j]=i+j-1;
				else ans[i][j]=i+j-n-1;
			}
		}
		for(int i=1;i<=k-n;i++)
		{
			for(int j=1;j<=n;j+=2)
			{
				if(i+1>j) ans[j][i+1-j]=n+i;
				else ans[j][i+n+1-j]=n+i;
			}
		}
		cout<<n<<endl;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++) printf("%d ",ans[i][j]);
			cout<<"\n";
		}
	}
	return 0;
}



Measured memory_bytes: 2176
#include <stdio.h>

int main(void)

{
 int i, j, minj, n, s;
 int a[100];
 int c = 0;

 scanf("%d", &n);

 for(i = 0; i < n; i++)
 scanf("%d", &a[i]);

 for(i = 0; i < n; i++)
{
 minj = i;

 for(j = i; j < n; j++)
  if(a[minj] > a[j])
    minj = j;

 s = a[i];
 a[i] = a[minj];
 a[minj] = s;
 
 if(i != minj)
  c++;

 }

 for(i = 0; i < n; i++)
  if(i < n-1)
    printf("%d ", a[i]);
  else
    printf("%d", a[i]);

 printf("\n%d\n", c);

 return 0;

}



Measured memory_bytes: 1924
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);

int main() {

	string s;
	cin >> s;

	int N = s.size();
	vector<int>ans(N);

	REP(ri, 2) {//はじめにR、次にLの処理を行う
		int count = 0;
		REP(i, N) {
			//Rについての処理
			if (s[i] == 'R') count++;
			else {
				ans[i] += count / 2;//切り捨て(R後の最初のLの位置)
				ans[i - 1] += (count + 1) / 2;
				count = 0;//0に戻す
			}
		}

		//Lの処理のために逆にする、Lの処理が終わるとまた逆順にし、元に戻る
		reverse(ans.begin(), ans.end());
		reverse(s.begin(), s.end());
		REP(i, N) {
			if (s[i] == 'L') s[i] = 'R';
			else s[i] = 'L';
		}
	}


	REP(i, N) {
		if (i < N - 1) cout << ans[i] << " ";
		else cout << ans[i] << endl;
	}


	return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include<string.h>
using namespace std;

int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u==s)
    cout<<a-1<<" "<<b<<endl;
    else
    cout<<a<<" "<<b-1<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 7;

vector <vector <int>> g;
int h[N];

int ans = 0;

const int Inf = 1e9;

int k;

void dfs(int u, int p) {
    for (auto v : g[u]) {
        dfs(v, u);
        h[u] = max(h[u], h[v] + 1);
    }
    if (p != 0 && h[u] == k - 1) {
        ++ans;
        h[u] = -Inf;
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n >> k;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        --a[i];
    }
    g.resize(n);
    for (int i = 1; i < n; ++i) g[a[i]].push_back(i);
    if (a[0] != 0) {
        ++ans;
    }
    dfs(0, 0);
    cout << ans << '\n';
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
int prime[MAX_N];
bool is_prime[MAX_N + 1];

int sieve(int n)
{
    int p = 0;
    for (int i = 0; i <= n; i++)
    {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i] == true)
        {
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i)
            {
                is_prime[j] = false;
            }
        }
    }
    return p;
}

int dp[MAX_N + 1];
int q;

int main()
{
    sieve(MAX_N);
    for (int i = 1; i < MAX_N + 1; i++)
    {
        if (i % 2 == 0)
        {
            dp[i] = dp[i - 1];
            continue;
        }
        if (is_prime[i] && is_prime[(i + 1) / 2])
            dp[i] = dp[i - 1] + 1;
        else
        {
            dp[i] = dp[i - 1];
        }
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(){
  
   int N, M, X, Y, a, b, i, j;
   int max=-101,min=101;
  
   scanf("%d", &N);
   scanf("%d", &M);
   scanf("%d", &X);
   scanf("%d", &Y);
  
   for(i = 0; i < N; ++i){
     scanf("%d", &a);
       if(max < a){
         max = a;
       }
   }
  
   for (j = 0; j < M; ++j){
     scanf("%d", &b);
       if(min >= b){
         min = b;
       }
   }
  
   if (max>X&&min<=Y&&min>max) {
     printf("No War\n");
   }
  
   else {
     printf("War\n");
   }
  
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    string ans;
    for (int i=0; i<s.size(); i++){
        if (i%2 == 0)ans += s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
n= int(input())
words= [input()]
for _ in range(n-1):
  s = input()
  if words[-1][-1] != s[0]:
    print('No')
    break
  words.append(s)
else:
  if len(set(words)) == n:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 3060
import collections

N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

res = collections.Counter(prime_factorize(N))
keys = list(res.keys())

length = len(keys)
ans = 0
for i in range(length):
    temp = 1
    num = res[keys[i]]
    while(num >= temp):
        ans += 1
        num -= temp
        temp += 1
print(ans)

Measured memory_bytes: 65924
#include<stdio.h>
int main(){
  char a[4];
  char b[4];
  scanf("%s",a);
  scanf("%s",b);
  int count=0;
  for(int i=0;i<3;i++){
    if(a[i]==b[i])
      count++;
  }
  printf("%d",count);
}

Measured memory_bytes: 1732
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <bitset>
#include <map>
#include <queue>
 
using namespace std;

typedef long long ll;

void solve(){
	int n;
	cin >> n;
	string out;
	int d = n % 10;
	if (d == 3){
		out = "bon";
	} else if (d == 0 || d == 1 || d== 6 || d == 8){
		out = "pon";
	} else {
		out = "hon";
	}
	cout << out << endl;
}

int main(){
    int t = 1;
	while (t--){
		solve();
	}
}



Measured memory_bytes: 3600
string = []
while 1:
    s = input()
    if s == "-":
        break
    try:
        n = int(s)
        for i in range(n):
            m = int(input())
            string = string[m:] + string[:m]
        output = "".join(string)
        print(output)
    except ValueError:
        string = list(s)
        continue

Measured memory_bytes: 7716
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// ??? x ??¨??? y ?????????
vector<P> crossp_cc(C x, C y) {
    vector<P> ps;
    P a = x.first, b = y.first;
    double ar = x.second, br = y.second;

    P ab = b-a;
    double d = abs(ab);
    double crL = (norm(ab) + ar * ar - br * br) / (2 * d);
    if(EQ(d,0) || ar < abs(crL)) return ps;

    P abN = ab * P(0, sqrt(ar*ar - crL*crL) / d);
    P cp = a + crL/d * ab;
    ps.push_back(cp + abN);
    if(!EQ(norm(abN), 0)) ps.push_back(cp - abN);
    return ps;
}

int main() {
    C a, b;
    cin >> a.fr.X >> a.fr.Y >> a.sc >> b.fr.X >> b.fr.Y >> b.sc;
    vector<P> ans = crossp_cc(a, b);
    if(ans.size() == 1) {
        printf("%.10f %.10f %.10f %.10f\n", ans[0].X, ans[0].Y, ans[0].X, ans[0].Y);
    }
    else {
        sort(ans.begin(), ans.end());
        printf("%.10f %.10f %.10f %.10f\n", ans[0].X, ans[0].Y, ans[1].X, ans[1].Y);
    }
    return 0;
}

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

using namespace std;

typedef long long	ll;
const int N = 21;
const int M = 1 << N;
vector< int > masks[N + 1];
int adj[N][N];
ll dp[N][M];
const ll mod = ll(1e9) + 7LL;

int sum(int i, int mask){
	if(mask == 0){
		return 1;
	}

	if(i < 0){
		return 0;
	}

	return dp[i][mask];
}

int main(){
	for(int i = 0 ; i < (1 << N) ; i++){
		int b = __builtin_popcount(i);

		masks[b].push_back(i);
	}

	int n;

	scanf("%d", &n);

	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			scanf("%d", &adj[i][j]);
		}
	}

	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			if(adj[i][j]){
				for(int k = 0 ; k < masks[i].size() ; k++){
					int mask = masks[i][k];
					int e = (1 << j);

					if((mask & e) == 0){
						int mask1 = mask | e;
						dp[i][mask1] += sum(i - 1, mask);
						
						if(dp[i][mask1] >= mod){
							dp[i][mask1] -= mod;
						}
					}
				}
			}
		}
	}

	printf("%lld\n", dp[n - 1][(1 << n) - 1]);

	return 0;
}

Measured memory_bytes: 316860
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
int main() {
    int N,T;cin>>N>>T;
    vi A(N),B(N);
    for (int i = 0; i < N; i++){
        cin>>A[i]>>B[i];
    }
    vector<vector<vi>> dp(T,vector<vi>(N,vi(2,0)));
    for (int t = 0; t < T; t++){
        for (int i = 0; i < N; i++){
            //食べる
            if(t+A[i]<T){
                if(i!=0){
                    dp[t+A[i]][i][0]=max(dp[t+A[i]][i][0],dp[t][i-1][0]+B[i]);
                    dp[t+A[i]][i][1]=max(dp[t+A[i]][i][1],dp[t][i-1][1]+B[i]);
                }else if(i==0){
                    dp[t+A[i]][i][0]=max(dp[t+A[i]][i][0],B[i]);
                    dp[t+A[i]][i][1]=max(dp[t+A[i]][i][1],B[i]);
                }
            }
            //食べない
            if(i!=0){
                dp[t][i][0]=max(dp[t][i][0],dp[t][i-1][0]);
                dp[t][i][1]=max(dp[t][i][1],dp[t][i-1][1]);
                //デザート
                dp[t][i][1]=max(dp[t][i][1],dp[t][i-1][0]+B[i]);
            }
            if(t!=0){
                dp[t][i][0]=max(dp[t][i][0],dp[t-1][i][0]);
                dp[t][i][1]=max(dp[t][i][1],dp[t-1][i][1]);
            }
        }
    }
    cout<<dp[T-1][N-1][1]<<endl;
}

Measured memory_bytes: 495752
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {

        try (final Scanner sc = new Scanner(System.in)) {
            final long N = sc.nextLong();
            final long[] nums = new long[5];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = sc.nextLong();
            }
            long min = Long.MAX_VALUE;
            for (int i = 0; i < nums.length; i++) {
                if (nums[i] < min) {
                    min = nums[i];
                }
            }
            long minutes = (N / min) + (N % min > 0 ? 1 : 0) + 4;
            System.out.println(minutes);
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s, t; cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s.size() < t.size()) {
        bool fl = true;
        rep(i, s.size()) if(s[i] != t[i]) fl = false;
        if(fl) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(i, min(s.size(), t.size())) {
        if(s[i] < t[i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < 10){
    if (b < 10) cout << a*b <<endl;
    else cout << -1 << endl;
  }
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <vector>
// #include <bits/stdc++.h>
using namespace std;
// using Parameter = tuple<int, int>;
using Result = tuple<short, short, short>;
using Table = vector<vector<Result>>;

const Result ZERO = make_tuple(0, 0, 0);
const Result FAIL = make_tuple(-1, -1, -1);
const Result UNDEFINED = make_tuple(-2, -2, -2);

int num_solve_called = 0;

void print_result(const Result& result) {
  cout << get<0>(result) << " " << get<1>(result) << " " << get<2>(result)
       << endl;
}

const Result solve(const int N, const int Y, Table& table) {
  // // NOTE: デバッグ
  // cout << "current state: " << N << ", " << Y << endl;

  // cout << "table:" << endl;
  // for (int n = 0; n <= N; n++) {
  //   for (int y = 0; y <= Y; y++) {
  //     cout << "[" << n << ", " << y << "]: ";
  //     print_result(table[n][y]);
  //   }
  // }
  // cout << endl;

  // num_solve_called++;
  // if (num_solve_called % 100000 == 0) cout << num_solve_called << endl;
  // // NOTE: デバッグここまで

  // テーブルにすでに答えが存在するかチェック
  Result cache = table[N][Y];
  if (cache != UNDEFINED) {
    return cache;
  }
  // 残り1枚も使えない場合
  if (N == 0) {
    if (Y == 0) {
      table[N][Y] = ZERO;
      return ZERO;
    } else {
      table[N][Y] = FAIL;
      return FAIL;
    }
  }

  if (Y < 0) {
    return FAIL;
  }

  // 1枚使ってみる
  Result subresult;

  if (Y >= 1) {
    subresult = solve(N - 1, Y - 1, table);
    if (subresult != FAIL) {
      const Result result = make_tuple(get<0>(subresult), get<1>(subresult),
                                       get<2>(subresult) + 1);
      table[N][Y] = result;
      return result;
    }
  }

  if (Y >= 5) {
    subresult = solve(N - 1, Y - 5, table);
    if (subresult != FAIL) {
      const Result result = make_tuple(get<0>(subresult), get<1>(subresult) + 1,
                                       get<2>(subresult));
      table[N][Y] = result;
      return result;
    }
  }

  if (Y >= 10) {
    subresult = solve(N - 1, Y - 10, table);
    if (subresult != FAIL) {
      const Result result = make_tuple(get<0>(subresult) + 1, get<1>(subresult),
                                       get<2>(subresult));
      table[N][Y] = result;
      return result;
    }
  }

  table[N][Y] = FAIL;
  return FAIL;
}

int main(int argc, char const* argv[]) {
  int N, Y;
  cin >> N >> Y;
  Y /= 1000;

  Table table(N + 1, vector<Result>(Y + 1, UNDEFINED));
  table[0][0] = ZERO;

  const Result result = solve(N, Y, table);
  print_result(result);

  return 0;
}


Measured memory_bytes: 235136
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

int q, a, b, c, d, co, m[2][100005];
string s[2];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s[0] >> s[1] >> q;
  FOR(i, 0, 2){
    co = 0;
    FOR(j, 0, s[i].size()){
      co += s[i][j] - '@';
      m[i][j + 1] = co;
    }
  }
  FOR(i, 0, q){
    cin >> a >> b >> c >> d;
    cout << ((m[0][b] - m[0][a - 1] - m[1][d] + m[1][c - 1]) % 3 == 0 ? "YES" : "NO") << endl;
  }
}


Measured memory_bytes: 1744
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main(void) {
    io;
    ll n, k; cin >> n >> k;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    rep(i,k){
        v.pop_back();
    }
    int rem = v.size();
    ll ans = 0;
    rep(i,rem) {
        ans += v[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4764
using System;
class Example
{
    static void Main()
    {
        while (true)
        {
            string s = Console.ReadLine();
            if (string.IsNullOrEmpty(s)) break;
                int num = int.Parse(s);
            int counter = 0;
            for (int a = 0; a <= 9; a++)
            {
                for (int b = 0; b <= 9; b++)
                {
                    for (int c = 0; c <= 9; c++)
                    {
                        for (int d = 0; d <= 9; d++)
                        {
                            if (a + b + c + d == num)
                                counter++;
                        }
                    }
                }
            }
            Console.WriteLine(counter);
        }
    }
}

Measured memory_bytes: 9028
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int> a(5);
	int tmp,min=1000,sum=0,tmp2;
	for(int i=0;i<5;i++){
		cin>>tmp;
		if(tmp%10==0){
			sum+=tmp;
		}else{
			sum+=tmp-tmp%10+10;
		}
		if(tmp%10==0)tmp2=10;
		else tmp2=tmp%10;
		min=(min<tmp2)?min:tmp2;
	}
	cout<<sum-10+min<<endl;
	return 0;
}

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

int MOD = 1000000007;

long dp[110][10];

long F[10];

int main() {
  F[0] = F[1] = 1;
  for (int i = 2; i < 10; i++) F[i] = F[i-1] + F[i-2];
  int H, W, K; cin >> H >> W >> K; K--;
  for (int i = 0; i < W; i++) dp[0][i] = 0;
  dp[0][0] = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) dp[i+1][j] = 0;
    for (int j = 0; j < W; j++) {
      dp[i+1][j] += dp[i][j] * F[j] * F[W-1-j];
      if (j > 0) dp[i+1][j-1] += dp[i][j] * F[j-1] * F[W-1-j];
      if (j < W-1) dp[i+1][j+1] += dp[i][j] * F[j] * F[W-1-(j+1)];
    }
    for (int j = 0; j < W; j++) dp[i+1][j] %= MOD;
  }
  cout<<dp[H][K] <<endl;
}

Measured memory_bytes: 3636
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = IN()
	#s = input()
	r=0
	for i in range(1,n+1):
		if i % 3 == 0 or i % 5 == 0:
			continue
		r+=i
	print(r)
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 67280
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> f(n);
  rep(i, n){
    f.at(i) = 0;
    rep(j, 10){
      int in;
      cin >> in;
      f.at(i) *= 2;
      f.at(i) += in;
    }
  }
  vector<vector<int>> p(n, vector<int>(11));
  rep(i, n){
    rep(j, 11){
      int in;
      cin >> in;
      p.at(i).at(j) = in;
    }
  }

  int ans = -2e9;
  rep2(bit, 1, 1 << 10){
    int add = 0;
    rep(i, n){
      int c = __builtin_popcount(bit & f.at(i));
      add += p.at(i).at(c);
    }
    ans = max(ans, add);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int x, k; cin >> x >> k;
  V<> r(k + 2); for (int i = 0; i < k; i++) cin >> r[i + 1]; r[k + 1] = 2e9;
  V<> l(k + 2), u(k + 2), la(k + 2), ua(k + 2);
  u[0] = ua[0] = x;
  for (int i = 1; i < k + 2; i++) {
    la[i] = la[i - 1], ua[i] = ua[i - 1];
    if (i & 1) {
      u[i] = max(u[i - 1] - (r[i] - r[i - 1]), 0);
      l[i] = max(l[i - 1] - (r[i] - r[i - 1]), 0);
      if (r[i] - r[i - 1] > l[i - 1]) la[i] = min(la[i] + r[i] - r[i - 1] - l[i - 1], x);
    } else {
      u[i] = min(u[i - 1] + r[i] - r[i - 1], x);
      l[i] = min(l[i - 1] + r[i] - r[i - 1], x);
      if (r[i] - r[i - 1] > x - u[i - 1]) ua[i] = max(ua[i] - (r[i] - r[i - 1] - (x - u[i - 1])), 0);
    }
  }
  int q; cin >> q;
  int p = 0;
  for (int iq = 0; iq < q; iq++) {
    int t, a; cin >> t >> a;
    while (r[p + 1] <= t) p++;
    int res;
    if (a <= la[p]) res = l[p];
    else if (a >= ua[p]) res = u[p];
    else if (p & 1) res = l[p] + a - la[p];
    else res = u[p] - (ua[p] - a);
    cout << min(max(res + (p & 1 ? t - r[p] : r[p] - t), 0), x) << '\n';
  }
}

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int i##_to_ = (t), i = (f); i <= i##_to_; i++)
#define uptil(f, t, i)   for(int i##_to_ = (t), i = (f); i <  i##_to_; i++)
#define downto(f, t, i)  for(int i##_to_ = (t), i = (f); i >= i##_to_; i--)
#define downtil(f, t, i) for(int i##_to_ = (t), i = (f); i >  i##_to_; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '



signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N; scanf("%d", &N);
    N += 2;
    vector<long> A(N);
    A[0] = 1; A[N-1] = 1;
    times(N, i) {
        scanf("%lld", &A[i+1]);
    }

    long va, ia, vb, ib;
    {
        int i = 0; while((1 << i) < A[0]) ++i;
        bool k = (1<<i) != A[0];
        va = k; ia = i;
        vb = k; ib = i - k;
        if(debug) cout << ia << ": " << va << ", " << ib << ": " << vb ln;
    }
    uptil(1, N, j) {
        int i = 0; while((1 << i) < A[j]) ++i;
        bool k = (1<<i) != A[j];
        int va0 = va, ia0 = ia, ib0 = ib;
        ia = i;
        ib = i - k;
        va = min(va0 + abs(ia0 - ib) + k, vb + abs(ib0 - ib) + k);
        vb = min(va0 + abs(ia0 - ia) + k, vb + abs(ib0 - ia) + k);
        if(debug) cout << ia << ": " << va << ", " << ib << ": " << vb ln;
    }
    cout << min(va, vb) / 2 ln;

    return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = vec![];
    for i in 0..n {
        a.push(read::<i64>());
    }
    if a.iter().any(|&x| x % 2 == 1) {
        println!("first");
    } else {
        println!("second");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

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

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll N;
    cin >> N;
    set<ll> A;
    rep(i,N)
    {
        ll tmp;
        cin >> tmp;
        A.insert(tmp);
    }
    if( N == A.size() ) cout << "YES" << endl;
    else cout << "NO" << endl;


}


Measured memory_bytes: 9600
n = int(input())
p = [int(input()) for _ in range(n)]

q = [0] * n
for i in range(n):
    q[p[i]-1] = i
mxk = 1
k = 1
for i in range(n-1):
    if q[i] < q[i+1]:
        k += 1
        if k > mxk:
            mxk = k
    else:
        k = 1
print(n-mxk)


Measured memory_bytes: 18924
#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define all(v) v.begin(),v.end()
#define pb push_back
#define INF 1e9
using namespace std;

int abs(int num){
	return (num>=0)?num:-num;
}

int main(){
	int n,in,k;
	cin>>n>>k;
	vector<int> h;
	rep(i,n){
		cin>>in;
		h.pb(in);
	} 
	int dp[n];
	fill(dp,dp+n,INF);
	dp[0]=0;
	rep(i,n){
		loop(j,1,min(k+1,n-i))dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1144
def func(n):
    return 3*n + 1 if n % 2 != 0 else n//2 

s = int(input())
inf = 1000000
l = []
l.append(s)
for i in range(1, inf+1):
    ai = func(l[i-1])
    if ai in l:
        print(i+1)
        break
    else:
        l.append(ai)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
// #define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
const int INF = 1e9 + 1;

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{	
	ll a, b, k;
	cin >> a >> b >> k;
	ll c = min(a, k);
	a -= c;
	k -= c;
	b -= min(k, b);
	cout << a << " " << b;
}
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String atg[])
	{		
		Scanner sc = new Scanner(System.in);
		String s[] = new String[2002];
		int index = 0;
		while(sc.hasNext())
		{
			String str = sc.next();
			s[index] = str;
			index++;
		}
		int r[] = new int [index];
		for(int i=0; i<index; i++)
		{
			for(int j=i+1; j<index; j++)
			{
				if(s[i].equals(s[j]))
					r[i]++;
			}
		}
		int max=0;
		int maxin=0;
		for(int i=0; i<index; i++)
		{
			if(max < r[i])
			{
				max=r[i];
				maxin = i;
			}
		}
		System.out.print(s[maxin]+" ");
		max =0;
		for(int i=0; i<index; i++)
			if(s[max].length()<s[i].length())
				max =i;
		System.out.println(s[max]);
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<stdlib.h>

long long cnt;
int l,A[1000000],n,Gsize;
int * G;

void insertionSort(int A[], int n, int g){
  int i,j,v;
  for(i=g;i<=n-1;i++) {
    v=A[i];
    j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[], int n) {
  int i=0,j,h;
  for(h=1;;) {
    if(h>n) break;
    G[i++]=h;
     h=h*3+1;
  }
  Gsize=i;
  for(i=Gsize-1;i>=0;i--) {
    insertionSort(A,n,G[i]);
  }
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  G=(int *)malloc(sizeof(int)*n);
  cnt = 0;
  shellSort(A,n);
  printf("%d\n",Gsize);
  for(i=Gsize-1;i>=0;i--) {
    printf("%d",G[i]);
    if(i){
      printf(" ");
    }
  }
  printf("\n" );
  printf("%lld\n", cnt);
  for (i=0;i<n;i++){
    printf("%d\n",A[i]);
  }
  return 0;
}



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

int n, W, v[104], w[104];
map<pair<int,int>,long long> dp;

long long maxValue(int item, int weight){
	if(item == n)	return 0;
	pair<int,int> state = {item,weight};
	if(dp.count(state))
		return	dp[state];
	dp[state] = 0;
	long long& ret = dp[state];
	for(int i = item+1;i<=n;i++){
		if(weight>=w[i])
			ret = max(ret,maxValue(i,weight-w[i])+v[i]);
	}
	return ret;
}

int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n>>W;
	for(int i = 1; i<= n;i++)	cin>>w[i]>>v[i];
	cout<<maxValue(0,W);
	
	
	
	return 0;
}


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

using ll = long long;

const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K, X;
    cin >> K >> X;
    if (K * 500 >= X)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int x,y;
    cin>>y>>x;
    string t,s;
    cin>>s>>t;
    int l=1,r=w,u=1,d=h;
    
    bool ok=true;
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());

    for(int i=0;i<n;i++){
        if(i){
            if(t[i]=='L') r=min(w,r+1);
            else if(t[i]=='R') l=max(1,l-1);
            else if(t[i]=='U') d=min(d+1,h);
            else if(t[i]=='D') u=max(1,u-1);
        }

        if(s[i]=='L') l++;
        else if(s[i]=='R') r--;
        else if(s[i]=='U') u++;
        else d--;
        if(l>r || u>d) ok=false;

        //cerr<<l<<" "<<r<<" "<<u<<" "<<d<<endl;

    }

    if(x<l || x>r || y<u || y>d) ok=false;
    if(ok){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;

}

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

int main() {
  int a = 0;
  vector<int> vec(3);
  for (int i = 0; i < 3; i++) {
    cin >> vec.at(i);
    a+=vec.at(i);
  }
  sort(vec.begin(), vec.end());
  cout << a-vec.at(2) << endl;
}

Measured memory_bytes: 256