akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque
import copy

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = inputs[0]
    if S[0] != 'A':
        return 'WA'

    count = 0
    for i in range(1, len(S)):
        if i >= 2 and i <= len(S) - 2 and S[i] == 'C':
            count += 1
        else:
            if not (S[i] >= 'a' and S[i] <= 'z'):
                return 'WA'

    if count == 1:
        return "AC"

    return 'WA'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3436
function Main(input) {

	input = input.split(" ");
  //空白で区切るってことやろ

	var A = parseInt(input[0], 10);
	var B = parseInt(input[1], 10);
	var C = parseInt(input[2], 10);
  //とりあえず入力持ってきて10進数にした
  var five = 2;
  //後で使う
  if( A + B + C != 17){

  console.log("NO");
  //合計が　17じゃなきゃ　違うやろ
  } else {
     if(A == 5){
      five --;
    }if(B == 5){
      five --;
    }if(C == 5){
      five --;
    }
//5が二回出てくることの確認
    if(five == 0){
    console.log("YES");
    } else {
    console.log("NO");
    }
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//おまじない

//汚ねぇコードだ

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
        ll n=0;
        cin>>n;
        float array[n]={0};
        for(int i=0;i<n;i++){
            cin>>array[i];
        }
        sort(array,array+n);
        float sum=(array[0]+array[1])/2;
        for(int i=2;i<n;i++){
            sum+=array[i];
            sum=sum/2;
        }
        cout<<sum;
        
        
    }

    return 0;
}


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

