akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define int long long
 



 
 
 signed main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    
    
    
    int T; 
    T=1;
    //cin>>T;
    while(T--)
    {
          string a,b;  cin>>a>>b;
          int n=a.length();
          int m=b.length();
          int dp[n+1][m+1];
          string ans="";
          for(int i=0;i<=n;i++)
          {
              for(int j=0;j<=m;j++)
              {
                  if(i==0||j==0)dp[i][j]=0;
                  else if(a[i-1]==b[j-1])dp[i][j]=1+dp[i-1][j-1];
                  else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
              }
          }
          int len=dp[n][m];
          int i=n; int j=m;
          while(ans.length()<len)
          {
              if(a[i-1]==b[j-1])
              {
                  ans+=a[i-1];
                  i--;
                  j--;
              }
              else if(dp[i-1][j]>dp[i][j-1])
              {
                  i--;
              }
              else j--;
          }
          for(int i=0;i<len;i++)cout<<ans[len-i-1];
    }
    
    
        return 0;
	
}

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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF LONG_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  lli N,L;
  string S[100];

  cin>>N>>L;
  rep(i,N){
    cin>>S[i];
  }

  sort(S,S+N);

  rep(i,N){
    cout<<S[i];
  }

  cout<<endl;
  
  return 0;
}


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

using namespace std;

bool is_evenstring(string& str) {
    int size = str.size();
    if(size%2==0) {
        int mid = size / 2;
        for(int i=0; i<mid; ++i) {
            if(str[i] != str[mid+i]) return false;
        }
        return true;
    }
    return false;
}

