akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long W = scan.nextLong();
        long H = scan.nextLong();
        long x = scan.nextLong();
        long y = scan.nextLong();
        double area = ((double) W * H) / 2;
        if (is_corner(W, H, x, y)) {
            System.out.println(String.format("%.10f",area) + " " + 0);
            return;
        }
        if (x == 0 || x == W) {
            System.out.println(String.format("%.10f",area) + " " + 0);
            return;
        }
        if (y == 0 || y == H) {
            System.out.println(String.format("%.10f",area) + " " + 0);
            return;
        }
        int multiple = W == 2 * x && H == 2 * y ? 1 : 0;
        System.out.println(String.format("%.10f",area) + " " + multiple);

    }
    public static boolean is_corner(long W, long H, long x, long y) {
        if (x == 0 && y == 0) {
            return true;
        }
        if (x == 0 && y == H) {
            return true;
        }
        if (x == W && y == 0) {
            return true;
        }
        if (x == W && y == H) {
            return true;
        }
        return false;
    }
}


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

main()
{
    int k,a,b; cin>>k>>a>>b;
    if((a-1)/k<b/k)
    {
        cout << "OK" << "\n";
    }
    else
    {
        cout << "NG" << "\n";
    }
}

Measured memory_bytes: 3604
num, all_ans = [int(i) for i in input().split(" ")]
d_wa = [0 for _ in range(num)]
d_ac = [0 for _ in range(num)]
ans = 0

for _ in range(all_ans):
    ans_num, ac_wa = [i for i in input().split(" ")]
    if d_ac[int(ans_num) - 1] == 1: continue
    if ac_wa == "AC": 
        d_ac[int(ans_num) - 1] = 1
        continue
    if ac_wa == "WA":
        d_wa[int(ans_num) - 1] += 1
        continue

for num, i in enumerate(d_ac):
    if i:
       ans += d_wa[num]

print(sum(d_ac),ans)

Measured memory_bytes: 4760
D, N = map(int, input().split())
if D == 0:
    if N < 100:
        print(N)
    else:
        print(101)
elif D == 1:
    if N < 100:
        print(100 * N)
    else:
        print(10100)
else:
    if N < 100:
        print(10000 * N)
    else:
        print(1010000)

Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;

public class Main{
    
    static int i = 1;
    static int n;
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        
        while (i <= n) {
            int x = i;
            if (x % 3 == 0) {
                System.out.print(" " + i);
            } else {
                while (x % 10 != 3) {
                    x /= 10;
                    if (x == 0) {
                        break;
                    }
                }
                if (x % 10 == 3) {
                    System.out.print(" " + i);
                }
            }
            i++;
        }
        System.out.println();
    }
}


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