int main() {
    long a, b;
    std::cin >> a >> b;
    if (a > b) {
        std::swap(a, b);
    }

    if ((b + a) % 2 == 0) {
        std::cout << (b + a) / 2 << std::endl;
    } else {
        std::cout << "IMPOSSIBLE" << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
void Read ( int &x, char c = getchar(), bool f = 0 ) {
	for ( x = 0 ; !isdigit(c) ; c = getchar() ) if (c == '-') f = 1 ;
	for ( ; isdigit(c) ; c = getchar() ) x = 10*x + c - '0' ;
	if (f) x = -x ;
}
const int maxn = 1005, maxv = 5005, zhf = 0x3f3f3f3f ;
int n, m, f[maxn], g[2][maxv], a[maxn] ;
int e, Begin[maxn], To[maxn*2], Next[maxn*2] ;
void add ( int x, int y ) {
	To[++e] = y ;
	Next[e] = Begin[x] ;
	Begin[x] = e ;
}
void dfs ( int x ) {
	//printf ( "dfs %d\n", x ) ;
	int i, j, u ;
	for ( i = Begin[x] ; i ; i = Next[i] ) dfs(To[i]) ;
	bool t = 0 ;
	memset ( g[0], 0x3f, sizeof g[0] ) ;
	g[t][0] = 0 ;
	for ( i = Begin[x] ; i ; i = Next[i] ) {
		u = To[i] ;
		t ^= 1 ;
		memset ( g[t], 0x3f, sizeof g[t] ) ;
		for ( j = 0 ; j <= a[x] ; j ++ ) {
			if (j >= a[u]) g[t][j] = min(g[t][j], g[t^1][j - a[u]] + f[u]) ;
			if (j >= f[u]) g[t][j] = min(g[t][j], g[t^1][j - f[u]] + a[u]) ;
		}
	}
	f[x] = zhf ;
	for ( i = 0 ; i <= a[x] ; i ++ )
		f[x] = min(f[x], g[t][i]) ;
	//printf ( "f[%d]=%d\n\n", x, f[x] ) ;
}
int main() {
	int i, u, x ;
	Read(n) ;
	for ( i = 2 ; i <= n ; i ++ ) {
		Read(x) ;
		add(x, i) ;
	}
	for ( i = 1 ; i <= n ; i ++ ) Read(a[i]) ;
	dfs(1) ;
	if (f[1] < zhf) puts("POSSIBLE") ;
	else puts("IMPOSSIBLE") ;
	return 0 ;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


ll inf = (long long)(1e18) + 1;
using namespace std;

int main(){
    int n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll l = -inf, r = inf;
    while (l + 1 < r) {
        ll x = (l + r) / 2;
        bool ok = [&] {
            ll tot = 0;
            rep(i, n) {
                if (a[i] < 0) {
                    int l = -1, r = n;
                    while(l+1<r) {
                        int c = (l+r) / 2;
                        if (a[c]*a[i] < x) r = c; else l = c;
                    }
                    tot += n - r;
                } else {
                    int l = -1, r = n;
                    while (l + 1 < r) {
                        int c = (l + r) / 2;
                        if (a[c]*a[i] < x) l = c; else r = c;
                    }
                    tot += r;
                }
                if (a[i] * a[i] < x) tot--;
            }
            tot /= 2;
            return tot < k;

        }();
        if (ok) l = x; else r = x;

    }
    cout << l << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main(){
  int N; cin >> N;
  int oi, ei, idx = 0;
  vector<int> o(N / 2, 0), e(N / 2, 0), oc(100001, 0), ec(100001, 0);
  while(cin >> oi >> ei){
    o[idx] = oi;
    e[idx] = ei;
    oc[oi]++; ec[ei]++;
    idx++;
  }
  
  int id_o_max = 0, id_e_max = 0, co_max = 0, ce_max = 0;
  for(int i = 0; i < oc.size(); i++){
  	if(co_max <= oc[i]){
      co_max = oc[i];
      id_o_max = i;
    }
    if(ce_max <= ec[i]){
      ce_max = ec[i];
      id_e_max = i;
    }
  }
  
  if(id_e_max != id_o_max){
    cout << N - oc[id_o_max] - ec[id_e_max] << endl;
  }
  else{
    sort(oc.begin(), oc.end(), greater<int>());
    sort(ec.begin(), ec.end(), greater<int>());
    int count = max(oc[0] + ec[1], oc[1] + ec[0]);
  	cout << N - count << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int dfs(int n, int s, int minimum) {
    if (n == 0 && s == 0) {
        return 1;
    }
    if (n <= 0 && s <= 0) {
        return 0;
    }
    int ret = 0;
    for (int i = minimum; i < 10; ++i) {
        ret += dfs(n - 1, s - i, i + 1);
    }
    return ret;
}

int main() {
    while (true) {
        int n, s;
        cin >> n >> s;
        if (n == 0 && s == 0) {
            return 0;
        }
        cout << dfs(n, s, 0) << endl;
    }
}

Measured memory_bytes: 1160
datalist = [list(map (int, input().split(" "))) for i in range(3)]
checktbl = [[0,0,0],[0,0,0],[0,0,0]]
num = int(input())
for i in range(num):
    data = int(input())
    for j in range(3):
        for k in range(3):
            if datalist[k][j] == data:
                checktbl[k][j] = 1

result = "No"
for i in range(3):
    if checktbl[i][0] == 1 and checktbl[i][1] == 1 and checktbl[i][2] == 1:
        result = "Yes"
for i in range(3):
    if checktbl[0][i] == 1 and checktbl[1][i] == 1 and checktbl[2][i] == 1:
        result = "Yes"
if checktbl[0][0] == 1 and checktbl[1][1] == 1 and checktbl[2][2] == 1:
    result = "Yes"
if checktbl[0][2] == 1 and checktbl[1][1] == 1 and checktbl[2][0] == 1:
    result = "Yes"

print(result)

Measured memory_bytes: 3064
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, readline().split())
students = []
for _ in range(N):
    a, b = map(int, readline().split())
    students.append((a, b))
flags = []
for _ in range(M):
    c, d = map(int, readline().split())
    flags.append((c, d))


# マンハッタン距離を計算する
def calc(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

ans = [0] * N
distances = [INF] * N
for i, (x1, y1) in enumerate(students):
    for j, (x2, y2) in enumerate(flags):
        dis = calc(x1, y1, x2, y2)
        # print("i: {} j: {} dis: {}".format(i, j, dis))
        if dis < distances[i]:
            ans[i] = j + 1
            distances[i] = dis

for a in ans:
    print(a)

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

#define fir first
#define sec second
using namespace std;
typedef long long LL;
typedef unsigned long long u64;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
int inp() {
	int x = 0, f = 1;char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = -1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return x * f;
}

#define y1 thisisbad
#define x1 thisisworse

const int MaxN = 401234;
int x1, y1, x2, y2, n, m;
int x[MaxN], y[MaxN], rk[MaxN];

bool cmp(int u, int v) {
	return make_pair(x[u], y[u]) < make_pair(x[v], y[v]); 
}

bool cmp1(int u, int v) {
	return y[u] < y[v]; 
}

bool cmp2(int u, int v) {
	return y[u] > y[v]; 
}

int a[MaxN], dp[MaxN];

int abs(int x) {
	return x < 0 ? -x : x;
}

int main() {
	int i;
	cin >> x1 >> y1 >> x2 >> y2;
	cin >> n;
	for(i = 1; i <= n; i++) 
		x[i] = inp(), y[i] = inp();
		
	if(x1 > x2) swap(x1, x2), swap(y1, y2);
	
	int u, d, l, r; 
	u = max(x1, x2); d = min(x1, x2); 
	l = min(y1, y2); r = max(y1, y2);
	
	for(i = 1; i <= n; i++) 
		if(x[i] > u || x[i] < d || y[i] < l || y[i] > r)
			continue;
		else
			x[++m] = x[i], y[m] = y[i];
				
	n = m;
	for(i = 1; i <= n; i++) rk[i] = i;
	sort(rk + 1, rk + n + 1, cmp);
	
	sort(rk + 1, rk + n + 1, y1 < y2 ? cmp1 : cmp2);
	
	for(i = 0; i < n; i++) a[i] = x[rk[i + 1]];
	fill(dp, dp + n, 233333333);
	for(i = 0; i < n; i++) 
		*lower_bound(dp, dp + n, a[i]) = a[i];
	
	int L = lower_bound(dp, dp + n, 233333333) - dp;
	double ans = abs(x2 - x1) + abs(y2 - y1); 
	ans *= 100;
	ans -= (20 - 5 * acos(-1)) * L;
	int lim = min(r - l + 1, u - d + 1);
	 
	if(L == lim) ans += 5 * acos(-1);	
	printf("%.20lf", ans);
	return 0;
}




Measured memory_bytes: 6400
n=int(input())
a=list(map(int,input().split()))
import fractions
ans=0
m=a[0]
for i in range(1,n):
  m=(m*a[i])//fractions.gcd(m,a[i])
for i in range(n):
  ans=ans+(m-1)%a[i]
print(ans)

Measured memory_bytes: 5280
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            WriteLine(string.Join("", cin.ReadStrArray(3).Select(a => a[0].ToString().ToUpper())));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11348
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
int mod = 1000000007;
int mod1 = 998244353;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};



int32_t main(){
	IO
	int n;
	cin>>n;
	int sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                    sum+= gcd(gcd(i,j),k);
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/

signed main()
{
    fast;
    ll n;
    cin>>n;
    string a,b;
    For(i,n)
    {
        char c;
        cin>>c;
        a+=c;
    }
    For(i,n)
    {
        char c;
        cin>>c;
        b+=c;
    }
    if(a>b)
    {
        swap(a,b);
    }
    ll cnt=0;
    while(a!=b)
    {
        next_permutation(all(a));
        cnt++;
    }
    cout<<cnt<<endl;
}   


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define len(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string s;cin>>s;
  int cnt = 0;
  for (auto c : s) if (c=='1') cnt++;
  cout << cnt;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String ACL = "ACL";
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < K; i++) {
            sb.append(ACL);
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 35652
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

ll gcd(ll a, ll b) {
	if (a < b) { return gcd(b, a); }
	ll r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return a/gcd(a,b)*b;
}

ll conb(ll n, ll r) {
	if (n - r < r) { return conb(n, n - r); }
	ll tmp = 1;
	FOR(i, n - r + 1, n + 1) {
		tmp *= i;
	}
	FOR(i, 1, r + 1) {
		tmp /= i;
	}
	return tmp;
}

ll mod(ll n, ll r) {
	ll q = n % r;
	return (q < 0) ? q + r : q;
}

int main() {
	ll n, m;
	cin >> n >> m;
	string s1, s2;
	cin >> s1 >> s2;
	//
	ll r = gcd(n, m);
	ll p = n * m / r;

	for (ll i = 0; i < p; i += (p / r)) {
		if (s1[i/(m/r)] != s2[i / (n / r)]) {
			cout << -1 << endl;
			return 0;
		}
	}
	
	
	//
	cout << p << endl;
}

Measured memory_bytes: 512
def resolve():
  N = int(input())
  a = [int(x) for x in input().split(" ")]
  S = a[0]
  for i in range(1, N):
    S^=a[i]

  for i in range(N):
    print(S^a[i], "", end="")

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 93496
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int inf = 5e18;  
const int mod = 1e9+7;
const int mod1 = 998244353;
const int nax = 2005;
int n,x,y,dist[nax];
void solve()
 {
  cin>>n>>x>>y;
  loop(i,1,n+1)
   loop(j,i+1,n+1)
     {
      int d = min({j-i,abs(x-i) + abs(j-y) + 1,abs(x-j) + abs(y-i) + 1});
      dist[d]++;
     }
  loop(i,1,n)
   cout<<dist[i]<<END;
 } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
 // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
  return 0;
} 

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define BIN(n,x) bitset<>  
using namespace std;

//BITSET
//bitset< ##no of digits required in binary## > x( ##integral string value## )   // bitset< ##no of digits required in binary## > x( ##number## ) 
//stores binary value of the string in x // constructor sets all values to 0 by default // x.set() sets all value to 1 //x.none() checks for 0{gives bool}
//-->x.count() gives no of 1's //--> x.size() gives total bits //--> x.test(i) returns binary value of i'th bit

//SETPRECISION
//cout<<fixed<<setprecision(#n#)<<x;  --> sets the no of digits of x after decimal to n

//SET STL
//insert();*** count() returns 1 if element is present or 0  **** ;find() {returns iterator pointing to element else returns end iterator}; ---> O(log(N))
//begin();end(){next to last};---->O(1)
//See sorting

//VECTOR STL
//begin(); back();-->O(1)
//sort(v.begin(),v.end()); -->{O(Nlog(N))}

//MAP STL map<U,V> mp; U=key val  V = mapped val
//count(k) (returns 1 if element with key value k is found}-->O(log(N))
//See sorting



long long BERem(long long a, long long b, long long m){
    a%=m;
    long long res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


int main(){

    int k,n;
    cin>>k>>n;
    int a[n];
    int max=0;
    f(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    int d[n];
    //d[i]=a[i+1]-a[i];
    //d[n-1]=a[0]-a[n-1];
    f(i,n-1){
        d[i]=a[i+1]-a[i];
        if(d[i]>max){
            max=d[i];
        }
    }
    d[n-1]=a[0]+(k-a[n-1]);
    if(d[n-1]>max){
        max=d[n-1];
    }
    cout<<k-max<<endl;
    


    return 0;
}



Measured memory_bytes: 1792
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  cin >> n;
  char tail = n[SIZE(n, int)-1];
  if (tail == '3') cout << "bon" << endl;
  else if (tail == '0' || tail == '1' || tail == '6' || tail == '8') cout << "pon" << endl;
  else cout << "hon" << endl;
  return 0;
}


Measured memory_bytes: 3512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long r = scn.nextLong();
		long d = scn.nextLong();
		long x = scn.nextLong();
		for(int i = 0;i<10;i++) {
			x=r*x-d;
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 19668
#include <stdio.h>
#include <string.h>

#define MAX 1000

int max(int a, int b)
{
	if(a>b) return a;
	else return b;
}

int main(void)
{
	int i, j, q, Xlen, Ylen, l[MAX+1][MAX+1]={0};
	char X[MAX+1], Y[MAX+1];
	
	scanf("%d",&q);
	while (q--) {
		scanf("%s",X);
		scanf("%s",Y);
		Xlen = strlen(X);
		Ylen = strlen(Y);
		for (i=1; i<=Xlen; i++) {
			for (j=1; j<=Ylen; j++) {
				if (X[i-1] == Y[j-1]) {
					l[i][j] = l[i-1][j-1] + 1;
				} else {
					l[i][j] = max(l[i-1][j], l[i][j-1]);
				}
			}
		}
		printf("%d\n", l[Xlen][Ylen]);
	}
	
	return 0;
}

Measured memory_bytes: 4524
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int flag = 0;
  for(int i = b;i < c + 1;i++){
    if(i % a == 0){
      flag = 1;
      break;
    }
  }
  if(flag == 0){
    cout << "NG" << endl;
  }
  else{
    cout << "OK" << endl;
  }
}

Measured memory_bytes: 3636
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// height
		int h = sc.nextInt();

		// width
		int w = sc.nextInt();

		// マス目の状態
		char[][] masu = new char[h][w];

		// BFSのQueueを準備
		Deque<XY> q = new ArrayDeque<>();

		// 入力を受け取る & '#'のマスをEnQueue
		for (int i = 0; i < h; i++) {
			masu[i] = sc.next().toCharArray();
			for (int j = 0; j < w; j++) {
				if ('#' == masu[i][j]) {
					q.add(new XY(i, j, 0));
				}
			}
		}

		// ans
		int max_depth = 0;

		// BFS主処理
		for (;;) {
			// 無限ループ開始

			// 終了条件
			if (q.size() < 1) {
				break;
			}

			// queueからdequeue
			// pollメソッドはqueueから取り出し & queueから削除
			XY xy = q.poll();
			int x = xy.x;
			int y = xy.y;
			int depth = xy.depth;

			if (depth >= max_depth) {
				max_depth = depth;
			}

			// 現在の位置の周囲を黒にする
			if (x + 1 < w && masu[y][x + 1] == '.') {
				masu[y][x + 1] = '#';
				q.add(new XY(y, x + 1, depth + 1));
			}
			if (x - 1 >= 0 && masu[y][x - 1] == '.') {
				masu[y][x - 1] = '#';
				q.add(new XY(y, x - 1, depth + 1));
			}
			if (y + 1 < h && masu[y + 1][x] == '.') {
				masu[y + 1][x] = '#';
				q.add(new XY(y + 1, x, depth + 1));
			}
			if (y - 1 >= 0 && masu[y - 1][x] == '.') {
				masu[y - 1][x] = '#';
				q.add(new XY(y - 1, x, depth + 1));
			}

		}

		System.out.println(max_depth);

	}
}

class XY {
	int y;
	int x;

	int depth;

	XY(int y, int x, int d) {
		this.x = x;
		this.y = y;
		depth = d;
	}
}

Measured memory_bytes: 69372
import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.math.BigInteger;
public class Main
{
	public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
       String s=st.nextToken();
st = new StringTokenizer(br.readLine());
int n=Integer.parseInt(st.nextToken());
String s1="";
s1+=s.charAt(0);
for(int i=0;i<s.length();i++)
{
	if(i+n<s.length())
	{
	   s1+=s.charAt(i+n);
	   i=i+n-1;
	}
}
System.out.println(s1);
}
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define pll pair<ll,ll>

int main() {

    ll n;
    cin>>n;

    vector<ll> A(n),B(n),C(n-1);
    for(int i=0;i<n;i++)
    	cin>>A[i];

    for(int i=0;i<n;i++)
    	cin>>B[i];

    for(int i=0;i<n-1;i++)
    	cin>>C[i];

    ll sum = B[A[0]-1];
    for(int i=1;i<n;i++) {
    	if(A[i-1]+1==A[i]) {
    		sum += C[A[i-1]-1] + B[A[i]-1];
    	}
    	else
    		sum += B[A[i]-1];
    }

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> dp(n + 1);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for(int i = 2; i < n; ++i){
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i-2] + abs(h[i] - h[i - 2]));

  }
  cout << dp[n - 1] << endl;
}


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

int main() {
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;s[i];i++){
	    ans=(ans+(s[i]-'0'))%9;
	}
	if(ans==0){
	    cout<<"Yes\n";
	}
	else
	{
	    cout<<"No\n";
	}
}


Measured memory_bytes: 3720
from string import ascii_uppercase as alph


def main():
    N = int(input())
    S = input()
    result = ''
    alphabets = []
    for a in alph:
        alphabets.append(a)
    for s in S:
        result += alphabets[(alphabets.index(s) + N) % len(alphabets)]
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3768
#include<iostream>
#include<vector>
#include<string>
using namespace std;
vector<int> map[10];
void init(){
  for(int i=0;i<10;i++){
    map[i].clear();
  }
}
void input(string s){
  for(int i=0;i<s.size();i++){
    map[0].push_back(s[i]-'0');
  }
}

int solve(){
  for(int i=0;i<10;i++){
    for(int j=0;j<map[i].size()-1;j++){
      map[i+1].push_back((map[i][j]+map[i][j+1])%10);
    }
  }
  return map[9][0];
}

int main(){
  string s;
  while(cin>>s){
    init();
    input(s);
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
long long x;
int main(){
	cin>>x;
	for (long long i=-1000;i<=1000;i++)
		for (long long j=-1000;j<=1000;j++)
			if (i*i*i*i*i-j*j*j*j*j==x){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(int argc, char const *argv[]) {

  unsigned long long int N, K;
  scanf("%lld %lld", &N, &K);

  unsigned long long int A, B;
  A = N % K;

  if (A == 0) {
    printf("0\n");
  }else{
    B = (A - K) * (-1);
    if (A < B) {
      printf("%lld\n", A);
    }else{
      printf("%lld\n", B);
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int c1,c5,c10,c50,c100,c500;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    
    if (c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500 >= 1000)  cout << "1" << endl;
    else  cout << "0" << endl;
}


Measured memory_bytes: 3088
N=int(input())
a=list(map(int, input().split()))

d = {}

ans=0

for i in range(N):
    if a[i] in d.keys():
        d[a[i]]+=1
        ans+=1
        if d[a[i]] == a[i]:
            ans-=a[i]
    else:
        d[a[i]] = 1
        ans+=1
        if a[i] == 1:
            ans-=1
print(ans)

Measured memory_bytes: 17780
N, K = map(int, input().split())
X = list(map(int, input().split()))
a= []
for i in range(N-K+1):
    l = X[i]
    r = X[i+K-1]
    a.append(min(abs(l)+abs(r-l), abs(r) + abs(r-l)))
print(min(a))



Measured memory_bytes: 19996
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll dpOld[2019];
    ll dp[2019];
    string S;
    ll l;
    char s;
    ll sNum;
    ll ans = 0;

    cin >> S;
    l = S.size();

    for(ll i = 0; i < 2019; i++){
        dpOld[i] = 0;
    }
    for(ll i = 1; i <= l; i++){
        s = S[i - 1];
        sNum = (int)s - '0';
        for(ll j = 0; j < 2019; j++){
            dp[(j * 10 + sNum) % 2019] = dpOld[j];
        }
        dp[sNum] += 1;
        ans += dp[0];
        for(ll j = 0; j < 2019; j++){
            dpOld[j] = dp[j];
            dp[j] = 0;
        }

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

ll solve(int N, int K, vi& t, vi& d){
  map<int, vi> sushi_list;
  for (int i=0;i<N;i++){
    sushi_list[t[i]].push_back(d[i]);
  }

  vi head, tail;
  for (auto p:sushi_list){
    vi q=p.second;
    sort(q.begin(), q.end());
    head.push_back(q.back());
    q.pop_back();
    tail.insert(tail.end(), q.begin(), q.end());
  }

  sort(head.begin(), head.end(), greater<int>());
  sort(tail.begin(), tail.end(), greater<int>());

  int H=head.size();
  int T=tail.size();
  vl head_cum(H+1);
  vl tail_cum(T+1);
  head_cum[0]=0;
  tail_cum[0]=0;

  for (int i=1;i<H+1;i++){
    head_cum[i]=head_cum[i-1]+head[i-1];
  }

  for (int i=1;i<T+1;i++){
    tail_cum[i]=tail_cum[i-1]+tail[i-1];
  }

  ll best=0;
  for (int n_unique=1;n_unique<=H;n_unique++){
    if (n_unique<=K&&K-n_unique<=T){
      ll tmp=head_cum[n_unique]+tail_cum[K-n_unique]+(ll)n_unique*n_unique;
      best=max(tmp, best);
    }
  }
  return best;
}

int main(){
  int N, K;cin>>N>>K;
  vi t, d;
  for (int i=0;i<N;i++){
    int t_, d_;cin>>t_>>d_;
    t.push_back(t_);
    d.push_back(d_);
  }
  cout << solve(N, K, t, d);
  return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

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

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    int N,R;
    cin >> N >> R;

    int ans = (N>=10) ? R : (R+100*(10-N)) ;
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, p[max_n], nxt[max_n], used[max_n], ans[max_n];
vector<int> g[max_n], g2[max_n];

bool dfs(int v) {
    if (used[v]) {
        return false;
    }
    used[v] = 1;
    for (int to : g[v]) {
        if (p[to] == -1) {
            p[to] = v;
            nxt[v] = to;
            return true;
        }
    }
    for (int to : g[v]) {
        if (dfs(p[to])) {
            p[to] = v;
            nxt[v] = to;
            return true;
        }
    }
    return false;
}

void dfs2(int v) {
    used[v] = 1;
    for (int to : g2[v]) {
        if (used[to] == 0) {
            dfs2(to);
            ans[to] = nxt[v];
        }
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i + 1 < n; ++i) {
        int k;
        scanf("%d", &k);
        g[i].resize(k);
        for (int &x : g[i]) {
            scanf("%d", &x);
            --x;
        }
    }
    memset(nxt, -1, sizeof(nxt));
    memset(p, -1, sizeof(p));
    for (int run = 1; run; ) {
        run = 0;
        memset(used, 0, sizeof(used));
        for (int i = 0; i + 1 < n; ++i) {
            if (nxt[i] == -1 && dfs(i)) {
                run = 1;
            }
        }
    }
    for (int i = 0; i + 1 < n; ++i) {
        if (nxt[i] == -1) {
            puts("-1");
            return 0;
        }
    }
    int root;
    for (int i = 0; i < n; ++i) {
        if (p[i] == -1) {
            root = i;
            break;
        }
    }
    p[root] = n - 1;
    nxt[n - 1] = root;
    for (int i = 0; i + 1 < n; ++i) {
        for (int to : g[i]) {
            if (to != nxt[i]) {
                g2[p[to]].push_back(i);
            }
        }
    }
    memset(used, 0, sizeof(used));
    dfs2(n - 1);
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            puts("-1");
            return 0;
        }
    }
    for (int i = 0; i + 1 < n; ++i) {
        printf("%d %d\n", nxt[i] + 1, ans[i] + 1);
    }
    return 0;
}


Measured memory_bytes: 17664
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
namespace io
{
	const int N=1<<20;
	char buf[N],*t1=buf,*t2=buf;
	#ifdef cjy 
	#define getc() getchar()
	#else
	#define getc() t1==t2&&(t2=(t1=buf)+fread(buf,1,N,stdin),t1==t2)?EOF:*t1++
	#endif
	inline int read()
	{
		static int an,f;an=0,f=1;
		static char ch;ch=getc();
		while(ch<48||ch>57)ch=='-'?f=-1:0,ch=getc();
		while(ch>=48&&ch<=57)an=(an<<3)+(an<<1)+(ch^48),ch=getc();
		return an*f;
	}
	char buff[N],*T=buff;
	inline void flush(){fwrite(buff,1,T-buff,stdout);}
	inline void putc(char ch){T==buff+N?flush(),T=buff:0;*T++=ch;}
	inline void print(int x)
	{
		if(!x){putc('0');return;}
		static int st[20],tp;
		while(x)st[++tp]=x%10,x/=10;
		while(tp)putc(st[tp--]^48);
	}
}
using io::read;
using io::putc;
using io::flush;
using io::print;
int h1,m1,h2,m2,k;
int main()
{
	scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
	printf("%d",h2*60+m2-h1*60-m1-k);
	flush();
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
 
int main (){
  int N,X,T;
  cin>>N>>X>>T;
  cout<<(((N-1)/X)+1)*T;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;
int c[5];

int main() {
    int n;
    cin>>n;
    string s;
    while(n-->0){
        cin>>s;
        if(s[0]=='A') c[1]++;
        else if(s[0]=='W') c[2]++;
        else if(s[0]=='T') c[3]++;
        else if(s[0]=='R') c[4]++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",c[1],c[2],c[3],c[4]);
    return 0;
}

Measured memory_bytes: 3692
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define                   pi acos(-1)
map<string,int>mp;

int main () {
    string s,ss;
    cin>>s>>ss;
    ss.erase(ss.size()-1,1);
    if(s==ss) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    End
}
/* pray for me
Do before die
*/


Measured memory_bytes: 3592
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e18;
const int inf = 2e9;
const int nmax = 5e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

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

    string s;
    cin>>s;
    if(s.back()=='s') s+="es";
    else s.push_back('s');
    cout<<s<<"\n";

}
/*
*/


Measured memory_bytes: 3640
N = int(input())
AA = list(map(int,input().split()))

aa = [0]*N
for a in AA:
  aa[a-1] += 1
ans = 0
for i in range(N):
  if aa[i-1] > 1:
    ans += int(aa[i-1]*(aa[i-1]-1)/2)
for i in range(N):
  if aa[AA[i]-1] >1:
    print(int(ans-aa[AA[i]-1]+1))
  else:
    print(ans)


Measured memory_bytes: 24744
import sys
#import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
s = list(rs()+"R")
cnt=0
ans=[0]*(len(s)-1)
for i in range(len(s)-1):
    cnt+=1
    if s[i]=="R" and s[i+1]=="L":
        ans[i]+=cnt-(cnt//2)
        ans[i+1]+=cnt//2
        cnt=0
        hook=i
        continue
    if s[i]=="L" and s[i+1]=="R":
        ans[hook]+=cnt//2
        ans[hook+1]+=cnt-(cnt//2)
        cnt=0
        continue
print(*ans)


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

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};

int main(void) 
{
    int n, m;
    cin >> n >> m;
    UnionFind tree(n);
    rep(i,m)
    {
        int a, b;
        cin >> a >> b;
        tree.unite(a,b);
    }
    int ans = 0;
    rep(i,n) ans = max(ans, tree.size(i));
    cout << ans << endl;

}

Measured memory_bytes: 4020
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<int> L(N); cin >> L;
  sort(L.begin(),L.end());

  int cnt = 0;
  for (int i = 0; i < N-1; ++i) {
    for (int j = i + 1; j < N-1; ++j) {
      auto it = lower_bound(L.begin(), L.end(), L[i] + L[j]);
      int k = it - L.begin();
      cnt += k - j - 1;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#define N 100
#define INF 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int color[N];
int M[N][N];
int d[N];
int p[N];
int n;

void dijkstra(void);

int main()
{
    int i,j,u,k,v,c;
    
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        for(j = 0;j < n;j++){
            M[i][j] = INF;
        }
    }
    
    for(i = 0;i < n;i++){
        scanf("%d %d",&u,&k);
        for(j = 0;j < k;j++){
            scanf("%d %d",&v,&c);
            M[u][v] = c;
        }
    }
    
    dijkstra();
    
    return 0;
}

void dijkstra(void)
{
    int minv,i,v;
    int u;
    
    for(i = 0;i < n;i++){
        d[i] = INF;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    
    while(1){
        minv = INF;
        u = -1;
        for(i = 0;i < n;i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        
        color[u] = BLACK;
        for(v = 0;v < n;v++){
            if(color[v] != BLACK && M[u][v] != INF){
                if(d[v] > d[u] + M[u][v]){
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(i = 0;i < n;i++){
        if(d[i] == INF){
            printf("%d %d\n",i,-1);
        }
        else{
            printf("%d %d\n",i,d[i]);
        }
    }
}



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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
    rep(i, n) {
        if (s[i] == "AC") c0++;
        if (s[i] == "WA") c1++;
        if (s[i] == "TLE") c2++;
        if (s[i] == "RE") c3++;
    }
    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
    return 0;
}

Measured memory_bytes: 6408
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 文字の数 */
	private static final int N = 26;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			char[][] s = new char[n][];
			IntStream.range(0, n).forEach(i -> s[i] = scanner.next().toCharArray());
			int[] result = new int[N];
			int[] temp = new int[N];
			if (n > 0) {
				calcResult(s[0], result, result);
				IntStream.range(1, s.length).forEach(i -> calcResult(s[i], temp, result));
			}
			System.out.println(getResult(result));
		}
	}

	/**
	 * @param s      文字列
	 * @param temp   一時計算結果格納用
	 * @param result 共通計算結果格納用
	 */
	private static void calcResult(char[] s, int[] temp, int[] result) {
		Arrays.fill(temp, 0);
		IntStream.range(0, s.length).forEach(i -> temp[s[i] - 'a']++);
		if (temp != result) {
			// 2回目以降の実行ではtempとresultをマージする
			IntStream.range(0, N).forEach(i -> result[i] = Math.min(temp[i], result[i]));
		}
	}

	/**
	 * @param result 各文字の数
	 * @return 計算結果
	 */
	private static String getResult(int[] result) {
		StringBuilder sb = new StringBuilder();
		IntStream.range(0, N).forEach(i -> IntStream.range(0, result[i]).forEach(j -> sb.append((char) (i + 'a'))));
		return sb.toString();
	}
}


Measured memory_bytes: 26708