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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
vector<int> di{-1, 0};
vector<int> dj{0, -1};
int h, w;
bool isvalid(int i, int j){
    return (i >= 0 && i < h && j >= 0 && j < w);
}
void solve() {
    cin>>h>>w;
    vector<vector<int>> a, dp;
    a.resize(h, vector<int>(w, 0));
    dp.resize(h, vector<int>(w, 0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c;
            cin>>c;
            if(c == '#'){
                dp[i][j] = -1;
            }
            else{
                a[i][j] = 1;
            }
        }
    }
    dp[0][0] = 1;
    int i1, j1;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == 1){
                for(int k = 0; k < 2; k++){
                    if(k == 0){
                        i1 = i-1;
                        j1 = j;
                    }
                    else if(k == 1){
                        i1 = i;
                        j1 = j-1;
                    }
                    if(isvalid(i1, j1) && dp[i1][j1] != -1){
                        dp[i][j] = (dp[i][j] + dp[i1][j1])%mod;
                    }
                }
            }
        }
    }
    // debug(dp);
    cout<<dp[h-1][w-1];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

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

int main() {
    ll n, A[5];
    cin >> n;
    rep(i, 5) cin >> A[i];
    ll minMove = *min_element(A, A + 5);
    ll ans = ceil((double)n / minMove) + 4;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MIN(a,b) ((a)<(b)?(a):(b))

int main(void){
    unsigned long long n,a,b,ans;
    scanf("%llu %llu %llu",&n,&a,&b);
    ans += (n/(a+b))*a;
    ans += MIN(a,n%(a+b));
    printf("%llu",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
long long MOD = 1e9+7;
long long INF = 1e15;
typedef pair<long long, long long> P;

int main(){
    string L;
    cin >> L;
    long long N = L.size();
    long long e2[N+1], e3[N+1];
    e2[0] = 1, e3[0] = 1;
    rep(i, N){
        e2[i+1] = (2 * e2[i]) % MOD;
        e3[i+1] = (3 * e3[i]) % MOD;
    }
    long long count = 0;
    long long ans = 0;
    rep(i, N){
        if(L[i] == '0') continue;
        long long n = N-i-1;
        ans += e2[count] * e3[n];
        ans %= MOD;
        count++;
    }
    ans += e2[count];
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
    using namespace std;
 
    typedef long long ll;
    typedef long double ld;
 
    typedef pair<int, int> pi;
    typedef pair<ll,ll> pl;

    typedef vector<int> vi;
    typedef vector<ll> vl;
    typedef vector<pi> vpi;
    typedef vector<pl> vpl;
    typedef vector<vi> vvi;

 
    #define FOR(i, a, b) for (int i=a; i<(b); i++)
    #define F0R(i, a) for (int i=0; i<(a); i++)
    
    #define sz(x) (int)(x).size()
    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
    #define lb lower_bound
    #define ub upper_bound
    #define all(x) x.begin(), x.end()
 
    template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
    template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
    
    #define trav(container, it) for(typeof(container.begin()) it=container.begin(); it!=container.end(); it++)
 
    const int MOD = 1000000007;
    const char nl = '\n';
 
    int main() 
    {
        ios_base::sync_with_stdio(0); cin.tie(0);
        int n,k;cin>>n>>k;

        vi v(n);
        FOR(i,0,n) cin>>v[i];

        sort(all(v));

        int ans=0;

        FOR(i,0,k) ans+=v[i];

        cout<<ans<<nl;
    }


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める
int main(){
	int n ; cin >> n;
	vector<int> A(n);
	rep(i,n){
		cin>>A[i];
		A[i]-=(i+1);
	}
	SORT(A);
	//for(auto x:A){
	//	cout<<x<<" ";
	//}
	int a ,b ;
	a = A[n/2]; b=A[(n+1)/2];//整数列の長さが奇数の時はbも使う。悲しみが小さいほうを出力すればよい。
	ll candidate1=0,candidate2=0;
	rep(i,n){
		candidate1 += abs(A[i]-a);
		candidate2 +=abs(A[i]-b);
	}
	ll ans = min(candidate1,candidate2);
	cout<<ans<<endl;
}


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

using namespace std;



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

	vector<int> v(N + 1, -1);

	bool err = false;

	for (int i = 0; i < M; i++)
	{
		int s, c;
		cin >> s >> c;
		
		if (v[s] != -1 && v[s] != c)
		{
			err = true;
			break;
		}
		
		v[s] = c;
	}

	if (v[1] == 0 && N > 1)
	{
		err = true;
	}
	else if (v[1] == -1)
	{
		if (N > 1) v[1] = 1;
		else v[1] = 0;
	}


	if (err != true)
	{
		for (int i = 1; i <= N; i++)
		{
			if (v[i] == -1)
			{
				v[i] = 0;
			}
			cout << v[i];
		}
	}
	else
	{
		cout << -1;
	}
}




Measured memory_bytes: 256
import math

def F(A,B):
    checkA = len(str(A))
    checkB = len(str(B))
    return max(checkA, checkB)
    
N = int(input())
min = N**2

for i in range(1, int(math.sqrt(N))+1):
    if N % i == 0:
        tmp = F(i, int(N/i))
        if tmp < min:
            min = tmp

print(min)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int n,i,a[100000],p=0,q=0,x,t;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  x=a[n-1];
  for(i=0;i<n;i++){
    if(a[i]<=x){
      t = a[i];
      a[i] = a[p];
      a[p] = t;
      p++;
    }
  }

  for(i=0;i<p-1;i++){
    printf("%d ",a[i]);
  }
  printf("[%d]",a[p-1]);
  for(i=p;i<n;i++){
    printf(" %d",a[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2160
#include <set>          
#include <map>           
#include <list>
#include <ctime>
#include <deque>         
#include <bitset>        
#include <vector>
#include <list>
#include <stack>
#include <random>		 
#include <string>       
#include <numeric>      //  needed for  accumulate
#include <utility>     // needed for std:: move
#include <iterator> 
#include <fstream>
#include <iostream> 
#include <iomanip>  
#include <algorithm> 
#include <functional>    
#include <cmath>         
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair                     
#define srt(x) sort(x.begin(),x.end())         
#define mod static_cast<long long> (1e9+7)     
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define int2 int64_t
#define pi 3.14159265358979323846
#define testing 0
#define code_chef 0
#define code_jam 0

using namespace std;
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		scanf("%d",&x);
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		in << x << " ";
	return in;
}
long long fast(long long a,long long b,long long pr)
{
	if(b==0)
		return 1%pr;
	long long ans=1%pr;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
			ans%=pr;
		}
		b>>=1;
		a*=a;
		a%=pr;
	}
	return ans;
}

class solve
{
public:
	solve()
	{
		long long N;
		cin >> N;
		long long a=2,b=1;
		if(N==1)
			cout <<1;
		else
			if(N==2)
				cout << 3;
			else
			{
				ve<unsigned long long> v(87);
				v[0]=2;
				v[1]=1;
				for(int i=2;i<87;i++)
				{
					v[i]=v[i-1]+v[i-2];
				}
				cout << v[N] ;
			}
	}
};
int32_t main()
{
	int t = 1, i = 1;
	if (code_chef)
		scanf("%d", &t);
	while (t--)
	{
		if (code_jam)
			printf("Case #%d: ", i++);
		new solve;
	}
	return 0;
}

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


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
     static int dx[]={1,-1,0,0};
      static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1}; 

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

//  int n=sc.nextInt();  
  int n=sc.nextInt(), m=sc.nextInt();  
   int d[] = new int[100];
   for( int i=0; i<m; i++ ){
    int a=sc.nextInt();
    int b=sc.nextInt();
    d[a]++; d[b]++;
   }
   for( int i=1; i<=n; i++ ){
    out.println(d[i]);
   }

    // out.println();
    out.flush();
}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}

