akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

typedef struct{
  char city[11];
  int P;
  int index;
} guideBook;

void swap_struct(guideBook *x,guideBook*y){
  guideBook temp = *x;
  *x = *y;
  *y = temp;
}

void sort(guideBook a[], int n){
  for (int i = 0; i < n-1; i++){
    for (int j = n-1; j > i; j--){
      if (strcmp(a[j-1].city,a[j].city)>0){
        swap_struct(&a[j-1],&a[j]);
      }
    }
  }
}


int main(){

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

guideBook G[N];

for (int i = 0; i < N; i++){
    scanf("%s %d",G[i].city,&G[i].P);
    G[i].index = i;
}

sort(G,N);

for (int i = 0; i < N-1; i++)
{
  int j = i+1;
  while (strcmp(G[i].city,G[j].city)==0)
  {
    if (G[i].P < G[j].P){ 
      swap_struct(&G[i],&G[j]);
    }
    j++;
  }     
}

for (int i = 0; i < N; i++)
{
  printf("%d\n",G[i].index+1);
}




return 0;

}

Measured memory_bytes: 1704
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpii = vector<pii>;
using vpll = vector<pll>;

int main(){
  long A, B, K;
  cin >> A >> B >> K;

  if(A >= K){
    cout << A - K << ' ' << B << endl;
  } else if(B >= (K - A)){
    cout << 0 << ' ' << B - (K - A) << endl;
  } else{
    cout << 0 << ' ' << 0 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k = 0;
	char str[15],str2[15],str3[15];
	scanf("%lld",&n);
	if (n < 1200) { printf("ABC"); }
	else {
		printf("ARC");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n;
  vector<string> ss(n);
  for(int i=0;i<n;i++){cin>>ss.at(i);}
  cin>>m;
  vector<string> ts(m);
  for(int i=0;i<m;i++){cin>>ts.at(i);}
  int max_count=0;
  for(int i=0;i<n;i++){
    int count=1;
    string card=ss.at(i);
    for(int j=0;j<n;j++){
      if(i==j){continue;}
      else if(ss.at(i)==ss.at(j)){count++;}
    }
    for(int j=0;j<m;j++){
      if(ss.at(i)==ts.at(j)){count--;}
    }
    max_count=max(count,max_count);
  }
  cout<<max_count<<endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define Ans(s) cout << s << endl

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

typedef long long ll;
typedef vector<int> inv;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int n;

vector<int> c;
vector<int> s;
vector<int> f;

int main()
{
	cin >> n;
	c.resize(n);
	s.resize(n);
	f.resize(n);

	rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];

	rep(i, n)
	{
		int t = 0;

		for (int j = i; j < n - 1; j++)
		{
			if (t < s[j]) t = s[j];
			else if (t % f[j] == 0);
			else t += f[j] - t % f[j];

			t += c[j];
		}
		cout << t << endl;
	}
}

Measured memory_bytes: 256
A, B, C, D, E, F = [int(i) for i in input().split()]

max_sugar = 0
max_water = 100 * A
max_conc = 0.0
A_limit = F // (100 * A)
for i in range(A_limit + 1):
    B_limit = (F - 100 * A * i) // (100 * B)
    for j in range(B_limit + 1):
        if i == 0 and j == 0:
            continue
        water_rate = A * i + B * j
        sugar_limit = min(E * water_rate, F - 100 * water_rate)

        sugar = 0
        for c in range(sugar_limit // C + 1):
            d = (sugar_limit - c * C) // D
            temp_sugar = c * C + d * D
            sugar = max(sugar, temp_sugar)
        temp_cons = sugar / (sugar + 100 * water_rate)
        if temp_cons > max_conc:
            max_conc = temp_cons
            max_water = 100 * water_rate
            max_sugar = sugar
print("{} {}".format(max_water + max_sugar, max_sugar))


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << distance(d.begin(), unique(d.begin(), d.end())) << endl;
    return 0;
}


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

int main() {
    int h, w;
    char s[50][50];
    cin >> h >> w;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> s[i][j];
        }
    }
    const int dx[4] = {0, 0, 1,-1};
    const int dy[4] = {1,-1, 0, 0};
    bool can1 = true;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (s[i][j] == '.') continue;
            
            bool can2 = false;
            for (int d=0; d<4; d++) {
                int ni = i + dy[d];
                int nj = j + dx[d];

                if (ni < 0 || ni >= h) continue;
                if (nj < 0 || nj >= w) continue;
                if (s[ni][nj] == '#') can2 = true;
            }
            if (!can2) {
                can1 = false;
                break;
            }
        }
    }
    
    if (can1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
S1 = int(S[0:2])
S2 = int(S[2:])

if 0 < S1 and S1 < 13:
	if 0 < S2 and S2 < 13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 0 < S2 and S2 < 13:
		print("YYMM")
	else:
		print("NA")

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"



void Main()
{
	string S,T;
	cin>>S>>T;
	int cnt=0;
	rep(i,S.size()){
		cnt += (S[i]!=T[i]);
	}
	cout<<cnt<<_n;
}



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


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,x,a;
    cin>>n>>x;
    std::deque<long long int> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end());
    long long int count=0;
    for (int i=0;i<n;i++) {
        if (x-deq[i]>=0) {
            count++;
            x-=deq[i];
        } else {
            cout<<count<<endl;
            return 0;
        }
    }
    if (x>0) {
        cout<<count-1<<endl;
    } else {
        cout<<count<<endl;
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

void svtr(vector<int> &a){
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
}

int main() {
  string s;
  cin >> s;
  if(s=="A"||s=="T")
    cout << (s == "A" ? 'T' : 'A');

  else
    cout << (s == "C" ? 'G' : 'C');
  return 0;
}


Measured memory_bytes: 256
A, B, M = map(int, input().split())
fridge_prices = list(map(int,input().split()))
wave_prices = list(map(int,input().split()))
coupons =[list(map(int,input().split()))for _ in range(M)]

fridge_min = min(fridge_prices)
wave_min = min(wave_prices)

f_min_index = fridge_prices.index(fridge_min)
w_min_index = wave_prices.index(wave_min)

no_coupon_min = fridge_prices[f_min_index] + wave_prices[w_min_index]

min_price = no_coupon_min

for i in range(M):
  tp = fridge_prices[coupons[i][0] - 1] + wave_prices[coupons[i][1] - 1]  - coupons[i][2]
  if min_price > tp:
    min_price = tp
print(min_price)

Measured memory_bytes: 38576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    cout << (x-a)%b << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s;
		Map<String, Integer> poll = new TreeMap<String, Integer>();
		int max = 0;
		
		for(int i = 0; i < n; i++){
			s = scan.next();
			
			if(poll.containsKey(s)){
				poll.put(s, poll.get(s)+1);
			}
			else{
				poll.put(s, 1);
			}
		}
		
        for (String key : poll.keySet()) {
        	if(max < poll.get(key)){
        		max = poll.get(key);
        	}
		}
        
        Object[] mapkey = poll.keySet().toArray();
        Arrays.sort(mapkey);
        
        for (String key : poll.keySet()) {
        	if(poll.get(key)== max){
    			System.out.println(key);        		
        	}
		}
		
	}
}