int a, b, c, d;

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

  cin >> a >> b >> c >> d;
  if(ceil(1.0*c/b) <= ceil(1.0*a/d)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3640
#数列Aの取りうるものをcombinations_with_replacementで作って、全探索
#データ入力
from itertools import combinations_with_replacement
N,M,Q = (int(x) for x in input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

#
all_A =[i for i in range(1,M+1)] #数列Aの取りうる値
A =[0]*N
ans =[]
for A in combinations_with_replacement(all_A,N):
    count =0
    for i in range(Q):
        ai,bi,ci,di =abcd[i]
        if A[bi-1] -A[ai-1] ==ci:
            count += di
    ans.append(count)
print(max(ans))

Measured memory_bytes: 12508
n = int(input().strip())
arrayV = list(map(int, input().strip().split(' ')))
arrayC = list(map(int, input().strip().split(' ')))
ans = 0
for i in range(n):
    netV = arrayV[i] - arrayC[i]
    if netV > 0:
        ans = ans + netV
print(ans)


Measured memory_bytes: 38256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, std::string S){
    int a=0;
    int b=0;
    int cnt=0;
    REP(i, S.size()){
        if(S[i]=='(')cnt++;
        else cnt--;
        if(cnt<0){
            a++;
            cnt=0;
        }
    }
    REP(i,a){
        cout<<"(";
    }
    cout<<S;
    REP(i,cnt){
        cout<<")";
    }cout<<endl;
    return;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
function main(input) {
  const s = input.trim()

  let array = s.split('').reduce((a, c) => {
    a[c.charCodeAt() - 'a'.charCodeAt()]++
    return a
  }, [0, 0, 0])

  if (Math.max(...array) - Math.min(...array) >= 2) {
    console.log('NO')
  } else {
    console.log('YES')
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 32472
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  if(n%10==3){
    cout << "bon" << endl;
  }
  else if(n%10==0||n%10==1||n%10==6||n%10==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod[] = {999999937, 1000000007}, base = 9973;
struct rolling_hash {
    int n;
    vector<ll> hs[2], pw[2];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < 2; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    ll hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < 2; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, ll h[]) {
        bool ret = 1;
        for (int i = 0; i < 2; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};
int main()
{
    string a, b;
    cin >> a >> b;
    string ae;
    while(ae.size() < 2 * b.size())
    {
        ae += a;
    }
    ae += ae;

    rolling_hash ar(ae);
    rolling_hash br(b);

    ll bs = b.size();
    int aes = ae.size();
    vector<bool> ok(aes, false);
    for(int i = 0; i + bs <= aes; i++)
    {
        bool match = true;
        if(i + bs < aes)
        {
            for(int j = 0; j < 2; j++)
            {
                if(ar.hash(i, i+bs, j) != br.hash(0, bs, j)) match = false;
            }
            ok[i] = match;
        }
    }
    int seq = 0;
    int ans = 0;
    for(int start = 0; start < bs; start++)
    {
        int seq = 0;
        for(int i = 0; start + i < aes; i += bs)
        {
            if(ok[start+i])
            {
                seq++;
                ans = max(ans, seq);
            }
            else seq = 0;
        }
    }
    ae += ae;
    rolling_hash ar2(ae);
    int aes2 = ae.size();
    vector<bool> ok2(aes2, false);
    for(int i = 0; i + bs <= aes2; i++)
    {
        bool match = true;
        if(i + bs < aes2)
        {
            for(int j = 0; j < 2; j++)
            {
                if(ar2.hash(i, i+bs, j) != br.hash(0, bs, j)) match = false;
            }
            ok2[i] = match;
        }

    }
    for(int start = 0; start < bs; start++)
    {
        seq = 0;
        for(int i = 0; start + i < aes2; i += bs)
        {
            if(ok2[start+i])
            {
                seq++;
                if(seq > ans)
                {
                    cout << -1 << endl;
                    return 0;
                }
            }
            else seq = 0;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 307072
#include <iostream>
#include <cmath>

using namespace std;
int main()
{
    long long n;
    cin >> n;
    long long cnt = 0;
    while(n>=1){
        n/=2;
        cnt++;
    }
    long long ans = pow(2,cnt)-1;
    cout << ans;
    

    return 0;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(S: String){
    fun isEvenString(s: String): Boolean{
        if (s.length % 2 != 0) return false
        val l = s.length
        return s.slice(0 until l / 2) == s.slice(l / 2 until l)
    }
    val l = S.length
    for(i in 1 until l){
        if (isEvenString(S.slice(0 until l - i))){
            println(l-i)
            return
        }
    }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val S = sc.next()
    solve(S)
}



Measured memory_bytes: 29592
N = int(input())
t_list = [int(t) for t in input().split()]
M = int(input())
table = [[int(i) for i in input().split()] for m in range(M)]

sum1 = 0
for n in range(N):
    sum1 += t_list[n]

for m in range(M):
    sum2 = sum1 - t_list[table[m][0] - 1] + table[m][1]
    print(sum2)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
typedef pair<long long,pair<int,int>> plii;
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
struct union_find{
    vector<int> par; 
    vector<int> size;
    //1からnまで初期化:par[i] = i(1<=i<=n)
    union_find(int n){
        par.push_back(0);
        for(int i = 1;i<=n;i++){
            par.push_back(i);
            size.push_back(1);
        }
    }
    int root(int a){
        if (par[a] == a) return a;
        par[a] = root(par[a]);
        return root(par[a]);
    }
    void unite(int a,int b){
        if (root(a) == root(b)) return;
        size[root(b)]+=size[root(a)];
        par[root(a)] = root(b);
    }
    bool same(int a,int b){
        return (root(a) == root(b));
    }
    //頂点aが含まれる木の大きさ(頂点数)
    int treesize(int a){
        return size[root(a)];
    }
};
int main(){
    int n;
    cin >> n;
    vector<pair<long long,int>> vecx;
    vector<pair<long long,int>> vecy;
    long long x,y;
    rep(i,n){
        cin >> x >> y;
        vecx.push_back(make_pair(x,i));
        vecy.push_back(make_pair(y,i));
    }
    sort(vecx.begin(),vecx.end());
    sort(vecy.begin(),vecy.end());
    priority_queue<plii,vector<plii>,greater<plii>> edge;
    rep(i,n-1){
        edge.push(make_pair(vecx[i+1].first-vecx[i].first,make_pair(vecx[i].second,vecx[i+1].second)));
        edge.push(make_pair(vecy[i+1].first-vecy[i].first,make_pair(vecy[i].second,vecy[i+1].second)));
    }
    union_find tree(n);
    long long ans = 0;
    while(tree.treesize(0)<n){
        plii pr = edge.top();
        if(!tree.same(pr.second.first,pr.second.second)){
            tree.unite(pr.second.first,pr.second.second);
            ans+=pr.first;
        }
        edge.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 9572
// c
fn main() {
    input! {
        n: usize
    }

    let mut cnt = 0;
    for a in 1..n {
        cnt += (n - 1) / a;
    }

    println!("{}", cnt);
}

#[macro_export(local_inner_maccros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[macro_export(lcal_inner_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export(lcal_inner_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


Measured memory_bytes: 2132
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

const int MAX_N = 100005;
 
int parent[MAX_N];
int ran[MAX_N];
 
void init(int n){
    int i;
    rep(i,n){
        parent[i]=i;
        ran[i]=0;
    }
}
 
int find(int x){
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
 
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
 
    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}
 
struct edge{ int u,v,cost;};
 
bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}
 
edge es[2*MAX_N];
int v,e=0;
 
int kruskal(){
    sort(es,es+e,comp);
    init(v);
    int res=0,i;
    rep(i,e){
        edge e=es[i];
        if(find(e.u) != find(e.v)){
            unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}

int main(){
  int n; cin >> n;
  v = n;
  
  vector<tuple<int,int,int>> p(n);
  rep(i,n){
    int x,y; cin >> x >> y;
    p[i] = make_tuple(x,y,i);
  }
  
  sort(p.begin(),p.end());
  
  rep(i,n-1){
    int x1,y1,num1; tie(x1,y1,num1) = p[i];
    int x2,y2,num2; tie(x2,y2,num2) = p[i+1];
    es[e].u = num1;
    es[e].v = num2;
    es[e].cost = x2 - x1;
    e++;
  }
  
  rep(i,n){
    int x,y,num; tie(x,y,num) = p[i];
    p[i] = make_tuple(y,x,num);
  }
  sort(p.begin(),p.end());
  
  rep(i,n-1){
    int y1,x1,num1; tie(y1,x1,num1) = p[i];
    int y2,x2,num2; tie(y2,x2,num2) = p[i+1];
    es[e].u = num1;
    es[e].v = num2;
    es[e].cost = y2 - y1;
    e++;
  }
  
  cout << kruskal() << endl;
  
  return 0;
}


Measured memory_bytes: 4480
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,i;
  long long int num[52],patty[52],X,eat,center;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  X=atol(p);
  
  for(i=1,num[0]=1,patty[0]=1;i<N+1;i++){
    num[i]=2*num[i-1]+3;
    patty[i]=2*patty[i-1]+1;
  }
  i=N,eat=0;
  
  while(i>=0){
    center=num[i]/2+1;
    if(X==num[i]){
      eat+=patty[i];
      break;
    }
    if(X==0){
      break;
    }
    if(X<center){
      X-=1;
      i--;
    }else if(X>center){
      eat+=patty[i-1]+1;
      X-=center;
      i--;
    }else{
      eat+=patty[i-1]+1;
      break;
    }
  }
  
  printf("%lld\n",eat);
  
  
  return 0;
}


Measured memory_bytes: 128
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	string s;
    cin>>s;
  	cout<<string("ABC")+s;
	
	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)
using namespace std;

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	printf("%d\n", n - m + 1);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
using namespace std;
int main()
{
	int limit,i;
	scanf("%d",&limit);
	for(i=1;i<=limit;i*=2);
	printf("%d",i/2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;

	if (a > b) {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;
	}
}

Measured memory_bytes: 888
/*input
31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll MAX = 1e18;

void run() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	for(auto &x : a)
		cin >> x;
	sort(a.begin(), a.end());
	ll ret = 1;
	if(a[0] == 0) {
		cout << 0 << endl;
		return;
	}
	bool bad = false;
	for(auto x : a) {
		if(x > MAX / ret) {
			bad = true;
			break;
		}
		ret *= x;
	}
	if(bad) cout << -1 << endl;
	else cout << ret << endl;
}

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


Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n;
    cin >> n;
    bool check = false;
    rrep(i, n) {
        if(int(i * 1.08) == n) {
            cout << i << endl;
            check = true;
            break;
        }
    }
    if(check == false) cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve 

solve :: [Int] -> Int
solve [a, p] = (3 * a + p) `div` 2

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself

*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAX = 1e5 + 5;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

//basic mathematics
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

//modular arithmetic
int powermod(int x, int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;

	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

//Prime numbers till n precomputation - range query
int prefix[MAX + 1];

void buildPrefix()
{
	bool prime[MAX + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= MAX; p++) {
		if (prime[p] == true) {
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = false;
		}
	}
	prefix[0] = prefix[1] = 0;
	for (int p = 2; p <= MAX; p++) {
		prefix[p] = prefix[p - 1];
		if (prime[p])
			prefix[p]++;
	}
}

int query(int L, int R)
{
	return prefix[R] - prefix[L - 1];
}


//Find all paths from a to b in an undirected graph
vector<int> g[MAX];
int visited[MAX];
//count of all the paths from 1 to n;

void dfs(int visited[MAX], int u, int v, vector<int> path)
{
	visited[u] = 1;
	if (u == v)
	{
		for (int i = 0; i < path.size(); i++)
		{
			cout << path[i] << " ";
		}
		cout << "\n";
	}
	else
	{
		for (int i = 0; i < g[u].size(); i++)
		{
			int y = g[u][i];

			if (visited[y] == 0)
			{
				visited[y] = 1;
				path.pb(y);
				dfs(visited, y, v, path);
				path.pop_back();
			}

		}
	}

	visited[u] = 0;

}

vector<int> graph[MAX];
int vis[MAX];

void dfs(int v)
{
	vis[v] = 1;
	
	for(auto x: graph[v]){
	    
		if(vis[x] == 0)
		{
		    dfs(x);
		}
		
	}
}

void solve()
{
	int n;
	cin>>n;
	n-=1;
	int sum = 0;
	for(int i=1;i<=n;i++)
	sum+=(floor(n/i));
	cout << sum <<"\n";
}

int32_t main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "\n" << "Time elapsed : " << time_passed << "\n";
	return 0;
}

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

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

    ll value[N];
    ll weight[N];

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

    ll dp[N + 10][W + 10];
    fill(dp[0], dp[N + 10], -1);
    for (int i = 0; i < W + 9; i++)
    {
        dp[0][i] = 0;
    }

    for (int i = 0; i < N; i++)
    {
        for (int w = 0; w <= W; w++)
        {
            if (weight[i] <= w)
            {
                dp[i + 1][w] = max(dp[i][w], dp[i][w - weight[i]] + value[i]);
            }
            else
            {
                dp[i + 1][w] = dp[i][w];
            }
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 86144
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <tuple>
#include <iomanip>
#include <iterator>
#define PB push_back
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v) for (auto e : v) cerr << e << ' '; cerr << endl;
#define SHOWP(p) cerr << "[" << p.first << "," << p.second << "]" << endl;
#define FI first
#define SE second
#define Decimal fixed << setprecision(20)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
constexpr int INF = 1100000000;
constexpr ll LLINF = 1100000000000000000;

ll dp[210000][2];
int main()
{
  int N;
  cin >> N;
  priority_queue<double, vector<double>, greater<double>> pq;
  REP(i, N) {
    int V;
    cin >> V;
    pq.push(static_cast<double>(V));
  }
  while (1) {
    double t1 = pq.top(); pq.pop();
    if (pq.empty()) {
      cout << Decimal << t1 << endl;
      break;
    }
    double t2 = pq.top(); pq.pop();
    pq.push((t1 + t2) / 2);
  }

  return 0;
}


Measured memory_bytes: 256
N,*xys=$<.read.split.map(&:to_i)
xys=xys.each_slice(2).to_a

sum = 0
count = 0
(0..N-1).to_a.permutation do |is|
    dist=0
    is.each_cons(2) do |ab,cd|
        a,b=xys[ab]
        c,d=xys[cd]
        dist += Math.sqrt((a-c)**2+(b-d)**2)
    end
    sum += dist
    count += 1
end

puts(sum/count)


Measured memory_bytes: 1916
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y,z,ans;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=a+b+c+d;
	y=x/60;
	z=x%60;
	printf("%d\n",y);
	printf("%d\n",z);
	return 0;
}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define debug(x) { cout << #x << " = " << x << endl; }
typedef long long ll;
int main() { _
  int n,k;
  cin >> n >> k;
  int dp[n],a[n];
  for(int i = 0;i < n;i++){
    cin >> a[i];
    dp[i] = 0;
  }
  for(int i = 0;i < n;i++){
    int l = max(0, i - k);
    dp[i] = dp[l] + abs(a[i] - a[l]);
    for(int j = l + 1;j < i;j++){
      dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
    }
  }
  cout << dp[n - 1];
}

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

typedef long long ll;
typedef pair<int,int> pii;
#define fore(i,ii,iii)for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii)for(int i=iii-1;i>=ii;i--)
#define all(s) s.begin(),s.end()
#define sz(a) ((int)a.size())
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const ll N=2e5+15;
ll l[N];
pair<ll,ll>r[N];
ll n,m;
vector<int>t[N];

struct STree { // example: range sum with range addition
	vector<ll> st,lazy;int n;
	STree(int n): st(4*n+5,0), lazy(4*n+5,0), n(n) {}
	void push(int k, int s, int e){
		if(!lazy[k])return; // if neutral, nothing to do
		st[k]+=lazy[k]; // update st according to lazy
		if(s+1<e){ // propagate to children
			lazy[2*k]+=lazy[k];
			lazy[2*k+1]+=lazy[k];
		}
		lazy[k]=0; // clear node lazy
	}
	void upd(int k, int s, int e, int a, int b, ll v){
		push(k,s,e);
		if(s>=b||e<=a)return;
		if(s>=a&&e<=b){
			lazy[k]+=v; // accumulate lazy
			push(k,s,e);return;
		}
		int m=(s+e)/2;
		upd(2*k,s,m,a,b,v);upd(2*k+1,m,e,a,b,v);
		st[k]=max(st[2*k],st[2*k+1]); // operation
	}
	ll query(int k, int s, int e, int a, int b){
		if(s>=b||e<=a)return 0; // operation neutral
		push(k,s,e);
		if(s>=a&&e<=b)return st[k];
		int m=(s+e)/2;
		return max(query(2*k,s,m,a,b),query(2*k+1,m,e,a,b)); // operation
	}
	void upd(int a, int b, ll v){upd(1,0,n,a,b,v);}
	ll query(int a, int b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(s,e,v);rmq.query(s,e);


vector<pair<ll,ll>>a[N];
int main() {
	ios::sync_with_stdio(false);
	STree st(N);
	cin>>n>>m;
	fore(i,0,m) {
		ll l,r,c;
		cin>>l>>r>>c;
		a[l].pb({r,c});
	}
	for(int i=n;i>=0;i--) {
		for(auto it:a[i+1]) {
			st.upd(i+1,it.fst+1,it.snd);
		}
		st.upd(i,i+1,st.query(i+1,n+1));
	}
	cout<<st.query(0,n+1)<<endl;
}

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

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif




ll n;
const ll MAX_COLOR = 200001;
const ll MAX_N = 200001;

vector<int> col_to_stk[MAX_COLOR];
vector<int> col_to_roots[MAX_COLOR];

struct nodeinfo {
	vector<int> next;
	int parent;
	vector<int> color_child; // 親ノードと同じ色の子孫ノード。木を親ノードの色で区切ったときに、ここから到達可能な他の区切り位置
	int subtree_size;
	int color;
};

nodeinfo nodes[MAX_N];

// node以下の、nodeと同じ色で分割される各グループの size(size+1)/2 の合計を返す
ll dfs2( int node ){
	eprintf( "dfs2: node=%d\n", node );
	ll result = 0;
	for ( auto sub : nodes[node].next ){
		if ( sub == nodes[node].parent )
			continue;
		ll ct = nodes[sub].subtree_size;
		for ( auto child : nodes[sub].color_child ){
			result += dfs2( child );
			ct -= nodes[child].subtree_size;
		}
		
		eprintf( "sub=%d, ct = %d\n", (int)sub, (int)ct );
		result += ct*(ct+1)/2;
	}
	return result;
}

/*
   subtreeのノード数のカウント
   このノードと同じ色を持つ祖先の1歩手前のノードに、このノードを登録する
*/
int dfs( int node, int parent_node ){
	nodeinfo &nd = nodes[node];
	auto &stk = col_to_stk[nd.color];
	
	nd.parent = parent_node;
	int ct = 1;
	if ( stk.size() == 0 ){
		col_to_roots[nd.color].push_back(node);
		eprintf("root : color=%d, root=%d\n", (int)nd.color, (int)node);
	}
	else {
		nodes[stk.back()].color_child.push_back(node);
		eprintf("noroot : color=%d, root=%d\n", (int)nd.color, (int)node);
	}
	
	for ( auto next_node : nd.next ){
		if ( next_node == parent_node )
			continue;
		stk.push_back(next_node);
		ct += dfs( next_node, node );
		stk.pop_back();
	}
	
	nd.subtree_size = ct;
	return ct;
}



int main(){
	cin >> n;
	rep(i, n){
		cin >> nodes[i].color;
		nodes[i].color--;
	}
	
	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		nodes[a].next.push_back(b);
		nodes[b].next.push_back(a);
	}
	
	dfs( 0, -1 );
	
	rep(i, n){
		ll t = n*(n+1)/2;
		ll u = n;
		for ( auto node : col_to_roots[i] ){
			eprintf( "\ncolor=%d, root=%d\n", (int)i, (int)node );
			t -= dfs2(node);
			u -= nodes[node].subtree_size;
		}
		
		cout << t - u*(u+1)/2 << "\n";
	}
	
	return 0;
}




Measured memory_bytes: 63764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	return b ? gcd(b,a%b) : a;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>sb(n,0);
    vector<pair<ll,ll>>p;
    rep(i,0,n){
        ll a,b;
        cin>>a>>b;
        p.push_back(make_pair(a,b));
    }
    sort(all(p));
    ll x=0;
    rep(i,0,n){
        x+=p[i].second;
        sb[i]=x;
    }
    ll i=0;
    while(k>sb[i]){
        i++;
    }
    cout<<p[i].first<<endl;
    

    
}


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

int main(){
    int n;
    int nn[100];
    int max = 0;
    for(int i=0;i<100;i++){
        nn[i] = 0;
    }
    while(cin >> n){
        nn[n-1] += 1;
        if(nn[n-1] > max){
            max = nn[n-1];
        }
    }
    for(int i=0;i<100;i++){
        if(nn[i] == max){
            cout << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll H, W;
    cin >> H >> W;

    vector<ll> a(H * W);
    rep(i, H * W) cin >> a[i];

    // じぐざくに一筆書き
    typedef pair<ll, ll> P;
    vector<P> b;
    rep(y, H) rep(x, W) {
        if (y % 2 == 0) {
            b.push_back(P(x, y));
        }
        else {
            b.push_back(P(W - 1 - x, y));
        }
    }

    vector<ll> res;
    rep(i, b.size() - 1) {
        ll index = b[i].first + b[i].second * W;
        ll index2 = b[i+1].first + b[i+1].second * W;
        if (a[index] % 2 != 0) {
            res.push_back(1+b[i].second);
            res.push_back(1+b[i].first);
            res.push_back(1+b[i+1].second);
            res.push_back(1+b[i+1].first);
            // cout << (1+b[i].second) << " " << (1+b[i].first) << " ";
            // cout << (1+b[i+1].second) << " " << (1+b[i+1].first) << endl;
            a[index]--;
            a[index2]++;
        }
    }

    put(res.size() / 4);
    rep(i, res.size() / 4) {
        cout << res[4*i+0] << " " << res[4*i+1] << " " << 
                res[4*i+2] << " " << res[4*i+3] << endl;
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 15196
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


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

	if (X == 3 || X == 5 || X == 7) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long ans[101];
int n;
int main(){
    ans[0]=1;ans[1]=1;
    cin>>n;
    for(int i=2;i<=n;i++){
        ans[i]=ans[i-1]+ans[i-2];
    }
    cout<<ans[n]<<endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,ak,h;
    cin>>n>>k>>a;
    h=a;
    for(int i=2;i<=n;i++)
    {
        cin>>ak;
        a=__gcd(a,ak);
        h=max(ak,h);
    }
    if(k%a==0&&k<=h)   
    {
        cout<<"POSSIBLE"<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

typedef std::stack<int> IntStack;
typedef std::queue<int> IntQueue;
 
using namespace std;
  
int main(){
  int N, K;
  cin >> N >> K;
  int p[N];
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  
  double e[N];
  for(int i=0;i<N;i++){
    e[i] = ((double)(p[i]+1))/2.0;
  }
  double cum[N+1];
  cum[0] = 0;
  for(int i=1;i<N+1;i++){
    cum[i] = cum[i-1] + e[i-1];
  }
  double max_sum = 0.0;
  for(int i=0;i<=N-K;i++){
    max_sum = max(max_sum, (cum[i+K]-cum[i]));
  }
  
  printf("%.12f", max_sum);
  
  //cout << ans << endl;
}

Measured memory_bytes: 4096
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		System.out.println("Yes");
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(), m=sc.nextInt();
		ArrayList<ArrayList<Integer>> array = new ArrayList<ArrayList<Integer>>();
		for(int i=0;i<n;i++) array.add(new ArrayList<Integer>());
		for(int i=0;i<m;i++) {
			int a=sc.nextInt()-1, b=sc.nextInt()-1;
			array.get(a).add(b);
			array.get(b).add(a);
		}
		sc.close();
		//BFS
		HashSet<Integer> closed = new HashSet<Integer>();
		Queue<Integer> q = new ArrayDeque<Integer>();
		int[] from = new int[n];
		q.add(0);
		while(!q.isEmpty()) {
			int now=q.poll();
			closed.add(now);
			ArrayList<Integer> temp = array.get(now);
			for(int i=0;i<temp.size();i++) {
				if(!closed.contains(temp.get(i))) {
					from[temp.get(i)]=now+1;
					closed.add(temp.get(i));
					q.add(temp.get(i));
				}
			}
		}
		for(int i=1;i<n;i++) System.out.println(from[i]);
	}
}

Measured memory_bytes: 78212
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

A = np.array(A, dtype=float)
A -= A.mean()
A = np.abs(A)
ans = A.argmin()

print(ans)


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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if (a+b < c+d){
		cout << "Right" << endl;
	}
	else if (a+b == c+d){
		cout << "Balanced" << endl;
	}
	else {
		cout << "Left" << endl; 
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

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

const ll MOD = 1e9 + 7;
const int A = 1, G = 2, C = 3, T = 4;
ll dp[101][4][4][4]; //初期値0

int main(){
    int n; cin >> n;
    // dp[n][最後の前の前の文字][最後の前の文字][最後の文字] := 長さnの文字列が何通り作れるか
    rep(i,4) rep(j,4) rep(k,4) dp[3][i][j][k] = 1;
    dp[3][A][G][C] = dp[3][A][C][G] = dp[3][G][A][C] = 0;
    for(int i = 4; i <= n; i++){
        rep(j,4){ //i-3文字目
            rep(k,4){ //i-2文字目
                rep(l,4){ //i-1文字目
                    rep(m,4){ //i文字目
                        if((j == A && k == G && m == C) || (j == A && l == G && m == C)) continue;
                        dp[i][k][l][m] = (dp[i][k][l][m] + dp[i-1][j][k][l]) % MOD;
                    }
                }
            }
        }
        // AGCが現れたら0に
        dp[i][A][G][C] = dp[i][A][C][G] = dp[i][G][A][C] = 0;
    }
    ll ans = 0;
    rep(i,4) rep(j,4) rep(k,4) ans = (ans + dp[n][i][j][k]) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define MAX_N 100000



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

  vector<string> ans(100);

  string alls, allb;
  REP(i,100){
    allb += '.';
    alls += '#';
  }
  REP(i,50){
    ans[i] = allb;
    ans[99-i] = alls;
  }

  REP(i,(a-1)/50){
    REP(j,50){
      ans[99-i*2][j*2] = '.';
    }
  }
  REP(j, (a-1)%50){
    ans[99-(a-1)/50*2][j*2] = '.';
  }

  REP(i,(b-1)/50){
    REP(j,50){
      ans[i*2][j*2] = '#';
    }
  }
  REP(j, (b-1)%50){
    ans[(b-1)/50*2][j*2] = '#';
  }

  cout << 100 << " " << 100 << endl;
  REP(i,100){
    cout << ans[i] << endl;
  }

  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using VI = vector<int>;
using VII = vector<VI>;

bool tateyoko(VII &check) {
  REP(i, 3) {
    bool yoko = true, tate = true;
    REP(j, 3) {
      if(check.at(i).at(j))
        continue;
      yoko = false;
    }
    if(yoko) return true;
    REP(j, 3) {
      if(check.at(j).at(i))
        continue;
      tate = false;
    }
    if(tate) return true;
  }
  return false;
}

bool naname(VII &check) {
  bool r = true, l = true;
  REP(i, 3) {
    if(check.at(i).at(i))
      continue;
    r = false;
  }
  REP(i, 3) {
    if(check.at(i).at(2-i))
      continue;
    l = false;
  }
  if(r || l)
    return true;
  else
    return false;
}

int main() {
  VII card(3, VI(3));
  REP(i, 3) REP(j, 3) cin >> card.at(i).at(j);
  VII check(3, VI(3));
  int N;
  cin >> N;
  REP(k, N) {
    int b;
    cin >> b;
    REP(i, 3) {
      REP(j, 3) {
        if(b == card.at(i).at(j))
          check.at(i).at(j) = 1;
      }
    }
  }
  if(tateyoko(check) || naname(check))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define MAX 1000000
class UnionFind{
  vector<int> v,deep;
  public:

  UnionFind(){
    v.resize(MAX);
    deep.resize(MAX);
    for(int i=1;i<MAX;i++){

      v[i]=i;

      deep[i] = 0;

    }

  }
    
  UnionFind(int num){
    v.resize(num+10);
    deep.resize(num+10);
    for(int i=1;i<num+10;i++){

      v[i]=i;

      deep[i] = 0;

    }
  }
   

  int root(int x){

    if(v[x]==x)return x;

    else return v[x] = root(v[x]);

  }



  bool same(int x, int y){

    return (root(x) == root(y));

  }



  void unite(int x,int y){

    x = root(x);

    y = root(y);

    if(deep[x] > deep[y]){

            v[y] = x;

    }else{

      if(deep[x] == deep[y])deep[y]++;

      v[x] = y;

    }

    return;

  }

};

int main(){
  int n,m;
  cin >> n >> m;
  UnionFind uf(n+m);
  for(int i=1;i<=n;i++){
      int j;
      cin >> j;
      for(int k = 0;k<j;k++){
          int l;
          cin >> l;
          uf.unite(i,n+l);
      }
  }
  for(int i=1;i<n;i++){
      if(!uf.same(i,i+1)){
          cout << "NO" << endl;
          return 0;
      }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1792
N,X,T=map(int,input().split())
#N個作る，X個T分で作れる

c=0

if N<X:
  c=1
  print(c*T)
  exit()

if N%X==0:
  c=N/X
else:
  c=(N//X)+1
  
print(int(c*T))

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

long long minsub(long long a, long long b, long long c)
{
    long long min, max;
    if (a < b)
    {
        min = a;
        max = b;
    }
    else
    {
        min = b;
        max = a;
    }

    if (c < min)
    {
        min = c;
    }

    if (max < c)
    {
        max = c;
    }

    return max - min;
}

int main()
{
    long long H, W;
    cin >> H >> W;

    if (0 == H % 3 || 0 == W % 3)
    {
        cout << 0 << endl;
    }
    else if (0 == H % 2 || 0 == W % 2)
    {
        long long mins = min(W, H);
        if (0 == H % 2)
        {
            mins = min(mins,
                       min(
                           abs(H * (W / 3) - (H / 2) * (W - W / 3)),
                           abs(H * (W / 3 + 1) - (H / 2) * (W - W / 3 - 1))));
        }
        if (0 == W % 2)
        {
            mins = min(mins,
                       min(
                           abs(W * (H / 3) - (W / 2) * (H - H / 3)),
                           abs(W * (H / 3 + 1) - (W / 2) * (H - H / 3 - 1))));
        }

        cout << mins << endl;
    }
    else
    {
        long long a1 = H * (W / 3), a2 = (H / 2) * (W - W / 3), a3 = (H / 2 + 1) * (W - W / 3);
        long long a4 = H * (W / 3 + 1), a5 = (H / 2) * (W - W / 3 - 1), a6 = (H / 2 + 1) * (W - W / 3 - 1);
        long long b1 = W * (H / 3), b2 = (W / 2) * (H - H / 3), b3 = (W / 2 + 1) * (H - H / 3);
        long long b4 = W * (H / 3 + 1), b5 = (W / 2) * (H - H / 3 - 1), b6 = (W / 2 + 1) * (H - H / 3 - 1);
        cout << min(min(min(
                            min(
                                minsub(a1, a2, a3),
                                minsub(a4, a5, a6)),
                            min(
                                minsub(b1, b2, b3),
                                minsub(b4, b5, b6))),
                        W),
                    H)
             << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(),b = scanner.nextInt();
		if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");
		}

	}

}


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

int main() {
  int N,K;
  cin >> N >> K;
  int num = 1;
  int A,B;
  rep(i,N){
    A = num * 2;
    B = num + K;
    if (A > B)
      num = B;
    else
      num = A;
  }
  cout << num << endl;
}


Measured memory_bytes: 256