akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 0;i * i <= n;i++){
    ret.push_back(i);
    if(i*i != n) ret.push_back(i);
  }
  sort(ALL(ret));
  return ret;
}

signed main()
{
  ios();
  int A,P;  
  cin >> A >> P ;
  cout << (3 * A + P ) /2 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        System.out.println(calc(a));

    }

    private static String calc(int a) {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if (i * j == a) {
                    return "Yes";

                }
            }
        }
        return "No";
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <string>

using namespace std;

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

// stringのソート
// string str = "abccba";
// sort(str.begin(), str.end());
//
// ハッシュテーブル
// unordered_map<string, int> mp;
// mp["aabbcc"] = 0;

// 配列Aにcinする
int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  int maxCount = 0;
  int counter = 0;
  for (int i = 0; i < N - 1; i++) {
    //cout << counter << endl;
    if (H.at(i) >= H.at(i+1)) {
      counter++;
      if (counter > maxCount) maxCount = counter;
    } else {
      counter = 0;
    }
  }
  cout << maxCount << endl;
  return 0;
}

// 標準入出力
//int main() {
//	int a, b;
//	cin >> a >> b;
//  if (a * b % 2 == 0) {
//	  cout << "Even" << endl;
//  } else {
//	  cout << "Odd" << endl;
//  }
//  return 0;
//}

// 文字列を1文字ずつループ
//int main() {
//  string str;
//  cin >> str;
//  int sum = 0;
//  for(int i = 0; i < (int)str.size(); ++i){
//    char ch = str[i];
//
//    if (ch == '1') {
//      sum++;
//    }
//  }
//  cout << sum << endl;
//  return 0;
//}



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

int main() {
    int N, M, Q;
    while (cin >> N >> M >> Q, N || M || Q) {

        vector<string> S(2*Q+1), B(2*Q+1);
        vector<vector<int>> D(2*Q+1, vector<int>(M));

        string str;

        for (int i = 0; i < M; i++) {
            B[0] += '0';
            str += '1';
        }

        for (int i = 1; i <= Q; i++) {
            cin >> S[i-1] >> B[i];

            for (int j = 0; j < N; j++) {
                S[i+Q-1] += (S[i-1][j] == '0' ? '1' : '0');
            }

            for (int j = 0; j < M; j++) {
                if (B[i-1][j] != B[i][j]) {
                    D[i-1][j] = 1;
                } else {
                    D[i+Q-1][j] = 1;
                }
            }
        }

        vector<set<int>> ans(M);
        if (Q == 0) {
            if (N == 1) {
                for (auto &i : ans) i.insert(0);
            }
        } else {
            for (int i = 0; i < N; i++) {
                auto tmp = str;

                for (int j = 0; j < 2*Q; j++) {
                    if (S[j][i] == '0') continue;
                    for (int k = 0; k < M; k++) {
                        if (D[j][k] == 0) tmp[k] = '0';
                    }
                }

                for (int j = 0; j < M; j++) {
                    if (tmp[j] == '1') ans[j].insert(i);
                }
            }
        }

        for (int i = 0; i < M; i++) {
            if (ans[i].size() != 1) cout << '?';
            else if (*(ans[i].begin()) < 10) cout << *(ans[i].begin());
            else cout << (char)('A' + *(ans[i].begin()) - 10);
        }
        cout << endl;
    }

    return 0;
}

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

const int vmax=10010;
const int inf=1023456789;

int N,M;
typedef tuple<int,int,int> node;
vector<node> graph;

int par[vmax];
void init(){rep(i,vmax) par[i]=i;}
int find(int x){return (par[x]==x)?x:par[x]=find(par[x]);}
void unite(int a,int b){a=find(a),b=find(b);par[a]=b;}
bool same(int a,int b){return find(a)==find(b);}

int kruskal(){
	init();
	sort(begin(graph),end(graph));
	int res=inf,num=0;
	for(auto &e:graph){
		int a,b,c;
		tie(c,a,b)=e;
		if(!same(a,b)) unite(a,b),num++;
		if(num==N/2) res=min(res,c);
	}
	return res;
}

int main(void){
	while(cin >> N >> M,N){
		graph.clear();
		rep(i,M){
			int a,b,c;
			cin >> a >> b >> c;
			graph.push_back(node(c,a,b));
		}
		cout << kruskal() << endl;
	}
	return 0;
}

Measured memory_bytes: 1460
#include<stdio.h>

 int main()
 {
 	int a, b, c,t;
 	scanf("%d",&a);
 	scanf("%d",&b);
 	scanf("%d",&c);
	if(a > b )
	{
		t=b,b=a,a=t;
	}
	if(a > c)
	{
		t=c,c=a,a=t;
	}
		
	if(b > c)
	{
		t=c,c=b,b=t;
	}
		
	printf("%d %d %d\n",a, b, c);
 	return 0;
 	
 }


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n, m;
   cin>>n>>m;

   if(n==m) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3632
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

