akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
template<class T,class C> T max(T a,C b){ return ((a)>(T)(b) ? (a) : (T)(b)); }
template<class T,class C> T min(T a,C b){ return ((a)<(T)(b) ? (a) : (T)(b)); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
const int MAX = 1010000;
const int MOD = 1000000007;//998244353;
long long fac[MAX], finv[MAX], inv[MAX];
#define FACT(a) PERM(a,a)
#define modinv(a,mod) modpow((a),(mod)-2,(mod))
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
//二項係数計算
ll COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//順列計算
ll PERM(int n, int k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n] * finv[n-k]) % MOD;
}
void initialize(){
  COMinit();
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  string s;
  
  cin >> n;
  if(n==1){
    cout << 0 << endl;
    return 0;
  }
  
  result = modpow(10,n,MOD1);
  rep(i,2){
    result -= modpow(9,n,MOD1);
    if(result<0) result+=MOD1;
  }
  result += modpow(8,n,MOD1);
  result %= MOD1;
  
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 27300
n = int(input())

h = [int(i) for i in input().split()]

dp = (n+1) * [1000000000]
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2,n):
	dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
	dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[n-1]) 

Measured memory_bytes: 13976
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

vector<pair<ll, ll> > prime_factorize(ll n) {
  vector<pair<ll, ll> > res;

  for (ll p = 2; p * p <= n; p++) {
    if (n % p != 0) { continue; }
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }

  if (n != 1) { res.push_back(make_pair(n, 1)); }
  return res;
}

// n! の約数の数を mod で割った余りを返す
ll mod_div_fact(ll n, ll mod) {
  map<ll, ll> mp;
  for (ll i = 2; i <= n; i++) {
    vector<pair<ll, ll> > v = prime_factorize(i);
    for (ll j = 0; j < v.size(); j++) {
      ll prime = v[j].first;
      ll exp = v[j].second;

      mp[prime] += exp;
    }
  }
  ll res = 1;
  for (std::map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
    res *= ((it->second) + 1);
    res %= mod;
  }
  return res;
}

int main() {
  int n; cin >> n;
  const ll mod = ll(1e9)+7;
  
  cout << mod_div_fact(n, mod) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
int main(){
    using namespace std;
    int t,h,m,s;
    cin >> t;
    h = (t-t%3600)/3600;
    m = (t-h*3600-(t-h*3600)%60)/60;
    s = t-h*3600-m*60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}

Measured memory_bytes: 3104
#include "bits/stdc++.h"
#define rep(i,a,n) for(int = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	
	
	ll a,b,c,cnt = 0,tmpa,tmpb,tmpc;
	cin >> a >> b >> c;
	ll memo_a = a,memo_b = b,memo_c = c;
	bool flag = false;
	
	while(1){
		
		if(a % 2 || b % 2 || c % 2){
			cout << cnt << endl;
			break;
		}
		
		if(flag && a == memo_a && b == memo_b && c == memo_c){
			cout << -1 << endl;
			break;
		}
		
		tmpa = a / 2;
		tmpb = b / 2;
		tmpc = c / 2;
		
		a = tmpb+tmpc;
		b = tmpa+tmpc;
		c = tmpa+tmpb;
		
		if(!flag) flag = true;
		cnt++;
	}
	
	return 0;
}

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


