akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define endl "\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1n(i, n) for (int i = 1; i < (int)(n); ++i)
#define forln(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define forl1n(i, n) for (long long i = 1; i < (long long)(n); ++i)


const ll maxLONG = 9223372036854775807;
const int maxINT = 2147483647;
const ll mod = 1000000007;
const ld EPS = 1e-9;
const int N = 1000000;
const ll INF = LONG_LONG_MAX;

ll GetMod(ll n, ll z) { // func to get mod for positive num and negitive nums
    return (n % z + z) % z;
}

//          U   R  D  L
int dx[] = {-1, 0, 1, 0, -1, +1, +1, -1}; // dx for the 8 adjacent places in matrix
int dy[] = {0, 1, 0, -1, +1, +1, -1, -1};// dy for the 8 adjacent places in matrix
int dp[3001][3001];

int main() {

    ios_base::sync_with_stdio(false), cin.tie(NULL);
    string s1, s2;
    cin >> s1 >> s2;


    for (int i = 0; i < s1.size(); i++) {
        for (int j = 0; j < s2.size(); j++) {
            if (s1[i] == s2[j]) {
                int a = i - 1;
                int b = j - 1;
                if (a < 0 || b < 0) {
                    dp[i][j] += 1;
                } else {
                    dp[i][j] = dp[i - 1][j - 1] + 1;

                }

            } else {
                int a = j - 1;
                int b = i - 1;
                if (a < 0 && b < 0) {
                    dp[i][j] = 0;
                } else if (a < 0 && b >= 0) {
                    dp[i][j] = dp[i - 1][j];
                } else if (a >= 0 && b < 0) {
                    dp[i][j] = dp[i][j - 1];

                } else {
                    dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);

                }
            }

        }
    }
    string res;
    for (int i = s1.size() - 1, j = s2.size() - 1; i >= 0 && j >= 0;) {
        if (s1[i] == s2[j]) {
            res += s1[i];
            i -= 1;
            j -= 1;
        } else {
            int a = j - 1;
            int b = i - 1;
            if (a < 0 && b < 0) {
                break;
            } else if (a < 0 && b >= 0) {
                i--;
            } else if (a >= 0 && b < 0) {
                j--;
            } else {
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    i--;
                } else {
                    j--;

                }


            }


        }

    }

   for(int i =res.size()-1;i>=0;i--){
       cout<<res[i];
   }
}

Measured memory_bytes: 35456
#include <stdio.h>
#define N 3

int get_max_index(int n[]);

int main(void) {
    int num[N], k, result = 0;
    for(int i=0; i<N; i++) scanf("%d", &num[i]);
    scanf("%d", &k);
    
    int m = get_max_index(num);
    
    for(int i=0; i<k; i++) {
        num[m] = num[m] * 2;
    }
    
    for(int i=0; i<N; i++) {
        result += num[i];
    }
    
    printf("%d\n", result);
    
    return 0;
}