let MOD = 1000000007L

[<EntryPoint>]
let main _ =
    let N = read int64
    let AS = reads int64

    let ds = Array.create 62 0L
    let f n =
        for i in 0 .. 61 do
            let mask = 1L <<< i
            if n &&& mask <> 0L then
                ds.[i] <- ds.[i] + 1L

    Array.iter f AS

    let pow2 = Array.scan ( * ) 1L (Array.replicate 61 2L)

    let mutable ans = 0L
    for i in 0 .. 61 do
        let one = ds.[i]
        let zero = N - one
        let add = ((zero * one) % MOD) * (pow2.[i] % MOD)
        ans <- (ans + add) % MOD

    printfn "%i" ans
    0

Measured memory_bytes: 55996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int ans = 1;
ll a, b;
ll gcd(ll a, ll b){
	if(a < b) swap(a,b);
	while(b){
		a %= b;
		swap(a,b);
	}
	return a;
}
int main(){
	scanf("%lld%lld", &a, &b);
	a = gcd(a,b);
	for(ll i = 2; i*i <= a; i++){
		if(a % i == 0){
			ans++;
			while(a % i == 0) a /= i;
		}
	}
	if(a != 1) ans++;
	printf("%d\n", ans);
}

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 inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;cin>>N;
    int a;
    int max=0;
    int min=1000;
    rep(i,N){
        cin>>a;
        if(a>max){
            max=a;
        }
        if(a<min){
            min=a;
        }
    }
    cout<<max-min<<endl;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int k = obj.nextInt(),a = obj.nextInt(),b = obj.nextInt();
        for(int i=a;i<=b;i++)
            if(i%k==0)
            {
                System.out.print("OK");
                return;
            }
        System.out.print("NG");
    }
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int main() {
  ll N, T;
  cin >> N >> T;

  vector<pair<ll, ll>> P(N);

  rep0(i, N) {
    ll a, b;
    cin >> a >> b;
    P[i] = make_pair(a, b);
  }
  sort(P.begin(), P.end());

  vector<vector<ll>> dp(N + 1, vector<ll>(T + 1, 0));

  ll ans = 0;

  if (P[0].first < T) dp[0][T - 1] = P[0].second;

  rep(i, 1, N){
    ll tempA = P[i - 1].first, tempB = P[i - 1].second;

    rep(j, 0, T) {
      if (j < tempA) {
        dp[i][j] = dp[i - 1][j];
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - tempA] + tempB);
      }
    }
    ans = max(ans, dp[i][T - 1] + P[i].second);
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 70784
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b == c){
        cout <<"Yes" <<endl;
    }
    else if(a+c == b){
        cout << "Yes" << endl;
    }
    else if(b+c == a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl; 
    }
    
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    int p1,p2;
    boolean[] used;
    int[] c1,c2,per;

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        while(n-->0){
            c1 = new int[9];
            c2 = new int[9];
            for(int i=0; i<9; i++) c1[i] = sc.nextInt();
            for(int i=0; i<9; i++) c2[i] = sc.nextInt();

            p1 = 0; p2 = 0;
            used = new boolean[9];
            per = new int[9];
            dfs(0);

            double all = p1+p2;
            System.out.printf("%.5f %.5f\n",p1/all,p2/all);
        }
    }

    void dfs(int pos){
        if(pos==9){
            int s1 = 0, s2 = 0;
            for(int i=0; i<9; i++){
                if(c1[per[i]]>c2[i]) s1 += c1[per[i]] + c2[i];
                else s2 += c1[per[i]] + c2[i];
            }
            if(s1>s2) p1++;
            if(s1<s2) p2++;
            return;
        }
        
        for(int i=0; i<9; i++){
            if(used[i]) continue;
            used[i] = true;
            per[pos] = i;
            dfs(pos+1);
            used[i] = false;
        }
    }

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

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

vector<int> G[200010];
int cnt[200010];

void dfs(int p, int v){
  rep(i,(int)G[v].size()){
    int next=G[v][i];
    if(next==p)continue;//親元に逆流を防ぐ
    cnt[next]+=cnt[v];
    dfs(v,next);
  }
}

int main(int argc, char const *argv[]) {
  int n,x,p,q;
  cin >> n >> q;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--,b--;
    G[a].pb(b);
    G[b].pb(a);
  }

  rep(i,q){
    cin >> p >> x;
    p--;
    cnt[p]+=x;
  }
  dfs(-1,0);

  rep(i,n){
    cout << cnt[i];
    if(i+1<n) cout << " ";
  }
  cout  << endl;
  return 0;
}


Measured memory_bytes: 29696
#include <stdio.h>
#include <stdlib.h>
void MergeSort(long long int x[ ],long long int left,long long int right);
        long long int temp[200001];
