akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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 gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n,k;
cin>>n>>k;
ll a=1;
for(int i=0;i<n;i++){
    if(a<=k){
        a*=2;
    }else{
        a+=k;
    }
}
cout<<a<<endl;
}












Measured memory_bytes: 256
//
//  main.cpp
//  AGC043A2
//
#include <iostream>
#include <vector>
#include <algorithm> // min
using namespace std;
int main(int argc, const char * argv[]) {
    int H,W;
    cin>>H>>W;
    vector<vector<char>> p(H+1,vector<char>(W+1,'.')); // 盤のデータ #黒　.白
    for (int r=1; r<=H; r++) {
        for (int c=1; c<=W; c++) {
            cin>>p.at(r).at(c);
        }
    }
    vector<vector<int>>dp(H+1,vector<int>(W+1,0)); // ゴールにたどり着くまで 違う色に移動する回数
    for (int i=1; i<=H; i++) {
        for (int j=1; j<=W; j++) {
            int from_Left=0;
            int from_Up=0;
            if (p.at(i).at(j)!=p.at(i).at(j-1)) {
                from_Left=1;
            }
            if(p.at(i).at(j)!=p.at(i-1).at(j)){
                from_Up=1;
            }
            if (i==1) { // １行目は左からのみ
                dp.at(i).at(j)=dp.at(i).at(j-1)+from_Left;
            }
            if(j==1){ // 一列目は上からのみ
                dp.at(i).at(j)=dp.at(i-1).at(j)+from_Up;
            }
            if (i!=1 && j!=1) {
                dp.at(i).at(j)=min(dp.at(i).at(j-1)+from_Left,dp.at(i-1).at(j)+from_Up);
            }
        }
    }
    if (p.at(H).at(W)=='#') {
        dp.at(H).at(W)++;
    }
            cout<<dp.at(H).at(W)/2<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=a*b;
	y=c*d;
	if(x>y) printf("%d\n",x);
	else if(x<y) printf("%d\n",y);
	else printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n;
    vector<string> s;
    cin >> n;
    s.resize(n);
    int c=0;
    int na = 0, nb = 0, nab = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        bool b = false;
        for (int j=0; j<s[i].size(); j++) {
            if (s[i][j] == 'A') {
                b = true;
            }
            else if (s[i][j] == 'B') {
                if (b) c++;
                b = false;
            }
            else {
                b = false;
            }
        }
        if ( s[i][0] == 'B' && s[i][s[i].size()-1] == 'A' ) nab++;
        else if ( s[i][s[i].size()-1] == 'A' ) na++;
        else if ( s[i][0] == 'B' ) nb++;
    }

    if (nab != 0 && na + nb == 0)  
        cout << c + nab-1 << endl;
    else
        cout << c + nab + min(na, nb) << endl;

    return 0;
}

Measured memory_bytes: 768
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <queue>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int H, W, cnt;
vector<string> s(50);
vector<vector<int>> d(50, vector<int>(50, INT_INF));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
typedef pair<int, int> P;

int main()
{
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        cin >> s[i];
    }
    if (s[0][0] == '#')
    {
        cout << -1 << endl;
        return 0;
    }
    queue<P> que;
    que.push(P(0, 0));
    d[0][0] = 0;
    while (que.size())
    {
        P p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++)
        {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < W && 0 <= ny && ny < H && s[ny][nx] != '#' && d[nx][ny] == INT_INF)
            {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    if (d[W - 1][H - 1] == INT_INF)
    {
        cout << -1 << endl;
    }
    else
    {
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (s[i][j] == '#')
                {
                    cnt++;
                }
            }
        }
        cout << H * W - (d[W - 1][H - 1] + 1) - cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

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

# 同じ桁に1が2回現れたらダメ
# 現在のビット列を持ち、同じ桁に1が2回現れない限り延長していく尺取り法

right = 0
xor = 0 # 現在のビット列
ans = 0

def isOk(x, v):
#  print("x",x,bin(x)[2:].zfill(5),"v",v,bin(v)[2:].zfill(5))
  K = min(x, v)
  while K:
    if (x & 1) and (v & 1):
#      print("ng")
      return False
    K >>= 1
    x >>= 1
    v >>= 1
#  print("ok")
  return True

for left in range(N):
  while right < N:
    if isOk(xor, A[right]): # 同じ桁に1が2回現れないことをチェック
      xor ^= A[right]
      right += 1
    else:
      break
      
#  print("left",left,"right",right)
  ans += (right - left)
  # その区間に含まれる組み合わせはすべて選べる