Measured memory_bytes: 85712
#include <stdio.h>
#include <math.h>
int f[168],z[]={24,23,25,12,36,11,13,35,37,22,26,48,0},x,y,s;
int main(void){
	for(;~scanf("%d,%d,%d",&x,&y,&s);)
		for(s*=4;s+1;++f[y*12+x+z[s--]]);
	for(x=y=0,s=23;++s<144;s%12<10?y=fmax(y,f[s]),f[s]&&++x:0);
	return!printf("%d\n%d\n",100-x,y);
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;                

//#define INT_MAX 0x7fffffff

typedef long long lld;
typedef long double llf;
typedef pair<int, int> pii;

int main(void) {
    
    lld arr[5];
    lld N,min,ind;
    lld ans;
    
    min = 0x7fffffffffffffff;
    cin>>N;
    
    for(int i=0;i<5;i++) {
        cin>>arr[i];
        if(arr[i]<min){
            min=arr[i];
            ind = i;
        }
    }
    
    if(N%min==0) ans=N/min-1;
    else ans = N/min;
    
    ans+=5;
    
    cout<<ans;
    
    return 0;
}







































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define INF 2147483647 // 2^31-1
 
vector<int> value; // ノードの値を持つ配列
int N;             // 葉の数
 
// i 番目の葉の値を x に変える
void update(int i, int x) {
    i += N - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = min(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の min を計算しなおす
    }
}
 
// [a, b) の区間に対するクエリについてノード k （区間 [l, r) 担当）が答える 
//query(s, t + 1, 0, 0, N)でas,as+1,...,atの最小値を答える
int query(int a, int b, int k, int l, int r) {
    
    if (r <= a || b <= l) return INF; // 区間が被らない場合は INF を返す
    if (a <= l && r <= b)
        return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
                         // に完全に含まれる
    else {
        int c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        int c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return min(c1, c2); // 左右の子の値の min を取る
    }
}
 
int main(void) {
    int n, q;
    cin >> n >> q;
    N = 1;
    while (N < n) N *= 2; // 葉の数を計算（n以上の最小の2冪数）
 
    value = vector<int>(2 * N - 1, INF);
 
    for (int j = 0; j < q; j++) {
        int c; cin >> c;
        if (c == 0) {
            // update(i, x)
            int i, x;
            cin >> i >> x;
            update(i, x);
        } 
        else {
            // find(s, t)
            int s, t;
            cin >> s >> t;
            cout << query(s, t + 1, 0, 0, N) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<stdio.h>
using namespace std;
int main(void) {
	int n;
	int x;
	int t;
	int a;


	scanf("%d%d%d", &n,&x,&t);
	a = n / x;
	if (n%x == 0) {
		cout << a * t;
	}
	else {
		cout << (a + 1) * t;
	}






	return 0;
}

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

int main() {
  string s;
  cin >> s;

  if(s[0] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
    }
  else if(s[1] == s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
    }
  else {
    cout << "No" << endl;

}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int N = in.nextInt();
			int A = in.nextInt();
			int B = in.nextInt();
			int[] t = new int[N];
			for (int i = 0; i < t.length; i++) {
				t[i] = in.nextInt();
				if (A<=t[i]&&t[i]<B) {
					N--;
				}
			}
			System.out.println(N);
		}
		
		
	}
}

Measured memory_bytes: 9808
#!/usr/bin/env python3
import sys


def solve(L: int):
    tmp = L
    a = []
    while tmp > 0:
        a.append(tmp)
        tmp //= 2
    a.reverse()
    #print(a)
    e = []
    for i in range(1, len(a)):
        e.append([i, i + 1, 0])
        e.append([i, i + 1, a[i - 1]])
        if a[i] % 2 > 0:
            e.append([1, i + 1, a[i] - 1])
    print(len(a), len(e))
    for t in e:
        print(t[0], t[1], t[2])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    solve(L)

if __name__ == '__main__':
    main()


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

int main(){
    //入力
    string S;
    bitset<26> alphabet;

    cin >> S ;

    //処理
    int num;
    bool ans=true;
    for(int i=0;i<S.size();i++){
        num=S.at(i)-'a';
        if(alphabet.test(num)){
            cout << "no" << endl;
            ans = false;
            break;
        }else{
            alphabet.set(num);
        }
    }
    
    if(ans){
        cout << "yes" << endl;
    }

}

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

bool d[52][52][52][52];
int X, Y, tx, ty, kx, ky;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}, mem[52][52];

int main()
{
loop:
  cin >> X >> Y;
  if(!X)
    return 0;
  cin >> tx >> ty >> kx >> ky;
  for(int y = 1; y <= Y; y++)
  {
    for(int x = 1; x <= X; x++)
    {
      int a;
      cin >> a;
      mem[y][x] = a;
    }
    mem[y][0] = 1;
    mem[y][X + 1] = 1;
  }
  for(int x = 0; x <= X + 1; x++)
  {
    mem[0][x] = 1;
    mem[Y + 1][x] = 1;
  }

  fill_n((bool*)d, 52 * 52 * 52 * 52, false);
  
  queue<int> q;
  q.push(tx);
  q.push(ty);
  q.push(kx);
  q.push(ky);
  q.push(0);
  while(!q.empty())
  {
    int x1 = q.front(); q.pop();
    int y1 = q.front(); q.pop();
    int x2 = q.front(); q.pop();
    int y2 = q.front(); q.pop();
    int n = q.front(); q.pop();
    
    if(n > 100)
    {
      break;
    }
    
    if(y1 == y2 && x1 == x2)
    {
      cout << n << endl;
      goto loop;
    }

    for(int i = 0; i < 4; i++)
    {
      int tx1 = x1 + dx[i];
      int ty1 = y1 + dy[i];
      int tx2 = x2 - dx[i];
      int ty2 = y2 - dy[i];

      if(mem[ty1][tx1])
      {
        tx1 = x1;
        ty1 = y1;
      }
      if(mem[ty2][tx2])
      {
        tx2 = x2;
        ty2 = y2;
      }
      if(d[tx1][ty1][tx2][ty2])
        continue; 

      d[tx1][ty1][tx2][ty2] = true;
      q.push(tx1);
      q.push(ty1);
      q.push(tx2);
      q.push(ty2);
      q.push(n + 1);
    }
  }
  cout << "NA" << endl;
  goto loop;
}

Measured memory_bytes: 8720
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if((x - r) >= 0 && (x + r) <= W && (y - r) >= 0 && (y + r) <= H){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26344
import java.io.IOException;
import java.util.*;

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

		while (true) {
			int H = in.nextInt();
			int W = in.nextInt();
			if (H == 0 && W == 0) return;

			in.nextLine();

			String[] map = new String[H + 200];
			String str = "";
			for (int i = 0; i < W + 2; i++) {
				str += ".";
			}
			map[0] = str;
			for (int i = 1; i <= H; i++) {
				String s = in.nextLine();
				map[i] = "." + s + ".";
			}
			map[H + 1] = str;

			solve(H, W, map);
		}
	}

	public static void print(String[] map, int H, int W) {
		for (int i = 0; i < H + 2; i++) {
			for (int j = 0; j < W + 2; j++) {
				System.out.print(map[i].charAt(j));
			}
			System.out.println("");
		}
	}

	public static void solve(int H, int W, String[] map) {
//		print(map, H, W);
		boolean visited[][] = new boolean[H + 200][W + 200];
		int ans = 0;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if (!visited[i][j]) {
					dfs(visited, map, "" + map[i].charAt(j), i, j);
					ans++;
				}
			}
		}
		System.out.println(ans);
	}

	public static void dfs(boolean[][] visited, String[] map, String key, int h, int w) {
		Stack<P> sta = new Stack<>();
		sta.push(new P(h, w));
		while (sta.isEmpty() == false) {
			P p = sta.pop();
			h = p.h;
			w = p.w;
			visited[h][w] = true;
			int di[] = {0, 0, -1, +1};
			int dj[] = {+1, -1, 0, 0};
			for (int i = 0; i < 4; i++) {
				int ni = h + di[i];
				int nj = w + dj[i];
				if (visited[ni][nj] == false && ("" + map[ni].charAt(nj)).equals(key)) {
					sta.push(new P(ni, nj));
//					dfs(visited, map, key, ni, nj);
				}
			}
		}
	}
}