class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return x - p.x;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 21332
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int A;
  int B;
  cin >>A>>B;
  if((A-B)%2 !=0) {
cout << "IMPOSSIBLE"  << endl;
  }
else {
  cout << (A+B)/2 << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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 n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
	string s,t;
	cin >> s >> t;
	string k = t.substr(0, s.size());
	if(s==k){
		cout << "Yes";
	}
	else
		cout << "No";
}

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
     
    #define sz(x) ((int)x.size())
    #define int long long

    using namespace std;
     
     
    const int MAXN = 100 * 1000 + 23;
     
     
     
     
     
     
     
     
    int n, a[MAXN], ps[MAXN], ans;
     
     
    int32_t main() {
        cin >> n;
        for (int i = 0; i < n; i++) cin >> a[i];
        sort(a, a + n);
        partial_sum(a, a + n, ps + 1);
        for (int i = n - 1; i; i--)
            if (ps[i] * 2 < a[i]) {
                ans = i;
                break;
            }
        cout << n - ans;
        return 0;
    }

Measured memory_bytes: 1792
n=int(input())
a=[int(input()) for i in range(n)] 
m=a[0]
k=0

for i in range(n):
    if m<a[i]:
        m=a[i]
        k=i

for j in range(n):
    if j==k:
        print(sorted(a)[-2])
    else:
        print(m)

Measured memory_bytes: 14204
n=int(input())
b=list(map(int,input().split()))
a=[]
ans=b[0]
a.append(ans)
#print(n-2)
#exit()
if(n-2==0):
    print(b[0]*2)
    exit()
for i in range(1,n-1):
    if(b[i] < ans):
        a.append(b[i])
    else:
        a.append(ans)
    ans=b[i]
a.append(b[i])
print(sum(a))

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

int n,m,N,f[15][1<<15],s[1<<15],e[15][15],ans;

void upd(int &x,int y){if (x<y)  x=y;}