#  ans += (ran * (ran - 1)) // 2 + ran
  
  if right == left:
    right += 1
  else:
    xor ^= A[left]
  
print(ans)

Measured memory_bytes: 23508
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
const ll MOD=1e9+7;
using namespace std;

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  int r=0,b=0;
  rep(i,N){
    if(s[i]=='R') r++;
    else b++;
  }
  if(r>b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
const int N = 2e5 + 5;
vector<vector<int>> adj;
int val[N];

class DKi {
public:
    void dfs(int u, int p) {
        val[u] += val[p];
        for (int v: adj[u]) {
            if (v != p) dfs(v, u);
        }
    }

    void solve(std::istream &in, std::ostream &out) {
        int n, q;
        in >> n >> q;
        memset(val, 0, sizeof val);
        adj = vector<vector<int>>(n + 1);
        for (int i = 0; i < n - 1; ++i) {
            int u, v;
            in >> u >> v;
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        for (int i = 0; i < q; ++i) {
            int p, x;
            in >> p >> x;
            val[p] += x;
        }
        dfs(1, 0);
        for (int i = 1; i <= n; ++i) out << val[i] << ' ';
    }
};


int32_t main() {
    DKi solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 20480
#include<stdio.h>
#include<string.h>
#define N 100
static const int INFTY=(1<<21);

int n,M[N][N];
int d[N],Q[N*2],head,tail;

void bfs(int s){
  int i,u,v;
  head=tail=1;
  Q[tail++]=s;

  for(i=0;i<n;i++)d[i]=INFTY;
  d[s]=0;
  while(!(head==tail)){
    u=Q[head++];
    for(v=0;v<n;v++){
      if(M[u][v]==0)continue;
      if(d[v]!=INFTY)continue;
      d[v]=d[u]+1;
      Q[tail++]=v;
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,((d[i]==INFTY)?(-1):d[i]));
  }
} 

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

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  bfs(0);
  
  return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main() {
    double a,b,x;
    cin >>a>>b>>x;
    double v=a*a*b/2;
    double ans;
    if(v<=x){
        double tmp;
        tmp=(2*a*a*b-2*x)/(a*a*a);
        ans=atan(tmp);
    }
    else {
        double tmp;
        tmp=a*b*b/(2*x);
        ans=atan(tmp);
    }
    double pi=3.1415926535897932384;
//    cout <<atan(1)*180/pi<<endl;
    cout <<setprecision(20)<<ans*180/pi <<endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

vector<int> tonari[51];

struct Stat{
    ll cost;
    int silver;
    int city;

    bool operator< (const Stat &y) const {
        return this->cost<y.cost;
    };
    bool operator> (const Stat &y) const {
        return this->cost>y.cost;
    };
};

void solve(int ca){
    int N, M, S; cin>>N>>M>>S;
    S=min(S,5000);
    int a[50][50],b[50][50];
    int u,v,ain,bin;
    for (int i = 0; i < M; ++i) {
        cin>>u>>v>>ain>>bin; --u; --v;
        tonari[u].push_back(v);
        tonari[v].push_back(u);
        a[u][v]=ain; a[v][u]=ain;
        b[u][v]=bin; b[v][u]=bin;
    }

    int c[50],d[50];
    for (int i = 0; i < N; ++i) {
        cin>>c[i]>>d[i];
    }
    for (int i = 1; i < N; ++i) {
        //cout<<i<<endl;
        bool passed[50][5010];
        for (int j = 0; j < 50; ++j) {
            for (int k = 0; k < 5010; ++k) {
                passed[j][k]=false;
            }
        }

        priority_queue<Stat,vector<Stat>,greater<Stat>> pq;

        pq.push({0,S,0});

        while(!pq.empty()){
            auto st=pq.top();
            pq.pop();

            if(st.city==i){
                cout<<st.cost<<endl;
                break;
            }
            if(passed[st.city][st.silver]) continue;
            passed[st.city][st.silver]=true;
            //cout<<st.cost<<" "<<st.silver<<" "<<st.city<<endl;

            //kankin
            if(st.silver+c[st.city]<=5000&&!passed[st.city][st.silver+c[st.city]]){
                //cout<<"kankin"<<endl;
                pq.push({st.cost+d[st.city],st.silver+c[st.city],st.city});
            }

            //move
            for(auto n:tonari[st.city]){
                int sil=st.silver-a[n][st.city];
                if(sil<0||passed[n][sil]) continue;
                //cout<<st.cost+b[n][st.city]<<" "<<sil<<" "<<n<<endl;
                pq.push({st.cost+b[n][st.city],sil,n});
            }

        }

    }


}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 16300
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, a, b; cin >> n >> a >> b;
  vector<int> c(3, 0);
  int p;
  for(int i=0; i<n; i++){
    cin >> p;
    if(p <= a) c[0]++;
    else if(p <= b) c[1]++;
    else c[2]++;
  }

  cout << min({c[0], c[1], c[2]}) << endl;


  return 0;
}



///


Measured memory_bytes: 256
while True:
    a,b=map(int,input().split())
    c=0
    if a==0:
        break
    tuki=[31,29,31,30,31,30,31,31,30,31,30,31]
    a-=1
    for i in range(a):
        c=c+tuki[i]
    c+=b
    if c%7==1:
        ans="Thursday"
    if c%7==2:
        ans="Friday"
    if c%7==3:
        ans="Saturday"
    if c%7==4:
        ans="Sunday"
    if c%7==5:
        ans="Monday"
    if c%7==6:
        ans="Tuesday"
    if c%7==0:
        ans="Wednesday"
    print(ans)


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		sc.close();

		// 処理
		if(N >= 30) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 35668
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
//const ll MOD = 998244353;
 
////////////////////////////////////////////////////////////////////
 
const int N = 5e3 + 5;

int DP[N];

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n, MOD; cin >> n >> MOD;
	DP[0] = 1;
	for (int i = 1; i < n; i++) {
		int z = min(i, n - i + 1);
		for (int j = z; j < n; j++) DP[j] = (DP[j] + DP[j - z]) % MOD;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) ans = (ans + 1LL * (n - i) * DP[i]) % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3676
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int a,b,c,d,e,f;
		double x,y;
		String ln;
		String[] dat=null;
		while((ln=br.readLine()) != null){
			dat=ln.split(" ");
			a=Integer.parseInt(dat[0]);
			b=Integer.parseInt(dat[1]);
			c=Integer.parseInt(dat[2]);
			d=Integer.parseInt(dat[3]);
			e=Integer.parseInt(dat[4]);
			f=Integer.parseInt(dat[5]);
			y=(double)(c*d-a*f)/(b*d-a*e);
			x=(double)(c-b*y)/a;

			System.out.printf("%.3f %.3f\n",x,y);
			}

	}

}

Measured memory_bytes: 16960
#include<bits/stdc++.h>
#define st first
#define nd second
using namespace std;
using pii = pair<int, int>;
int a[200005];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 1;i <=n;i++){
        scanf("%d",&a[i]);
        a[i] += a[i-1] + 1;
    }
    int ma = 0;
    for(int i = k; i <=n;i++){
        ma = max(ma, a[i] - a[i-k]);
    }
    printf("%.12f",1.0 * ma/2.0);

}