int main(){
    string s;
    cin >> s;
    while(true) {
        s.pop_back();
        if(is_evenstring(s)) {
            cout << s.size() << endl;
            break;
        }
    }


    return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


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

	int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << ans << endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
#define mxsize (int)1e6
void fun(){
    int n;
    cin>>n;
    int a[n][3];
    fi(0,n){
        fj(0,3) cin>>a[i][j];
    }
    ll dp[n][3];
    fi(0,3) dp[0][i]=a[0][i];
    fi(1,n){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
    }
    ll ans=0;
    fi(0,3) ans=max(ans,dp[n-1][i]);
    cout<<ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 7028
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn discard(deck: &mut VecDeque<char>) -> Option<char>{

    match deck.pop_front() {
        Some(x) => Some(x),
        None => None,
    }

}

fn main(){
    let sa:Vec<char> = read::<String>().chars().collect();
    let sb:Vec<char> = read::<String>().chars().collect();
    let sc:Vec<char> = read::<String>().chars().collect();

    let mut a = VecDeque::new();
    let mut b = VecDeque::new();
    let mut c = VecDeque::new();
    for i in 0..sa.len(){
        a.push_back(sa[i]);
    }
    for i in 0..sb.len(){
        b.push_back(sb[i]);
    }
    for i in 0..sc.len(){
        c.push_back(sc[i]);
    }
    
    let mut turn = discard(&mut a);
    let mut ans:char = 'a';

    while turn != None {
        ans = turn.unwrap();
        turn = match ans{
            'a' => discard(&mut a),
            'b' => discard(&mut b),
            'c' => discard(&mut c),
            _ => discard(&mut a),
        };
    }

    let ans = match ans {
        'a' => 'A',
        'b' => 'B',
        'c' => 'C',
        _ => 'a',
    };
    println!("{}",ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();

		System.out.printf("%d %d %d",Z,X,Y);

		sc.close();

	}

}


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

int main() {
  int w,n;
  cin >> w >> n;
  int array[w];
  for (int i = 0; i < w; i++) array[i] = i+1;
  for (int i = 0; i < n; i++) {
    int a,b,tmp;
    char c;
    cin >> a >> c >> b;
    tmp = array[a-1];
    array[a-1] = array[b-1];
    array[b-1] = tmp;
  }
  for (int i = 0; i < w; i++) cout << array[i] << endl;
  return 0;
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007
	int N,M,R;
	vec(r)
	int dp[300][300];
	ll ans=LONG_LONG_MAX;
	bool flag[300];
	
	void solve(int start,int already,ll cost){
		
		if(already==R){
			ans=min(ans,cost);
		}else{
		
		fx(R){
			if(!flag[r.at(x)]){
				flag[r.at(x)]=true;
				solve(r.at(x),already+1,cost+dp[start][r.at(x)]);
				flag[r.at(x)]=false;
			}
		}
		}
	}

int main() {
	

	cin>>N>>M>>R;
	fx(R){
		vecp(r)
	}
	fx(N){
		fy(N){
			if(x==y){
				dp[x+1][y+1]=0;
			}else{
			dp[x+1][y+1]=INT_MAX/2;
			}
		}
	}
	fx(M){
		int a,b,c;
		cin>>a>>b>>c;
		dp[a][b]=c;
		dp[b][a]=c;
	}
	fx(N){
	fy(N){
	fz(N){
		dp[y+1][z+1]=min(dp[y+1][z+1],dp[y+1][x+1]+dp[x+1][z+1]);
	}
	}
	flag[x+1]=false;
	}
	
	fx(R){
		flag[r.at(x)]=true;
		solve(r.at(x),1,0);
		flag[r.at(x)]=false;
	}
	ce(ans)
	
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int n;

  int array[100005];
  cin>>n;
  while(n!=0){
    int sum=0;
    int cnt=0;
    for(int i=0;i<n;i++){
      cin>>array[i];
      sum+=array[i];
    }
    
    for(int i=0;i<n;i++){
      if(array[i]*n<=sum){
	cnt++;
      }
    }
    cout<<cnt<<endl;
    cin>>n;
  }
  return(0);
}  


Measured memory_bytes: 3140
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int deg[100000];
long long comb[100001];
long long combk[100001];
int main(){
   int N, K;
   cin >> N >> K;
   comb[0]=1;
   combk[0]=1;
   int mod = 1000000007;
   for(int i=1; i<= K-2; i++){
      comb[i] = comb[i-1] * (K-1-i);
      comb[i] %= mod;
   }
   for(int i=1; i<= K; i++){
      combk[i] = combk[i-1] * (K+1-i);
      combk[i] %= mod;
   }
   for(int i=0;i<N-1;i++){
      int a,b;
      cin >> a >> b;
      a--;b--;
      deg[a]++;
      deg[b]++;
   }
   long long ans = combk[deg[0]+1];
   for(int i=1; i<N; i++){
      if(deg[i]+1 > K){
         cout << 0 << endl;
         return 0;
      }
      else{
         int d = deg[i]-1;
         ans *= comb[d];
         ans %= mod;
      }
   }
   cout << ans << endl;
   
   return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


int par[(int)1e5 + 1];  //親

int trank[(int)1e5 + 1];  //木の深さ

//n要素で初期化
void init(int n)
{
    for (int i = 0; i < n; i++) {
        par[i] = i;
        trank[i] = 0;
    }
}

//木の根を求める
int find(int x)
{
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;
    if (trank[x] < trank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (trank[x] == trank[y])
            trank[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y)
{
    return find(x) == find(y);
}

signed main()
{
    int n, m;
    std::cin >> n >> m;
    std::vector<int> p(n);
    std::vector<int> place(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
        place[p[i]] = i;
    }
    init(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        unite(p[a], p[b]);
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (same(p[i], p[place[i]])) {
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3456
// AtCoder Beginner Contest - Problem B: Time Limit Exceeded (https://beta.atcoder.jp/contests/abc112/tasks/abc112_b)
#include <bits/stdc++.h>

#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)

using namespace std;

const int MAX { 1010 };
const int oo { 2000000010 };

int cs[MAX], ts[MAX];

void solve(int N, int T)
{
    int ans = oo;

    REPN(i, N)
        if (ts[i] <= T)
            ans = min(ans, cs[i]);

    if (ans == oo)
        cout << "TLE\n";
    else
        cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, T;
    cin >> N >> T;

    REPN(i, N)
        cin >> cs[i] >> ts[i];

    solve(N, T);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pi pair<int,int>
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
const int MAXN = 1e6 + 5;

void cp()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    ll l, r;
    if(n % 2 == 0)
        l = a[n / 2 - 1] + a[n / 2], r = b[n / 2 - 1] + b[n / 2];
    else
        l = a[n / 2], r = b[n / 2];
    cout << r - l + 1;

}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

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

int main(int argc, char * argv[])
{
  int a,b,c;
  scanf("%d %d %d",&a, &b,&c);
  if ( ( a == b ) && ( b == c ) && ( c == a ) )
    printf("Yes");
  else printf("No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s1,s2,temp;
	cin>>s1>>s2;
	int a1,a2;
	cin>>a1>>a2>>temp;
	if(s1==temp) a1--;
	if(s2==temp) a2--;
	cout<<a1<<' '<<a2<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int r, g, b;
  cin >> r >> g >> b;
  if((100 * r + 10 * g + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int64_t res = 0;
    int n_w = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s.at(i) == 'B')
        {
            res += n_w;
        }
        else
        {
            n_w++;
        }
    }
    cout << res << endl;
}

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

using namespace std;

long long naive_xor_sum(long long v) {
    long long ret = 0;
    for (int i = 0; i < 40; i++) {
        auto div = v / (1LL << i);
        auto mod = v % (1LL << i);
        long long cnt = div / 2 * (1LL << i);
        if (div % 2) {
            cnt += mod;
        }
        if (cnt % 2) {
            ret |= (1LL << i);
        }
    }
    return ret;
}

int main(void) {
    long long A, B;
    cin >> A >> B;
    cout << (naive_xor_sum(B + 1) ^ naive_xor_sum(A)) << endl;
}

// 00000
// 00001
// 00010
// 00011
// 00100
// 00101
// 00110
// 00111
// 01000
// 01001
// 01010
// 01011
// 01100
// 01101
// 01110
// 01111
// 10000


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
    int R[MAX], i, n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n",maxv);

    return 0;
}



Measured memory_bytes: 2588
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
ll w[N], d[N];
ll n, k;

bool check(ll x){
	ll s = 0;
	rep(i, n){
		if(x>=w[i]) s += (x-w[i])/d[i]+1;
	}
	return s<k;
}

int main(){
	cin>>n>>k;
	rep(i, n){
		cin>>w[i]>>d[i];
	}
	ll lb = 1, ub = 3e18;
	while(ub-lb>1){
		ll md = (lb+ub)/2;
		(check(md-1)?lb:ub) = md;
	}
	cout<<lb<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct { int p, l, r;} Node;//pが親 lが左の子 rが右の子 これは各節点のデータ

Node T[MAX];//T[0]の要素では0番目のp,l,rのデータを表してくれる
int n, D[MAX];

//このリストを表示 uは子の番号
void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}
/*
13
0 3 1 4 10
1 2 2 3
2 0
3 0
4 3 5 6 7
5 0
6 0
7 2 8 9
8 0
9 0
10 2 11 12
11 0
12 0
*/


Measured memory_bytes: 6400
import java.util.*;

public class Main {
    public static void main( String args[] ) {
        Scanner scan = new Scanner( System.in );
        
        while ( true ) {
            char[] charaArray = scan.nextLine().toCharArray();
            
            int result = 0;
            for( char chara: charaArray ) {
                result += Character.getNumericValue( chara );
                

            }
            if (result == 0) break;
            System.out.println(result);

        }
        scan.close();
        
    }
}

Measured memory_bytes: 17472
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

// 5 2 4 
// 111000
// 000111

using namespace std;

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



int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	rep(y,H) {
		rep(x,W) {
			if ((x < A && y < B) || (x >= A && y >=B)) {
				cout << 0;
			} else {
				cout << 1;
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

int main(){
  string S;
  cin >> S;
  S[1] = (S[1] == 'B'? 'R' : 'B');
  cout << S << endl;

  return 0;
}

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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)
ll a[1000005],vis[1000005];
int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        int ans=0,x;
        loop(i,0,n-1)
        {
            cin>>x;
            a[x]++;
        }
        loop(i,1,1000000)
        {
            if(a[i]==0 or vis[i])
                continue;
            if(a[i]==1 and !vis[i]) ans++;
            for(int j=i;j<=1000000;j+=i) vis[j]=1;
        }
        cout<<ans;

    }
    return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  for(int i=0;i<k;i++){
    int a,b;
    cin >> a >> b; a--; b--;
    a = min(a,n-1-a); b = min(b,n-1-b);

    cout << min(a,b)%3+1 << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int n,k;
ll ans;
ll a[20];
void dfs(int i,int c,ll ma,ll sum){
	if(i==n){
		if(c>=k){
			ans=min(ans,sum);
		}
		return;
	}
	if(a[i]<=ma){
		dfs(i+1,c,ma,sum);
		dfs(i+1,c+1,ma+1LL,sum+(ma+1LL-a[i]));
	}else{
		dfs(i+1,c+1,a[i],sum);
	}
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	ans=LINF;
	dfs(1,1,a[0],0);
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
const int N = 1e3+5;
 
int n,m,ans;
 
int dx[4]={1,0,-1,0};
 
int dy[4]={0,1,0,-1};
 
char e[N][N];
 
struct node{
 
    int x;
 
    int y;
 
    int step;
 
};
 
queue<node>Q;
 
 
 
void bfs(){
 
    while(!Q.empty()){
 
        node a=Q.front();
 
        Q.pop();
 
        ans=max(ans,a.step);
 
        for(int i=0;i<4;i++)
		{
 
            node b;
 
            int xx=a.x+dx[i];
 
            int yy=a.y+dy[i];
 
            if(xx<0||xx>=n||yy<0||yy>=m)
				continue;
 
            b.x=xx;
 
            b.y=yy;
 
            b.step=a.step+1;
 
            if(e[xx][yy]=='.')
			{
                e[xx][yy]='#';
                Q.push(b);
            }
 
        }
 
    }
}
 
int main()
 
{
 
    std::ios::sync_with_stdio(false);
 	cin.tie(0);
    cin>>n>>m;
 
    for(int i=0;i<n;i++)
	{
        cin>>e[i];
        for(int j=0;j<m;j++)
            if(e[i][j]=='#')
				Q.push(node{i,j,0});
    }
 
    bfs();
 
    cout<<ans<<endl;
 
    return 0;
}


Measured memory_bytes: 16340
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int s;
  double w,h;


  while(scanf("%d,%lf,%lf",&s,&w,&h)!=EOF){
    double bmi=w/h/h;
    if(bmi>=25.0)
      cout<<s<<endl;

  }
}

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

char s[20][21];
int d[20][20];
int dx[]{ 0,-1,0,0,1 }, dy[]{ 0,0,1,-1,0 };

int main() {
	int h, w;
	while (scanf("%d%d", &h, &w), h) {
		int ax, ay, x, y;
		rep(i, h) {
			scanf("%s", s[i]);
			rep(j, w) {
				if (s[i][j] == 'A')ax = i, ay = j;
				if (s[i][j] == 'B')x = i, y = j;
			}
		}
		string p; cin >> p;
		for (char&c : p) {
			if (c == '5')c = 0;
			if (c == '8')c = 1;
			if (c == '6')c = 2;
			if (c == '4')c = 3;
			if (c == '2')c = 4;
		}
		queue<P>que;
		memset(d, -1, sizeof(d));
		d[ax][ay] = 0; que.push(P(ax, ay));
		while (!que.empty()) {
			P p = que.front(); que.pop();
			for (int i = 1; i <= 4; i++) {
				int nx = p.first + dx[i], ny = p.second + dy[i];
				if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&s[nx][ny] != '#'&&d[nx][ny] == -1) {
					d[nx][ny] = d[p.first][p.second] + 1;
					que.push(P(nx, ny));
				}
			}
		}
		int t = 0;
		rep(i, 100) {
			for (char c : p) {
				if (d[x][y] != -1 && d[x][y] <= t) {
					printf("%d %d %d\n", t, x, y); goto g;
				}
				int nx = x + dx[c], ny = y + dy[c]; t++;
				if (0 <= nx&&nx < h && 0 <= ny&&ny < w)x = nx, y = ny;
			}
		}
		puts("impossible");
	g:;
	}
}

Measured memory_bytes: 3192
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#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--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int a, b, m;
    int sa[100001]; INITA(sa, 0, 100001, 0);
    int sb[100001]; INITA(sb, 0, 100001, 0);
    cin >> a >> b >> m;

    int mina = 100001;
    int minb = 100001;
    FOR(i, 1, a) { cin >> sa[i]; mina = min(mina, sa[i]);}
    FOR(i, 1, b) { cin >> sb[i]; minb = min(minb, sb[i]);}

    int res = mina + minb;
    REP(i, m) {
        int x, y, c;
        cin >> x >> y >> c;
        res = min(res, sa[x] + sb[y] - c);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
T = [0]*n
A = [0]*n

for i in range(n):
    T[i],A[i] = map(int,input().split())

votes = [T[0],A[0]]

for i in range(1,n):
    m = max(-(-votes[0]//T[i]),-(-votes[1]//A[i]))
    votes[0] = m*T[i]
    votes[1] = m*A[i]

print(votes[0]+votes[1])

#floatで正確に表示できるのは15桁程度

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdlib.h>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <queue>
#include<unordered_map>
#define mod 1000000007
typedef unsigned long long int ll;
using namespace std;
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    ll res=(n-1)*n/2;
    cout<<res<<"\n";
    return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long l[n+1];
    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i < n + 1; i++) {
        l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int n=in(),i,a[100002]={},s=0;
	rep(i,n){
		a[i+1]=in();
		s+=abs(a[i+1]-a[i]);
	}
	s+=abs(a[n]);
	rep(i,n){
		print(s-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i]));
	}
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    int A,B, sum;
    scanf ("%d %d", &A, &B);
    if (A<=9 && B<=9){
        sum = A*B;
        printf ("%d",sum);
    }
    else
        printf ("-1");
    return 0;
}


Measured memory_bytes: 256
N = int(input())
d = {}
for i in range(N):
  s = "".join(sorted(input()))
  if s in d.keys():
    d[s] += 1
  else:
    d.setdefault(s, 1)
count = 0
for v in d.values():
  count += (v-1)*v//2
print(count)

Measured memory_bytes: 17848
N = int(input())
a = list(map(int, input().split()))

snuke = a[0]
arai = sum(a) - snuke
ans = abs(arai-snuke)

for i in range(1,N-1):
    snuke += a[i]
    arai -= a[i]
    ans = min(ans, abs(arai-snuke))
    
print(ans)

Measured memory_bytes: 24812
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

set<int> se;

void f(int x){
	for(int i=2;i*i<=x;i++){
		if(x%i == 0){
			se.insert(i);
			f(x/i);
			return;
		}
	}
	se.insert(x);
}

int32_t main(){
	int n,m;
	cin>>n>>m;
	int g = __gcd(n,m);
	f(g);
	cout<<se.size()+!se.count(1);
}


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

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

const int L = 100000;

string l;

mint dp1[L + 2], dp2[L + 2];

int main() {
  cin >> l;

  dp1[0] = 1;
  rep(i, l.size()) {
    if (l[i] == '0') dp1[i + 1] = dp1[i];
    else dp1[i + 1] = dp1[i] * 2;
  }

  dp2[l.size() + 1] = 1;
  for (int i = l.size(); i > 0; i--) {
    dp2[i] = dp2[i + 1] * 3;
  }

  mint ans = dp1[l.size()];
  rep(i, l.size()) {
    // cout << ans << endl;
    if (l[i] == '0') continue;
    ans += dp1[i] * dp2[i + 2];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5288
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int mod=1000000007;
    int teep=120*60;
    int s;
    double w,h;
    while(scanf("%d,%lf,%lf",&s,&w,&h)!=EOF) {
        if (25.0-w/(h*h)<1e-10) printf("%d\n",s);
    }
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main() {

  int n, bee;
  cin >> n;
  if(n == 1){
    cout << "1.0000000000";
  }else if(!(n % 2 == 0)){
    double ans;
    ans = double((n - 1) / 2 + 1) / double(n);
    cout << setprecision(10) << fixed << ans;
  }else{
    cout << "0.5000000000";
  }
  return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,i=0;
	cin>>a>>b;
	int c=b;
	while(c!=0)
	{
		c=c/10;
		i++;
	}
	int s=a*pow(10,i)+b;
	if(int(sqrt(s))*int(sqrt(s))==s)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 512
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    double cur = 100.0;
    rep(i,0,5000){
        double r = cur * 0.01;
        ll ri = (ll)floor(r);
        cur += ri;
        ll v = (ll)floor(cur);
        if(v >= X){
            print(i+1);
            return 0;
        }
    }



    
    

}

Measured memory_bytes: 3704
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

#define ll long long

using namespace std;

ll
gcd(ll a, ll b) {
  if (a > b)
    return gcd(b, a);

  if (a == 0)
    return b;

  return gcd(b % a, a);
}

int
main() {
  ll n, x, d;
  cin>>n>>x>>d;

  if (d == 0) {
    if (x == 0)
      cout<<1<<endl;
    else
      cout<<n+1<<endl;

    return 0;
  }

  if (d < 0) {
    d = -d;
    x = -x;
  }

  ll g = gcd(abs(d), abs(x));
  d /= g;
  x /= g;

  map<ll, vector<pair<ll, ll>>> data;
  for (ll i=0; i<=n; i++) {
    ll mod = (x * i) % d; 

    if (data.find(mod) == data.end())
      data[mod] = vector<pair<ll, ll>>();

    ll s = ((x * i) - mod) / d;
    data[mod].push_back({s + (0+(i-1))*i/2, s + ((n-1)+(n-i))*i/2});
  }

  ll ans = 0;
  for (auto & p : data) {
    sort(p.second.begin(), p.second.end());

    ll last = INT64_MIN;
    for (auto & v : p.second) {
      if (v.first > last) {
        ans += v.second - v.first + 1;
        last = v.second;
      }
      else if (last >= v.first && last <= v.second) {
        ans += v.second - last;
        last = v.second;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

 


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

int main(){
	int r;
  cin >> r;
  if (r < 1200){
  	cout << "ABC" << endl;
  }else if (r >= 1200 && r < 2800){
  	cout << "ARC" << endl;
  }else{
  	cout << "AGC" << endl;
  }
  return 0;
}

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

int main(){
	int N;
	cin>>N;
	int a[N+1];
	for(int i=1;i<=N;++i){
		cin>>a[i];
	}
	int b[N+1];
	int total;
	int M=0;
	for(int i=N;i>0;--i){
		total = 0;
		for(int j=2;j<=N/i;++j){
			total += b[i*j];
		}
		total %= 2;
		if(total != a[i]){
			M++;
			b[i] = 1;
		}
		else b[i] = 0;
	}
	cout<<M<<endl;
	for(int i=1;i<=N;++i){
		if(b[i]!=0)cout<<i<<" ";
	}
	cout<<endl;
}


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


void solve(long long N, std::vector<long long> A){
    int ans = -1;
    for(int i=0; i<N-1; i++)
        for(int j=i+1; j<N; j++){
            auto tmp = abs(A[i]-A[j]);
            ans = (ans > tmp ? ans : tmp);
        }
    cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
s = input()
for i in range(len(s)//2):
    if s[i] != s[-1-i]:
        print("No")
        sys.exit()
s2 = s[:(len(s)-1)//2]
for i in range((len(s)-1)//2):
    if s2[i] != s2[-1-i]:
        print("No")
        sys.exit()
s3 = s[(len(s)+3)//2-1:]
for i in range((len(s)-1)//2):
    if s3[i] != s3[-1-i]:
        print("No")
        sys.exit()
print("Yes")

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  for(int i=0; i<K; i++) {
    if(A+i>B) break;
    cout << A+i <<endl;
  }
  for(int i=0; i<K; i++){
    if(B-K+1+i<=A+K-1) continue;
    if(B-K+1+i>B) break; 
    else cout << B-K+1+i <<endl;
  }
}

Measured memory_bytes: 256
a = input().split(" ")
b = list(map(int, a))
c = int(input())
ans = 0
r = min([b[0] * 4, b[1] * 2, b[2]])
r2 = min([r * 2, b[3]])
if c % 2 == 1:
    ans += r
    c -= 1
ans += r2 * (c // 2)
print(int(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
//高橋君は, 現在のレーティングが R で, 次のコンテストでレーティングをちょうど G にしたいと思っています。
//そのとき, 高橋君が取るべきパフォーマンス = N を求めなさい。
//0 ≦ R, G ≦ 4500, 入力は全て整数

// (R + N) / 2 = G
// G * 2 - R = N

int main() {
  int R, G;
  
  cin >> R >> G ;  //入力を受け取る  // R, G みたいには書けない
  cout << ( G * 2 ) - R << endl;
}

Measured memory_bytes: 256
#include<iostream>

#include<string>
#include <algorithm> 
using namespace std;

int main()
{
    int setA[]={1,3,5,7,8,10,12};
    int setB[]={4,6,9,11};
    int setC[]={2};
    int x,y;
    cin >> x >> y;

    bool fx=false,fy=false;
    for(int i = 0 ; i < 7 ; i++){
        if(x==setA[i]) fx=true;
        if(y==setA[i]) fy=true;
        if(fx && fy){
           cout << "Yes" << endl;
           return 0;
        }
    }

    fx=false,fy=false;
    for(int i = 0 ; i < 4 ; i++){
        if(x==setB[i]) fx=true;
        if(y==setB[i]) fy=true;
        if(fx && fy){
           cout << "Yes" << endl;
           return 0;
        }
    }

    fx=false,fy=false;
    for(int i = 0 ; i < 1 ; i++){
        if(x==setC[i]) fx=true;
        if(y==setC[i]) fy=true;
        if(fx && fy){
           cout << "Yes" << endl;
           return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long n, m, ans = 0;struct Node{ int p, d; bool operator < (Node b) {return p<b.p;} }a[300000];
int main(){
	cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i].p >> a[i].d;
	sort(a + 1, a + n + 1); for (int i = 1; i <= n; ++i) { 
	while (m && a[i].d) --m, --a[i].d, ans += a[i].p; }
	cout << ans; return 0;
}


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






int main(){
  


  int h,w;
  cin>>h>>w;
  
  vector<vector<char>> data(h+2,vector<char>(w+2));
  
  for (int i=0;i<w+2;i++){
    data.at(0).at(i)='.';
    data.at(h+1).at(i)='.';
  }
  
  for (int i=0;i<h+2;i++){
    data.at(i).at(0)='.';
    data.at(i).at(w+1)='.';
  }
  
  for (int i=1;i<=h;i++){
    string tmp;
    cin>>tmp;
    for (int j=1;j<=w;j++){

      data.at(i).at(j)=tmp.at(j-1);
    }
  }
  

  
  
  string answer="Yes";
  
  for (int i=1;i<=h;i++){
    
    bool flag=false;
    
    for (int j=1;j<=w;j++){
      char a,b,c,d;
      a=data.at(i).at(j-1);
      b=data.at(i).at(j+1);
      c=data.at(i+1).at(j);
      d=data.at(i-1).at(j);
      

      
      if (data.at(i).at(j)=='#' and a!='#' and b!='#' and c!='#' and d!='#'){
        answer="No";
        flag=true;
        break;
      }
    }
    if (flag){
      break;
    }
  }
  
  cout<<answer<<endl;
      
      
    
  
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int main(){

    long long a;
    cin>>a;
    double b;
    cin>>b;

    int c=int(100*b+0.5);

    cout<<(a*c)/100<<endl;



}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<vector>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int n;
    cin >> n;

    int* m = new int[n];
    for(int i =0; i< n;++i) {
        cin >> m[i];
    }

    int v = 1;

    for(int j=1; j<n; ++j){

        bool visible = true;

        for(int u=0; u<j; ++u){
            if(m[u]>m[j]) {
                visible = false;
                break;
            }
        }

        if(visible) {
            v++;
        }
    }

    cout << v << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean hantei = true;
        int num = 0;
        for(int i = 0; i < N; i++) {
            num = sc.nextInt();
            if(num % 2 == 1) {
                continue;
            }else if(num % 3 == 0 || num % 5 == 0) {
                continue;
            }else {
                hantei = false;
                break;
            }
            
        }
        if(hantei) {
            System.out.println("APPROVED");
        }else {
            System.out.println("DENIED");
        }
        
    }
}

Measured memory_bytes: 22612
def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = {-1:1}
    def prime_factorize(n):
        a = set()
        while n % 2 == 0:
            a.add(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.add(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.add(n)
        for i in a:
            d[i] = d.get(i, 0) + 1
    for x in A:
        prime_factorize(x)
    m = max(d.values())
    if m == 1:
        return 'pairwise coprime'
    if m == N:
        return 'not coprime'
    return 'setwise coprime'
print(main())


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

int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;
  int n=s.size();
  for(int i=0;i<n-1;++i){
    if(s[i]=='a')continue;
    int number=s[i]-'a';
    //cout << number << endl;
    int t=26-number;
    //cout << t << endl;
    if(t<=k){
      s[i]='a';
      k=k-t;
    }
  }
  //cout << k << endl;
  if(k>0){
    k=k%26;
    int number=s[n-1]-'a';
    int t=26-number;
    if(t>k){
      //cout << k << endl;
      s[n-1]=char(s[n-1]+k);
    }else{
      k=k-t;
      s[n-1]=char('a'+k);
    }
    //s[n-1]=char(s[n-1]+k);
  }
  cout << s << endl;
  return 0;
}


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

using namespace std;

long long const MMM = 1002 , MOD = 1e9 +7;
int n , m;
int dp[MMM][MMM];
char mat[MMM][MMM];

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

    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= m ; j++){
            cin >> mat[i][j];
        }
    }
    dp[1][1] = 1;
    for(int i = 2 ; i <= m ; i++){
        if(mat[1][i] == '.'){
            dp[1][i] += dp[1][i - 1];
        }
    }
    for(int j = 2 ; j <= n ; j++){
        if(mat[j][1] == '.'){
            dp[j][1] += dp[j - 1][1];
        }
    }
    for(int i = 2 ; i <= n ; i++){
        for(int j = 2 ; j <= m ; j++){
            if(mat[i][j] == '.'){
                dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]);
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[n][m];

    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>

int N=100;

int main(){
  int M[N][N];
  int n,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;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j) printf(" ");
      printf("%d", M[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2100
#include <iostream>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    int f = (x < 0) * 4 + (y < 0) * 2 + (abs(x) > abs(y));
    switch (f) {
        case 0: case 7: cout << y - x << endl; break;
        case 1: case 6: cout << x - y + 1 + (y != 0) << endl; break;
        case 2: case 5: cout << (y != 0) - x - y << endl; break;
        case 3: case 4: cout << x + y + 1 << endl; break;
    }
    return 0;
}


Measured memory_bytes: 256
Module Module1

    Sub Main()

        Dim N As Integer = Console.ReadLine()
        Dim tmp As String = Console.ReadLine()
        Dim i, j As Integer
        Dim ans As Integer = 0

        i = 0
        Do Until i > N - 1
            ans += 1
            j = i + 1
            Do Until i > N - 1 Or Mid(tmp, i + 1, 1) <> Mid(tmp, j + 1, 1)
                j += 1
            Loop
            i = j
        Loop

        Console.WriteLine(ans)
        'Console.Read()

    End Sub

End Module


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int N;
    cin >> N;

    cout << N * N * N << "\n";

return 0;
}

Measured memory_bytes: 256