int main() {
    string S, T;
    cin >> S >> T;

    bool ans = false;
    for (int i = 0; i < T.size(); ++i) {
        char tmp = T[T.size()-1];
        for (int j = T.size(); j > 0; --j) {
            T[j] = T[j-1];
        }
        T[0] = tmp;
        if (S == T) {
            ans = true;
            break;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
long long  MIN(long long a,long long b){return a<b?a:b;}
int main(){
  long long n,m,a[2010],b[2010],min=1e18,s,i,j;
  scanf("%lld %lld",&n,&m);//printf("%lld\n",min);
  for(i=0;i<n;i++)scanf("%lld",&a[i]);
  for(i=0;i<n;i++)b[i]=1e9;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)b[j]=MIN(b[j],a[(j-i+n)%n]);
    for(j=s=0;j<n;j++)s+=b[j];
    min=MIN(min,s+m*i);
  }
  printf("%lld\n",min);
  return 0;
}


Measured memory_bytes: 256
/*
    C - Dice and Coin
    https://atcoder.jp/contests/abc126/tasks/abc126_c
*/
#include <bits/stdc++.h>
using namespace std;

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

    double n, k;
    cin >> n >> k;

    // サイコロを降る回数
    vector<int> num_of_playing_dice(n);

    // サイコロを何回振る必要があるか
    for (int i = 1; i <= n; i++) {
        int count = 0;
        int dice = i;
        while (dice < k) {
            dice *= 2;
            count++;
        }
        num_of_playing_dice[i - 1] = count;
    }

    // cout << "num of playing dice" << endl;
    // for (auto dice : num_of_playing_dice)
    //     cout << dice << endl;

    double probability = 0.0;
    for (auto dice : num_of_playing_dice) {
        probability += (double)pow(0.5, dice);
    }
    cout << fixed;
    cout << setprecision(10) << (probability / n) << endl;
}


Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn comp(s: &[char], t: &[char], o: Ordering) -> bool {
    let mut pos = 0;
    let lim = match o {
        Ordering::Less => 'a',
        Ordering::Greater => 'z',
        _ => panic!(),
    };
    loop {
        if pos >= s.len() && pos >= t.len() {
            return true;
        }
        if pos >= t.len() {
            return o == Ordering::Greater;
        }
        if pos >= s.len() {
            return o == Ordering::Less;
        }
        if s[pos] == '?' {
            if t[pos] != lim {
                return true;
            }
        }
        if s[pos] != t[pos] {
            return s[pos].cmp(&t[pos]) == o;
        }
        pos += 1;
    }
}