void work()
{
	scanf("%d %d",&n,&m),N=1<<n;
	for (int i=1,u,v,w; i<=m; i++)
		scanf("%d %d %d",&u,&v,&w),u--,v--,e[u][v]=e[v][u]=w;
	for (int i=1; i<N; i++)
		for (int j=0; j<n; j++)
			for (int k=j; k<n; k++)
				if ((i&(1<<j))&&(i&(1<<k)))
					s[i]+=e[j][k];
	memset(f,128,sizeof(f));
	f[0][1]=0;
	for (int i=1; i<N; i+=2)
		for (int j=0; j<n; j++)
			if (i&(1<<j))
				{
					int x=N-1-i;
					for (int k=x; k; k-=x&-x,k&=x)
						upd(f[j][i|k],f[j][i]+s[k|(1<<j)]);
					for (int k=0; k<n; k++)
						if ((x&(1<<k))&&(e[j][k]))
							upd(f[k][i|(1<<k)],f[j][i]+e[j][k]);
					if (j==n-1)  upd(ans,f[j][i]);
				}
	printf("%d",s[N-1]-ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 2432
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int N=1e5+3;
int n,v[N],odd[N],even[N],num1[N],num2[N];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>v[i];
    int maxo=-1,maxe=-1,max1=-1,max2=-1;
    for(int i=1;i<=n-1;i+=2){
    	odd[v[i]]++;
    	if(maxo<odd[v[i]]){
    		maxo=odd[v[i]];
    		max1=v[i];
    	}
    }
    for(int i=2;i<=n;i+=2){
    	even[v[i]]++;
    	if(maxe<even[v[i]]){
    		maxe=even[v[i]];
    		max2=v[i];
    	}
    }
    if(maxo==n/2&&maxe==n/2){
    	if(max1==max2) cout<<n/2<<endl;
    	else cout<<0<<endl;
    	return 0;
    }
    if(max1!=max2){
    	cout<<n-maxe-maxo<<endl;
    	return 0;
    }
    sort(odd+1,odd+N);
    sort(even+1,even+N);
    int ans=min(n-even[N-1]-odd[N-2],n-even[N-2]-odd[N-1]);
    cout<<ans<<endl;
    return 0;
}

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

int main(void)
{
    int k, a, b; cin >> k >> a >> b;
    bool flag = 0;
    int tmp = k;
    while (tmp <= b)
    {
        if (tmp >= a && tmp <= b)
        {
            flag = true;
            break;
        }
        tmp += k;
    }
    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3568
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF=1e9;
random_device rnd;
mt19937 mt(rnd());
uniform_real_distribution<> rnd1(0, 1.0);

struct node_t{
	int val;
	node_t *lch;
	node_t *rch;
	double pri;
	int cnt;
	int mn;
	node_t(ll v, double p):val(v), pri(p), cnt(1), mn(v), lch(nullptr), rch(nullptr){}

};

int count(node_t *t){
	return !t ? 0 : t->cnt;
}

int min(node_t *t){
	return !t ? INF : t->mn;
}

node_t *update(node_t *t){
	t->cnt=count(t->lch)+count(t->rch)+1;
	t->mn=min(t->val, min(min(t->lch), min(t->rch)));
	return t;
}

node_t *merge(node_t *l, node_t *r){
	if(!l || !r) return !l ? r : l;
	if(l->pri > r->pri){
		l->rch=merge(l->rch, r);
		return update(l);
	}else{
		r->lch=merge(l, r->lch);
		return update(r);
	}
}
pair<node_t*, node_t*> split(node_t *t, int k){ //[0, k), [k,n)
	if(!t) return make_pair(nullptr, nullptr);
	if(k <= count(t->lch)){
		pair<node_t*, node_t*> s=split(t->lch, k);
		t->lch=s.second;
		return make_pair(s.first, update(t));
	}else{
		pair<node_t*, node_t*> s=split(t->rch, k-1-count(t->lch));
		t->rch=s.first;
		return make_pair(update(t), s.second);
	}
}

node_t *shift(node_t *t, int l, int r){
	pair<node_t*, node_t*> s=split(t, l);
	pair<node_t*, node_t*> s2=split(s.second, r-l);
	pair<node_t*, node_t*> s3=split(s2.second, 1);
	return merge(merge(s.first, s3.first), merge(s2.first, s3.second));
}

node_t *insert(node_t *t, int pos, int x){
	pair<node_t*, node_t*> s=split(t, pos);
	pair<node_t*, node_t*> s2=split(s.second, 1);
	return merge(merge(s.first, new node_t(x, rnd1(mt))), s2.second);
}

int find(node_t *t, int l, int r){
	pair<node_t*, node_t*> s=split(t, l);
	pair<node_t*, node_t*> s2=split(s.second, r-l+1);
	int ans=min(s2.first);
	t=merge(s.first, merge(s2.first, s2.second));
	return ans;
}

node_t *init(node_t *t, int a){
	return merge(t, new node_t(a, rnd1(mt)));
}

int main()
{
	int n, q;
	cin>>n>>q;
	node_t* s=nullptr;
	for(int i=0; i<n; i++){
		int a; cin>>a;
		s=init(s, a);
	}
	for(int i=0; i<q; i++){
		int x, y, z;
		cin>>x>>y>>z;
		if(x==0){
			s=shift(s, y, z);
		}else if(x==1){
			cout<<find(s, y, z)<<endl;
		}else{
			s=insert(s, y, z);
		}
	}
    return 0;
}


Measured memory_bytes: 15676
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = int(input())

stations = [inpl() for _ in range(N-1)]

for i in range(N):
    now = 0
    for C, S, F in stations[i:]:
        if now <= S:
            now = S
        now = S + -(-(now - S)//F)*F + C
        
    print(now)


Measured memory_bytes: 3188
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			count += Math.min(x[i], k - x[i]);
		}
		System.out.println(count * 2);
	}
}


Measured memory_bytes: 21972
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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