int main (void){
int A,B,C;
int X,Y;
scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
if(2*C>=A+B){
  printf("%d\n",A*X+B*Y);
}else if(2*C<=A&&2*C<=B){
  if(X>=Y){
    printf("%d\n",C*2*X);
  }else{
    printf("%d\n",C*2*Y);
  }
}else if(2*C<=A||2*C<=B){
  if (2*C<=A) {
    if (X>=Y) {
      printf("%d\n",C*2*X);
    }else{
      printf("%d\n",C*2*X+B*(Y-X));
    }
  }else{
    if (Y>=X) {
      printf("%d\n",C*2*Y);
    }else{
      printf("%d\n",C*2*Y+A*(X-Y));
    }
  }
}else{
  if (X>=Y) {
    printf("%d\n",C*2*Y+A*(X-Y));
  }else{
    printf("%d\n",C*2*X+B*(Y-X));
  }
}
        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main() {
  int n, a; cin >> n >> a;

  bool flag = false;
  
  n -= 500 * (n / 500);
  if(n <= a) flag = true;
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#define scanf scanf_s
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int l,max,i,j;
    scanf("%d",&l);
    int data[l];
    for(i = 0; i < l;i++){
        scanf("%d",&data[i]);
    }
    max = 0;
    for(i = 0;i < l;i++){
        for(j = i + 1;j < l;j++){
            if(abs(data[i] - data[j]) > max){
                max = abs(data[i] - data[j]);
            }
        }
    }
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 128
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N,K,Q = LI()
A = [0 for i in range(Q)]
for i in range(Q):
    A[i] = int(input()) - 1

cnt = {}

for i in range(N):
    cnt[i] = 0

for a in A:
    cnt[a] += 1

for i in range(N):
    if K - Q + cnt[i] > 0:
        print("Yes")
    else:
        print("No")


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll dfs(ll n,ll x,vl s,vl S){ //層の段,残り層数
    if(n==0)return 1;
    else if(x==1)return 0;
    else if(x>1 && x<= 1+s[n-1])return dfs(n-1,x-1,s,S);
    else if(x==2+s[n-1])return (1+S[n-1]);
    else if(x>2+s[n-1] && x<3+2*s[n-1])return S[n-1]+1+dfs(n-1,x-2-s[n-1],s,S);
    else return (1+2*S[n-1]);
}
signed main()
{   
    gearup;
    ll n,m; cin >> n >> m;

    vector<ll> S(n+1); //パティの数
    vector<ll> s(n+1); //層数
    s[0] = 1;
    S[0] = 1;
    rep1(i,n){
        s[i] = 2*s[i-1] + 3;
        S[i] = 2*S[i-1] + 1;
    }
    
    cout << dfs(n,m,s,S) << endl;
}


Measured memory_bytes: 256
/* ex 9_3
   アカウント名 */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 101

typedef struct queue{
  int size;
  int count;
  double data[SIZE];
  double *head, *tail;
} queue;

void enqueue(queue *que, char elem){
    if(que->count >= que->size){
        fprintf(stderr, "Error: queue overflow. (elem=%c)\n", elem);
        exit(1);
    }
    else{
        *(que->tail) = elem;
        if(que->tail == &(que->data[SIZE - 1])){
            que->tail = &que->data[0];
        }
        else{
            que->tail++;
        }
        que->count++;
    }
}

double dequeue(queue *que){
    char elem;
    if(que->count <= 0){
        fprintf(stderr, "Error: queue underflow.\n");
        exit(1);
    }
    else{
        elem = *(que->head);
        if(que->head == &(que->data[SIZE - 1])){
            que->head = &que->data[0];
        }
        else{
            que->head++;
        }
        que->count--;
        return elem;
    }
}

void initialize_queue(queue *que){
    que->count = 0;
    que->size = SIZE;
    que->head = que->tail = &(que->data[0]);
}


int main(void){
    char str[101], *ptr, tmp;
    int i;
    queue que_list[3];
    for(i = 0; i < 3; i++){
        initialize_queue(&que_list[i]);
        scanf("%s", str);
        ptr = str;
        while(*ptr != '\0'){
            enqueue(&que_list[i], *ptr);
            ptr++;
        }
    }
    tmp = dequeue(&que_list[0]);
    while(1){
        if(tmp == 'a'){
            i = 0;
        }
        else if(tmp == 'b'){
            i = 1;
        }
        else{
            i = 2;
        }
        if(que_list[i].count == 0) break;
        tmp = dequeue(&que_list[i]);
    }
    if(tmp == 'a'){
        printf("A\n");    
    }
    else if(tmp == 'b'){
        printf("B\n");       
    }
    else{
        printf("C\n");       
    }
    return 0;
}


Measured memory_bytes: 1628
open Printf
open Scanf

let () =
  let n, q = scanf "%d %d " (fun u v -> (u, v)) in
  let bs = 300 in
  let bn = (n + bs - 1) / bs in
  let iv = 2147483647 in
  let ar = Array.make (bs * bn) iv in
  let ubk = Array.make bn None in
  let mbk = Array.make bn iv in
  let wb i = match ubk.(i) with
      None -> ()
    | Some v -> let rec iter j =
                  if j = bs then ubk.(i) <- None
                  else begin
                      ar.(i*bs+j) <- v;
                      iter (j+1)
                    end in
                iter 0;
                mbk.(i) <- v
  in
  let fm i = match ubk.(i) with
      Some _ -> ()
    | None -> let rec iter j m =
                if j = bs then mbk.(i) <- m
                else iter (j+1) (min m ar.(i*bs+j)) in
              iter 0 iv
  in
  let update s t x =
    let rec iter i =
      if i >= t then ()
      else
        if i mod bs = 0 && i + bs <= t then
          begin
            ubk.(i / bs) <- Some x;
            mbk.(i / bs) <- x;
            iter (i + bs)
          end
        else
          begin
            wb (i / bs);
            ar.(i) <- x;
            iter (i + 1)
          end
    in
    let fma sb tb =
      let rec loop i =
        if i > tb then ()
        else begin
            fm i;
            loop (i+1)
          end in
      loop sb
    in
    iter s;
    fma (s / bs) ((t-1) / bs)
  in
  let find s t =
    let rec iter i m =
      if i >= t then m
      else
        if i mod bs = 0 && i + bs <= t then
          iter (i + bs) (min m mbk.(i / bs))
        else
          let u = match ubk.(i / bs) with
              None -> ar.(i)
            | Some v -> v in
          iter (i + 1) (min m u)
    in
    iter s iv
  in
  let rec loop c =
    if c = 0 then ()
    else
      begin
        (let com = scanf "%d " (fun u -> u) in
        if com = 0 then
          let s, t, x = scanf "%d %d %d " (fun u v w -> (u, v+1, w)) in
          update s t x
        else
          let s, t = scanf "%d %d " (fun u v -> (u, v+1)) in
          find s t |> printf "%d\n");
        loop (c - 1)
      end
  in
  loop q

Measured memory_bytes: 6852
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 1010

ll inv[N], fac[N], finv[N];

void make()
{
	fac[0] = fac[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = MOD - MOD/i * inv[MOD % i] % MOD;
		finv[i] = inv[i] * finv[i - 1] % MOD;
	}
}

ll C(ll n, ll k)
{
	if(n < k || n < 0) return 0;
	return fac[n] * finv[n - k] % MOD* finv[k] % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
int n, m;
char a[N][N];
ll dp[N][N];
ll dpf(int i, int j)
{
	if(i > n || j > m)
		return 0;
	if(i == n && j == m)
		return 1;
	if(dp[i][j] >= 0)
		return dp[i][j];
	dp[i][j] = 0;
	if(a[i + 1][j] == '.')
		dp[i][j] = (dp[i][j] + dpf(i + 1, j)) % MOD;
	if(a[i][j + 1] == '.')
		dp[i][j] = (dp[i][j] + dpf(i, j + 1)) % MOD;
	return dp[i][j];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));	
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i] + 1;
	}
	ll ans = dpf(1, 1);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 9344