fn solve() {
    let n = get();
    let s: Vec<Vec<_>> = (0 .. n).map(|_| get_word().chars().collect())
        .collect();
    let t: Vec<_> = get_word().chars().collect();
    let mut le = 0;
    let mut ge = 0;
    for i in 0 .. n {
        if comp(&s[i], &t, Ordering::Less) {
            le += 1;
        }
        if comp(&s[i], &t, Ordering::Greater) {
            ge += 1;
        }
    }
    for i in n - ge .. le + 1 {
        print!("{}{}", i + 1, if i == le { "\n" } else { " " });
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <cstdio>
int main() {
	int E,Y;
	scanf("%d %d",&E,&Y);
	if(E==0) {
		if(Y<=1911) printf("M%d\n",Y-1868+1);
		else if(Y<=1925) printf("T%d\n",Y-1912+1);
		else if(Y<=1988) printf("S%d\n",Y-1926+1);
		else printf("H%d\n",Y-1989+1);
	}else if(E==1) {
		printf("%d\n",1868+(Y-1));
	}else if(E==2) {
		printf("%d\n",1912+(Y-1));	
	}else if(E==3) {
		printf("%d\n",1926+(Y-1));	
	}else {
		printf("%d\n",1989+(Y-1));	
	}
}


Measured memory_bytes: 2712
import java.util.Scanner;

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

		int a = sc.nextInt();
		int p = sc.nextInt();

		int pie = (a * 3 + p) / 2;

		System.out.println(pie);

		sc.close();
	}

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    int K,A,B;
    cin>>K>>A>>B;
    REP(i,B-A+1){
        if((i+A)%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    
            cout<<"NG"<<endl;
            return 0;
    

    return 0;
}

Measured memory_bytes: 3652
A,B = list(map(int,input().split()))
S = input()

for i in range(A):
    if S[i] == "-":
        print("No")
        exit()

if S[A] != "-":
    print("No")
    exit()

for i in range(A+1,A+1+B):
    if S[i] == "-":
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 3060
n = gets.to_i
a = [1]
six = 6
6.times do
  a << six
  six *= 6
end
nine = 9
5.times do
  a << nine
  nine *= 9
end
ret = []
ret[0] = 0
for i in 1...100001
  ret[i] = 100000
end
for i in 1..n
  for j in a
    if i - j >= 0
      ret[i] = ret[i] < ret[i-j] + 1 ? ret[i] : ret[i-j] + 1
    end
  end
end
puts ret[n]

Measured memory_bytes: 2632
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long

#define VI vector<int> 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数定義や変数宣言



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int N;
cin>>N;

int P[N];
int Q[N];
int R[N];

REP(i,N){cin>>P[i];}
REP(i,N){cin>>Q[i];}
REP(i,N){R[i]=i+1;} //元の辞書通りのもの

int p_cnt=0,q_cnt=0;
int num=1;

do
{
	REP(i,N){ 
		if(R[i]!=P[i]){
			break;
		}
		if ( i== N-1 && R[i]==P[i])//breakせずに最後まで行き、一致したとき
		{
			p_cnt=num;
		}
	}

	REP(i,N){ 
		if(R[i]!=Q[i]){
			break;
		}
		if (i== N-1 && R[i]==Q[i])//breakせずに最後まで行き、一致したとき
		{
			q_cnt=num;
		}
	}

num++;


	
} while(next_permutation(R,R+N));


cout<<abs(p_cnt - q_cnt)<<endl;


}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 1e5 + 7;
char s[maxn];
int main(){
    scanf("%s", s+1);
    int len = strlen(s+1);
    if(s[1] != '1' || s[len] != '0'){
        printf("-1\n");
        return 0;
    }
    for(int i = 1; i <= len/2; ++i){
        if(s[i] != s[len-i]){
            printf("-1\n");
            return 0;
        }
    }
    int record = -1;
    for(int i = len/2; i >= 1; --i){
        if(s[i] == '1'){
            record = i;
            printf("%d %d\n", i, i+1);
            for(int j = i+2; j <= len; ++j){
                printf("%d %d\n", i+1, j);
            }
            break;
        }
    }
    for(int i = record-1; i >= 1; --i){
        printf("%d %d\n", record, i);
        if(s[i] == '1'){
            record = i;
        }
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
  int root(int x) {
        if (data[x] < 0) return x;
        else return data[x] = root(data[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  srep(b,1,n+1){
    ans+=n/b * max(0LL,b-k);
    ans+=max(0LL,n%b-k+1);
  }
  if(k == 0)ans-=n;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main()
{
  int n,m;
  while(cin>>n>>m)
  {
    vector<pair<int,string>> idol;
    map<string,int> vocal;
    map<string,int> dance;
    map<string,int> face;

    int C,vo,da,lx;
    for(int i = 0;i < n;++i){
      string name;
      cin.ignore();  
      getline(cin,name);
      cin>>C;
      idol.push_back(make_pair(C,name));
      
      cin>>vo>>da>>lx;
      vocal[name] = vo;
      dance[name] = da;
      face[name] = lx;
    }

    sort(idol.begin(),idol.end());

    int v[301] = {0};
    for(int i = 1;i <= m;++i){
      for(pair<int,string> e : idol){
        int c = e.first;
        string n = e.second;

        if(i - c >= 0){
          v[i] = max(v[i],v[i - c] + vocal[n]);
        }
      }
    }

    int d[301] = {0};
    for(int i = 1;i <= m;++i){
      for(pair<int,string> e : idol){
        int c = e.first;
        string n = e.second;

        if(i - c >= 0){
          d[i] = max(d[i],d[i - c] + dance[n]);
        }
      }
    }

    int f[301] = {0};
    for(int i = 1;i <= m;++i){
      for(pair<int,string> e : idol){
        int c = e.first;
        string n = e.second;

        if(i - c >= 0){
          f[i] = max(f[i],f[i - c] + face[n]);
        }
      }
    }

    int ans = max(v[m],d[m]);
    ans = max(ans,f[m]);
    cout<<ans<<endl;
  }

  return 0;
}


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

#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

#define MAXX 2050


#define PI 3.14159265358979323846264338327950

#define ll   long long int
ll mod = 1000000007;
ll a[MAXX], b[MAXX];

int main()
{
	FAST;
	ll n, t , h = 1;
	char c;
	cin >> c;
	if(c > 90){
		cout << "a";
	}
	else{
		cout << "A";
	}
	
}

Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include<map>
using namespace std;

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

int main() {
	int N;
	int p[100005];
	cin >> N;
	REP(i, N) {
		cin >> p[i + 1];//1-indexed
	}

	int cnt = 0;
	for(int i=1;i<=N;i++) {
		if (i == p[i]) cnt++;
	}

	int bef = 0;
	for (int i = 1;i <= N;i++) {
		if (bef == 0) {
			if (i == p[i]) bef = 1;
		}
		else {
			if (i == p[i]) {
				cnt--;
				bef = 0;
			}
			else {
				bef = 0;
			}
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
#a ,b  = list(map(int,input().split()))
list = []
judge = False
for i in range(9):
    for j in range(9):
        list.append((i+1)*(j+1))
for i in range(len(list)):
    if list[i] == n:
        judge = True
if judge == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
    public static void main(String[] args) throws Exception {
        int count = 0;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] z = str.split(" ");
        int a = Integer.parseInt(z[0]);
        int b = Integer.parseInt(z[1]);
        int c = Integer.parseInt(z[2]);
        
        while(a<=b){
            if(0==c%a){
                count++;
            }
            a++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 24408
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1e9+9;
const int INF = 1e9;

int main(){
    ll n, k;
    cin >> n >> k;

    if (k == 0){
        cout << n * n << endl;
        return 0;
    }

    ll cnt = 0;
    REP(x,k+1,n+1){
        ll y = x - k;
        cnt += (n / x) * y;
        ll z = n % x;
        if (z >= k && z != 0) cnt += z - k + 1;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;
 
 
typedef long long ll;
typedef vector<int> VI;
    
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}
//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
ll N, K;
string s;
ll a[100010];
int main(void) {
    cin >> N >> K;
    REP(i, N) cin >> a[i];
    
    ll gcd=a[0];
    ll maxV=0;
    
    REP(i, N) maxV = max(maxV, a[i]);
    
    for(int i=1; i<N; ++i){
        gcd = GCD(gcd, a[i]);
    }
    if(K%gcd==0&&maxV>=K) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl; 
	return 0;
}

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

struct Dice {
  int top, front, right, left, back, bottom;
  // constructor
  //
  //         top:1
  //           |
  // left:4--front:2--right:3--back:5
  //           |
  //         bottom:6
  //
  Dice(vector<int> v) {
    top    = v.at(0);
    front  = v.at(1);
    right  = v.at(2);
    left   = v.at(3);
    back   = v.at(4);
    bottom = v.at(5);
  }

  void roll(char c) {
    int old_top = top;
    if (c == 'E') {
      top    = left;
      left   = bottom;
      bottom = right;
      right  = old_top;
    } else if (c == 'N') {
      top    = front;
      front  = bottom;
      bottom = back;
      back   = old_top;
    } else if (c == 'S') {
      top    = back;
      back   = bottom;
      bottom = front;
      front  = old_top;
    } else if (c == 'W') {
      top    = right;
      right  = bottom;
      bottom = left;
      left   = old_top;
    }
  }
};

int main() {
  // 各面の整数
  vector<int> v(6);
  for (int i = 0; i < 6; i++) {
    cin >> v.at(i);
  }
  // 命令を表す文字列
  string s;
  cin >> s;

  Dice dice(v);
  for (int i = 0; i < (int)s.length(); i++) {
    char c = s.at(i);
    dice.roll(c);
  }

  cout << dice.top << endl;
  return 0;
}



Measured memory_bytes: 3176
//kruskal tree
#include <iostream>
#include <algorithm>
using namespace std;
#define M 999
int parent[M],a[M],b[M];
pair<int,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	int i,s,n,m;
	for(;cin>>n>>m,n;cout<<s<<endl){
		for(i=0;i<m;i++)cin>>a[i]>>b[i]>>node[i].first,node[i].second=i;
		sort(node,node+m);
		for(i=0;i<n;i++)parent[i]=i;
		for(s=i=0;i<m;i++)if(unite(a[node[i].second],b[node[i].second]))s+=node[i].first;
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;
int T[1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	int ret=0;
	FOR(i,N) {
		cin>>x;
		if(x<A || x>=B) ret++;
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int32_t main()
{
    IOS
    cin>>n>>m;
    fun(i)
    {
        cin>>a[i];
    }
    fu(i,1,n)
    {
        int zuo=0,you=0;
        fu(j,1,n)
        {
            if(a[j]<a[i])
            {
                if(j<i)zuo++;
                else you++;
            }
        }
        ans=mod(ans+you*m);
        ans=mod(ans+(zuo+you)*mod(m*(m-1)/2));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#define ll long long
using namespace std;
ll l[100005], r[100005];

int main() {
	ll n, m, min, max;

	ll hogemax, hogemin;

	cin >> n >> m;
	min = 1;
	max = n;
	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i];
	}
	for (int i = 0; i < m; i++) {
		hogemin = l[i];
		hogemax = r[i];
		if (min < hogemin)min = hogemin;
		if (max > hogemax)max = hogemax;
	}

	ll ans = max - min + 1;
	if (ans < 0)ans = 0;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main () {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i]=='7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  printf("No");
}

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

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  string a,b; cin >> a >> b; int ans=0;
  for(int i=0;i<3;i++)if(a[i] == b[i]) ans++;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int dp[100001];

int solve(int n, int k, vector<int> h) {
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (int i = 1; i < n; i++) {
		int t = INF;
		for (int j = 1; (j <= k) && (i - j >= 0); j++) {
			t = min(t, dp[i-j] + abs(h[i-j] - h[i]));
		}
		dp[i] = t;
	}
	return dp[n-1];
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	cout << solve(n, k, h) << endl;
}

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

int main(){
	string w;
    cin>>w;
    vector<char> m(w.size());
  
    if(w.size()<=1){
    	cout<<"No"<<endl;
      	return 0;
    }
  
    for (int i=0;i<w.size();i++){
    	m.at(i)=w.at(i);
    }
  	sort(m.begin(),m.end());
    
  int count=1;
  for (int i=0;i<m.size()-1;i++){
    	if(m.at(i)==m.at(i+1)){
        	count++;
        }
        if(m.at(i)!=m.at(i+1)){
        	if(count%2!=0){
            	cout<<"No"<<endl;
              	return 0;
            }else{
            	count=1;
            }
        }
          
    }
   cout<<"Yes"<<endl;
}    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll l,r;
  cin >> l >> r;
  if (r-l >= 2018 or r%2019 <= l%2019) cout << 0;
  else{
    ll mini=INT_MAX;
    for (ll i=l; i<=r; ++i){
      for (ll j=i+1; j<=r; ++j){
        mini = min(mini,(i*j)%2019);
      }
    }
    cout << mini;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int a,b,c,d,ans,tmp;
    string s;
 
    a = b = c = d = ans = tmp = 0;
    //vector<int>a();

    cin >> s;
    tmp = s.size();


    for(int i=0;i < tmp;i++){
       	a =  (int)(s.at(i) - '0');
      	ans += a;
      	//cout << (unsigned char)s.at(i);
    }
  
    if(ans % 9 == 0)cout << "Yes";
    else cout << "No";
   
}


Measured memory_bytes: 3720
n=int(input())
P=list(map(int,input().split()))
wrong=[]
for i in range(n):
  if P[i]!=i+1:
    wrong.append(P[i])
if len(wrong)==0:
  print('YES')
elif len(wrong)==2:
  if wrong[0]==P[wrong[1]-1]:
    print('YES')
  else:
    print('NO')
else:
  print('NO')

Measured memory_bytes: 3316
import sys
input = sys.stdin.readline
import heapq as hq
n,m = map(int,input().split())
s,t = map(int,input().split())
abd = [list(map(int,input().split())) for i in range(m)]
mod = 10**9+7
graph = [[] for i in range(n+1)]
#隣接リスト
for a,b,d in abd:
  graph[a].append((b,d))
  graph[b].append((a,d))
dists = [[10**18,0] for i in range(n+1)]
distt = [[10**18,0] for i in range(n+1)]
#S,Tからdijkstra
#distX[i]: [Xからiへの最短経路長、そのパスの本数]
for start,dist in (s,dists),(t,distt):
  dist[start] = [0,1]
  q = [(0,start)]
  hq.heapify(q)
  while q:
    dx,x = hq.heappop(q)
    k = dist[x][1]
    for y,d in graph[x]:
      if dist[y][0] > dx+d:
        dist[y][0] = dx+d
        dist[y][1] = k
        hq.heappush(q,(dist[y][0],y))
      elif dist[y][0] == dx+d:
        dist[y][1] = (dist[y][1]+k)%mod
dst = dists[t][0]
#dst: S-T間の距離
#anslsに「2人が出会いうる辺/頂点を通るパスの本数」を格納
ans = dists[t][1]**2%mod
for v in range(1,n+1):
  if dists[v][0]+distt[v][0] != dst:
    continue
  if dists[v][0]*2 == distt[v][0]*2 == dst:
    ans = (ans-(dists[v][1]*distt[v][1])**2)%mod
  else:
    for u,d in graph[v]:
      if dists[u][0]*2 < dst and distt[v][0]*2 < dst:
        if dists[u][0]+distt[v][0]+d == dst:
          ans = (ans-(dists[u][1]*distt[v][1])**2)%mod
#答え: anslsの要素をaiとすると
#(Σai)^2-Σ(ai^2)になるはず…

print(ans%mod)

Measured memory_bytes: 128988
#include<iostream>
#include<deque>
#define pb push_back
#define pf push_front
using namespace std ;

char map[1001][1001] = {} ;
char num[] = { '0','1','2','3','4','5','6','7','8','9' } ;
int num_map[1001][1001] = {} ;
int dx[] = { -1,0,1,0 } ;
int dy[] = { 0,-1,0,1 } ;
deque<int> qx ;
deque<int> qy ;
deque<int> qc ;

int main(){
	
	int h , w , n ;
	int nx , ny , nc ;
	int ans = 0 ;
	
	cin >> h >> w >> n ;
	for( int i=0 ; i<h ; i++ ){
		for( int j=0 ; j<w ; j++ ){
			cin >> map[i][j] ;
			if( map[i][j] == 'S' ){
				qy.pb(i) ;
				qx.pb(j) ;
			}
		}
	}
	
	for( int i=1 ; i<=n ; i++ ){
		num_map[qy.front()][qx.front()] = i ;
		qc.pb(0) ;
		while(1){
			nx = qx.front() ;
			ny = qy.front() ;
			nc = qc.front() ;
			
			if( map[ny][nx] == num[i] ) break ;
			for( int j=0 ; j<4 ; j++ ){
				if( 0 <= ny+dy[j] && ny+dy[j] < h &&
					0 <= nx+dx[j] && nx+dx[j] < w &&
					num_map[ny+dy[j]][nx+dx[j]] < i &&
					map[ny+dy[j]][nx+dx[j]] != 'X' ){
						num_map[ny+dy[j]][nx+dx[j]] = i ;
						qy.pb( ny+dy[j] ) ;
						qx.pb( nx+dx[j] ) ;
						qc.pb( nc+1 ) ;
				}
			}
			qx.pop_front() ;
			qy.pop_front() ;
			qc.pop_front() ;
		}
		qy.clear() ;
		qx.clear() ;
		qc.clear() ;
		qy.pb(ny) ;
		qx.pb(nx) ;
		ans += nc ;
	}
	
	cout << ans << endl ;
	
return 0;
}

Measured memory_bytes: 6108
import numpy as np
A = [list(map(int, input().split())) for _ in range(3)]
A = A[0]+A[1]+A[2]
N = int(input())
for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = -1

C = [A[:3], A[3:6], A[6:]]
C = np.array(C)

ans = "No"
for i in range(3):
    if (C[i] == -1).all():
        ans = "Yes"
    if (C[:, i] == -1).all():
        ans = "Yes"

if C[0][0] == C[1][1] == C[2][2] == -1:
    ans = "Yes"
if C[2][0] == C[1][1] == C[0][2] == -1:
    ans = "Yes"

print(ans)


Measured memory_bytes: 21544
#include<stdio.h>
int main(void){
  char x[100000];
  scanf("%s",x);
  int i,t;
  for(i=0;x[i]!='\0';i++);
    for(t=0;t<i;t=t+2){
      printf("%c",x[t]);
    }
  return 0;
}
    

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

a = list(map(int,input().split()))
maxlen = 0
for i in range(1,n):
	maxlen = max(a[i] - a[i-1],maxlen) 

maxlen = max(a[0] + k - a[-1],maxlen) 


print(k - maxlen)


Measured memory_bytes: 25840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;


public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      List<String> workList = new LinkedList<>();
      List<String> stockList= new LinkedList<>();
      List<String> sList;
      int p = 0;
      String[] query;

      workList.add("END");
      int op,move;
      for ( int i=0; i<q; i++ ){
        query = br.readLine().split(" ");
        op  = Integer.parseInt(query[0]);

        switch( op ) {
          case 0 :
            workList.add(0,query[1]);
            break;
          case 1 :
            move = Integer.parseInt(query[1]);
            if(move < 0) {
              sList = stockList.subList(p + move, p);
              workList.addAll(0, sList);
              sList.clear();
              p += move;
            }
            else {
              p += move;
              sList = workList.subList(0, move);
              stockList.addAll(sList);
              sList.clear();
            }
            break;
          case 2 :
            workList.remove(0);
            break;
          default:
        }
      }
      stockList.addAll(workList);
      workList = stockList;
      workList.remove(workList.size()-1);

      workList.forEach(System.out::println);
    }
  }
}


Measured memory_bytes: 156572
import math

n=int(input())
city=[[int(i) for i in input().split()] for i in range(n)]
nkai=math.factorial(n)
n1kai=math.factorial(n-1)

lengths=[]
for i in range(n):
  for j in range(n):
    length=((city[i][0]-city[j][0])**2+(city[i][1]-city[j][1])**2)**0.5
    lengths.append(length)
   
total=n1kai*2*sum(lengths)
ans=total/nkai/2
print(ans)
    


Measured memory_bytes: 3188
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int a, b, c, d; cin >> a >> b >> c >> d;
    if(min(b, d) - max(a, c) > 0)
        cout << min(b, d) - max(a, c) << endl;
    else cout << 0 << endl;
    
return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    static int dp[][][][] = new int [101][4][4][4];

    public static void main(String[] args) {
        int N = sc.nextInt();
        int mod = 1000000007;

        dp[0][3][3][3] = 1;

        for (int len = 0; len < N; len++) {
            // 最後から1文字目
            for (int c1 = 0; c1 < 4; c1++) {
                // 最後から2文字目
                for (int c2 = 0; c2 < 4; c2++) {
                    // 最後から3文字目
                    for (int c3 = 0; c3 < 4; c3++) {

                        // 条件に当てはるものがなければスキップ
                        if (dp[len][c1][c2][c3] == 0) continue;

                        // 新しく追加する。A,G,C,Tの全パターン　
                        for (int a = 0; a < 4; a++) {

                            if (a == 2 && c1 == 1 && c2 == 0) continue;
                            if (a == 2 && c1 == 0 && c2 == 1) continue;
                            if (a == 1 && c1 == 2 && c2 == 0) continue;
                            if (a == 2 && c1 == 1 && c3 == 0) continue;
                            if (a == 2 && c2 == 1 && c3 == 0) continue;

                            dp[len+1][a][c1][c2] += dp[len][c1][c2][c3];
                            dp[len+1][a][c1][c2] = dp[len+1][a][c1][c2] % mod;
                        }


                    }
                }
            }
        }

        int ans = 0;
        for (int c1 = 0; c1 < 4; c1++) {
            for (int c2 = 0; c2 < 4; c2++) {
                for (int c3 = 0; c3 < 4; c3++) {
                    ans += dp[N][c1][c2][c3];
                    ans %= mod;
                }
            }
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N,K;
    cin >> N >> K;
    vector<int> l(N);
    VECCIN(l);

    RSORT(l);
    int ans = 0;
    REP(i, K) {
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 0;
		int count = 0;
		int[] ary = new int[100001];
		ary[0] = 0;
		while(i < 9){
			i++;
			count++;
			ary[i] = count;
		}
		while(i < 99){
			i++;
			ary[i] = count;
		}
		while(i < 999){
			i++;
			count++;
			ary[i] = count;
		}
		while(i < 9999){
			i++;
			ary[i] = count;
		}
		while(i < 99999){
			i++;
			count++;
			ary[i] = count;
		}
		i++;
		ary[i] = count;
		System.out.println(ary[n]);
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (int i = n - 1; i >= a; i--)
#define show(x) cout << x << '\n'
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vpair vector<pair<ll, ll>>
#define vtuple vector<tuple<ll, ll, ll>>
#define ff first
#define ss second
#define mod 1000000007
#define memset(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
auto t1 = chrono::high_resolution_clock::now();
bool prime[1000001];

ll expo(ll a, ll b)
{
	a = a % mod;
	b = b % mod;
	if (b == 0)
		return 1;
	if (b % 2)
		return ((a % mod) * (expo((a * a) % mod, b / 2) % mod)) % mod;
	return expo((a * a) % mod, b >> 1) % mod;
}

ll mul(ll a, ll b)
{
	a = a % mod;
	b = b % mod;
	if (b == 0)
		return 0;
	if (b % 2)
		return ((a % mod) + (mul((a + a) % mod, b >> 1) % mod)) % mod;
	return mul((a + a) % mod, b >> 1) % mod;
}

bool ispoweroftwo(ll x)
{
	return x && !(x & (x - 1));
}

ll xorcal(ll n)
{
	if (n % 4 == 0)
		return n;
	if (n % 4 == 1)
		return 1;
	if (n % 4 == 2)
		return n + 1;
	if (n % 4 == 3)
		return 0;
}

void sieve(ll n)
{
	memset(prime, true);
	prime[0] = false;
	prime[1] = false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (prime[i] == true)
		{
			for (ll j = i * i; j <= n; j += i)
				prime[j] = false;
		}
	}
}

ll modinverse(ll a, ll m)
{
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m;
		a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

void binary(ll a[], ll n)
{
	gor(i, 0, 64)
	{
		ll k = n >> i;
		a[i] = k & (ll)1;
	}
}

ll countBits(ll n)
{
	if (n == 0)
		return 0;
	return 1 + countBits(n & (n - 1));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, m, a, sum = 0;
	cin >> n >> m;
	go(i, 0, m)
	{
		cin >> a;
		sum += a;
	}
	if (n - sum < 0)
		show("-1");
	else
		show(n - sum);
	auto t2 = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
	clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
	return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <cmath>
using namespace std;

#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

int main() {
	int N;
	cin >> N;
	long long value = 0;
	for (int i = 1;; ++i) {
		value += i;
		if (N <= value) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "\n");
  }
  // os << '}';
  return os;
}

int main()
{
  ll n;
  cin >> n;
  vi a(n - 1);
  vi b(n);
  cin >> a;
  rep(i, n - 1)
  {
    a[i]--;
    b[a[i]]++;
  }
  cout << b << endl;
}

Measured memory_bytes: 4844
#include<stdio.h>

int main(){
  long n;
  scanf("%ld",&n);
  long n2 = n;
  int d = 1;//number of digit
  long l = 26;//large
  while(l < n2){
    n2 = n2 - l;
    l = l * 26;
    d++;
  }
  n2 = n;
  l = 26;
  char name[d + 1];//name;
  int tmp;
  for(int i = d - 1;i >= 0;i--){
    tmp = n % 26;
    name[i] =  'a' + tmp - 1;
    if(tmp == 0){
      name[i] ='z';
      tmp = 26;
    }
    n = (n - tmp)/26;
  }
  for(int i = 0;i < d;i++){
    printf("%c",name[i]);
  }
  //printf("%s",name);
  printf("\n");
  return 0;
}


Measured memory_bytes: 1656
// AC

#include <bits/stdc++.h>
using namespace std;

#define INF 1e18L+5
typedef long long int ll;

int main()
{
  // INPUT
  int n; ll w; cin >> n >> w;
  ll wt[n+1];
  int  val[n+1];
  int vmax=0;
  for(int i=1;  i<=n; i++)
  {
    cin >> wt[i] >> val[i];
    vmax +=val[i];
  }

  // INIT
  ll dp[vmax+1]={};

  for(int i=1;i<=vmax;i++) dp[i]=INF;
  // Base case already done: dp[0]=0;


  for(int i=1;i<=n;i++)
  {
    for(int k = vmax - val[i]; k>=0; k--)
    {
      // dp[x] = is the max val with weight x, and upto i items included
      dp[k+val[i]] = min(dp[k+val[i]],dp[k]+wt[i]);
      // cout << k << " " << val[i] << " " << dp[k+val[i]] << endl;

    }
  }

  // OUTPUT
  int ans=0;
  for(int i=1;i<=vmax;i++)
  {
    if(dp[i]<=w) ans=i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A;
  int B1, B2;
  scanf("%lld", &A);
  scanf("%d.%d", &B1, &B2);
  cout << A * (B1*100+B2) / 100 << "\n";
  return 0;
}


Measured memory_bytes: 3664