int main(){
    
    vector<int> p1(2),p2(2),p3(2),p4(2),v(2);
    cin >> p1[0]>>p1[1]>>p2[0]>>p2[1];
    
    for(int i=0;i<2;i++) v[i] = p2[i] - p1[i];
    vector<int> v2 = {-v[1],v[0]};
    
    for(int i=0;i<2;i++) p3[i] = p2[i] + v2[i];
    for(int i=0;i<2;i++) p4[i] = p3[i] - v[i];
    
    cout << p3[0] << " " << p3[1] << " " << p4[0] << " " << p4[1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int a;
    cin >> a;
    cout << 3 * a * a << endl;

    return 0;
}


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

int main() {
    long long N;
    cin >> N;
    vector <string> S(N);
    long long AC=0;
    long long WA=0;
    long long TLE=0;
    long long RE=0;
    for (long long i=0; i<N; i++) {
        string S;
        cin >> S;
        if (S=="AC") AC++;
        else if (S=="WA") WA++;
        else if (S=="TLE") TLE++;
        else RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 6348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int ans[1010][1010];
int key3[3][3]={{10, 11, 11}, {10, 0, 10}, {11, 11, 10}};
int key4[4][4]={{1, 1, 2, 3}, {4, 4, 2, 3}, {2, 3, 1, 1}, {2, 3, 4, 4}};
int key5[5][5]={{1, 2, 2, 3, 3}, {1, 4, 0, 0, 4}, {2, 4, 0, 0, 4}, {2, 0, 3, 3, 1}, {4, 4, 2, 2, 1}};

int main() {
	int N;
	cin >> N;
	if(N==2){
		cout << -1 << endl;
		return 0;
	}
	if(N==3){
		for(int i=0; i<3; ++i){
			for(int j=0; j<3; ++j) ans[i][j]=key3[i][j];
		}
	}else{
		if(N%4==1){
			for(int i=0; i<5; ++i){
				for(int j=0; j<5; ++j) ans[i][j]=key5[i][j];
			}
		}else if(N%4==2){
			for(int i=0; i<3; ++i){
				for(int j=0; j<3; ++j){
					ans[i][j]=ans[i+3][j+3]=key3[i][j];
					ans[i+3][j]=ans[i][j+3]=((i==0)^(j==2) ? 2 : 0);
				}
			}
		}else if(N%4==3){
			for(int i=1; i<7; ++i) ans[0][i]=ans[i][0]=(i+1)/2;
			for(int i=0; i<3; ++i){
				for(int j=0; j<3; ++j) ans[i+1][j+1]=ans[i+4][j+4]=key3[i][j];
			}
		}
		for(int i=(N%4==0 ? 0 : 4+N%4); i<N; i += 4){
			for(int j=0; j<4; ++j){
				for(int k=0; k<4; ++k) ans[i+j][i+k]=key4[j][k];
			}
		}
	}
	for(int i=0; i<N; ++i){
		for(int j=0; j<N; ++j){
			if(ans[i][j]==0) cout << '.';
			else{
				char ch='a'+ans[i][j]-1;
				cout << ch;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 5120
import Control.Applicative
import Control.Monad
import Data.List
import Data.List.Split (splitOn)
import Data.Char (digitToInt, intToDigit)

main :: IO ()
main = do
  s <- getLine
  unless (s == "#") $ do
    [a, b, c, d] <- f :: IO [Int]
    putStrLn . intercalate "/" . map enc . solve (a, b) (c, d) . map dec $ splitOn "/" s
    main
  where
    f = map read <$> words <$> getLine

solve :: (Int, Int) -> (Int, Int) -> [String] -> [String]
solve (a, b) (c, d) = exch (c, d) 'b' . exch (a, b) '.'

dec :: String -> String
dec = concatMap f
  where
    f 'b' = "b"
    f x = replicate (digitToInt x) '.'

enc :: String -> String
enc = concatMap f . group
  where
    f xs
      | head xs == 'b' = xs
      | otherwise = [intToDigit $ length xs]

exch :: (Int, Int) -> Char -> [String] -> [String]
exch (i, j) ch xss = let (as, b:bs) = splitAt (i - 1) xss
                         (cs, d:ds) = splitAt (j - 1) b
                     in as ++ (cs ++ (ch : ds)) : bs



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

int main(void) {
    int n;
    int c[640], s[640], f[640];
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (int i = 0; i < n - 1; i++) {
        int ans = 0;
        for (int j = 0; i + j < n - 1; j++) {
            ans += (ans >= s[i + j] ? (f[i + j] - (ans % f[i + j])) % f[i + j] : s[i + j] - ans) + c[i + j];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
}


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

int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=0; i<26; i++){
    for(int j=0; j<15; j++){
      if(i*4+j*7==N) ans++;
    }
  } 
  if(ans!=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(m)]
for i in range(10 ** n):
	flag = True
	st = str(i)
	if len(st) != n:
		continue
	for s, c in S:
		if int(st[s - 1]) != c:
			flag = False
			break
	if flag:
		print(int(st))
		break
else:
	print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>

#define mod 1000000007
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOREACH(i, v) for(auto i = v.begin(); i != v.end(); i++)

using namespace std;
using ll = long long;

int X[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Y[] = {1, 1, 1, 0, -1, -1, -1, 0};

int gcd(int a, int b) {
    int x = max(a, b);
    int y = min(a, b);
    int z = x % y;
    if(z == 0){
        return y;
    }else{
        return gcd(y, z);
    }
}

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

ll memo[2][105];

void solve() {
	int n;
	cin >> n;
	int a[2][n];
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}

	for(int i = 0; i < 2; i++){
		for(int j = 0; j < n; j++){
			memo[i][j] = 0;
		}
	}

	memo[0][0] = a[0][0]; 
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < n; j++){
			if(i == 0){
				memo[i][j+1] = a[i][j+1] + memo[i][j];
				memo[i+1][j] = a[i+1][j] + memo[i][j];
			}else{
				memo[i][j+1] = max(memo[i][j+1], memo[i][j]+a[i][j+1]);
			}
		}
	}
	/*
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < n; j++){
			cout << memo[i][j] << " ";
		}
		cout << endl;
	}
	*/
	cout << memo[1][n-1] << endl;
}

int main(){
    solve();
    return 0;
}

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

int main(){
  int i,j,k,cnt;
  int n;
  cin>>n;
  string s[n];
  for(i=0;i<n;i++)cin>>s[i];
  int m[26];
  for(i=0;i<26;i++)m[i]=INT_MAX;
  for(i=0;i<26;i++){
    for(j=0;j<n;j++){
      cnt=0;
      for(k=0;k<s[j].size();k++){
        if(s[j][k]=='a'+i)cnt++;
      }
      m[i]=min(m[i],cnt);
    }
  }
  string sum="";
  for(i=0;i<26;i++){
    for(j=0;j<m[i];j++){
      sum+=(char)('a'+i);
    }
  }
  cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,n,sum=0;
    cin>>k>>n;
    vector<int> a(n);
    vector<int> b(n);
    
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        if(i==n-1){
            b.at(i)=k-a.at(i)+a.at(0);
            sum+=b.at(i);
        }
        if(i!=0){
            b.at(i-1)=a.at(i)-a.at(i-1);
            sum+=b.at(i-1);
        }
    }
    sort(b.begin(),b.end());
    sum -= b.at(n-1);
    cout<<sum<<"\n";
}

Measured memory_bytes: 1792
typedef long long ll;
typedef long double ld;
#define mod 1000000007
#define INF 1000000000
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n;
	cin >> n;
	int total = 0;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			ll num = 0;
			while (n % i == 0) {
				n /= i;
				++num;
			}
			for (ll j = 1; ; ++j) {
				if (num < j) {
					break;
				}
				num -= j;
				++total;
			}
		}
	}
	if (n != 1) {
		++total;
	}
	cout << total << '\n';
	
	return 0;
}


Measured memory_bytes: 3620
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

int32_t N, K;
int32_t a[5000];

template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

constexpr int32_t INF = 2'000'000'000;
constexpr int32_t NUMBER = 5000;
int32_t ignore = -1;
int32_t sum[NUMBER + 1];
int8_t dp[NUMBER][NUMBER + 1];
//[i]以降でvalue「に」なるようにとることが可能ならtrue
int8_t func(int i, int value)
{
	if (value <= 0) {
		return value==0?1:0;
	}
	//if (i == N) {
	if (sum[i] < value) {
		return 0;
	}
	if (dp[i][value] != -1) {
		return dp[i][value];
	}

	auto pata = func(i + 1, value);
	if (i == ignore) {
		return dp[i][value] = std::move(pata);
	}
	return dp[i][value] = (pata | func(i + 1, value - a[i]));
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N >> K;
	for (size_t i = 0; i < N; i++)
	{
		in >> a[i];
		if (a[i] >= K) { --N; --i; }
	}
	std::sort(a, a + N);
	for (int i = N - 1; i >= 0; i--)
	{
		sum[i] = a[i] + sum[i + 1];
	}
	if (sum[0]<K) {
		out << N<<endl;
		return 0;
	}
	using BS_INT = int64_t;
	BS_INT beg = -1, end = N + 1;
	while (beg + 1 != end) {
		BS_INT mid = (beg + end) / 2;
		bool ok = false;
		//ここに書く
		for (auto& arr : dp)for (auto& i : arr) { if (i==0) { i = -1; } }
		ignore = mid;
		for (int v = K - a[mid]; v < K; ++v) {
			ok = func(0, v);
			if (ok) {
				break;
			}
		}
		if (ok) {
			end = mid;//必要
		}
		else {
			beg = mid;//不要
		}
	}
	out << beg+1 << endl;

	return 0;
}
#endif

Measured memory_bytes: 24960
n = int(input())
t = [int(m) for m in input().split()]
a = [int(m) for m in input().split()]
trcd = []
arcd = []
for i in range(n):
    if i == 0:
        trcd.append([t[i], 1])
    else:
        if t[i - 1] < t[i]:
            trcd.append([t[i], 1])
        elif t[i - 1] == t[i]:
            trcd.append([t[i], t[i]])

for i in reversed(range(n)):
    if i == n - 1:
        arcd.append([a[i], 1])
    else:
        if a[i] > a[i + 1]:
            arcd.append([a[i], 1])
        elif a[i] == a[i + 1]:
            arcd.append([a[i], a[i]])

ans = 1
mod = 10 ** 9 + 7
for i in range(n):
    if trcd[i][1] == arcd[-i-1][1] and trcd[i][1] == 1:#候補がひとつしかなくて
        if trcd[i][0] != arcd[-i-1][0]:#その候補の数字が違うとき
            print(0)
            exit()
    elif (trcd[i][0] > arcd[-i-1][0] and trcd[i][1] == 1) or (trcd[i][0] < arcd[-i-1][0] and arcd[-i-1][1] == 1):
        print(0)
        exit()
    else:
        ans *= min(trcd[i][1], arcd[-i-1][1])#候補が小さいほうをとる
        ans %= mod
print(ans)

Measured memory_bytes: 31552
/* AOJ 0042
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0042
 *
 */

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

#define DEBUG 0

typedef struct TTresure Tresure;
struct TTresure {
    int fValue;
    int fWeight;
};

Tresure items[1001];
int count;
int Capacity;

Tresure memo[1001][1001];


int max(int i, int j){
    if( i > j)
        return i;
    return j;
}

Tresure solve(int i, int j){
    Tresure res;
    Tresure a, b;
    if(memo[i][j].fWeight >=0){
        return memo[i][j];
    }
    if(i==count){
        res.fWeight = 0;
        res.fValue = 0;
    }else if (j < items[i].fWeight){
        res = solve(i+1, j);
    }else{
        a = solve(i+1, j);
        b = solve(i+1, j-items[i].fWeight);
        b.fValue += items[i].fValue;
        b.fWeight += items[i].fWeight;
        if(a.fValue >= b.fValue){
            res = a;
        }else{
            res = b;
        }
    }
    memo[i][j] = res;
    return res;
}

int main(){
    int Case;
    int i;
    Tresure result;
    Case = 1;

    while(scanf("%d", &Capacity)==1 && Capacity){
        scanf("%d", &count);
        for(i=0;i<count;i++){
            scanf("%d,%d", &((items+i)->fValue), &((items+i)->fWeight));
        }
        if(DEBUG){
            printf("%d\n", Capacity);
            printf("%d\n", count);
            for(i=0;i<count;i++){
                printf("%d,%d\n", ((items+i)->fValue), ((items+i)->fWeight));
            }
        }
        memset(memo, -1, sizeof(memo));
        result = solve(0, Capacity);
        printf("Case %d:\n", Case);
        printf("%d\n", result.fValue);
        printf("%d\n", result.fWeight);
        Case +=1;
    }
    return 0;
}

Measured memory_bytes: 8304
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
struct YPO
{
    int v;
    int w;
};
struct YPO tree[1000000];
int dp[520][100050];
int n;
void init()
{
    int i;
    for(i=1;i<=100000;i++)
    {
        if(i>=tree[1].w)
            dp[1][i]=tree[1].v;
        else
            dp[1][i]=0;
    }
}
void chuli(int k)
{
    int i,j;
    for(i=1;i<=100000;i++)
    {
        dp[k][i]=dp[k/2][i];
        if(i>=tree[k].w)
            dp[k][i]=max(dp[k][i],dp[k/2][i-tree[k].w]+tree[k].v);
    }
    int h=k*2;
    if(h<=n&&h<=511)
        chuli(h);
    h++;
    if(h<=n&&h<=511)
        chuli(h);
}
int cha(int a,int b)
{
    if(a<=511)
        return dp[a][b];
    int ci=0;
    if(b>=tree[a].w)
        ci=max(ci,cha(a/2,b-tree[a].w)+tree[a].v);
    ci=max(ci,cha(a/2,b));
    return ci;
}
int main()
{
    int q,a,b,i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d%d",&tree[i].v,&tree[i].w);

    init();
    if(n>=2)
        chuli(2);
    if(n>=3)
        chuli(3);

    scanf("%d",&q);
    for(i=1;i<=q;i++)
    {
        scanf("%d%d",&a,&b);
        int gg=cha(a,b);
        printf("%d\n",gg);
    }
    return 0;
}


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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]={-1,0,1,-1,1,-1,0,1};
//int dy[]={1,1,1,0,0,-1,-1,-1};






int main()
{
    FAST();
    int i,n;
    cin >> n;
    int a[n+2],b[n+2];
    for(i=1;i<=n;i++)cin >> a[i] >> b[i];
    for(i=3;i<=n;i++)
    {
        if(a[i] == b[i]  &&  a[i-1] == b[i-1]  && a[i-2] == b[i-2])
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3640
class MyList:
	head = tail = None

	def insert(self, x):
		n = [x, None, None]
		if self.head == None:
			self.head = self.tail = n
		else:
			n[2] = self.head
			self.head[1] = n
			self.head = n

	def delete(self, x):
		n = self.head
		while n and n[0] != x:
			n = n[2]
		if n: 
			self.__delete_node(n)

	def deleteFirst(self):
		self.__delete_node(self.head)

	def deleteLast(self):
		self.__delete_node(self.tail)

	def __delete_node(self, n):
		if n == self.head:
			self.head = n[2]
		if n == self.tail:
			self.tail = n[1]
		if n[1]:
			n[1][2] = n[2]
		if n[2]:
			n[2][1] = n[1]

	def print_all(self):
		n = self.head
		while n:
			print n[0],
			n = n[2]

myList = MyList()
n = int(raw_input())
for _ in xrange(n):
	line = raw_input()
	if line[0]=='i':
		myList.insert(line[7:])
	elif line[6]=='F':
		myList.deleteFirst()
	elif line[6]=='L':
		myList.deleteLast()
	else:
		myList.delete(line[7:])
myList.print_all()

Measured memory_bytes: 156592
<?php
  fscanf(STDIN,"%d %d %d %d %d",$a,$b,$c,$x,$y);
  $iti = $c*2*max($x,$y);
  if($x>$y){
    $ni = ($c*2*min($x,$y))+(abs($x-$y)*$a);
  }else{
    $ni = ($c*2*min($x,$y))+(abs($x-$y)*$b);
  }
  $san = ($a*$x)+($b*$y);
  echo min($iti,$ni,$san)."\n";
  


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

int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){ 
        cout<<"Yes";
        return 0;
    }
    cout<<"No";


    return 0;
}


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

#define ll long long
#define pb push_back

const int maxn = 3e5 + 20;

ll f(ll r , ll a , ll b)
{
	return r - (r / a + r / b - r / (a * b / __gcd(a , b)));
}

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

	ll a , b , c , d;
	cin >> a >> b >> c >> d;

	cout << f(b , c , d) - f(a - 1 , c , d) << endl;
}










 