#include <stdio.h>

enum {
	STAT_UL=0,
	STAT_L,
	STAT_DL,
	STAT_DR,
	STAT_R,
	STAT_UR
};

#define ishani(a) ((a)>=0 && (a)<102)
int getstat(int* kabe,int x,int y,int map[102][102]);
void gettuuro(int result[102][102],int x,int y,int map[102][102]);

int main(int argc,char* argv[]) {
	int map[102][102]={0};
	int map2[102][102]={0};
	int stat[6];
	int W,H;
	int i,j,k;
	int result;
	scanf("%d %d",&W,&H);
	for(i=0;i<H;i++) {
		for(j=0;j<W;j++) {
			scanf("%d",&map[i+1][j+1]);
		}
	}
	for(i=0;i<102;i++) {
		for(j=0;j<102;j++)map2[i][j]=1;
	}
	gettuuro(map2,0,0,map);
	result=0;
	for(i=1;i<101;i++) {
		for(j=1;j<101;j++) {
			if(getstat(stat,i,j,map2)) {
				for(k=0;k<6;k++) {
					if(!stat[k])result++;
				}
			}
		}
	}
	printf("%d\n",result);
	return 0;
}

int getstat(int* kabe,int x,int y,int map[102][102]) {
	if(y%2==1) {
		kabe[STAT_UL]=(ishani(y-1) && ishani(x))?map[y-1][x]:1;
		kabe[STAT_L]=(ishani(y) && ishani(x-1))?map[y][x-1]:1;
		kabe[STAT_DL]=(ishani(y+1) && ishani(x))?map[y+1][x]:1;
		kabe[STAT_DR]=(ishani(y+1) && ishani(x+1))?map[y+1][x+1]:1;
		kabe[STAT_R]=(ishani(y) && ishani(x+1))?map[y][x+1]:1;
		kabe[STAT_UR]=(ishani(y-1) && ishani(x+1))?map[y-1][x+1]:1;
	} else {
		kabe[STAT_UL]=(ishani(y-1) && ishani(x-1))?map[y-1][x-1]:1;
		kabe[STAT_L]=(ishani(y) && ishani(x-1))?map[y][x-1]:1;
		kabe[STAT_DL]=(ishani(y+1) && ishani(x-1))?map[y+1][x-1]:1;
		kabe[STAT_DR]=(ishani(y+1) && ishani(x))?map[y+1][x]:1;
		kabe[STAT_R]=(ishani(y) && ishani(x+1))?map[y][x+1]:1;
		kabe[STAT_UR]=(ishani(y-1) && ishani(x))?map[y-1][x]:1;
	}
	return (ishani(y) && ishani(x))?map[y][x]:1;
}