Measured memory_bytes: 1024
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let (n, m) = (line[0], line[1]);
    let kinds: Vec<usize> = read_as_vec();
     //                           0, 1, 2, 3, 4, 5, 6, 7, 8, 9
    let costs: Vec<usize> = vec![0, 2, 5, 5, 4, 5, 6, 3, 7, 6];
    let mut kind_cost: Vec<(usize, usize)> = Vec::new();

    for kind in &kinds{
        kind_cost.push((*kind, costs[*kind]));
    }

    
    //determine the number of digits
    let mut digits: Vec<Option<u32>> = vec![None;n+1];
    digits[0] = Some(0);

    for i in 0..n+1{
        let mut biggest = None;
        for &(_, cost) in &kind_cost{
            if i < cost{ continue;}
            if let Some(x) = digits[i-cost]{
                biggest = cmp::max(Some(x+1), biggest);
            }


        }

        digits[i] = cmp::max(biggest, digits[i]);
    }

    //println!("{:?}", digits);

    kind_cost.sort();
    kind_cost.reverse();
    //println!("{:?}", kind_cost);


    let mut num_match = n;
    for _ in 0..digits[n].unwrap(){
        for &(kind, cost) in &kind_cost{
            if num_match < cost{
                continue;
            }
            if digits[num_match-cost].is_none(){
                continue;
            }
            
            if (num_match >= cost && digits[num_match - cost].unwrap() == digits[num_match].unwrap() - 1) &&
                (digits[num_match].unwrap() - 1 != 0 || num_match == cost){
                print!("{}", kind);
                num_match -= cost;
                break;
            }

        }
    }

    println!("");
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    bool ispossible = false;

    int k = 0;
    while (k < N - 1 && !ispossible) {
        if (a[k] + a[k + 1] >= L) ispossible = true;
        k++;
    }
    if (!ispossible) {
        cout << "Impossible" << endl;
        return 0;
    }
    vector<int> ans;
    for (int i = k; i >= 1; i--) ans.push_back(i);
    for (int i = k + 1; i <= N - 1; i++) ans.push_back(i);

    cout << "Possible" << endl;
    rep(i,N-1) {
        cout << ans[N - 2 - i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1784
// https://atcoder.jp/contests/abc170/tasks/abc170_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int c, int d) { return c / gcd(c, d) * d; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<int, int> mp;
    REP(i, N) {
        int t;
        cin >> t;
        mp[t]++;
    }
    // 入力値の最大値
    int maxv = (*mp.rbegin()).first;
    // 入力値の2倍以上を保存
    bitset<1000001> bt;
    for (auto x : mp) {
        // 重複している数も2倍以上を計算
        for (int mul = 2; x.first * mul <= maxv; mul++) {
            bt.set(x.first * mul);
        }
    }
    int ans = 0;
    for (auto &x : mp) {
        // 重複なし
        if (x.second == 1 && !bt[x.first]) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 16240
N = input()
x0 = 0
x1 = 0

Ni = [int(s) for s in N]


for x in range(len(N)):
    if Ni[x] == 0:
        x0 += 1
    elif Ni[x] == 1:
        x1 += 1

print(min([x0, x1])*2)


Measured memory_bytes: 45916
from datetime import date


S = input()

x = int(S[0:2])
y = int(S[2:4])

try:
    date1 = date(x + 2000, y, 1)
except ValueError:
    date1 = None

try:
    date2 = date(y + 2000, x, 1)
except ValueError:
    date2 = None

if date1 and date2:
    print('AMBIGUOUS')
elif date1 is None and date2 is None:
    print('NA')
elif date1:
    print('YYMM')
elif date2:
    print('MMYY')


Measured memory_bytes: 3404
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define range 16500
#define mp make_pair
vector<vector<bool>>dpx(8000+5,vector<bool>(range,false));
vector<vector<bool>>dpy(8000+5,vector<bool>(range,false));
signed main(){
    string _s;cin>>_s;
    int cnt=0;
    vector<int>v;
    rep(i,_s.size()){
        if(_s[i]=='F'){
            cnt++;
        }else{
            v.push_back(cnt);
            cnt=0;
        }
    }
    v.push_back(cnt);
    pii g;cin>>g.first>>g.second;
    dpx[0][range/2]=dpy[0][range/2]=true;
    pii index=pii(0,0);
    rep(k,v.size()){
        if(k%2){
            rep(i,range){
                if(dpy[index.first][i]&&i+v[k]<=range){
                    dpy[index.first+1][i+v[k]]=true;
                }
                if(dpy[index.first][i]&&i-v[k]>=0){
                    dpy[index.first+1][i-v[k]]=true;
                }
            }
            index.first++;
        }else{
            rep(i,range){
                if(dpx[index.second][i]&&i+v[k]<=range){
                    dpx[index.second+1][i+v[k]]=true;
                }
                if(k)if(dpx[index.second][i]&&i-v[k]>=0){
                    dpx[index.second+1][i-v[k]]=true;
                }
            }
            index.second++;
        }
    }
    if(dpx[index.second][g.first+range/2]&&dpy[index.first][g.second+range/2])
        return puts("Yes")*0;
    cout<<"No"<<endl;
}


Measured memory_bytes: 33536
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        // 整数の入力
        int n = sc.nextInt();
        int ans = 0;

        int index= 0;
        while(true) {
            index++;
            int value = index * 111;
            if (value >= n) {
                ans = value;
                break;
            }
        }

        // 出力
        System.out.println(ans);
    }
}


Measured memory_bytes: 21460
// AOJ 2104: Country Road
// 2017.9.30

#include <stdio.h>
#include <stdlib.h>

int x[100002];
int d[100002];

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int t, n, k, i, ans;

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%d%d", &n, &k);
		for (i = 0; i < n; i++) scanf("%d", x+i);
		if (k >= n) { puts("0"); continue; }
		for (n--, i = 0; i < n; i++) d[i] = x[i+1]-x[i];
		qsort(d, n, sizeof(int), cmp);
		for (ans = 0, i = 0; i <= n-k; i++) ans += d[i];
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2920
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;

int main(){

  int m,n;
  int v[1001],w[1001];
  int dp[1001][1001];
  int cnt = 0;
  int d = 0;

  while(cin >> m, m){
    cin >> n;

    for(int i=0;i<n;i++) scanf("%d,%d",&v[i],&w[i]);

    memset(dp,0,sizeof(dp));

    for(int i=0;i<n;i++){
      for(int j=0;j<=m;j++){
	if(w[i] > j) dp[i+1][j] = dp[i][j];
	else dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }
    }

    for(int i=m;i>=0;i--){
      if(dp[n][i] == dp[n][m]) d = i;
    }

    cnt++;
    printf("Case %d:\n",cnt);
    printf("%d\n%d\n",dp[n][d],d);
  }
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {0,1},dy[] = {1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int x,y;
	int n;
	cin >> x >> y;
	if(x == 0 && y == 0) break;
	cin >> n;
	vector< pair<int,int> > v;
	REP(i,n){
	    pair<int,int> temp;
	    cin >> temp.first >> temp.second;
	    v.PB(temp);
	}
	int map[20][20];
	REP(i,20)REP(j,20) map[i][j] = 1;
	REP(i,n){
	    map[v[i].second][v[i].first] = -1;
	}
	int ans = 0;
	queue<int> qx;
	queue<int> qy;
	qx.push(1);
	qy.push(1);
	while(!qx.empty()){
	    int tx = qx.front();
	    int ty = qy.front();
	    qx.pop();
	    qy.pop();
	    REP(i,2){
		int nx = tx + dx[i];
		int ny = ty + dy[i];
		if(nx <= 0 || x < nx || ny <= 0 || y < ny) continue;
		if(ny == y && nx == x){
		    ans++;
		    continue;
		}
		if(map[ny][nx] == 1){
		    qx.push(nx);
		    qy.push(ny);
		}
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 7408
#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
typedef long long ll;
#ifdef _WIN32
inline unsigned int __builtin_clz(unsigned int x) {
	unsigned long r;
	_BitScanReverse(&r, x);
	return 31 - r;
}
#endif
class SparseTable {
	// bit-or sparse table
	vector<vector<ll> > st;
public:
	void init(vector<ll> v) {
		int b = 0;
		for (; (1 << b) <= v.size(); b++);
		st.assign(b, vector<ll>(1 << b));
		for (int i = 0; i < v.size(); i++) st[0][i] = v[i];
		for (int i = 1; i < b; i++) {
			for (int j = 0; j + (1 << i) <= (1 << b); j++) {
				st[i][j] = (st[i - 1][j] | st[i - 1][j + (1 << (i - 1))]);
			}
		}
	}
	ll query(int l, int r) {
		int b = 32 - __builtin_clz(r - l) - 1;
		return (st[b][l] | st[b][r - (1 << b)]);
	}
	SparseTable() {}
	SparseTable(vector<ll> v) { init(v); }
};
inline ll gcd(ll a, ll b) {
	while (b != 0) {
		ll r = a;
		a = b;
		b = r % b;
	}
	return a;
}
inline int modpow(int a, int b, int m) {
	int ret = 1; a %= m;
	while (b) {
		if (b & 1) ret = 1LL * ret * a % m;
		a = 1LL * a * a % m;
		b >>= 1;
	}
	return ret;
}
inline int modinv(int a, int m) {
	return modpow(a, m - 2, m); 
}
const int mod = 1000000007;
int N, Q, l, r; vector<int> p;
int main() {
	scanf("%d%d", &N, &Q); p.resize(N);
	for (int i = 0; i < N; i++) scanf("%d", &p[i]), p[i]--;
	vector<int> a(N), used(N, false);
	vector<ll> s(N);
	for (int i = 0; i < N; i++) {
		if (used[i]) continue;
		vector<int> comp; int r = i;
		while (!used[r]) {
			used[r] = true;
			comp.push_back(r);
			r = p[r];
		}
		int sum = 0;
		for (int j : comp) sum += j + 1, sum = (sum < mod ? sum : sum - mod);
		for (int j : comp) {
			a[j] = comp.size();
			s[j] = 1LL * sum * modinv(a[i], mod) % mod;
		}
	}
	vector<ll> b(N), sumv(N + 1);
	for (int i = 0; i < N; i++) b[i] = (1LL << a[i]);
	for (int i = 0; i < N; i++) sumv[i + 1] = sumv[i] + s[i];
	SparseTable S(b);
	while(Q--) {
		scanf("%d%d", &l, &r); l--;
		ll res = S.query(l, r);
		ll rep = 1;
		for (int i = 1; i <= 40; i++) {
			if (res & (1LL << i)) rep = rep / gcd(rep, i) * i;
		}
		rep %= mod;
		printf("%lld\n", (sumv[r] - sumv[l]) % mod * rep % mod);
	}
	return 0;
}

Measured memory_bytes: 25960
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

def BinarySearch(s,t):
    left = 0
    right = len(s)
    while(left < right):
        mid = (left + right)//2
        if(s[mid] == t):
            return 1
        elif (t < s[mid]):
            right = mid
        else:
            left = mid + 1
    return 0
count = 0
for i in t:
    count = count + BinarySearch(s,i)
print(count)


Measured memory_bytes: 16716
n,k=map(int,input().split())
a=[int(j) for j in input().split()]
a.sort(reverse=True)

def f(x):
    c=0
    for i in a:
        if i<x:
            break
        c+=-(-i//x)-1
        if c>k:
            return False
    return True



left=0
right=a[0]
while right-left>1:
    mid=(left+right)//2
    if f(mid):
        right=mid
    else:
        left=mid
print(right)






Measured memory_bytes: 94072
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int n,l,i,s[200],sum=0,ans=10000000,min_ab=1000000;
    scanf("%d %d",&n,&l);
    for(i=0;i<n;i++){
        s[i]=l+i;
        sum+=l+i;
    }
    for(i=0;i<n;i++){
        if(min_ab>abs(sum-(sum-s[i]))){
            ans=sum-s[i];
            min_ab=abs(sum-(sum-s[i]));
        }
    }
    printf("%d\n",ans);
    return 0;

}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([0])
    dist = [-1]*(N+M)
    dist[0] = 0
    
    while q:
        v = q.popleft()
        
        for nv in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+1
                q.append(nv)
    
    return dist

N, M = map(int, input().split())
G = [[] for _ in range(N+M)]

for i in range(N):
    KL = list(map(int, input().split()))
    
    for L in KL[1:]:
        G[i].append(L-1+N)
        G[L-1+N].append(i)

dist = bfs()

if -1 in dist[:N]:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 96760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	static boolean[][] mati=new boolean[4][4];
	static int[] ns = {0,1,2,3};
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		for(int i=0; i<3; i++) {
			int f=sc.nextInt()-1;
			int t=sc.nextInt()-1;
			mati[f][t]=true;
			mati[t][f]=true;
		}
		permute(ns, ns.length);
		pl("NO");
	}
	private static void swap(int[] v, int i, int j) {
		int t = v[i]; v[i] = v[j]; v[j] = t;
	}

	public static void permute(int[] v, int n) {
		if (n == 1) {
			if(mati[ns[0]][ns[1]] && mati[ns[1]][ns[2]] && mati[ns[2]][ns[3]]) {
				pl("YES");
				System.exit(0);
			}
			else {
				//
			}
		}
		else {
			for (int i = 0; i < n; i++) {
				permute(v, n-1);
				if (n % 2 == 1) {
					swap(v, 0, n-1);
				} else {
					swap(v, i, n-1);
				}
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 22996
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] house = new int[N];
		
		for (int i = 0; i < N; i++) {
			house[i] = sc.nextInt();
		}
		
		Arrays.sort(house);
		
		System.out.println(house[N - 1] - house[0]);
	}

}


Measured memory_bytes: 21844
#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 long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#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(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
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(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll h,n;
    cin>>h>>n;
    VI a(n);
    REP(i,n){
        int tmp;
        cin >> tmp;
        h-=tmp;
    }
    if(h<=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

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

int main(int argc, char *argv[])
{
    int h,w;
    char line[256];

    while (1) {

        if (!fgets(line, sizeof(line), stdin)) {
            fprintf(stderr, "error input val\n");
            return -1;
        }

        if (sscanf(line, "%d %d", &h, &w) != 2) {
            fprintf(stderr, "error input format\n");
            return -1;
        }

        if (!h && !w) {
            return 0;
        }

        int i, j;

        for (i=0; i<h; i++){
            for (j=0; j<w; j++){
                if (((i%2 == 0) && (j%2 == 0)) ||
                    ((i%2 == 1) && (j%2 == 1))) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}

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

class BigNum {
public:
	BigNum() : c(0), keta(0), size(0) {};

	BigNum(int n) : c(0), keta(0), size(0) {
		size = n;
		c = new char [size];
		memset(c, 0, size);
	};

	~BigNum() {
		if (c) {
			delete [] c;
		}
	};

	int getnum(const char* buf) {
		keta = strlen(buf);
		if (buf[keta-1] == '\n') {
			keta --;
		}
		if (keta == 0) {
			return -1;
		}
		if (c) {
			delete [] c;
		}
		size = keta;
		c = new char [size];
		int k = 0;
		for (int i = keta - 1; i >= 0; i--) {
			c[k++] = buf[i] - '0';
		}
		
		return 0;
	};

	void print(void) const {
		for (int i = keta - 1; i >= 0; i --) {
			printf("%d", c[i]);
		}
		printf("\n");
	};

	static int add(BigNum& x, BigNum& y) {
		BigNum* a;
		BigNum* b;

		if (x.keta > y.keta) {
			a = &x;
			b = &y;
		} else {
			a = &y;
			b = &x;
		}

		BigNum r(a->keta + 1);

		int h;
		int m = 0;
		for (int i = 0; i < a->keta; i++) {
			if (i < b->keta) {
				h = a->c[i] + b->c[i] + m;
			} else {
				h = a->c[i] + m;
			}
			
			m = h / 10;
			r.c[i] = h % 10;
		}

		r.keta = a->keta;
	
		if (m > 0) {
			r.c[r.keta] = m;
			r.keta ++;
		}

		if (r.keta > 80) {
			return 1;
		}

		r.print();

		return 0;
	};

	char* c;
	int keta;

private:
	size_t size;
};

int
main(void)
{
	char line[100];
	int n;

	if (fgets(line, sizeof line, stdin) == NULL) {
		return 1;
	}
	if (sscanf(line, "%d", &n) != 1) {
		return 1;
	}

	for (int i = 0; i < n; i++) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			return 1;
		}
		BigNum a;
		if (a.getnum(line)) {
			return 1;
		}

		if (fgets(line, sizeof line, stdin) == NULL) {
			return 1;
		}
		BigNum b;
		if (b.getnum(line)) {
			return 1;
		}

		if (BigNum::add(a, b)) {
			printf("overflow\n");
		}
	}

	return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll a,b; cin >> a >> b;
  if(a*b % 2 == 1){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3636
# ABC157a


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと
    n = int(input())
    from math import ceil
    print(ceil(n/2))


if __name__ == '__main__':
    main()


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

using namespace std;

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

int main() {
  int N, NC;
  cin >> N >> NC;
  vector<vector<int>> U(30, vector<int>(100005));
  for (int i = 0; i < N; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    c--;
    for (int i = s; i <= t; i++) {
      U[c][i] = 1;
    }
  }
  int ans = 0;
  for (int t = 0; t <= 100000; t++) {
    int cnt = 0;
    for (int i = 0; i < 30; i++) {
      if (U[i][t]) cnt++;
    }
    chmax(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 12416
#include <iostream>

using namespace std;

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

int n, p[101], d[101];

int main() {
	cin >> n;
	rep(i,n) {
		int k = i;
		rep(j,n) {
			while(k % j == 0) {
				k /= j;
				p[j]++;
			}
		}
	}
	rep(i,n) rep(j,n) if(p[j] >= i-1) d[i]++;
	cout << d[75] + d[25] * (d[3] - 1) + d[15] * (d[5] - 1) + d[5] * (d[5] - 1) / 2 * (d[3] - 2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

bool isp(string s){
    string t = s;
    reverse(all(t));
    return s == t;
}

int solve(){
    string s; cin >> s;
    bool flag = true;
    if(!isp(s)) flag = false;
    if(!isp(s.substr(0,s.size()/2))) flag = false;
    if(!isp(s.substr((s.size()+3)/2-1,s.size()-1))) flag = false;

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int E,Y,s,t;
    cin >> E >> Y;
    if(E==0&&1868<=Y&&Y<=1911){
        s=Y-1867;
        cout << "M"<<s;
    }
    else if(E==0&&1912<=Y&&Y<=1925){
        s=Y-1911;
        cout << "T"<<s;
    }
    else if(E==0&&1926<=Y&&Y<=1988){
        s=Y-1925;
        cout << "S"<<s;
    }
    else if(E==0&&1989<=Y&&Y<=2016){
        s=Y-1988;
        cout << "H"<<s;
    }
    else if(E==1&&1<=Y&&Y<=44){
        t=1868+Y-1;
        cout << t;
    }
    else if(E==2&&1<=Y&&Y<=14){
        t=1912+Y-1;
        cout << t;
    }
    else if(E==3&&1<=Y&&Y<=63){
        t=1926+Y-1;
        cout << t;
    }
    else if(E==4&&1<=Y&&Y<=28){
        t=1989+Y-1;
        cout << t;
    }
    cout << endl;
}



Measured memory_bytes: 3136
#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 << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl; 
  }
  else {
    cout << "Right" << endl;
  }
}

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

string rotation ( string S ){
    int N = S.size();
    char last = S[0];
    for ( int i = 0; i < N-1; ++i){
        S[i] = S[i+1];
    }
    S[N-1] = last;
    return S;
}

int main() {
    string S,T;
    cin >> S >> T;
    bool flg = false;
    int N = S.size();
    for ( int i = 0; i < 2*N; ++i){
        S = rotation(S);
        if ( S == T ) flg = true;
    }
    
    if ( flg ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
#define MOD 1000000007
typedef int ll;
using namespace std;
int  n,i,j,k,z,m,q,r,timer,v,tot,x,y,xx, yy,INF, sz;
int a[100500], cnt[100500];
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 1; i <= n - 1; i++) {
        if (a[i - 1] + a[i] >= k) {
            cout << "Possible" << endl;
            for (int j = 1; j < i; j++)
                cout << j << endl;
            for (int j = n-1; j > i; j--)
                cout << j << endl;
            cout << i << endl;
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 1152
num = list(map(int, input().split(' ')))
tate = num[0]
yoko = num[1]
letters = [0 for i in range(tate)]

for i in range(tate):
    letters[i] = input()

ans = []
for letter in letters:
    ans.append("#" + str(letter) + "#")

print("#" * (yoko + 2))
for ans_letter in ans:
    print(ans_letter)
print("#" * (yoko + 2))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c) cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b) cout << a << " " << c << " " << b << endl;
    else if (b <= a && a <= c) cout << b << " " << a << " " << c << endl;
    else if (b <= c && c <= a) cout << b << " " << c << " " << a << endl;
    else if (c <= a && a <= b) cout << c << " " << a << " " << b << endl;
    else cout << c << " " << b << " " << a << endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define M 998244353
#define MOD 1000000007
signed main()
{
    SPEED;
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=__gcd(__gcd(i,j),k);
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 3692
program Sum_of_Large_Numbers;
var
  n, k, x: int64;
begin
  read(n, k);
  x := (n+1)*(n+k+1)*(n-k+2) div 2+(n-k+2)-(n+1)*(n+2)*(2*n+3) div 6+(k-1)*k*(2*k-1) div 6;
  writeln(x mod 1000000007);
end.

Measured memory_bytes: 1388
import copy
N = int(input())
N2 = copy.copy(N)
bs = list(map(int, input().split()))
ans = []
flag = True
while bs:
    if not flag:
        break
    else:
        for i in range(N):
            if bs[-(i+1)] == N-i:
                if i != 0:
                    bs = bs[:-(i+1)]+bs[-i:]
                else:
                    bs = bs[:-(i+1)]
                ans.append(N-i)
                N -= 1
                break
        if bs:
            if bs[0] != 1:
                flag = False

if flag:
    for j in range(1, N2+1):
        print(ans[-j])
else:
    print(-1)

Measured memory_bytes: 3444
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int N, T, E;
	int i, x, ans = -1;
	
	scanf("%d %d %d", &N, &T, &E);
	
	for (i = 1; i <= N; i++){
		scanf("%d", &x);
		
		if (abs(T - (T / x * x)) <= E || abs(T - (T + x) / x * x) <= E){
			ans = i;
		}
	}
	
	printf("%d\n", ans);
	
	return (0);
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<utility>
#define LL long long
using namespace std;



int main() {
	int n, _n, k;
	cin >> n >> k;
	int sum = 1, ans = 1;
	_n = n - 1;

	while ((sum + k - 1) / k <= _n) {
		_n -= (sum + k - 1) / k;
		sum += (sum + k - 1) / k;
		ans++;
	}

	cout << ans << endl;

	return 0;
}





Measured memory_bytes: 3084
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int d=scan.nextInt();
		int ans=0;
		for(int i=0;i<=d;i++) {
			for(int j=0;j<=d;j++) {
				int r=a*i;
				int g=b*j;
				if((d-(r+g))%c==0&&d-(r+g)>=0){
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        var scan = new Scanner();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve(scan));
        Console.Out.Flush();
    }
    static object Solve(Scanner scan) {
        int N = scan.NextInt(), M = scan.NextInt();
        var foods = Enumerable.Range(1, M).ToHashSet();
        for (int i = 0; i < N; i++) {
            var K = scan.NextInt();
            var A = scan.ArrayInt(K);
            for (int j = 1; j <= M; j++) {
                if (!foods.Contains(j)) continue;
                if (!A.Contains(j)) foods.Remove(j);
            }
        }
        return foods.Count;
    }
}

class Scanner
{
    string[] s;
    int i;
    public Scanner() {
        s = new string[0];
        i = 0;
    }
    public string Next() {
        if (i < s.Length) return s[i++];
        string str = Console.ReadLine();
        while (str == "") str = Console.ReadLine();
        s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }
    public int NextInt() => int.Parse(Next());
    public int[] ArrayInt(int N, int add = 0) {
        var Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = NextInt() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 28360