Measured memory_bytes: 256
def slove():
    import sys
    import bisect
    import collections
    import fractions
    import heapq
    input = sys.stdin.readline
    a, b, c = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    while True:
        a, b, c = sorted([a, b, c])
        if abs(a - c) >= 2:
            a += 2
            cnt += 1
        else:
            if a == b == c:
                print(cnt)
                exit()
            if a == b:
                a += 1
                b += 1
                cnt += 1
            elif b == c:
                b += 1
                c += 1
                cnt += 1
            elif a == c:
                a += 1
                c += 1
                cnt += 1


if __name__ == '__main__':
    slove()


Measured memory_bytes: 63980
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if(Math.abs(a-c)<=d || (Math.abs(a-b)<=d && Math.abs(b-c)<=d)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
import java.io.*;
 
public class Main{
  public static void main(String[] args)throws IOException{
     
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
 
    String[] strAry = str.split(" ");
     
    int x = Integer.parseInt(strAry[0]);
    int y = Integer.parseInt(strAry[1]);
    int z = Integer.parseInt(strAry[2]);
 
    if(x < y && y < z && x < z){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 24212
#include <iostream>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	vector<vector<char>> ans(100, vector<char> (100));
	for (int i = 0; i < 50; ++i)
	{
		fill(ans[i].begin(), ans[i].end(), '#');
		fill(ans[i + 50].begin(), ans[i + 50].end(), '.');
	}
	--a; --b;
	cout << 100 << " " << 100 << endl;
	for (int x = 0, y = 0; a > 0; --a)
	{
		ans[y][x] = '.';
		x += 2;
		if (x >= 100)
		{
			x = 0;
			y += 2;
		}
	}
	for (int x = 0, y = 51; b > 0; --b)
	{
		ans[y][x] = '#';
		x += 2;
		if (x >= 100)
		{
			x = 0;
			y += 2;
		}
	}
	for (int i = 0; i < 100; ++i)
	{
		for (int j = 0; j < 100; ++j)
		{
			cout << ans[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair< int64, int > Pi;
struct edge {
  int64 to, cost;
};
typedef vector< vector< edge > > Graph;


// なるべく高い位置でいったほうがよさ
// 高さ = 秒数
// コスト = -高さ * 2 + 最初の高さ + 最後の高さがコストっぽい？？
const int64 INF = 1LL << 58;
int N, M, X;
int H[100000];

int64 Dijkstra(const Graph &graph){
  priority_queue< Pi > que;
  vector< int64 > max_height( graph.size(), -INF);
  que.push( Pi( X, 0));
  max_height[0] = X;
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(max_height[p.second] > p.first) continue;
    if(p.second == graph.size() - 1) return p.first;
    for(int i = 0; i < graph[p.second].size(); i++){
      const edge& e = graph[p.second][i];
      int64 next_height = min< int64 >( H[e.to], p.first - e.cost);
      if(max_height[e.to] >= next_height) continue;
      max_height[e.to] = next_height;
      que.push( Pi( next_height, e.to));
    }
  }
  return INF;
}

int main(){
 
  scanf("%d %d %d", &N, &M, &X);
  for(int i = 0; i < N; i++){
    scanf("%d", &H[i]);
  }
  Graph graph(N);
  for(int i = 0; i < M; i++){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    --a, --b;
    if(H[a] - c >= 0) graph[a].push_back( (edge){ b, c});
    if(H[b] - c >= 0) graph[b].push_back( (edge){ a, c});
  }
  int64 ret = Dijkstra(graph);

  if(ret == INF) puts("-1");
  else printf("%lld\n", X + H[N - 1] - ret * 2);
}

Measured memory_bytes: 18776
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<set>
#define mod 1000000007
using namespace std;
typedef long long ll;
int main(){
    int n;
    ll s[100000],ans=0,sum;
    set<int> st;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&s[i]);
    }
    for(int i=1;i<n-1;i++){
        st.clear();
        st.insert(0);
        sum=0;
        if(i<n-1-i){
            for(int j=1;i*j<n-1;j++){
                if(n-1-i*j<=i){
                    break;
                }
                set<int>::iterator it=st.find(i*j);
                if(it!=st.end()){
                    break;
                }
                st.insert(i*j);
                it=st.find(n-1-i*j);
                if(it!=st.end()){
                    break;
                }
                st.insert(n-1-i*j);
                sum+=s[i*j]+s[n-1-i*j];
                ans=max(ans,sum);
            }
        }
    }
    printf("%lld\n",ans);
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

struct Node_t {
  int id_, left_, right_, parent_;
  Node_t() { id_ = left_ = right_ = parent_ = -1; }
};

void preorder(vector<Node_t>& nodes, int id, vector<int>& ids)
{
  if (id == -1) { return; }
  ids.push_back(id);
  preorder(nodes, nodes[id].left_, ids);
  preorder(nodes, nodes[id].right_, ids);
}

void inorder(vector<Node_t>& nodes, int id, vector<int>& ids)
{
  if (id == -1) { return; }
  inorder(nodes, nodes[id].left_, ids);
  ids.push_back(id);
  inorder(nodes, nodes[id].right_, ids);
}

void postorder(vector<Node_t>& nodes, int id, vector<int>& ids)
{
  if (id == -1) { return; }
  postorder(nodes, nodes[id].left_, ids);
  postorder(nodes, nodes[id].right_, ids);
  ids.push_back(id);
}

void print(vector<int> ids)
{
  int n = ids.size();
  for (int i = 0; i < n; ++i) {
    fprintf(stdout, " %d", ids[i]);
  }
  fprintf(stdout, "\n");
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<Node_t> nodes(n);
  for (int i = 0; i < n; ++i) {
    int id, l, r;
    fscanf(stdin, "%d %d %d", &id, &l, &r);
    nodes[id].id_ = id;
    nodes[id].left_ = l;
    nodes[id].right_ = r;
    if (l != -1) { nodes[l].parent_ = id; }
    if (r != -1) { nodes[r].parent_ = id; }
  }
  int root_id = -1;
  for (int i = 0; i < n; ++i) {
    if (nodes[i].parent_ == -1) {
      root_id = nodes[i].id_;
      break;
    }
  }

  vector<int> pre, in, post;
  preorder(nodes, root_id, pre);
  fprintf(stdout, "Preorder\n");
  print(pre);
  inorder(nodes, root_id, in);
  fprintf(stdout, "Inorder\n");
  print(in);
  postorder(nodes, root_id, post);
  fprintf(stdout, "Postorder\n");
  print(post);
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

bool comp(vector<int> a, vector<int> b){
    return a[0] < b[0];
}

int main(){

    while(1){
        int n, m; cin >> n >> m;
        if(n == 0) break;
        vector<vector<int> > A(m, vector<int> (3));  //[0] := t [1] := s [2] := d
        for(int i = 0; i < m; i++){
            cin >> A[i][0] >> A[i][1] >> A[i][2];
            A[i][1]--;
            A[i][2]--;
        }
        vector<bool> virus(n, false);
        virus[0] = true;
        sort(A.begin(), A.end(), comp);

        for(int i = 0; i < m; i++){
            virus[A[i][2]] = virus[A[i][2]] || virus[A[i][1]];
        }

        int ans = 0;
        for(int i = 0; i < n; i++) if(virus[i]) ans++;

        cout << ans << endl;
    }
}


Measured memory_bytes: 3860
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(), b = scan.nextInt();
		
		if(a>b) System.out.println("a > b");
		else if(a<b) System.out.println("a < b");
		else System.out.println("a == b");
	
	}

}

Measured memory_bytes: 17160
//==========================================
// ABC133c Remainder Minimization 2019
//
// 2019/08/15
//  ver.1 TLE
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  long l, r;
  cin >> l >> r;

  int ans=2019;
  for(long i=l; i<r; i++)
  {
    if(i == l+2019) break;
    for(long j=l+1; j<=r; j++)
    {
      if(j == l+2019) break;
      int temp;
      temp = i*j%2019;
      if(ans > temp) ans=temp;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
	 
	class Main{
	  public static void main(String[] args){
	    
	 
	Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
        int[] X = new int[N];
        for (int j = 0; j < N ; j++){
  			X[j] = sc.nextInt();
        }
        String message = new String();
        for (int i = 0; i < N ; i++){
  			if (X[i]%2 == 0){
              if (X[i]%3 != 0 && X[i]%5 != 0){
                message = "DENIED";
                break;
              }
              else{ 
                message = "APPROVED";
  	          } 
            }
    		else{
              message = "APPROVED";
            }
            }
        System.out.println(message);
        }
	  }
	



Measured memory_bytes: 36056
#include <iostream>
#include <vector>

using namespace std;

bool printed = false;
vector<vector<int>> graph;
vector<vector<bool>> edges;

void dfs(int v, vector<int> path, vector<bool> used) {
    for (int i = path.size() - 1; !printed && i >= 0; i--) {
        if (edges[v][path[i]]) {
            path.push_back(v);
            cout << path.size() - i << endl;
            for (int j = i; j < path.size(); j++)cout << path[j] + 1 << endl;
            printed = true;
            return;
        }
    }
    if (printed)return;

    vector<bool> next_used = used;
    for (auto x:graph[v])next_used[x] = true;

    for (auto nextv:graph[v]) {
        if (!used[nextv]) {
            path.push_back(v);
            dfs(nextv, path, next_used);
            path.pop_back();
        }
    }
}

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

    graph = vector<vector<int>>(n);
    edges = vector<vector<bool>>(n, vector<bool>(n));
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        edges[a][b] = true;
    }

    for (int i = 0; i < n; i++)dfs(i, {}, vector<bool>(n, false));
    if (!printed)cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 7168