akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int k;
	cin >> k;

	int x[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	cout << x[k - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = 'abcdefghijklmnopqrstuvwxyz'
ANS = []

while n > 0:
    r = n % 26
    if r == 0:
        r = 26
    ANS.append(r)
    
    if ANS[-1] == 26:
      n -= 1
    n = n // 26

ANS = reversed(ANS)

for a in ANS:
    print(A[a-1], end="")


Measured memory_bytes: 9012
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5+5;
int n,m,val[N];
ll sum;
int main(){
  cin>>n>>m;
  for(int i=1;i<=n;++i)
    cin>>val[i];
  sort(val+1,val+1+n);
  for(int i=1;i<=n-m;++i)
    sum+=val[i];
  cout<<sum;
  return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

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

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush
from decimal import Decimal

def solve():
    a, b = map(Decimal, input().split())

    print(int(a * b))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 10040
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int N = in.nextInt();
        int[] T = new int[N];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            T[i] = in.nextInt();
            sum+= T[i];
        }
        int M = in.nextInt();
        int[] P = new int[M];
        int[] X = new int[M];
        for (int i = 0; i < M; i++) {
            P[i] = in.nextInt();
            X[i] = in.nextInt();
            System.out.println(sum - T[P[i] - 1] + X[i]);
        }
    }
}

Measured memory_bytes: 10324
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 3e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

void solve() {  
    LL n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
	char s;
    cin>>s;
    if(s=='A'||s=='B'||s=='C'||s=='D'||s=='E'||s=='F'||s=='G'||s=='H'||s=='I'||s=='J'||s=='K'||s=='L'||s=='M'||s=='N'||s=='O'||s=='P'||s=='Q'||s=='R'||s=='S'||s=='T'||s=='U'||s=='V'||s=='W'||s=='X'||s=='Y'||s=='Z') cout<<"A";
    else cout<<"a";
}


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

void solve() {
    int i, j, n, k;
    cin >> n;
    int a[n];
    for (i = 0; i < n; ++i) cin >> a[i];
}

int32_t main() {
    int n, i, j;
    cin >> n;
    int a[n];

    int masterXor = 0;

    for (i = 0; i < n; ++i) cin >> a[i], masterXor ^= a[i];
    for (i = 0; i < n; ++i) cout << (masterXor ^ a[i]) << " ";
}

Measured memory_bytes: 4312
N,M=map(int,input().split())
if N%2:
    x,y=N,1
    for i in range(M):
        print(x,y)
        x-=1
        y+=1
else:
    x,y=N,1
    for i in range(M):
        print(x,y)
        x-=1
        y+=1
        if x-y in (y+N-x,y+N-x-2):break
    x-=1
    for j in range(M-i-1):
        print(x,y)
        x-=1
        y+=1

Measured memory_bytes: 9296
#include <stdio.h>

int main(void){

	int N;
	int a[1000000];

	scanf("%d", &N);
	
	int i;

	for(i = 1; i <= N; i++ ){
		scanf("%d", &a[i]);
	}

	int ans = 0;
	int ANS = 0;

	for(i = 1; i <= N; i++){
		ans = a[i] - 1;
		ANS = ANS + ans;
	}
	
	printf("%d\n", ANS);
	
	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#define scan(n)      scanf("%I64d",&n);
#define scan2(a,b)   scanf("%I64d%I64d",&a,&b);
#define scan3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c);
#define sc(n)        scanf("%c",&n);
#define sf(n)        scanf("%lf",&n);
#define ss(n)        scanf("%s",n);
#define forall(i,a,b)for(long long int i=a;i<b;i++)
#define all(a)       a.begin(), a.end()
#define pb           push_back
#define mp           make_pair
#define FAST_IO      ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minimum(a)   *min_element(a.begin(),a.end())
#define maximum(a)   *max_element(a.begin(), a.end())
#define display(a)   for(auto i : a) cout<<i<<" ";
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
  ll temp;
  for(ll i = 0; i < n ; i++)
  {
     cin>>temp;
     v.pb(temp);
  }
  return v;
}