class P {
    int h;
    int w;

    P(int h, int w) {
        this.h = h;
        this.w = w;
    }
}

Measured memory_bytes: 38504
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cstdio>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<set>
#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)
#define INF9                1000000010
#define INF18               1000000000000000010
#define dist(ax,ay,bx,by)   sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define m_p(a,b)            make_pair(a,b)
#define sqr(a)              ((a)*(a))
#define pb                  push_back
#define bpll(a)             __builtin_popcountll(a)
#define MX                  1000006
#define PI                  acos(-1)
#define mod                  1000000007
#define cnt_bin(n)          __builtin_clzll(0ll) - __builtin_clzll(n)

typedef long long lli;
using namespace std;

int main()
{
    lli n, x, t;
    cin>>n>>x>>t;

    lli div= n/x;
    if(n%x) div++;

    cout<<div*t<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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


int main (){
    int n;
    cin >> n;
    if(n == 3){
        cout << 180 << "\n";
    }else{
        cout << 180*(n-2) << "\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcm(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcm(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcm(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    vector<int> v(3);
    rep(i, 3) cin >> v[i];
    sort(v.begin(), v.end());
    int k = 2 * v[2] - v[1] - v[0];
    if(k % 2 == 0) cout << k / 2 << endl;
    else cout << k / 2 + 2 << endl;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
typedef long long ll;
ll N, M, R, r[10], val[210][210], res;
bool used[10];
const ll INF = 320000000000000000;

void dfs(ll x, ll y, ll z){
    if (x == R) {
        res = min(res, y);
        return;
    } else {
        for (ll i = 0; i < R; i++) {
            if (used[i]) continue;
            used[i] = true;
            if (x == 0) {
                dfs(1, 0, i);
            } else {
                dfs(x + 1, y + val[r[z]][r[i]], i);
            }
            used[i] = false;
        }
        return;
    }
}

int main(void){
    // Your code here!
    cin >> N >> M >> R;
    for (ll i = 1; i <= N; i++) {
        for (ll j = 1; j <= N; j++) {
            if (i == j) {
                val[i][j] = 0;
            } else {
                val[i][j] = INF;
            }
        }
    }
    for (ll i = 0; i < R; i++) cin >> r[i];
    for (ll i = 0; i < M; i++) {
        ll A, B, C;
        cin >> A >> B >> C;
        val[A][B] = C;
        val[B][A] = C;
    }
    for (ll k = 1; k <= N; k++) {
        for (ll i = 1; i <= N; i++) {
            for (ll j = 1; j <= N; j++) {
                val[i][j] = min(val[i][k] + val[k][j], val[i][j]);
            }
        }
    }
    res = INF;
    dfs(0, 0, 0);
    cout << res << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(){
    int n,m;
    cin >>n;
    vector<int> t(n);
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int p,x;
        int ans = 0;
        cin >> p >> x;
        for(int i=0;i<n;i++){
            if(i==p-1){
                ans +=x;
            }else{
                ans +=t[i];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (int i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": ";
    printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

string s;
ll N;
vector<ll> a;

ll calc(ll i) {
  if (a[i] > 0) { return a[i]; }

  if (i > 0 && i < N-1) {
    if (s[i-1] == '>' && s[i] == '<') {
      return a[i] = 0;
    } else if (s[i-1] == '<' && s[i] == '>') {
      ll m = max(calc(i-1), calc(i+1));
      return a[i] = m+1;
    } else if (s[i-1] == '<' && s[i] == '<') {
      return a[i] = calc(i-1) + 1;
    } else { // > >
      return a[i] = calc(i+1) + 1;
    }
  } else if (i == 0) {
    if (s[i] == '<') {
      return a[i] = 0;
    } else { // >
      return a[i] = calc(i+1) + 1;
    }
  } else { // i == N-1
    if (s[i-1] == '<') {
      return a[i] = calc(i-1) + 1;
    } else { // >
      return a[i] = 0;
    }
  }
}
int main(int argc, char** argv) {
  cin >> s;
  N = s.size() + 1;
  a.assign(N, -1);

  rep(i, N) {
    calc(i);
  }
  ll ans = 0;
  rep(i, N) {
    ans += a[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 28164
// =====================================================================================
//
//       Filename:  atcoder.cpp
//
//    Description:  
//
//        Version:  1.0
//        Created:  26/04/20 03:38:51 AM IST
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Kiran Bhanushali (), kiranbhanushali143.kb143@gmail.com
//   Organization:  
//
// =====================================================================================

#include<bits/stdc++.h>


using namespace std;

#define int long long 
#define pb push_back
//#define _SHOW_TIME
int mp[100007];
void solve(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    int mx = 0; 
    for(int i =1; i<1e5+7;i++){
        mx = max(mx , mp[i] + mp[i-1] + mp[i+1]);
    }
    cout<<mx<<endl;
}
int32_t main(){
 /////////////////////////////////////
    #ifdef _SHOW_TIME
	int tt = (int) clock();
    #endif
    /////////////////////////////////////
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /////////////////////////////////////
    solve();
    /////////////////////////////////////
    #ifdef _SHOW_TIME
        cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
    #endif
    /////////////////////////////////////
    return 0;

}




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

int main(){
	int A, B, C, D;
	int test;
	cin >> test;
	A = test / 1000;
	B = test / 100 % 10;
	C = test / 10 % 10;
	D = test % 10;
	if(A+B+C+D==7){
		cout << A <<'+'<< B <<'+'<< C <<'+'<< D <<"=7"<< endl;
		return 0;
	}
	if(A+B+C-D==7){
		cout << A <<'+'<< B <<'+'<< C <<'-'<< D <<"=7"<< endl;
		return 0;
	}
	if(A+B-C+D==7){
		cout << A <<'+'<< B <<'-'<< C <<'+'<< D <<"=7"<< endl;
		return 0;
	}
	if(A+B-C-D==7){
		cout << A <<'+'<< B <<'-'<< C <<'-'<< D <<"=7"<< endl;
		return 0;
	}
	if(A-B+C+D==7){
		cout << A <<'-'<< B <<'+'<< C <<'+'<< D <<"=7"<< endl;
		return 0;
	}
	if(A-B+C-D==7){
		cout << A <<'-'<< B <<'+'<< C <<'-'<< D <<"=7"<< endl;
		return 0;
	}
	if(A-B-C+D==7){
		cout << A <<'-'<< B <<'-'<< C <<'+'<< D <<"=7"<< endl;
		return 0;
	}
	if(A-B-C-D==7){
		cout << A <<'-'<< B <<'-'<< C <<'-'<< D <<"=7"<< endl;
		return 0;
	}
}

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

int main() {
    int n;
    cin >> n;
    int A[200005];
    int a[200005];

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        ans += A[a[i]];
        A[a[i]]++;
    }

    for (int i = 1; i <= n; i++) {
        cout << ans - A[a[i]]+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
	int n, x;
	scanf("%d%d", &n, &x);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
	}

	int ans = 0;
	for(int i=1;i<=n;i++){
		int d = abs(a[i]-x);
		ans = __gcd(ans, d);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, a, b, c;
int Q, K, x[100010], y[100010];

/*==================================================*/
/*function*/
vector<pair<ll, ll>> edge[100010];   //<ノード, 距離>
ll d[100010];   //始点ノードからノードiへの最短距離
ll start;  //開始ノード番号

void dijkstra() {
    priority_queue< pair<ll, ll> > PQ;  //<(-1)*最短距離, ノード番号>

    REP(i,0,N) d[i] = LLINF;
    d[start] = 0;
    PQ.push(make_pair(0,start));  //開始ノードを0とする。

    while(!PQ.empty()){
        ll curCost = -PQ.top().first;
        ll curNode = PQ.top().second;
        PQ.pop();

        if(d[curNode] < curCost) continue;
        d[curNode] = curCost;

        REP(i,0,edge[curNode].size()){
            ll nextNode = edge[curNode][i].first;
            ll addCost = edge[curNode][i].second;

            if(d[nextNode] > d[curNode] + addCost){
                d[nextNode] = d[curNode] + addCost;
                PQ.push(make_pair(-d[nextNode], nextNode));
            }
        }
    }
}
/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N-1){
        cin>>a>>b>>c;
        edge[a-1].emplace_back(b-1, c);
        edge[b-1].emplace_back(a-1, c);
    }

    cin>>Q>>K;
    REP(i,0,Q){
        cin>>x[i]>>y[i];
    }

    start = K-1;
    dijkstra(); //Kを起点にすべてのノードへの最短距離を計算

    REP(i,0,Q){
        cout<<d[x[i]-1]+d[y[i]-1]<<endl;
    }
    return 0;
}


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

int main() {

  int N;
  string S; cin>>N>>S;

  for(int i =0; i<S.length();i++){
    if((int)S.at(i) + N>90){
      S.at(i)=(char)((int)S.at(i) + N -26);}
    else{S.at(i)=(char)((int)S.at(i) + N);}
  }

	cout<<S<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

int main(){
	fast;
	
	ll int h,a;
	cin>>h>>a;
	
	ll int b[a];
	ll int sum=0;
	
	forr(i,0,a){
		cin>>b[i];
		sum+=b[i];
	}
	
	if(sum>=h)
	cout<<"Yes";
	
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n%2==0&&s.substr(0,n/2)==s.substr(n/2,n/2)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
//#define mp make_pair
#define pb push_back
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdi pair<double, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

int a, b, t;
int main() {
	scanf("%d %d %d", &a, &b, &t);
	printf("%d\n", t/a*b);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    double Xd = (double)N / 1.08;
    int Xi = (Xd == (int)Xd) ? (int)Xd : (int)Xd + 1;

    if ((int)(Xi * 1.08) != N) {
        cout << ":(" << endl;
        return 0;
    }

    cout << Xi << endl;
    return 0;
}


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

int main(){
    int a1, a2, b1, b2;
    cin >> a1 >> a2 >> b1 >> b2;
    int x = b1 - a1;
    int y = b2 - a2;

    cout << b1 - y << " " << b2 + x << " " << a1 - y << " " << a2 + x << endl;
    return 0;
}

Measured memory_bytes: 256
/*
[abc137] F - Polynomial Construction
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_P = 2999;
int MOD;

class gf {
public:
    int n;
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator-(const gf x) const { return gf((n - x.n + MOD) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
    gf& operator+=(const gf x) { return *this = (*this + x); }
    gf& operator-=(const gf x) { return *this = (*this - x); }
    gf& operator*=(const gf x) { return *this = (*this * x); }
};

int p;
int a[MAX_P];
gf c[MAX_P];
gf b[MAX_P];

void solve() {
    c[0] = 1;
    for (int i = 1; i <= p - 1; i++) {
        for (int j = i; j > 0; j--) {
            c[j] += c[j - 1];
        }
    }

    for (int i = 0; i < p; i++) {
        if (a[i] == 0) {
            continue;
        }
        b[0] += 1;
        gf pi = 1;
        for (int j = p - 1; j >= 0; j--) {
            b[j] -= c[j] * pi;
            pi *= -i;
        }
    }

    for (int i = 0; i < p; i++) {
        cout << b[i].n << " ";
    }
    cout << endl;
}

int main() {
    cin >> p;
    MOD = p;
    for (int i = 0; i < p; i++) {
        cin >> a[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 256
class SegmentTree():
    def __init__(self, init, unit, f):
        self.unit = unit
        self.f = f
        if type(init) == int:
            self.n = init
            # self.n = 1 << (self.n - 1).bit_length()
            self.X = [unit] * (self.n * 2)
        else:
            self.n = len(init)
            # self.n = 1 << (self.n - 1).bit_length()
            self.X = [unit] * self.n + init + [unit] * (self.n - len(init))
            for i in range(self.n-1, 0, -1):
                self.X[i] = self.f(self.X[i*2], self.X[i*2|1])
    
    def getvalue(self, i):
        i += self.n
        return self.X[i]
        
    def update(self, i, x):
        i += self.n
        self.X[i] = x
        i >>= 1
        while i:
            self.X[i] = self.f(self.X[i*2], self.X[i*2|1])
            i >>= 1
    
    def add(self, i, x):
        i += self.n
        self.X[i] = (self.X[i] + x) % mod
        i >>= 1
        while i:
            self.X[i] = self.f(self.X[i*2], self.X[i*2|1])
            i >>= 1
    
    def getrange(self, l, r):
        l += self.n
        r += self.n
        al = self.unit
        ar = self.unit
        while l < r:
            if l & 1:
                al = self.f(al, self.X[l])
                l += 1
            if r & 1:
                r -= 1
                ar = self.f(self.X[r], ar)
            l >>= 1
            r >>= 1
        return self.f(al, ar)
    
    def debug(self):
        de = []
        a, b = self.n, self.n * 2
        while b:
            de.append(self.X[a:b])
            a, b = a//2, a
        print("--- debug ---")
        for d in de[::-1]:
            print(d)
        print("--- ---")

def r(a):
    for i in range(1, 10001):
        if i and a * i % mod <= 10000:
            return str(a*i%mod) + "/" + str(i)
        if i and -a * i % mod <= 10000:
            return str(-(-a*i%mod)) + "/" + str(i)
    return a

mod = 998244353
N, K = map(int, input().split())
P = [int(a) - 1 for a in input().split()]
f = lambda a, b: (a + b) % mod

p1 = (K - 1) * (K - 2) * pow(4, mod - 2, mod) % mod
p2 = K * (K - 1) * pow(4, mod - 2, mod) % mod
m = (K - 1) * pow(K, mod - 2, mod) % mod
invm = K * pow(K - 1, mod - 2, mod) % mod

st1 = SegmentTree(N, 0, f)
st2 = SegmentTree(N, 0, f)
ans = p2
for i, x in enumerate(P):
    if i >= K:
        ans = (ans + st1.getrange(x, N)) % mod
    st1.add(x, 1)

s = 1
invs = 1
st = SegmentTree(N, 0, f)
for i, x in enumerate(P[:K]):
    st.add(x, 1)
for i in range(K, N):
    s = s * m % mod
    invs = invs * invm % mod
    x = P[i]
    a = st.getrange(x, N) * s % mod
    ans = (ans + p2 - p1 - a) % mod
    st.add(x, invs % mod)

print(ans)

Measured memory_bytes: 94004
#include<stdio.h>
int main(void) {
  int count = 0,i;
  char s[3];
  scanf("%s", s);
  for (i=0 ; i<=2 ; i++) {
    if (s[i] == '1'){
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1668
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
string names;

string karuta[100100];
int nn[400];
vector<pair<int, int>> workk;
long long summ;
int main() {
	double dice = 0, aim = 0, bunbo1 = 0, bunbo2 = 1, counto = 0, bunsi = 1, summ = 0, manji = 0;
	int a = 0, b = 0;
	cin >> dice>>aim;
	bunbo1 = dice;
	for (int i = 1; i < aim; i=i*2) {
		bunbo2 = bunbo2 * 2;
	}
	counto = bunbo1 * bunbo2;
	for (int i = 1; i <= dice; i++) {
		manji = bunbo2;
		bunsi = i;
		while (bunsi < aim) {
			bunsi = bunsi * 2;
			manji = manji / 2;
		}
		summ += manji;
	}
	
	//cout << summ << ' ' << counto << endl;
	cout << setprecision(15)<<summ / counto  << endl;
	return 0;
}

Measured memory_bytes: 1024
from collections import Counter
N=int(input())
Ss=[input() for i in range(N)]
Ss=Counter(Ss).most_common()
mincount=Ss[0][1]
ans=[]
for s in Ss:
    if s[1]==mincount:
        ans.append(s[0])
for a in sorted(ans):
    print(a)





Measured memory_bytes: 45040
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	vector<pair<int,int> > v;
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if((i+j)%2==0)continue;
			if(i==0||j==0||j==a-1||i==a-1||i%3==0){
				v.push_back(make_pair(i,j));
			}
		}
	}
	printf("%d\n",(int)v.size());
	for(int i=0;i<v.size();i++){
		printf("%d %d\n",v[i].first,v[i].second);
	}
}



Measured memory_bytes: 3568
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    double N,K; cin>>N>>K;
    cout<<ceil((N-1)/(K-1))<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
using namespace std;

int N, K;

int main() {
    cin >> N >> K;
    vector <int> V(N,0), DP(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> V[i];
    }
    DP[0] = 0;
    for (int i = 1; i < N; ++i) {
        DP[i] = 2e9;
        for (int k = max(i - K, 0); k < i; ++k)
            DP[i] = min (DP[i], DP[k] + abs(V[i] - V[k]));
    }
    cout << DP[N - 1];
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<climits>

#define pii pair<int,int>
#define ll long long
#define MOD 1000000007
#define in2d(i,j,H,W)(0<=i&&i<H&&0<=j&&j<W)

using namespace std;
struct SegT{
	vector<ll>container;
	int n;
	void update(int i,ll x){
		int ii=i+n-1;
		container[ii]=x;
		while(ii>0){
			ii=(ii-1)/2;
			//////////////////////////////////////////
			container[ii]=max(container[2*ii+1],container[2*ii+2]);
			//////////////////////////////////////////
		}
	}
	ll get(int l,int r,int l2=0,int r2=-1,int k=0){
		if(r2==-1)r2=n;
		if(r2<=l||r<=l2)return 0;
		if(l<=l2&&r2<=r)return container[k];
		ll vl=get(l,r,l2,(l2+r2)/2,2*k+1);
		ll vr=get(l,r,(l2+r2)/2,r2,2*k+2);
		///////////////////////////
		return max(vl,vr);
		///////////////////////////
	}
	////////////////new///////////////////////
	SegT(vector<int> &A){
		n=pow(2,(int)log2(A.size())+1);
		container=vector<ll>(2*n,0);
		for(int i=0;i<A.size();i++)update(i,A[i]);
	}
	~SegT(){
		delete &container;
	}

};
string K;
int D;
int dp[10010][2][110];
int dfs(int k,int tight,int j){
	if(k==K.size())return j%D==0;
	if(dp[k][tight][j]!=-1)return dp[k][tight][j];
	int x=K[k]-'0';
	int r=(tight==1)?x:9;
	int ans=0;
	for(int i=0;i<=r;i++){
		int t;
		if(tight==0)t=0;
		else if(i==r)t=1;
		else t=0;
		ans+=dfs(k+1,t,(j+i)%D)%MOD;
		ans%=MOD;
	}
	return dp[k][tight][j]=ans%MOD;
}
int main(){
	cout<<fixed<<setprecision(11);
	cin>>K;
	cin>>D;
	for(int k=0;k<K.size();k++)for(int t=0;t<2;t++)for(int j=0;j<D;j++)dp[k][t][j]=-1;
	cout<<(dfs(0,1,0)+MOD-1)%MOD<<endl;
	return 0;
}



Measured memory_bytes: 9984
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
signed main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[25][25]={},dp[1<<22]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      cin >> a[i][j];
    }
  }
  dp[0]=1;
  for(int i=0; i<(1<<n); i++) {
    int cnt=__builtin_popcount(i);
    for(int j=0; j<n; j++) {
      if((i&(1<<j))&&a[cnt-1][j]) {
        (dp[i]+=dp[i^(1<<j)])%=MOD;
      }
    }
  }
  cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 33024
#include <stdio.h>

int main(void) {
   
   int X;
   
   scanf("%d", &X);
   
   int ans = 0;
   
   while (X >= 500) {
      X = X - 500;
      ans = ans + 1000;
   }
   
   while (X >= 5) {
      X = X - 5;
      ans = ans + 5;
   }
   
   printf("%d\n", ans);
   
   return 0;
}



Measured memory_bytes: 128
#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;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


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



int main(){
    string s;cin>>s;
    int k=0;
    rep(i,0,s.size()-1){
        if(s[i]=='S')k++;
        else if(k>0)k--;
    }
    cout<<k*2<<endl;
    return 0;
}


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

using namespace std;

int findIndex(int value,vector<int> v)
{
	auto iter = std::find(v.begin(), v.end(), value);
	size_t index = std::distance(v.begin(), iter);
	if (index == v.size())
	{
		return -1;
	}
	return index;
}

int main() {
	int  N;
	vector<int> a;

	cin >> N;
	for (int i = 0; i < N; i++) {
		int k;
		cin >> k;
		a.push_back(k);
	}
	sort(a.begin(), a.end());
	int num = a[0];
	int count = 1;
	int result = 0;
	for (int i = 1; i < N; i++) {
		if (a[i] == num) {
			count++;
		}
		else {
			if (count % 2 == 1) result++;
			num = a[i];
			count = 1;
		}
	}
	if (count % 2 == 1) result++;
	cout << result << endl;
}


Measured memory_bytes: 892
function main(arg) {
	arg = arg.trim();
	var day = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'];
  	var out = day.indexOf(arg);
  	switch (out) {
      case 0:
        out = 6;
        break;
      case 1:
        out = 5;
        break;
      case 2:
        out = 4;
        break;
      case 3:
        out = 3;
        break;
      case 4:
        out = 2;
        break;
      case 5:
        out = 1;
        break;
      case 6:
        out = 7;
        break;
	}
  console.log(out)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372