void gettuuro(int result[102][102],int x,int y,int map[102][102]) {
	int stat[6];
	if(!ishani(x) || !ishani(y))return;
	if(!result[y][x] || map[y][x])return;
	if(!getstat(stat,x,y,map)) {
		result[y][x]=0;
		if(y%2==1) {
			gettuuro(result,x,y-1,map);
			gettuuro(result,x-1,y,map);
			gettuuro(result,x,y+1,map);
			gettuuro(result,x+1,y+1,map);
			gettuuro(result,x+1,y,map);
			gettuuro(result,x+1,y-1,map);
		} else {
			gettuuro(result,x-1,y-1,map);
			gettuuro(result,x-1,y,map);
			gettuuro(result,x-1,y+1,map);
			gettuuro(result,x,y+1,map);
			gettuuro(result,x+1,y,map);
			gettuuro(result,x,y-1,map);
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    bool ifpossible=true;
    rep(i,n){
        if(a[i]%2==0){
            if(a[i]%3!=0 && a[i]%5!=0) ifpossible=false;
        }
    }
    if(ifpossible) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}

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

using namespace std;


void PrimalFactorize(int Nin, vector<int> &ans)
{

  int p = 2;
  const int Nsqrt = sqrt(Nin);

  while(Nin != 1 && p <= Nsqrt)
  {

    int last = -1;
    for(int i = 0; i < ans.size(); ++i)
    {
      last = ans[i];
      if(p % ans[i] == 0 && p != ans[i])
      {
	p += 2;
	continue;
      }
    }

    if(Nin % p == 0)
    {
      if(last != p || last < 0)
	ans.push_back(p);
      Nin /= p;
    }
    else 
    {
      if(p == 2)
	++p;
      else 
	p += 2;
    }
  }

  if(Nin != 1)
    ans.push_back(Nin);

  return;
}

int main()
{

  int N; 
  cin >> N;

  vector<int> p;
  PrimalFactorize(N, p);

  int ans = N;

  for(size_t i = 0; i < p.size(); ++i)
    ans *= (1 - 1.0 / (double) p[i]);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a.at(i);
    vector<ll> c(N/2);
    rep(i, N/2){
        c.at(i) = a.at(2*i)^a.at(2*i+1);
    }
    ll d = 0;
    rep(i, N/2){
        d = d^c.at(i);
    }
    vector<ll> b(N);
    rep(i, N){
        b.at(i) = a.at(i)^d;
    }
    rep(i, N-1){
        cout << b.at(i) << " ";
    }
    cout << b.at(N-1) << endl;
}

Measured memory_bytes: 7084
import java.util.Scanner;

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

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    char[] S = scanner.next().toCharArray();
    if (valid(S, A, B)) System.out.println("Yes");
    else System.out.println("No");
  }
  
  private static boolean valid(char[] S, int A, int B) {
    if (S.length != A + B + 1) return false;
    for (int i = 0; i < A; i++) {
      if (S[i] < '0' || S[i] > '9') return false;
    }
    if (S[A] != '-') return false;
    for (int i = A + 1; i < A + B + 1; i++) {
      if (S[i] < '0' || S[i] > '9') return false;
    }
    return true;
  }
}


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

using namespace std;

#define MAX_V 514
#define INF 1e9
typedef pair<int, int> pii;

struct Edge {
    int to, cap, cost, rev;
    Edge(int to, int cap, int cost, int rev) :
        to(to), cap(cap), cost(cost), rev(rev) {}
};

int V, h[MAX_V], dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];
vector<Edge> G[MAX_V];

void add_edge(int from, int to, int cap, int cost)
{
    G[from].push_back(Edge(to, cap, cost, G[to].size()));
    G[to].push_back(Edge(from, 0, -cost, G[from].size()-1));
}