int get_max_index(int n[]) {
    int m = 0, mi = 0;
    for(int i=0; i<N; i++) {
        if(n[i] > m) {
            m = n[i];
            mi = i;
        }
    }
    return mi;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
int main(){
  int H;
  int W;
  int N;
  int* sq;
  int i;
  int j;
  int odd;
  int putNum;
  int putNumMax;
  int printNum;
  
  scanf("%d %d\n", &H, &W);
  scanf("%d\n", &N);
  
  odd = 1;
  putNum = 0;
  printNum = 1;
  scanf("%d", &putNumMax);
  sq = (int *)malloc(sizeof(int) * W);
  for(i = 0; i < H; i++){
    if(odd % 2 == 1){
      for(j = 0; j < W; j++){
        if(putNum >= putNumMax){
          putNum = 0;
          printNum++;
          scanf("%d", &putNumMax);
        }
        sq[j] = printNum;
        putNum++;
      }
      odd++;
    }else{
      for(j = W - 1; j >= 0; j--){
        if(putNum >= putNumMax){
          putNum = 0;
          printNum++;
          scanf("%d", &putNumMax);
        }
        sq[j] = printNum;
        putNum++;
      }
      odd++;
    }
    for(j = 0; j < W; j++){
      printf("%d ", sq[j]);
    }
    printf("\n");
  }
  
  return 0;
}




Measured memory_bytes: 256
N,A,B = gets.split.map(&:to_i)
ans = 0
rep = 1
if N < (A + B)
  if N < A
    ans = N
  else
    ans = A
  end
else
  rep = N / (A + B)
  mod = N % (A + B)
  ans = rep * A
  if A < mod
    ans += A
  else
    ans += mod
  end
end
puts ans


Measured memory_bytes: 1788
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    cout << "Christmas";
    rep(i,25-n){
        cout << " Eve";
    }

    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(){
    string S;
    cin >> S;
    
    for(int kk=0; kk<(1<<4);kk++){
        string ans;
        ans += S[0];
        int sum = S[0] - '0';
        for(int i=1; i<4;i++){
            if((kk>>i)&1){
                ans += "+";
                sum += S[i] - '0';
            }else{
                ans += "-";
                sum -= S[i] - '0';
            }
            ans += S[i];
        }
        if(sum == 7){
            cout << ans << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 384
h,n=map(int,input().split())
ab=[]
p=0
for i in range(n):
	a,b=map(int,input().split())
	p=max(p,a)
	ab.append([a,b])
dp=[[10**9]*(p+1+h) for _ in range(n+1)]
for i in range(n+1):
	dp[i][0]=0

for i in range(n):
	for j in range(p+h):
		if j+1-ab[i][0]>=0:
			dp[i+1][j+1]=min(dp[i][j+1],dp[i+1][j+1-ab[i][0]]+ab[i][1])
		else:
			dp[i+1][j+1]=dp[i][j+1]
ans=10**10
for i in range(h,h+p):
	ans=min(dp[n][i],ans)
print(ans)

Measured memory_bytes: 126960
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll x,n;cin >> x >> n;
    vl v(n);
    rep(i,n)cin >> v[i];
    sort(all(v));
    ll t=x;
    while(1){
        if(!binary_search(all(v),x)){
            cout << x <<endl;
            return 0;
        }
        x--;
        if(!binary_search(all(v),t)){
            cout << t <<endl;
            return 0;
        }
        t++;
    }
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const int MOD = 1e9 + 7;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll dp[101][4][4];

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    profile("all");

    auto solve = [](int _) {
        int n;
        cin >> n;
        vector<int> a(n + 1);
        map<int, int> xx;
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
            xx[a[i] - 1]++;
            xx[a[i] + 1]++;
            xx[a[i]]++;
        }
        int mx = 0;
        for (auto it:xx) {
            mx = max(mx, it.second);
        }
        cout << mx;
    };


    fast_io();
    cout.precision(9);
    cout << fixed;

    solve(1);


}


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

using namespace std;
long long knapSack(long long W, long long wt[], long long val[], int n)
{
   long long i, w;
   long long K[n+1][W+1];

   // Build table K[][] in bottom up manner
   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }

   return K[n][W];
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    long long w;
    cin>>w;
    long long wt[n],val[n];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    cout<<knapSack(w,wt,val,n);
}


Measured memory_bytes: 79232
n = int(input())
ans = []
for i in range(1,99):
    if n>26**i:
        n-=26**i
    else:
        n-=1
        for j in range(i):
            ans.append(chr(ord('a')+n%26))
            n//=26
        break
print(*ans[::-1],sep="")
            

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{  
  int N,M;
  cin>>M>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  vector<int> DIST(N,0);
  sort(ALL(vec));
  
  for (int i = 0; i < N-1; i++)
  {
    DIST[i+1] = vec[i+1] - vec[i];
  }
  sort(ALL(DIST),greater<int>());
  int ANS = 0;
  for (int i = M-1; i < N; i++)
  {
    ANS += DIST[i];
  }
  cout<<ANS<<endl;
  
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

int main () {
  vector<int> a(3);
  rep(i, 3) cin >> a.at(i);
  sort(a.begin(), a.end());
  rep(i, 3) {
    cout << a.at(i);
    if (!(i == 2)) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3128
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 21:16:04 2020

@author: Kei
"""

import math

A,B,H,M = map(int,input().split())


theta_s = H*30 + M*0.5
theta_l = M*6


theta = abs(theta_s-theta_l)

if theta > 180:
    theta = 360 - theta

#print(theta)
C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta)))

print(C)

Measured memory_bytes: 9392
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int T;
	scanf("%d", &T);
	for(int ii = 0; ii < T; ++ ii) {
		char S[1001];
		scanf("%s", S);
		vector<int> stk, tmp;
		int lastResult = -1;
		auto check = [&](int L, int U) -> bool {
			tmp = stk;
			while(!tmp.empty()) {
				if(tmp.end()[-1] < 0) {
					if(tmp.end()[-1] == -1)
						amax(U, 99);
					else
						amin(L, 0);
					tmp.pop_back();
				} else if(tmp.end()[-2] < 0) {
					if(tmp.end()[-2] == -1) {
						amax(L, tmp.back());
						amax(U, tmp.back());
					} else {
						amin(L, tmp.back());
						amin(U, tmp.back());
					}
					tmp.pop_back();
					tmp.pop_back();
				} else {
					assert(false);
				}
			}
			assert(L <= U);
			lastResult = L;
			return L == U;
		};
		const char *p;
		for(p = S; *p != '?'; ) {
			if(*p == '^' || *p == '_') {
				stk.push_back(*p == '^' ? -1 : -2);
				p += 2;
			} else {
				assert(isdigit(*p));
				int d1 = *p - '0';
				++ p;
				if(check(d1, d1 == 0 ? d1 : d1 * 10 + 9))
					break;
				int d;
				bool flag = false;
				if(isdigit(*p)) {
					d = d1 * 10 + (*p - '0');
				} else {
					flag = true;
					d = d1;
				}
				++ p;
				if(check(d, d))
					break;
				if(flag) -- p;
				stk.push_back(d);
				while(*p == ')') {
					assert(stk.size() >= 3);
					++ p;
					assert(stk.end()[-3] < 0);
					int val;
					if(stk.end()[-3] == -1)
						val = max(stk.end()[-1], stk.end()[-2]);
					else
						val = min(stk.end()[-1], stk.end()[-2]);
					stk.pop_back();
					stk.pop_back();
					stk.pop_back();
					stk.push_back(val);
				}
				if(*p == ',')
					++ p;
			}
		}
		printf("%d %d\n", lastResult, (int)(p - S));
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll x, n;
    cin >> x >> n;
    vll p(n);
    for(ll i = 0; i < n; i++) cin >> p[i];
    sort(p.begin(), p.end());
    ll diff = INFL;
    ll ans = -INFL;
    for(ll i = -100; i <= 300; i++) {
        if(binary_search(p.begin(), p.end(), i)) continue;
        if(diff > abs(x - i)) {
            diff = abs(x - i);
            ans = i;
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

class UFT{
private:
    vector<int> par;
    vector<int> siz;
public:
    UFT(int n) : par(vector<int>(n)), siz(vector<int>(n, 1)){ For(i, n) par[i] = i; };
    bool same(int x, int y){ return find(x) == find(y); };
    void unite(int x, int y){ if(!same(x = find(x), y = find(y))){ par[x] = y; siz[y] += siz[x]; } };
    int find(int x){ return (par[x] == x) ? x : (par[x] = find(par[x])); };
    int size(int x){ return siz[find(x)]; };
    void print() const{ Couts(par); };
};

#include <map>

int main(void){
    Cin(int, n, k, l);
    UFT uk(n), ul(n);
    Rep(k){
        Cin(int, p, q);
        uk.unite(p-1, q-1);
    }
    Rep(l){
        Cin(int, p, q);
        ul.unite(p-1, q-1);
    }
    vector<pair<int, int>> a(n);
    map<pair<int, int>, int> m;
    For(i, n){
        a[i].first = uk.find(i);
        a[i].second = ul.find(i);
        m[a[i]] ++;
    }
    For(i, n){
        cout << m[a[i]] << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 16640
# coding: utf-8
from fractions import gcd
def lcm(a, b):
    return a*b//gcd(a, b)
N = int(input())
A = list(map(int, input().split()))
m = A[0]
for i in range(1, N):
    m = lcm(m, A[i])
ans = 0
m -= 1
for i in range(N):
    ans += m % A[i]
print(ans)

Measured memory_bytes: 5344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace practice001
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            string three = input.Substring(2,1);
            string four = input.Substring(3,1);
            string five = input.Substring(4,1);
            string six = input.Substring(5,1);

            if (three.Equals(four))
            {
                if (five.Equals(six))
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

struct work
{
    int s;
    int t;
    int x;
    bool operator<(const work &another) const
    {
        return x < another.x;
    }
    bool operator>(const work &another) const
    {
        return x > another.x;
    }
};

int main()
{
    int n, q;
    map<int, int> ans;
    set<int> st;
    cin >> n >> q;
    vector<work> w(n);

    REP(i, n)
    {
        cin >> w[i].s >> w[i].t >> w[i].x;
    }

    REP(i, q)
    {
        int d;
        cin >> d;
        st.insert(d);
        ans[d] = -1;
    }
    sort(w.begin(), w.end());
    REP(i, n)
    {
        int l = w[i].s - w[i].x;
        int r = w[i].t - w[i].x;
        auto it = st.lower_bound(l);
        auto end = st.lower_bound(r);
        while (it != end)
        {
            ans[*it] = w[i].x;
            st.erase(it++);
        }
    }
    for (auto it : ans)
    {
        cout << it.second << endl;
    }
}

Measured memory_bytes: 23040
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    n = ri()
    print((n + 1) // 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13180
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ve vector
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())
//using namespace __gnu_pbds;
using namespace std;

// // // functions: find_by_order  & order_of_key
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int inf=(int)2e9;
const long long md=1000000007; //1E9+7
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

ll powmod(ll a,ll p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=md;a%=md;
	}
	return ans;
}
ll mdinv(ll a){return powmod(a,md-2); }

const int N=1e5+10;
ve<signed> adj[N],ch[N];
vi pr[N],sf[N];
int d[N],up[N],com[N];
int n,m;

void dfs1(int i,int p){
	int h=1;
	for(int v:adj[i]){
		if(v!=p){
			dfs1(v,i);
			h*=(d[v]+1);
			h%=m;
			ch[i].pb(v);
			pr[i].pb((d[v]+1));
		}
	}
	sf[i]=pr[i];
	for(int x=1;x<pr[i].size();x++)
		pr[i][x]=(pr[i][x]*pr[i][x-1])%m;
	for(int x=sf[i].size()-2;x>=0;x--)
		sf[i][x]=(sf[i][x]*sf[i][x+1])%m;
	d[i]=h;
	// cout<<i<<" "<<d[i]<<endl;
}

void dfs2(int i,int p,int ind){
	if(p==0) {
		up[i]=0;com[i]=d[i];
		for(int x=0;x<ch[i].size();x++)
			dfs2(ch[i][x],i,x);
		return;
	}
	int here=up[p]+1;
	if(ind)
		here*=pr[p][ind-1];
	here%=m;
	if(ind+1<sf[p].size())
		here*=sf[p][ind+1];
	here%=m;
	up[i]=here;
	// cout<<"d "<<i<<" "<<ind<<endl;
	// cout<<"u "<<i<<" "<<up[i]<<endl;
	com[i]=d[i]*(up[i]+1);
	com[i]%=m;
	for(int x=0;x<ch[i].size();x++)
		dfs2(ch[i][x],i,x);
}

signed main(){
	IOS
	cin>>n>>m;
	forn(i,n-1){
		int a,b;cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	up[0]=1;
	dfs1(1,0);
	dfs2(1,0,0);
	for(int i=1;i<=n;i++)
		cout<<com[i]<<"\n";
}



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

int main(){

  int N;
  cin >> N;
  int A[N];
  int result[N];
  for(int i = 0; i < N; ++i){
  	cin >> A[i];
  }
  
  for(int i = 0; i < N; ++i){
    result[A[i] - 1] = i + 1;
  }
  
  for(int i = 0; i < N; ++i){
    cout << result[i] << " ";
  }
  
  cout << endl;
  
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	int N, M;
	cin >> N >> M;

	vector<pair<ll,ll>> drink;//値段・本数
	for (int i = 0; i < N; i++) {
		ll temp1, temp2;
		cin >> temp1 >> temp2;
		drink.emplace_back(temp1, temp2);
	}

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

	int kazu = 0;
	ll kane = 0;
	for (int i = 0; i < N; i++) {
		if (kazu + drink[i].second <= M) {
			kazu += drink[i].second;
			kane += drink[i].first * drink[i].second;
		}
		else {
			kane += drink[i].first * (M - kazu);
			break;
		}
	}

	cout << kane;

}





Measured memory_bytes: 2420
#include <stdio.h>

int check[101];

int main() {

	int a, b, c;
	scanf("%d %d %d",&a,&b,&c);

	check[a]++;
	check[b]++;
	check[c]++;

	int i;

	int ans = 0;

	for (i = 1; i <= 100; i++) {
		if (check[i] > 0) { ans++; }
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
A=sorted(list(map(int,input().split())))
c=A[2]-(A[0]+(A[2]-A[1]))%2
t=2 if c==1 or c%2==1 else 0
print(int((A[2]-A[1]+(A[2]-(A[0]+A[2]-A[1]))/2)+t))

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
 
int main(int argc, const char * argv[]) {
     
    int i,j,n,s,xy[2][100]={0};
     
    scanf("%d",&n);
     
    for(i = 0; i < 2; i++) {
        for(j = 0; j < n ; j++){
            scanf("%d",&xy[i][j]);
        }
    }
     
    //p1
    double p1 = 0;
    for(i = 0 ; i < n ; i++) {
        p1 +=  abs((double)(xy[0][i] - xy[1][i]));
    }
    printf("%f\n",p1);
     
    //p2
    double p2 = 0;
    for(i = 0; i < n; i++){
        p2 += pow(abs((double)(xy[0][i] - xy[1][i])),2);
    }
     
    p2 = sqrt(p2);
    printf("%f\n",p2);
     
    //p3
    double p3 = 0;
    for(i = 0; i < n; i++){
        p3 += pow(abs((double)(xy[0][i] - xy[1][i])),3);
    }
     
    p3 = cbrt(p3);
    printf("%f\n",p3);
 
     
    //pinf
    double pinf = -1;
    for(i = 0; i < n; i++) {
        if(abs(xy[0][i] - xy[1][i]) > pinf) {
            pinf = abs(xy[0][i] - xy[1][i]);
        }
    }
    printf("%f\n",pinf);
     
    return 0;
     
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vp a(n);
	rep(i,n){
		int b; cin >> b;
		a[i] = P(b,i);
	}
	SORT(a); REV(a);
	int mx = a[0].fi;
	int mxi = a[0].se;	
	int mx2 = a[1].fi;	
	rep(i,n){
		if(i==mxi) cout << mx2 << endl;
		else cout << mx << endl;
	}
}




Measured memory_bytes: 3200
#! /usr/bin/python3

# ABC119 B


if __name__ == "__main__":
    N = int(input())
    total = 0
    for i in range(N):
        x,y = input().split()
        if y == "BTC":
            total += float(x) * 380000
        else:
            total += float(x)
    print(total)


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<pair<int, string>> v(n);
  for(int i=0;i<n;++i) {
    cin >> v[i].second >> v[i].first;
  }
  sort(v.begin(), v.end());

  int m; cin >> m;
  vector<string> order(m);
  for(int i=0;i<m;++i) {
    cin >> order[i];
  }

  int pos = 0;
  for(int i=0;i<n;++i) {
    if(v[i].second == order[pos]) {
      int now = v[i].first;
      pos++;
      while(i < n-1 && v[i+1].first == now) {
        i++;
      }
    }

    if(pos == m) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

}



Measured memory_bytes: 20756
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val csf = (1..n - 1).map { readLine()!!.split(" ").map { it.toLong() } }
    for(i in 0..n-2){
        var time = 0L
        for(j in i..n-2){
            val (c, s, f) = csf[j]
            val nextF = if(time%f==0L) time else time+f-time%f
            time = Math.max(s, nextF ) + c
        }
        println(time)
    }
    println(0)
}

Measured memory_bytes: 37776
#include<bits/stdc++.h>
#define N 2005
#define LL long long
using namespace std;
const int mo=1e9+7;
int n,k,w[N],lw,f[N],ans;
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
int main()
{
	int i,j;
	cin>>n>>k;
	for(i=1;i*i<=n;i++)
		if(n%i==0){
			w[++lw]=i;
			if(i*i!=n) w[++lw]=n/i;
		  }
	sort(w+1,w+lw+1);
	for(i=1;i<=lw;i++){
		f[i]=fpm(k,(w[i]+1)/2);
		for(j=1;j<i;j++)
			if(w[i]%w[j]==0)
				f[i]=(f[i]-f[j]+mo)%mo;
		if(w[i]%2==0)
			ans=(ans+1LL*f[i]*(w[i]/2))%mo;
		else
			ans=(ans+1LL*f[i]*w[i])%mo;
	  }
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
n,m = gets.chomp.split(' ').map(&:to_i)
arys = []
m.times do
  arys << gets.chomp.split(' ').map(&:to_i)
end

arys = arys.uniq
hoge = arys.flatten.each_slice(2).map(&:first)

arys.each do |ary|
  if hoge.count(ary[0]) > 1
    puts -1
    exit
  end
end

strs = '~' * n
arys.each do |ary|
  hoge = strs[ary[0]-1]
  if hoge == '~'
    strs[ary[0]-1] = ary[1].to_s
    next
  end
  if hoge.to_i > ary[1]
    strs[ary[0]-1] = ary[1].to_s
  end
end

strs[0] = '1' if strs[0].to_s == '~' &&  strs.size > 1

val = strs.gsub(/~/, '0').to_i
if val.to_s.size == n
  puts val.to_i
else
  puts -1
end


Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    ll x = 0, y = 0;
    int N;
    cin >> N;
    map<ll, int>cnt;
    for(int i = 0; i < N; i++){
        ll a;
        cin >> a;
        cnt[a]++;
        if(x < y)swap(x, y);
        if(cnt[a]>=2 && y < a){
            cnt[a] -= 2;
            y = a;
        }
    }
    cout << x * y << endl;

    return 0;
}

Measured memory_bytes: 6528
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		sc.close();
		int ans = (X/500)*1000+(X%500)/5*5;
		System.out.println(ans);

	}
}


Measured memory_bytes: 21716
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
using namespace std;

string s, t;
int sn, tn;
int dp[3002][3002];
int preTI[3002][3002];
int preSI[3002][3002];

int main() {
  while (cin >> s >> t) {
    sn = s.size();
    tn = t.size();
    for (int si = 0; si <= sn; si++) {
      for (int ti = 0; ti <= tn; ti++) {
        dp[si][ti] = -1;
        preTI[si][ti] = -1;
        preSI[si][ti] = -1;
      }
    }
    dp[0][0] = 0;

    for (int si = 0; si <= sn; si++) {
      for (int ti = 0; ti <= tn; ti++) {
        if (dp[si + 1][ti] < dp[si][ti]) {
          dp[si + 1][ti] = dp[si][ti];
          preSI[si + 1][ti] = preSI[si][ti];
          preTI[si + 1][ti] = preTI[si][ti];
        }

        if (dp[si][ti + 1] < dp[si][ti]) {
          dp[si][ti + 1] = dp[si][ti];
          preSI[si][ti + 1] = preSI[si][ti];
          preTI[si][ti + 1] = preTI[si][ti];
        }

        if (si < sn && ti < tn && s[si] == t[ti] && dp[si + 1][ti + 1] < dp[si][ti] + 1) {
          dp[si + 1][ti + 1] = dp[si][ti] + 1;
          preSI[si + 1][ti + 1] = si;
          preTI[si + 1][ti + 1] = ti;
        }
      }
    }

    string ans = "";
    int si = sn;
    int ti = tn;

    while (true) {
      if (si != sn) {
        ans += s[si];
      }

      int nsi = preSI[si][ti];
      int nti = preTI[si][ti];
      if (nsi == -1) {
        break;
      }
      si = nsi;
      ti = nti;
    }

	reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
}


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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b){
    cout << c;
  }
  if(c == b){
    cout << a;
  }
  if(a == c){
    cout << b;
  }
  
  return 0;
}






Measured memory_bytes: 3608
#include <string.h>
#include <stdio.h>
#include <math.h>



int main(void){
	
	int x;
	scanf("%d",&x);

	for(int i=-200;i<200;i++)
	{
		for(int j=-200;j<200;j++)
		{
			if(pow(i,5)-pow(j,5)==x)
			{
				printf("%d %d",i,j);
				return 0;
			}
		}
	}

		}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

int v,e,s;
struct edge{
    ll to; ll cost;
};
vector<edge> g[100020];
vector<ll> ans;
void dijkstra(int start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(make_pair(start,0));
    ans[start] = 0;
    while(!que.empty()){
        P tmp = que.top();que.pop();
        ll to = tmp.first;ll cost = tmp.second;
        if(ans[to] < cost)continue;
        FOR(i,0,g[to].size()){
            edge tmp = g[to][i];
            if(ans[tmp.to] > ans[to] + tmp.cost){
                ans[tmp.to] = ans[to] + tmp.cost;
                que.push(make_pair(tmp.to, ans[tmp.to]));
            }
        }
    }
}
signed main () {
    scanf("%d %d %d",&v,&e,&s);
    REP(i,e){
        int a,b,c;scanf("%d %d %d",&a,&b,&c);
        g[a].push_back(edge{b,c});
    }
    ans.assign(v,INF);

    dijkstra(s);

    REP(i,v){
        if(ans[i]==INF){
            printf("INF\n");
        } else {
            printf("%d\n",ans[i]);
        }
    }
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=(int)b-1;i>=(int)a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    if ((s1[s1.length()-1] == s2[0]) &&  (s2[s2.length()-1]==s3[0])){
        cout <<"YES" << "\n";
    }
    else {
        cout << "NO" << '\n';
    }


}









Measured memory_bytes: 3580
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){
  if(x%y == 0) return y;
  else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  ll N,M,i,j;string s,t;cin >> N >> M >> s >> t;
  ll a = N/gcd(N,M),b = M/gcd(N,M);
  for(i=0;i*a<N;i++){
    if(s[i*a] != t[i*b]){
      cout << "-1\n";return 0;
    }
  }
  cout << lcm(N,M) << "\n";
}

Measured memory_bytes: 3756
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N = int(input())
    A = [int(x) for x in input().strip().split()]
    i = 0
    stock = 0
    cash = 1000
    while i+1 < N:
        if A[i] < A[i+1] and stock == 0:
            stock += cash // A[i]
            cash -= stock * A[i]
            # print('buy {} at {} yen'.format(stock, A[i]))
        elif A[i] > A[i+1]:
            cash += stock * A[i]
            # print('sell {} at {} yen, total cash {}'.format(stock, A[i], cash))
            stock = 0
        i += 1
    else:
        cash += stock * A[-1]
        # print('sell {} at {} yen, total cash {}'.format(stock, A[-1], cash))
    print(cash)

if __name__ == '__main__':
    main()

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

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2] && s[1] == 'R') {
		cout << 3 << endl;
	} else if (s[0] == s[1] && s[1] == 'R') {
		cout << 2 << endl;
	}
	else if (s[1] == s[2] && s[1] == 'R') {
		cout << 2 << endl;
	}
	else if (s[1] == 'R' || s[2] == 'R' || s[0] == 'R') {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
}

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

int main() {
 int n; cin >> n;
  vector<int> a(n);
  for(int i = 0;i<n;i++) cin >> a[i];
  int next = a[0];
  int count = 0;
  bool ans = false;
  for(int i = 0;i<n;i++){
    if(next == 2){
      count++;
      ans = true;
      break;
    } else {
      next = a[next-1];
      count++;
    }
  }
  if(ans) cout << count << endl;
  else cout << -1 << endl;
}



Measured memory_bytes: 640
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int gcd(int x, int y){
  if(x==0)return y;
  return gcd(y%x, x);
}

int main(){
  int x;cin>>x;
  cout<<360/gcd(x, 360)<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3540
#include<stdio.h>
int main(void){
	int e,y;
	scanf("%d %d",&e,&y);
	if(e==0){
		if(y<=1911)
		printf("M%d\n",y-1867);
		else if(y<=1925)
		printf("T%d\n",y-1911);
		else if(y<=1988)
		printf("S%d\n",y-1925);
		else if(y<=2016)
		printf("H%d\n",y-1988);
	}
	if(e==1)
	printf("%d\n",y+1867);
	else if(e==2)
	printf("%d\n",y+1911);
	else if(e==3)
	printf("%d\n",y+1925);
	else if(e==4)
	printf("%d\n",y+1988);
	return 0;
}

Measured memory_bytes: 1860
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(void)
{
    int N,C,K;
    int ans1 = 0, ans2 = 0;
    int num=0;
    unsigned long long int last,first;

    cin >> N >> C >> K;

    vector<int> T(N);

    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }

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

    for (int i = N-1; i >= 0; i--) {
        last = T[i];
        num = 1;
        ans1++;
        for (int j = i-1; j >= 0; j--) {
            if (last-K <= T[j] && num < C) {
                num++;
            } else {
                break;
            }
        }
        i -= num-1;
    }

    for (int i = 0; i < N; i++) {
        first = T[i];
        num = 1;
        ans2++;
        for (int j = i+1; j < N; j++) {
            if (first+K >= T[j] && num < C) {
                num++;
            } else {
                break;
            }
        }
        i += num-1;
    }

    cout << min(ans1,ans2) << endl;

    return 0;
}


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

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

const int MOD = 1000000007;

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }

    sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    long long N;
    cin >> N;
    vector<long long> divs = divisor(N);

    long long ans = 10000000000000;
    for (auto d: divs) {
        chmin(ans, d - 1 + N / d - 1);
    }

    cout << ans << endl;
}

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

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

    int M[N][N];

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        int u, k;
        cin >> u >> k;
        u--;

        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (j > 0)
                cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}





Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
void func(string X,vector<string> &S){
  bool flag=1;
  rep(i,0,S.size()){
    if(S[i]==X){
      flag=0;
      break;
      }
    }
  if(flag){
    S[0]=X;
    rep(i,1,S.size()){
      if(S[i]>S[i-1])
        swap(S[i],S[i-1]);
      else
        break;
      }
    }
  }
signed main(){
  int K;
  string s;
  cin>>s>>K;
  vector<string> S(K,"{");
  rep(i,0,s.size()){
    REP(j,1,s.size()-i){
      string P=s.substr(i,j);
      if(S[0]>P)
        func(P,S);
      else
        break;
      }
    }
  cout<<S[0]<<endl;
  }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	int N, M;
	cin >> N >> M;
	if (abs(N - M) > 1) {
		cout << 0 << endl;
	}
	else {
		ll fac[100100];
		fac[0] = fac[1] = 1;
		for (int i = 2; i < 100100; ++i) {
			fac[i] = fac[i - 1] * i%INF;
		}
		if (N != M) {
			cout <<( fac[N] * fac[M])%INF << endl;
		}
		else {
			cout << (2*fac[N] * fac[M])%INF << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

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

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
using namespace std;

int main(){

	double x[4];
	double y[4];
	char cm;
	while(cin>>x[0]){
		cin>>cm;
		cin>>y[0];
		for(int i = 1; i < 4; i++){
			cin>>cm>>x[i]>>cm>>y[i];
		}
		// ツつサツづェツつシツづェツづ個角ツづ個角ツ度ツづーツ計ツ算ツつオツ、180ツ度ツづーツ越ツつヲツづゥツ角ツ度ツつェツ堕カツ催敖つキツづェツづ篠、ツつュツづ堋づアツづつ「ツづゥ
		P A1(x[1]-x[0],y[1]-y[0]);
		P A2(x[3]-x[0],y[3]-y[0]);
		P B1(x[2]-x[1],y[2]-y[1]);
		P B2(x[0]-x[1],y[0]-y[1]);
		P C1(x[3]-x[2],y[3]-y[2]);
		P C2(x[1]-x[2],y[1]-y[2]);
		P D1(x[0]-x[3],y[0]-y[3]);
		P D2(x[2]-x[3],y[2]-y[3]);
		double t1=cross(A1,A2);
		double t2=cross(B1,B2);
		double t3=cross(C1,C2);
		double t4=cross(D1,D2);
		if(cross(A1,A2)*cross(B1,B2)*cross(C1,C2)*cross(D1,D2)<0){
			cout<<"NO"<<endl;
		}
		else
			cout<<"YES"<<endl;
	}

	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie();
    cout.tie();
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k) cout<<s<<'\n';
    else{
        for(int i=0; i<k; i++) cout<<s[i];
        cout<<"...";
    }

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>

int main(){
	int in,A,B,C,D;
	std::cin>>in;
	A = in/1000;
	B = (in-A*1000)/100;
	C = (in-A*1000-B*100)/10;
	D = (in-A*1000-B*100-C*10);

	if(A+B+C+D == 7){std::cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7";return 0;} 
	if(A-B+C+D == 7){std::cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7";return 0;}
	if(A+B+C-D == 7){std::cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7";return 0;}
	if(A-B+C-D == 7){std::cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7";return 0;}
	if(A+B-C+D == 7){std::cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7";return 0;}
	if(A-B-C+D == 7){std::cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7";return 0;}
	if(A+B-C-D == 7){std::cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7";return 0;}
	if(A-B-C-D == 7){std::cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7";return 0;}
}


Measured memory_bytes: 256