int main() {
    FAST_IO
    ll t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        ll n,w;
        cin>>n>>w;
        vector<ll> w1;
        vector<ll> v1;
        ll w2,v2;
        w1.pb(0);
        v1.pb(0);
        ll totSum = 0;
        for(ll i = 0; i < n ; i++)
        {
            cin>>w2>>v2;
            w1.pb(w2);
            v1.pb(v2);
            totSum += v2;
        }
        //cout<<"maximum is"<<maximum(v1)<<endl;
        ll dp[n+1][totSum+1];
        for(ll i = 0; i < n+1; i++)
        {
            for(ll j = 0; j < totSum+1; j++)
            {
                dp[i][j] = 1e18L+5;
            }
        }
        dp[0][0] = 0;
        for(ll i = 1; i < n+1; i++)
        {
            for(ll j = 0; j < totSum+1; j++)
            {
                if(j>=v1[i])
                {
                    dp[i][j] = min(w1[i]+dp[i-1][j-v1[i]],dp[i-1][j]);
                }
                else dp[i][j] = dp[i-1][j];
            }
        }
        ll ans = 0;
        for(ll i = 0; i < n+1; i++)
        {
            for(ll j = 0; j <totSum+1; j++)
            {
               // cout<<dp[i][j]<<" ";
                if(dp[i][j] <= w)
                {
                    ans = max(ans,j);
                }
            }
           //cout<<endl;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 79232
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

long long A, B;
long long ans;

long long GCD(long long a, long long b) {
	if (a % b == 0)return b;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b, long long r) {
	return a * b / r;
}

int main() {
	cin >> A >> B;
	long long r = GCD(A, B);
	ans = LCM(A, B, r);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  LL i,ans=0,N,t;
  cin>>N;
  VL C;
  rep(i,N){
    cin>>t;
    C.EB(t);
  }
  SORT(C);
  REV(C);
  t=POW(2,N-1);
  rep(i,N)ans=(ans+C[i]*((((t+POW(2,N-2)*i)%MOD)*((t*2)%MOD))%MOD))%MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 2420
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int64_t N, M, a, b;
  cin >> N >> M;
  vector<int64_t> H(N), Y(N, true);

  for (int64_t i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }
  for (int64_t i = 0; i < M; i++)
  {
    cin >> a >> b;
    if (H[a - 1] > H[b - 1])
    {
      Y[b - 1] = false;
    }
    else if (H[b - 1] > H[a - 1])
    {
      Y[a - 1] = false;
    }
    else
    {
      Y[a - 1] = false;
      Y[b - 1] = false;
    }
  }
  cout << count(Y.begin(), Y.end(), true);
}


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

using ll = long long;

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

  bool ans = true;
  if(N%2)ans=false;
  rep(i,N/2){
    if(S[i] != S[i+(N/2)]){
      ans = false;
      break;
      }
  }
//  string T1 = S.substr(begin(),(N/2))
//  string T2 = S.substr(begin()+(N/2),(N/2))

  cout << ( ans ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 256
def main():
  n = int(input())
  a = list(map(int, input().split()))

  ans = [0] * (max(a) + 1)
  length = max(a) + 1
  for x in a:
    if ans[x] == 0:
      for j in range(x, length, x):
        ans[j] += 1
    else:
      ans[x] += 1

  print(len(list(filter(lambda x: ans[x] == 1, a))))

  
if __name__ == '__main__':
  main()

Measured memory_bytes: 104000
from collections import*
s=input()

c=Counter(s)

if (c["S"]==0 and c["N"]>0) or (c["N"]==0 and c["S"]>0) or (c["E"]==0 and c["W"]>0) or (c["W"]==0 and c["E"]>0):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int H,N;
  cin >> H >> N;
  int A[N],B[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  int DP[20001];
  for (int i = 0; i < 20001; i++) {
    DP[i] = 100000000;
  }
  DP[H+10000] = 0;
  for (int i = 10000 + H - 1; i >= 0; i--) {
    for (int j = 0; j < N; j++) {
      if (H + 10000 >= i + A[j]) {
        DP[i] = min(DP[i],DP[i+A[j]] + B[j]);
      }
    }
  }
  int ans = 100000000;
  for (int i = 0; i <= 10000; i++) {
    ans = min(ans,DP[i]);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a[3*n];
  priority_queue<int,vector<int>,greater<int>> former;
  priority_queue<int> latter;
  ll sum_f[n+1],sum_l[n+1];
  sum_f[0]=0;sum_l[n]=0;
  for(int i=0;i<3*n;i++){
    cin>>a[i];
    if(i<=n-1){
      former.push(a[i]);
      sum_f[0]+=a[i];
    }
    else if(i>=2*n){
      latter.push(a[i]);
      sum_l[n]+=a[i];
    }
  }
  for(int i=1;i<=n;i++){
    sum_f[i]=sum_f[i-1]+a[n-1+i];
    former.push(a[n-1+i]);
    sum_f[i]-=former.top();
    former.pop();
  }
  for(int i=1;i<=n;i++){
    sum_l[n-i]=sum_l[n-i+1]+a[2*n-i];
    latter.push(a[2*n-i]);
    sum_l[n-i]-=latter.top();
    latter.pop();
  }
  ll ans=sum_f[0]-sum_l[0];
  for(int i=1;i<=n;i++){
    ans=max(ans,sum_f[i]-sum_l[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define rep(i,N) for(int i=1;i<=N;i++)
using namespace std;
int gcd(int p,int q){
  if(p%q==0)return q;
  return gcd(q,p%q);
}


int main(void){
   int N;
   cin>>N;
   long long a=0;
   rep(i,N)rep(j,N)rep(k,N)a+=gcd(i,gcd(j,k));
   cout<<a<<endl;
   return 0;
   
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int K,A,B;
  cin>>K>>A>>B;
  REP(i,0,2000){
    if(A<=i*K && i*K<=B){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;

  return 0;
}


Measured memory_bytes: 3640
IDENTIFICATION DIVISION.
PROGRAM-ID. A-BEGINNER.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP     PIC X(501).
01 IN-DATA.
   03 DT-X1 PIC X(10).
   03 DT-X2 PIC X(10).
01 IN-LEN.
   03 DT-L1 PIC 9(2).
   03 DT-L2 PIC 9(2).
01 IN-N     PIC 9(3).
01 IN-A-ALL.
   03 IN-A  PIC 9(4) OCCURS 100.
01 IN-AW1   PIC 9(4).
01 IN-AW2   PIC 9(4).
01 I        PIC 9(3).
01 P1       PIC 9(3).
01 P2       PIC 9(3).
01 OUT-N    PIC X(8).
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO DT-X1 COUNT IN DT-L1.
  MOVE DT-X1(1:DT-L1) TO IN-N.
 
  ACCEPT INP.
  MOVE 1 TO I.
  MOVE 1 TO P1.
  PERFORM UNTIL I > IN-N
    MOVE P1 TO P2
    PERFORM UNTIL INP(P1:1) < '0' OR INP(P1:1) > '9'
      ADD 1 TO P1
    END-PERFORM
 
    MOVE INP(P2:P1 - P2) TO IN-A(I)
    ADD 1 TO I
    ADD 1 TO P1
  END-PERFORM.
 
  MOVE 'APPROVED' TO OUT-N.
  MOVE 1 TO I.
  PERFORM UNTIL (I > IN-N) OR
                (OUT-N = 'DENIED')
    COMPUTE IN-AW1 = IN-A(I) / 2
    IF (IN-A(I) = IN-AW1 * 2)
      COMPUTE IN-AW1 = IN-A(I) / 3
      COMPUTE IN-AW2 = IN-A(I) / 5
      IF (IN-A(I) = IN-AW1 * 3) OR
         (IN-A(I) = IN-AW2 * 5)
        CONTINUE
      ELSE
        MOVE 'DENIED' TO OUT-N
      END-IF
    END-IF
    ADD 1 TO I  
  END-PERFORM.
  DISPLAY OUT-N.
 
MAIN-EXIT.
  STOP RUN.
  

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		int  n = sc.nextInt();
		
		if(n == 1){
			System.out.println("Hello World");
		}else{
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			System.out.println(a+b);
		}
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	 freopen("input.txt","r",stdin);
	 freopen("output.txt","w",stdout);
	#endif
	double w,h;
	cin>>w>>h;
	double x,y;
	cin>>x>>y;
	double ans=(w*h)/2;
	cout<<ans<<" ";
	if(w/2==x && h/2==y)
		cout<<"1";
	else
		cout<<"0";
    return 0;
}

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

#define ll long long
#define endl "\n"

const ll MAX = 200;
const ll INF = 1e18;

struct Train{
    ll s, c, d;
    Train(ll s,ll c,ll d):s(s),c(c),d(d){}
    bool operator>(const Train& x) const {return d>x.d;}
};

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

    ll n,m,s;
    cin>>n>>m>>s;
    vector <Train> graph[n];
    for (int i=0; i<m; ++i){
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        graph[u-1].emplace_back(v-1,a,b);
        graph[v-1].emplace_back(u-1,a,b);
    }
    for (int i=0; i<n; ++i){
        int c,d;
        cin>>c>>d;
        graph[i].emplace_back(i, -c, d);
    }
    vector <array<ll, MAX+1>> dp(n);
    for (auto& arr:dp){
        arr.fill(INF);
    }
    dp[0][min(s, MAX)]=0;
    priority_queue<Train, vector <Train>, greater<>> q;
    q.emplace(0,s,0);
    while (!q.empty()){
        auto [s,c,d] = q.top();
        q.pop();
        if (d>dp[s][min(c, MAX)]){
            continue;
        }
        for (auto t: graph[s]){
            if(c-t.c<0){
                continue;
            }
            if(d+t.d>=dp[t.s][min(c-t.c, MAX)]){
                continue;
            }
            dp[t.s][min(c-t.c, MAX)]=d+t.d;
            q.emplace(t.s, c-t.c, d+t.d);
        }
    }
    for (int i=1; i<n; ++i){
        cout<<*min_element(dp[i].begin(), dp[i].end())<<endl;
    }
}

Measured memory_bytes: 3844
x, k, d = map(int, input().split())
if k % 2 == 1:
    x = abs(x) - d
    k -= 1
else:
    x = abs(x)
if abs(x) - d * k <= 0:
    temp = x % (d * 2)
    print(min(temp, d * 2 - temp))
else:
    print(abs(x) - d * k)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1000000007;
#define MAX 10000

int x[MAX];

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,K, ans = 0;

    cin >> N;
    cin >> K;
    for (int i = 0; i < N;i++){
        cin >> x[i];
        if(x[i] > ( K - x[i]) ){
            ans += 2 * (K - x[i] );
        }
        else{
            ans += 2 *x[i];
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int K;
	cin >> K;
	
	cout << ((K + 1) / 2) * (K / 2) << "\n";
	return 0;
}

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

int main(){
    int y,m,d;
    long long a;
    while(cin>>y>>m>>d){
        a=d+100*m+10000*y;
        if(a<18680908)cout<<"pre-meiji"<<endl;
        else if(a>=18680908&&a<=19120729){
            cout<<"meiji "<<y-1867<<' '<<m<<' '<<d<<endl;
        }
        else if(a>=19120730&&a<=19261224){
            cout<<"taisho "<<y-1911<<' '<<m<<' '<<d<<endl;
        }
        else if(a>=19261225&&a<=19890107){
            cout<<"showa "<<y-1925<<' '<<m<<' '<<d<<endl;
        }
        else{
            cout<<"heisei "<<y-1988<<' '<<m<<' '<<d<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
import math

all = list(map(int,input().split()))
a = all[0]
b = all[1]
c = all[2]
d = all[3]

if a >= 0 and c >= 0:
    print(b * d)
elif b <=0 and d <= 0:
    print(a * c)
elif a >= 0 and b >= 0 and c <= 0 and d <= 0:
    print(a * d)
elif a <= 0 and b <= 0 and c >= 0 and d >= 0:
    print(b * c)
elif a <= 0 and b >= 0 and c <= 0 and d >= 0:
    if a * c > b * d:
        print(a * c)
    else:
        print(b * d)
elif a <= 0 and b >= 0 and c <= 0 and d <= 0:
    if a * c > a * d:
        print(a * c)
    else:
        print(a * d)
elif a <= 0 and b <= 0 and c <= 0 and d >= 0:
    if a * c > b * c:
        print(a * c)
    else:
        print(b * c)
elif a <= 0 and b >= 0 and c >= 0 and d >= 0:
    if b * c > b * d:
        print(b * c)
    else:
        print(b * d)
elif a >= 0 and b >= 0 and c <= 0 and d >= 0:
    if a * d > b * d:
        print(a * d)
    else:
        print(b * d)

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int r = count(all(s), 'R');
	int b = count(all(s), 'B');
	cout << (r > b ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int h,w;
    in>>h>>w;
    vector<string> s(h);
    for(auto&c:s) in>>c;
    vector<vector<int>> d(h*w,vector<int>(h*w,1e9));
    fr(i,h) fr(j,w){
        int k=i*w+j;
        d[k][k]=0;
        if(i) d[k-w][k]=1;
        if(i<h-1) d[k][k+w]=1;
        if(j) d[k-1][k]=1;
        if(j<w-1) d[k][k+1]=1;
    }
    fr(i,h) fr(j,w) if(s[i][j]=='#'){
                int k=i*w+j;
                if(i) d[k-w][k]=1e9;
                if(i<h-1) d[k][k+w]=1e9;
                if(j) d[k-1][k]=1e9;
                if(j<w-1) d[k][k+1]=1e9;
            }
    fr(i,h*w) fr(j,i) d[i][j]=d[j][i];
    fr(k,h*w) fr(i,h*w) fr(j,h*w) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    int ans{};
    fr(i,h*w) fr(j,h*w) if(d[i][j]!=1e9) ans=max(ans,d[i][j]);
    cout<<ans<<endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long
#define maxn 1000010
using namespace std ;
struct dy {
	int y , next ;
}A[maxn];
int n , num , cnt , tot, ans ;
int head[maxn] , a[1010][1010] , vis[1010][1010] ;
int in[maxn] , t[maxn] , day[maxn] ;
void add(int u,int v) {
	A[++cnt].y = v ;
	A[cnt].next = head[u] ;
	head[u] = cnt ;
	return ;
}
void topsort() {
	for(int i = 1 ; i <= tot ; i ++) {
		int u = t[i] ;
		for(int j = head[u] ; j ; j = A[j].next) {
			int v = A[j].y ;
			day[v] = day[u] + 1 ;
			in[v] -- ;
			if(!in[v])
				t[++tot] = v ;
		}
	}
	for(int i = 1 ; i <= num ; i ++)
		 ans=max(ans,day[i]);
	return;
}
signed main() {
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i ++) {
		for(int j = 1 ; j < n ; j ++) {
			scanf("%d",&a[i][j]) ;
			if(!vis[i][j]&&!vis[j][i]) 
				vis[i][j] = vis[j][i] = ++num ;
		}
	}
	for(int i = 1 ; i <= n ; i ++) {
		for(int j = 2 ; j < n ; j ++) {
			add(vis[i][a[i][j-1]],vis[i][a[i][j]]);
			in[vis[i][a[i][j]]] ++ ;
		}
	}
	for(int i = 1 ; i <= num ; i ++)
	  if(!in[i]) {
	  	t[++tot] = i ;
	  	day[i] = 1 ;
	  }
	topsort() ;
	if(tot != num) puts("-1");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 54784
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



////////////////////////////////////////

ll calc(ll k){
    return k*(k+1)/2;
}


int main(){
   
    ll x;cin>>x;
    ll l=0,r=100000;
    while(l<r){
        ll m=(l+r)/2;
        if(x<=calc(m))r=m;
        else l=m+1;
    }
    cout<<l<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b;
  int ans;
  int tmp;
  scanf("%d %d",&a,&b);
  if(b==1){
    ans=0;
  }
  else{
  tmp=a;
  for(ans=1;tmp<b;ans++){
    tmp=tmp+a-1;
  }
  }
  printf("%d",ans);  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c=0, d=0, e, f, g;
  string s, k, t;
  cin >> a >> b;
  co(6-a-b);
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def chk(a,first):
    count = 0
    x = 0 # sum
    t = first # True : plus, False : minus
    for item in a:
        x += item
        if t == True and x<1:
            count += 1-x
            x = 1
        elif t == False and x>-1:
            count += x+1
            x = -1
        t = not t
    return count

print(min(chk(a,True),chk(a,False)))

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 1000 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    int multi_split = 0;
    if (w / 2.0 == x && h / 2.0 == y) {
        multi_split = 1;
    } else {
        multi_split = 0;
    }
    double area = double(w * h) / 2.0;
    cout << area << " " << multi_split << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d",$N);
for($i=0;$i<$N;$i++){
  fscanf(STDIN,"%d",$A);
  $array[] = $A;
}

$max1 = max($array);
$key = array_search(max($array), $array);
$array2 = $array;
unset($array2[$key]);
$max2 = max($array2);

for($i=0;$i<$N;$i++){
  if($array[$i] === $max1){
    echo $max2."\n";
  }else{
    echo $max1."\n";
  }
}

Measured memory_bytes: 53492
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  REPP(i,9){
    if(n%i==0){
      if(n/i <= 9){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

int main() {
  int a,b,c;
  char ch;
  int rect=0, lozen=0;
  
  while(cin>>a>>ch>>b>>ch>>c) {
    if(a*a+b*b==c*c) rect++;
    else if(a == b) lozen++;
  }
  cout << rect << endl << lozen << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==b){
		printf("Draw");
	}
	else if(a==1){
		printf("Alice");
	}
	else if(b==1){
		printf("Bob");
	}
	else if(a>b){
		printf("Alice");
	}
	else{
		printf("Bob");
	}


	return 0;
}

Measured memory_bytes: 128
import numpy as np

def split(word): 
    return [int(char) for char in word]  

H, W, K = map(int, input().split())
C = []
for _ in range(H):
    buff = str(input())
    for i in range(W):
        if buff[i] == '#':
            C.append(1)
        else:
            C.append(0)

#C = [1 if i == '#' else 0 for i in C_]
C = np.array(C).reshape(H,W)

cnum = np.sum(C)

count = 0
if cnum < K:
    print(0)
    exit(0)
else:  # 全探索
    for h in range(2 ** H):
        for w in range(2 ** W):
            # '00111' みたいなのを作る
            wline = bin(w)[2:].zfill(W)
            wline = split(wline)  # split to lists
            wzero = split(''.zfill(W))
            hline = bin(h)[2:].zfill(H)
            hline = split(hline)  # split to lists
            
            HW = []
            for hlin in hline:
                if hlin:
                    HW.append(wline)
                else:
                    HW.append(wzero)
            HW = np.array(HW).reshape(H, W)
            cnew = np.sum(C * HW)
            
            if cnew == K:
                count += 1
            
print(count)


Measured memory_bytes: 27264
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

//debug処理
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n;
int a[334334];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, 61) {
		int zero = 0, one = 0;
		rep(j, n) {
			if ((a[j] >> i) & 1)one++;
			else zero++;
		}
		ans += (zero * one)%mod*mod_pow(2,i,mod);
		ans %= mod;
	}
	cout << ans << endl;
	ggr
}


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

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll a,b,c,k;ll ans=0;
    cin >> a >> b >> c >> k;
    if(k>=a && k<=a+b)
    ans=a;
    else if(k<a)
    ans=k;
    else
    ans=a-(k-(a+b));
    
    cout << ans << endl;
 
  return 0;
}  

Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
happiness = 0
memory = 100
for i in range(N):
  happiness += B[A[i]-1]
  if memory + 1 == A[i]:
    happiness += C[A[i]-2]
  memory = A[i]
print(happiness)

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
const int INF = 0x3f3f3f3f;

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> B(m);
    for (int i = 0; i < m; ++i) {
        cin >> B[i];
    }
    int ans = 0;
    int x;
    int curr = 0;
    for (int i = 0; i < n; ++i) {
        curr = 0;
        for (int j = 0; j < m; ++j) {
            cin >> x;
            curr += x * B[j];
        }
        if (curr + c > 0) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#ロジックは簡単だったが実装に手間取った. 
n = int(input())
h = [int(_) for _ in input().split()]
h.append(0) #ループエラー防止のためのダミー
x = [0]
a = 0
for i in range(0,n):
    if h[i] <= h[i-1]:
        a += 1
        if a > x[0]:
            x[0] = a
    else: # h[i] > h[i-1]:
        a = 0
print(*x)


Measured memory_bytes: 14252
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if (4 * h * n - N * n - N * h) != 0 and (N * h * n) % (4 * h * n - N * n - N * h) == 0:
            if (N * h * n) // (4 * h * n - N * n - N * h) > 0:
                print("{} {} {}".format(h,n,(N * h * n) // (4 * h * n - N * n - N * h)))
                exit()

Measured memory_bytes: 40940
s = input()
t = input()
#dp 0で初期化
#dp[i+1][j+1] sのi文字目までとtのj文字目までの最長部分列の長さ
#もしs[i] == t[j]なら、dp[i][j]に対して1文字増やせる => dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1) ...わかる
#dp[i+1][j+1] = max(dp[i+1][j],dp[i+1][j+1])　　...？
#dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j+1])　　...？
#dp[i+1][j+1]
dp = [[0]*(len(t)+1) for i in range(len(s)+1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1)
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1])

#復元
i = len(s)
j = len(t)
res = ""
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        res = s[i-1] + res
        i -= 1
        j -= 1
print(res)


Measured memory_bytes: 113628
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int m;
  cin >> m;
  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
    cout << s.at(i) << t.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/**
*   author: j o s e m a g o
*   user: m a m i s a k i
**/
using namespace std;

/***PLANTILLA***/

using namespace __gnu_pbds; //*st.find_by_order(1);  st.order_of_key(p);
#pragma GCC optimize ("Ofast")
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef double dbl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;

string tostring(auto a){
    stringstream ss;ss<<a;string s = ss.str();
    return s;
}

/**Mi Debug**/
#define var(x) cout<<#x<<" = ";
#define db(x) cout<<#x<<" = "<<x<<"\n";
void dbvector(vector<auto>&v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}
void dbmapa(map<auto,auto>mp){
   for(auto x : mp) cout<<"{"<<x.first<<":"<<x.second<<"} ";cout<<"\n";
}
void dbstring(string v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}

/***********Code***************/

const int JJJ = 100100;










int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);

    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k){
        cout<<s;
    }
    else{
        for(int i = 0;i < k;i++){
            cout<<s[i];
        }
        cout<<"...";
    }






    return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int x = Integer.parseInt(str[0]);
    int a = Integer.parseInt(str[1]);
    int b = Integer.parseInt(str[2]);
    if(a-b>=0)
      System.out.println("delicious");
    else if(b-a<=x)
      System.out.println("safe");
    else
      System.out.println("dangerous");
  }
}

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

typedef long long ll;

constexpr ll MAX = 1000010;
constexpr ll MOD = 1000000007;
ll fac[MAX + 1], facinv[MAX + 1];
// fac[i] = i!;
// facinv[i] = (i!)^-1 (mod MOD)

constexpr ll extgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  // ll d = extgcd(b, a % b, x, y);
  // ll temp = x;
  // x = y;
  // y = temp - (a / b) * x;
  ll d = extgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}

constexpr ll modinv(ll a, ll m) {
  // Need: gcd(a, m) = 1;
  // a^-1(mod. m)は
  // ax+my=gcd(a, m)=1;
  // を満たすxである。(それはそう,両辺をmodを法としてmodを考えてみよう)
  ll x = 0, y = 0;
  extgcd(a, m, x, y);
  return (x % m + m) % m;
}

constexpr void COMInit(ll *fac, ll *facinv) {
  // O(MAX log MOD)
  fac[0] = 1;
  for (int i = 1; i <= MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
  }
  facinv[MAX] = modinv(fac[MAX], MOD);
  for (int i = MAX; i >= 0; i--) {
    facinv[i - 1] = facinv[i] * (i) % MOD;
  }
}

ll comb(ll n, ll r) {
  //           n!
  // nCr = -----------
  //        r!*(n-r)!
  return (fac[n] * facinv[r]) % MOD * facinv[n - r] % MOD;
}

int main() {
  COMInit(fac, facinv);
  ll x, y;
  cin >> x >> y;
  if ((2 * x - y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if ((2 * y - x) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll a = (2 * x - y) / 3;
  ll b = (2 * y - x) / 3;
  if (a < 0 || b < 0) {
    cout << 0 << endl;
    return 0;
  }
  a %= MOD;
  b %= MOD;
  cout << comb((a + b) % MOD, a) << endl;
}


Measured memory_bytes: 15872
[n, m, l] = [int(x) for x in raw_input().split()]

A = []
B = []
C = []
counter = 0
while counter < n:
    A.append([int(x) for x in raw_input().split()])
    counter += 1

counter = 0
while counter < m:
    B.append([int(x) for x in raw_input().split()])
    counter += 1

counter = 0
while counter < n:
    C.append([0] * l)
    counter += 1

for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += (A[i][k] * B[k][j])

for data in C:
    print(' '.join([str(x) for x in data]))

Measured memory_bytes: 7052
//クラスカルを一気にやるために、今までにpを使った回数, qを使った回数, というのを覚えておく。
//実はソートしても答えは変わらない。
//…これ、眠いと全く思いつかないし、Div2-600レベルだと思う。

#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int w, h;
int p[100000];
int q[100000];
pair<int, int> sorted[200000];	//(cost, type(p:0, q:1))

signed main() {
	int i;
	
	cin >> w >> h;
	for (i = 0; i < w; i++) { cin >> p[i]; sorted[i] = pair<int, int>(p[i], 0); }
	for (i = 0; i < h; i++) { cin >> q[i]; sorted[i + w] = pair<int, int>(q[i], 1); }
	sort(sorted, sorted + w + h);
	
	int cnt[2] = {0};	//(0:p, 1:q)
	int ans = 0;
	for (i = 0; i < w + h; i++) {
		if (sorted[i].second == 0) {
			ans += (h + 1 - cnt[1]) * sorted[i].first;
		}
		else {
			ans += (w + 1 - cnt[0]) * sorted[i].first;
		}
		cnt[sorted[i].second]++;
	}
	cout << ans << endl;
	return 0;
}

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

vector<ll> enumDivisor(ll n){
    vector<ll> res;
    for(ll i=1;i*i<=n;++i){
        if(n%i!=0)continue;
        res.push_back(i);
        if(i*i!=n)res.push_back(n/i);
    }
    return res;
}

int main(void){
    ll n;
    cin >> n;
    int ans=0;
    for(ll x:enumDivisor(n)){
        if(x==1)continue;
        ll tmp=n;
        while(tmp%x==0)tmp/=x;
        tmp%=x;
        if(tmp==1)++ans;
    }
    ans+=enumDivisor(n-1).size()-1;

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


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, H, W;
	cin >> N >> H >> W;
	vector<int> A(N),B(N);
	for(int i=0; i<N; i++) cin >> A[i] >> B[i];

	int cnt=0;
	for (int i = 0; i < N; i++) {
		if ((A[i]-H) >= 0 && (B[i]-W) >= 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}
	


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

int main(){
  int n;
  cin >> n;
  vector<pair<string,pair<int,int>>> c(n);
  for(int i = 0; i < n; i++){
    string s;
    int a;
    cin >> s >> a;
    c[i].first = s;
    c[i].second.first = -a;
    c[i].second.second = i+1;
  }
  sort(c.begin(),c.end());
  for(int i = 0; i < n; i++){
    cout << c[i].second.second << endl;
  }
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

struct drink {
    int64_t A;
    int64_t B;
};

int compare (const void *a, const void *b)
{
    if(((struct drink *)a)->A - ((struct drink *)b)->A < 0)
        return -1;
    if(((struct drink *)a)->A - ((struct drink *)b)->A > 0)
        return 1;
    return 0;
}

int main (int argc, char const *argv[])
{
    int64_t N, M;
    struct drink d[(int)1e5];
    int64_t ans = 0;

    scanf("%"PRId64"%"PRId64, &N, &M);
    for (int i = 0; i < N; i++) {
        scanf("%"PRId64"%"PRId64, &d[i].A, &d[i].B);
    }

    qsort(d, N, sizeof(struct drink), compare);

    for (int i = 0; i < N; i++) {
        if (d[i].B < M) {
            ans += d[i].A * d[i].B;
            M -= d[i].B;
        } else {
            ans += d[i].A * M;
            break;
        }
    }
    
    printf("%"PRId64"\n", ans);
}


Measured memory_bytes: 3324
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int a,b;cin>>a>>b;
    string s; cin>>s;
    rep(i,0,s.size()){
        if(i!=a &&s[i]=='-'){
            cout<<"No"<<endl;
            return 0;
        }
        if(i==a&&s[i]!='-'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    

}

/*

*/


Measured memory_bytes: 256