int min_cost_flow(int s, int t, int f)
{
    int res = 0;
    fill(h, h+V, 0);
    while (f > 0) {
	priority_queue<pii, vector<pii>, greater<pii>> Q;
	fill(dist, dist+V, INF);
	dist[s] = 0;
	Q.push(pii(0, s));
	while (!Q.empty()) {
	    pii p = Q.top(); Q.pop();
	    int v = p.second;
	    if (dist[v] < p.first) continue;
	    for (int i = 0; i < (int)G[v].size(); i++) {
		Edge &e = G[v][i];
		if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
		    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
		    prevv[e.to] = v; preve[e.to] = i;
		    Q.push(pii(dist[e.to], e.to));
		}
	    }
	}
	if (dist[t] == INF) return -1;
	for (int v = 0; v < V; v++) {
	    h[v] += dist[v];
	}
	int d = f;
	for (int v = t; v != s; v = prevv[v]) {
	    d = min(d, G[prevv[v]][preve[v]].cap);
	}
	f -= d;
	res += d * h[t];
	for (int v = t; v != s; v = prevv[v]) {
	    Edge &e = G[prevv[v]][preve[v]];
	    e.cap -= d;
	    G[v][e.rev].cap += d;
	}
    }
    return res;
}

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

    int S = 2*N, T = S + 1;
    V = T + 1;
    for (int i = 0; i < N; i++) {        
        add_edge(S, i, 1, 0);
        add_edge(i + N, T, 1, 0);
        for (int j = 0; j < N; j++) {
            if (p[i]-1 != j) {
                add_edge(i, j + N, 1, (p[i]) * abs(i - j));
            }
        }
    }
    cout << min_cost_flow(S, T, N) << endl;
    return 0;
}

Measured memory_bytes: 3456
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    A = int(input())
    B = int(input())
    C = int(input())
    x = int(input())

    ans = 0
    for a in range(0, A+1):
        for b in range(0, B+1):
            for c in range(0, C+1):
                if 500*a+100*b+50*c == x:
                    ans += 1
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Measured memory_bytes: 3444
//https://atcoder.jp/contests/abc163/tasks/abc163_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll N,M; cin>>N>>M;
  vector<ll> am(M);
  for(auto&& a:am) cin>>a;
  ll sum=0;
  for(auto& a:am){
    sum += a;
  }
  ll ans=N-sum;
  ans=max(ans,-1LL);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3704
S = int(input())

rootS = S ** (1 / 2)
# print(rootS)

Xmax = int(rootS)

if Xmax < rootS:
    Xmax = Xmax + 1

Ymax = Xmax
delta = Xmax * Ymax-S
# print("差分"+str(delta))

if delta != 0:
    root_delta = int(delta ** (1 / 2))
    for i in range(root_delta, 0, -1):
        # print(i)
        if delta % i == 0:
            X = delta // i
            Y = i
            break
else:
    X = 0
    Y = 0
# print(Xmax)
# print(Ymax)
# print(X)
# print(Y)
ans = "0 0 "+str(Xmax)+" "+str(Y)+" "+str(X)+" "+str(Ymax)
print(ans)


Measured memory_bytes: 3316
#! /usr/bin/python
# -*- coding: utf-8 -*-

def dfs(Map, used, i, j):
    cnt = 0
    wc = False
    bc = False
    q = [[i, j]]
    used[i][j] = True
    while q!=[]:
        cnt += 1
        i = q[0][0]
        j = q[0][1]
        if Map[i][j] == 'W':
            wc = True
        elif Map[i][j] == 'B':
            bc = True
        q.pop(0)
        if i-1>=0:
            if Map[i-1][j] == 'W':
                wc = True
            elif Map[i-1][j] == 'B':
                bc = True
            elif used[i-1][j] == False:
                q.append([i-1, j])
                used[i-1][j] = True
        if i+1<len(used):
            if Map[i+1][j] == 'W':
                wc = True
            elif Map[i+1][j] == 'B':
                bc = True
            elif used[i+1][j] == False:
                q.append([i+1, j])
                used[i+1][j] = True
        if j-1>=0:
            if Map[i][j-1] == 'W':
                wc = True
            elif Map[i][j-1] == 'B':
                bc = True
            elif used[i][j-1] == False:
                q.append([i, j-1])
                used[i][j-1] = True
        if j+1<len(used[i]):
            if Map[i][j+1] == 'W':
                wc = True
            elif Map[i][j+1] == 'B':
                bc = True
            elif used[i][j+1] == False:
                q.append([i, j+1])
                used[i][j+1] = True
    if wc == True and bc == True:
        return int(0)
    elif wc == True:
        return -int(cnt)
    elif bc == True:
        return int(cnt)
    else:
        return 0

while 1:
    (w, h) = map(int, raw_input().split())
    if w==0: break
    M = []
    [wr, br] = [0, 0]
    for i in range(h):
        M.append(raw_input())
    used = [[False]*w for i in range(h)]
    for i in range(h):
        for j in range(w):
            if M[i][j] in ('W','B'): used[i][j] = True
    for i in range(h):
        for j in range(w):
            if used[i][j] == False:
                s = dfs(M, used, i, j)
                if s < 0:
                    wr -= s
                elif s > 0:
                    br += s
    print br, wr
            

Measured memory_bytes: 4436
#include<iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); ++i) { //消す先頭
        for (int j = 0; j < s.length() - i; ++j) { //何個
            string str = s;
            string str2;
            for (int k = 0; k < j; ++k) {
                str[i + k] = '1';
            }
            for (int k = 0; k < str.length(); ++k) {
                if (str[k] != '1') {
                    str2 += str[k];
                }
            }
            if (str2 == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	a := getNextInt(scanner)
	var xx [50]int
	for i := 0; i < n; i++ {
		xx[i] = getNextInt(scanner)
	}

	var dp [51][2501]int64
	dp[0][0] = 1

	for i := 0; i < n; i++ {
		for ii := i + 1; ii > 0; ii-- {
			for iii := 2500; iii > 0; iii-- {
				if iii-xx[i] < 0 {
					continue
				}
				dp[ii][iii] += dp[ii-1][iii-xx[i]]
			}
		}
	}
	var ans int64

	for i := 0; i < n; i++ {
		ans += dp[i+1][a*(i+1)]
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int md = 1e9+7;
const int sz = 1e6+1;
int F[sz+1];
 
int A[sz+1];

int dp(int index,int flag,vector<int>& v,int n){
    cout<<index<<" "<<flag<<endl;
    if(index>=n){
        cout<<"imit reached"<<endl;
        return 0;
    }

    if(A[index]!=-1){
        cout<<"precalculated"<<endl;
        return A[index];
    }
    int temp = max( dp(index+1,flag,v,n) , v[index]*(flag==0?1:-1) + dp(index+1,1-flag,v,n) );
    A[index] = temp;
    cout<<"ans = "<<temp<<endl;
    return temp;
}

void solve(){
    int n;cin>>n;
    string ans = "";
    for (int i = 0; i < n; ++i)
    {
        ans += "ACL";
    }

    cout<<ans<<endl;


return;
}
 
 
 
int32_t main()
{
    IOS;
    // int t;cin >> t;
    // while (t--)     
        solve();
    return 0;
        
 
    
}
 

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

using namespace std;

set<int> get_digits(int n) {
    set<int> s;
    while (n != 0) {
        s.insert(n % 10);
        n /= 10;
    }
    return s;
}

int main() {
    int N = 0, K = 0;
    cin >> N >> K;

    set<int> hate;
    for (int i = 0; i < K; ++i) {
        int n = 0;
        cin >> n;
        hate.insert(n);
    }

    int i = N;
    while (1) {
        set<int> d = get_digits(i);
        set<int> c;
        set_intersection(d.begin(), d.end(), hate.begin(), hate.end(),  inserter(c, c.begin()));
        if (c.empty()) {
            cout << i << endl;
            break;
        }
        i++;
    }

    return 0;
}

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

int main(){
    int n, m, x, i, a, c = 0;
    cin >> n >> m >> x;
    for(i=0; i<m; i++){
        cin >> a;
        if(a < x){
            c++;
        }
    }
    cout << min(c, m-c);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string s;cin>>s;
  bool hanteiA=false;
  int saisho=0;
  bool hanteiZ=false;
  int saigo=0;
  rep(i,s.size()){
    if(hanteiA==false){
      if(s[i]=='A'){
        hanteiA=true;
        saisho=i;
      }
    }else{
      if(s[i]=='Z')saigo=i;
    }
  }
  cout<<saigo-saisho+1<<endl;
  return 0;
}

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


int main() {
    string s;
    int ans = 0;
    while(cin >> s) {
        int pre_digit = 1;
        int n = s.size();
        for(int i = n-1; i>=0; i--) {
            if(isdigit(s[i])) {
                ans += (s[i] - '0') * pre_digit;
                pre_digit *= 10;
                continue;
            }
            pre_digit = 1;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

const int MAX_N=100*100+10,MAX_H=100+10,MAX_W=100+10;
int a[MAX_N],c[MAX_H][MAX_W];

int main()
{
    //INPUT
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    //SOLVE
    int z=0;
    for(int i=0;i<h;i++)
    {
        if(i%2==0)
        {
            for(int j=0;j<w;j++)
            {
                c[i][j]=z+1;
                a[z]--;
                if(a[z]==0)
                {
                    z++;
                }
            }
        }
        else
        {
            for(int j=w-1;j>=0;j--)
            {
                c[i][j]=z+1;
                a[z]--;
                if(a[z]==0)
                {
                    z++;
                }
            }
        }
    }
    //OUTPUT
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll rui[200010],ruig[200010];

int main() {
    ll n,sum = 9223372036854775807,sum2 = 0;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
        rui[i+1] = rui[i] + a[i];
    }
    for(int i = 0;i < n;i++){
        ruig[i+1] = ruig[i] + a[n-i-1];
    }
    for (int i = 0; i <= n; ++i) {
        sum = min(sum,abs(rui[i]-ruig[n-i]));
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<functional>

int main(){
  int n,m;
  std::cin>>n>>m;
  int arr[n];
  int sum=0;
  for(int i=0; i<n; ++i){
    std::cin>>arr[i];
    sum += arr[i];
  }


  std::sort(arr, arr+n, std::greater<int>());
  bool flag=true;
  for(int i=0; i<m; ++i){
      if((double)arr[i] < ((double)sum/(4*m))){
        flag = false;
        break;
      }
  }
  if(flag)
    std::cout<<"Yes\n";
  else
    std::cout<<"No\n";
}


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

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i <= b; i++) {
        if (i < a + k || b - k + 1 <= i) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n; cin >> n;
   V<V<int>> a(3, V<int>(n));
   for (int i = 0; i < n; i++) {
      for (int k = 0; k < 3; k++) {
         cin >> a[k][i];
      }
   }

   V<V<int>> dp(3, V<int>(n+1));
   for (int i = 0; i < n; i++) {
      for (int k = 0; k < 3; k++) {
         for (int l = 0; l < 3; l++) {
            if (k == l) continue;
            chmax(dp[l][i+1], dp[k][i] + a[l][i]);
         }
      }
   }
   cout << max({dp[0][n], dp[1][n], dp[2][n]}) << endl;

   return 0;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

std::string s;
int main() {
    std::cin >> s;
    int len = s.length();
    REP(i, len) {
        if(i % 2 == 0) {
            std::cout << s[i];
        }
    }
    std::cout << std::endl;
}

Measured memory_bytes: 512
#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);}}aaa;

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,a,b;
    cin >> n >> a >> b;
    if(a*n <= b) cout << a*n << endl;
    else cout << b << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int i,n,a[10],b,c,d,res,min;
    scanf("%lld",&n);
    for(i=0;i<5;i++)
        scanf("%lld",&a[i]);
    min=a[0];
    for(i=0;i<5;i++)
    {
        if(min>a[i])min=a[i];
    }
    if(n%min==0)
        res=(n/min)+4;
    else
        res=(n/min)+5;
        printf("%llu\n",res);
        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<"="<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000*1000*1000 + 7;
const LL LINF = 1LL*INF*INF;

const LL MOD = 1000000007;

const int MAX = 200005;

VI g[2][MAX];

int d[2][MAX];

int par[MAX];


void dfs(int v,int ind,int p)
{
	if(ind == 1)par[v] = p;
	FOR(i,0,SZ(g[ind][v]))
	{
		int to = g[ind][v][i];
		if(to == p)continue;

		d[ind][to] = d[ind][v]+1;
		dfs(to,ind,v);
	}
}

int ans = 0;
bool ok[MAX];
void getAns(int v,int p)
{
	ans = max(ans,d[1][v]);
	ok[v] = true;
	FOR(i,0,SZ(g[0][v]))
	{
		int to = g[0][v][i];
		if(to==p)continue;

		if(d[0][to]<d[1][to])getAns(to,v);
	}
}
set<PII> e2;


int main()
{
	//freopen("in.txt","r",stdin);
	//ios::sync_with_stdio(false);cin.tie(0);

	int n,r1,r2;
	cin>>n>>r1>>r2;

	--r1;--r2;

	FOR(ind,0,2)
	FOR(i,1,n)
	{
		int a,b;
		cin>>a>>b;
		--a;--b;
		g[ind][a].PB(b);
		g[ind][b].PB(a);
		if(ind == 1)e2.insert(MP(min(a,b),max(a,b)));
	}


	dfs(r1,0,-1);
	dfs(r2,1,-1);

	FOR(i,0,n)
	{
		int p = par[i];
		if(p==-1 || par[p] == -1)continue;
		p = par[p];
		e2.insert(MP(min(p,i),max(p,i)));
	}

	getAns(r1,-1);

	FOR(i,0,n)
	FOR(j,0,SZ(g[0][i]))
	{
		int to = g[0][i][j];
		int v = i;
			if(ok[v] && par[v]!=par[to] && !e2.count(MP(min(v,to),max(v,to))))
			{
				cout<<-1;
				return 0;
			}
	}


	cout<<ans*2;
	return 0;
}


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

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

    int a, b;
    cin >> a >> b;

    if(b == 1){
        cout << 0 << endl;
        return 0;
    }

    int ans = 1, now = a;
    while(true){
        if(now >= b){
            break;
        }
        ans++;
        now += a - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int N, i, count = 0;
	int a[100];
	scanf("%d", &N);
	for(i = 0; i < N; i++)
	{
		scanf("%d", &a[i]);
	}

	for(i = 0; i <= N; i = i + 2)
	{
		if(a[i] % 2 != 0)
		{
			count++;
		}
	}
	printf("%d", count);
}

Measured memory_bytes: 1712