akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n;
vector<int> v(3);
cin >> n;
for(int i = 0; i < n; i++){
cin >> v[0] >> v[1] >> v[2];
sort(v.begin(), v.end());
if(v[2]*v[2] == v[0]*v[0]+v[1]*v[1]){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
}

Measured memory_bytes: 1204
#include<stdio.h>
#define N 100
struct a{
  char m;
  int value;
  int bango;
};
void swap(struct a *x, struct a *y);
int main(){
  int n,i,j,flag=0;
  scanf("%d",&n);
  //BubbleSort card2
  struct a card1[n],card2[n],card3[n];
  for(i=0;i<n;i++){
    scanf(" %c",&card1[i].m);
    scanf("%d",&card1[i].value);
    card1[i].bango=i;
  }
  for(i=0;i<n;i++){
    card2[i].m=card1[i].m;
    card3[i].m=card1[i].m;
    card2[i].value=card1[i].value;
    card3[i].value=card1[i].value;
    card2[i].bango=card1[i].bango;
    card3[i].bango=card1[i].bango;
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(card2[j].value<card2[j-1].value){
	swap(card2+j,card2+(j-1));
      }
    }
  }
  //SelectionSort card3
  int min=0;
  for(i=0;i<n-1;i++){
    min=i;
    for(j=i;j<=n-1;j++){
      if(card3[j].value<card3[min].value){
	min=j;
      }
    }
    swap(card3+i,card3+min);
  }
  //??¨??? card2
  for(i=0;i<n-1;i++){
    printf("%c%d ",card2[i].m,card2[i].value);
  }
  printf("%c%d\n",card2[n-1].m,card2[n-1].value);
  for(i=0;i<n;i++){
    if(card2[i].value==card2[i+1].value){
      if(card2[i].bango>card2[i+1].bango)flag++;
    }
  }
  if(flag!=0)printf("Not stable\n");
  else printf("Stable\n");
  //??¨??? card3
  flag=0;
  for(i=0;i<n-1;i++){
    printf("%c%d ",card3[i].m,card3[i].value);
  }
  printf("%c%d\n",card3[n-1].m,card3[i].value);
  for(i=0;i<n;i++){
    if(card3[i].value==card3[i+1].value){
      if(card3[i].bango>card3[i+1].bango)flag++;
    }
  }
  if(flag!=0)printf("Not stable\n");
  else printf("Stable\n");
  return 0;
}
void swap(struct a *x,struct a *y){
  struct a z;
  z= *x;
  *x=*y;
  *y=z;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    string s;
    cin >>s;
    if(s.c_str()[0] ==s.c_str()[1] &&s.c_str()[1]==s.c_str()[2]) cout<<"No"<<endl;
    else cout << "Yes" <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'
#define pi 3.14159265358979323846

ll power(ll a,ll p,ll m=mod)
{ll res=1;while(p>0){if(p&1)res=(res*a)%m;a=(a*a)%m;p>>=1;}
return res;}

int ceil(int a,int b){
    if(a%b == 0)return a/b;
    else return a/b+1;
}

int pow(int a,int b){
    if(b == 0)return 1;
    int res = pow(a,b/2);
    res = res*res;
    if(b&1)res *= a;
    return res;
}

int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
 //    int t;
 //     cin >> t;

 //     while(t--){
 // }

 int n;
 cin >> n;
 set<string>s;
 fo(i,0,n){
    string se;
    cin >> se;
    s.insert(se);
 }
 cout << (int)s.size() << endl;
   
return 0;
	
	}




Measured memory_bytes: 19232
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/10 20:06:28
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

void run() {
    int n, m, x; cin >> n >> m >> x;
    vector <vector <int>> a(n);
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        a[i].resize(m + 1);
        a[i][m] = k;
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = INF;
    for (int i = 0; i < 1 << n; i++) {
        vector <int> cnt(m, 0);
        int res = 0;
        for (int j = 0; j < n; j++) if (i >> j & 1) {
            res += a[j][m];
            for (int k = 0; k < m; k++) {
                cnt[k] += a[j][k];
            }
        }
        bool f = true;
        for (auto it : cnt) {
            if (it < x) f = false;
        }
        if (f) {
            ans = min(ans, res);
        }
    }
    if (ans == INF) ans = -1;
    cout << ans << '\n';
}

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

Measured memory_bytes: 3664
N,T=input().split()
a=0
b=0
for i in range(int(N)):
    c,t=input().split()
    if int(t)<=int(T):
        if b==0:
            a=c
            b+=1
        if int(c)<int (a):
            a=c
            i+=1
if a==0:
    print("TLE")
else :
    print(a)

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

typedef long long int ll;

int main()
{
    string s;
    cin >> s;
    if(s == "SUN"){
        cout << 7;
    }
    else if(s == "MON"){
        cout << 6;
    }
    else if(s == "TUE"){
        cout << 5;
    }
    else if(s == "WED"){
        cout << 4;
    }
    else if(s == "THU"){
        cout << 3;
    }
    else if(s == "FRI"){
        cout << 2;
    }
    else if(s == "SAT"){
        cout << 1;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=205,M=2e4+10;
int mat[N];
int w[N][N];
int n,m,a[N][N],il[N],ir[N],t,b[N][N],c[N][N];
int vis[N];
int ext(int x){
	if (vis[x])return 0;vis[x]=1;
	for (int z=1;z<=n;z++){
		if (!w[x][z])continue;
		if (!mat[z+n]||ext(mat[z+n])){
			mat[z+n]=x;
			mat[x]=z+n;
			return 1;
		}
	}
	return 0;
}
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			scanf("%d",&a[i][j]);
			w[i][(a[i][j]-1)/m+1]++;
		}
	}
	for (int j=1;j<=m;j++){
		for (int i=1;i<=n;i++){
			ext(i);
			memset(vis,0,sizeof vis);
		}
		for (int i=1;i<=n;i++){
			for (int k=1;k<=m;k++)
				if (a[i][k]&&(a[i][k]-1)/m+1==mat[i]-n){
					b[i][j]=a[i][k];
					a[i][k]=0;
					break;
				}
			w[i][mat[i]-n]--;
			mat[i]=mat[mat[i]]=0;
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++)printf("%d ",b[i][j]),c[j][i]=b[i][j];
		printf("\n");
	}
	for (int i=1;i<=m;i++)
		sort(c[i]+1,c[i]+n+1);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++)printf("%d ",c[j][i]);
		printf("\n");
	}
}

Measured memory_bytes: 640
#include<cstdio>
using namespace std;

int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	bool flag=false;
	if(k%n==0||k%m==0)
		flag=true;
	else{
		for(int a=1;a<=m;a++){
			for(int b=1;b<=n;b++){
				if(a*n+b*m-2*a*b==k)
					flag=true;
			}
		}
	}
	if(flag)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>  // This will work only for g++ compiler. 
     
     
    #define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
    #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
    #define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
    #define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
    #define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
     
    //short hand for usual tokens
    #define pb push_back
    #define fi first
    #define se second
     
    // to be used with algorithms that processes a container Eg: find(all(c),42)
    #define all(x) (x).begin(), (x).end() //Forward traversal
    #define rall(x) (x).rbegin, (x).rend() //reverse traversal
     
    // traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
    #define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
     
    // find if a given value is present in a container. Container version. Runs in log(n) for set and map
    #define present(c,x) ((c).find(x) != (c).end())
     
    //find version works for all containers. This is present in std namespace.
    #define cpresent(c,x) (find(all(c),x) != (c).end())
     
    // Avoiding wrap around of size()-1 where size is a unsigned int.
    #define sz(a) int((a).size())
     
     
    using namespace std;
     
    // Shorthand for commonly used types
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef pair<int, int> ii;
    typedef vector<ii> vii;
    typedef long long ll;
    typedef vector<ll> vll;
    typedef vector<vll> vvll;
    typedef double ld;
     
     
    int main() 
    {
       int n,k;
       cin>>n;
       int a[n+1];
       for (int i=1;i<=n;i++)
       {
           cin>>a[i];
       }
       
       
           int itr=0; 
           int curi=1;
           int currvalue=a[curi];
           ll ans=0;
           while (currvalue!=2 && itr<=n)
           {
               itr++;
               ans++;
               curi=currvalue;
               currvalue=a[curi];
           }
           if (itr<=n)
           {
               cout<<ans+1<<"\n";
           }
           else
           {
               cout<<-1<<"\n";
           }
           
           
       
    
        return 0;
    } 
       

Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int a=0;
  for(Int i=0;i<4;i++){
    if(s[i]=='+') a++;
    else a--;
  }
  cout<<a<<endl;
  return 0;
}


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

int n,i,q,k,bil,freq[100003];

int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>k>>q;

	for(i=0;i<q;i++){
		cin>>bil;
		freq[bil]++;
	}
	for(i=1;i<=n;i++){
		if(k-(q-freq[i])>0)cout<<"Yes\n";
		else cout<<"No\n";
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int men;

void dfs(vector<int> &words,vector<int> &target,int cost,int pos,int k)
{
  if(men <= cost)
    return;
  if(pos >= k)
    {
      men = min(men,cost);
      return;
    }

  if(target[pos] == words[pos])
    {
      dfs(words,target,cost,pos+1,k);
      return;
    }

  for(int i=pos;i<k;i++)
    {
      int minus = target[pos]-words[pos];
      vector<int> prev = words;
      for(int j=pos;j<=i;j++)
	{
	  words[j] = (words[j]+minus);
	  if(words[j] < 0)words[j]+=10;
	  words[j] %= 10;
	}
      dfs(words,target,cost+1,pos+1,k);
      words = prev;
    }

}

int main()
{
  int k;
  while(cin >> k,k)
    {
      men = (1<<29);
      string initial,unlocking;
      vector<int> ini(k),uni(k);
      cin >> initial >> unlocking;

      for(int i=0;i<k;i++)
	{
	  ini[i] = initial[i]-'0';
	  uni[i] = unlocking[i]-'0';
	}
      dfs(ini,uni,0,0,k);
      cout << men << endl;
    }
  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
  }
  int left = 1;
  int right = N;
  for(int i = 0; i < M; i++) {
    if(L[i] > left) left = L[i];
    if(R[i] < right) right = R[i];
  }
  if(left > right) {cout << 0 << endl;} else {cout << right - left + 1 << endl;}
  
  return 0;
}

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

int main(int argc, const char * argv[]) {
    int N, K;
    cin >> N;
    cin >> K;
    
    int *h = new int[N];
    int count = 0;
    for (int i =0; i < N; i++) {
        cin >> h[i];
        if (h[i] >= K) {
            count++;
        }
    }
    
    std::cout << count;
    
    delete[] h;
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#define N 1000005
using namespace std;
typedef long long ll;

ll x, y, s, M=1e9+7;
ll fac[N]={1,1}, inv[N]={1,1}, fiv[N]={1,1};
int main() {
	cin >> x >> y;
	s = x + y;
	if(s%3) {puts("0"); return 0;}
	x -= s/3;
	y -= s/3;
	if(x<0 || y<0) {puts("0"); return 0;}
	for(int i=2; i<=x+y; i++) {
		fac[i] = fac[i-1] * i % M;
		inv[i] = inv[M%i] * (M-M/i) % M;
		fiv[i] = fiv[i-1] * inv[i] % M;
	}
	cout << fac[x+y] * fiv[x] % M * fiv[y] % M;
	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    ll n; cin >> n;
    string ans = "";
    for (int i = 1; ; i++) {
        if ( n <= pow(26,i)) {
            n--;
            rep(j,i) {
            //     if (j == i-1) {
            //         ans+= (char)(n%26  +'a');
            //         n/= 26;
            //         continue;
            // }
            // if (n == pow(26,i)) {
            //     ans += 'z';
            //     continue;
            // }
            // if (j == 0){
            //     ans+= (char)((n+25)%26+'a');
            //     n/= 26;
            //     continue;
            // }
                ans+= (char)((n)%26+'a');
                            // cout << n << endl;
                n/= 26;
            }
            break;
        }
        n -= pow(26,i);
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 4064
N,M = map(int,input().split())
T = [[]for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    T[a].append(b)
ans = "IMPOSSIBLE"
def f(v,p,n):
    global N,T,ans
    if n>2: return
    if n==2 and v==N: ans="POSSIBLE"
    for c in T[v]:
        if c!=p: f(c,v,n+1)
f(1,0,0)
print(ans)

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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n;
    cin >> n;
    vector<pll> a(n);
    FOR(i, n) { a[i].second = i + 1; cin >> a[i].fi; }
    sort(all(a));
    FOR(i, n) cout << a[i].se << " ";
    cout << '\n';

}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define UB upper_bound
#define LB lower_bound
#define PB push_back
#define mp make_pair
#define F first
#define S second
#define be(a) (a).begin(),(a).end()
#define deb(x) cout<< #x <<" "<<endl;
#define deb2(x, y) cout<< #x <<" "<< x <<endl<< #y <<" "<<y<<endl
#define fo(i, n) for(long long i=0; i<n; i++)
#define Fo(i, n, k) for(long long i=k; i<n; i++)
#define mod 1000000007
#define int long long

typedef long long ll;

void fileIO()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
typedef vector<pair<int, int>> vll;
typedef unordered_map<int, int> ump;



bool sortbysecdesc(const pair<int, int> &a, 
                    const pair<int, int> &b) 
{ 
    return a.second>b.second;
}



int32_t main()
{
    IOS;
    int T;
    T = 1;
    //cin>>T;

    while(T--)
    {
        int n;
        cin>>n;
        int *h = new int[n];
        for(int i = 0; i<n; i++)cin>>h[i];

        int *dp = new int[n+1];
        for(int i = 0; i<=n; i++)dp[i] = INT_MAX;

        dp[n] = 0;
        for(int i = n-1; i>=1; i--)
        {
            int temp1 = INT_MAX;
            int temp2 = INT_MAX;
            if(i+1<=n) temp1 = dp[i+1] + abs(h[i]-h[i-1]);
            if(i+2<=n) temp2 = dp[i+2] + abs(h[i+1] - h[i-1]);

            dp[i] = min(temp1, temp2);

        }

        cout<<dp[1]<<"\n";


        delete [] h;
        
    }
    
    return 0;
}



Measured memory_bytes: 4772
use itertools::Itertools;
use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! {
        n: usize, m: usize, q: usize,
        qs: [(usize, usize, usize, usize); q],
    }
    let mut max = 0;
    for xs in (1..=m).combinations_with_replacement(n) {
        let mut score = 0;
        for &(a, b, c, d) in &qs {
            if xs[b - 1] - xs[a - 1] == c {
                score += d;
            }
        }
        max = max.max(score);
    }
    println!("{}", max);
}


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

int main() {
  string s; cin>>s;
  int ans;
  
  for (int i = 1; i < s.size(); i++) {
    ans = s.size() - i;
    if (!(ans % 2)) {
      bool done = true;
      for (int j = 0; j < ans / 2; j++) {
        if (s[j] != s[j + ans / 2]) {
          done = false;
          break;
        }
      }
      if (done) break;
    }
  }
  
  cout << ans << endl;
}

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

x = []
rain_sum = sum(a)
x.append(rain_sum - 2 * (sum(a[1:n:2])))

for i in range(1, n):
    x.append(2 * a[i-1] - x[i-1])

print(*x)


Measured memory_bytes: 15120
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] W = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int ans = int.MaxValue;
            int L = 0;
            int R = W.Sum();
            for (int i = 0; i < N; i++)
            {
                L += W[i];
                R -= W[i];
                ans = Math.Min(ans, Math.Abs(L - R));
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main()
{
    int n,m;
    int i,j;
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >>a.at(i);
    }
    long long s = 0,h1 = 0,h2 = 0;
    for(i = 0;i < n;++i){
        s += a[i];
        if(i%2 && s >= 0){
            h1 += s+1;
            s = -1;
        }else if(i%2 == 0 && s <= 0){
            h1 += 1-s;
            s = 1;
        }
    }
    s = 0;
    for(i = 0;i < n;++i){
        s += a[i];
        if(i%2 == 0 && s >= 0){
            h2 += s+1;
            s = -1;
        }else if(i%2&& s <= 0){
            h2 += 1-s;
            s = 1;
        }
    }
    cout << min(h1,h2) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

#include <functional>
template<typename T>
class SegmentTree{
private:
  const size_t offset;
  const std::function<T(T,T)> f;
  const T unit;
  std::vector<T> tree;
  size_t mlb(size_t N) const{
    N |= (N >> 1);
    N |= (N >> 2);
    N |= (N >> 4);
    N |= (N >> 8);
    N |= (N >> 16);
    N |= (N >> 32);
    return (N - (N >> 1));
  };
public:
  SegmentTree(const size_t N, const std::function<T(T,T)> f_, const T unit_):
    offset((mlb(N) << 1) - 1),
    f(f_),
    unit(unit_),
    tree(std::vector<T>(((offset+1) << 1) - 1))
  {
    std::fill(tree.begin(), tree.end(), unit);
  };

  ~SegmentTree(){
  };
  const T& operator[](const size_t i) const{
    return tree[i+offset];
  }

  void update(const size_t i, const T t){
    size_t index = i + offset;
    tree[index] = t;
    while(index){
      index = (index-1)/2;
      tree[index] = f(tree[2*index + 2], tree[2*index + 1]);
    }
  }

  T query(size_t a, size_t b, const bool first_call = true) const{
    if(first_call){
      a += offset;
      b += offset;
    }
    if(a == b){
      return tree[a];
    }
    else if(a+1 == b){
      return f(tree[a], tree[b]);
    }
    else if(a&1 and !(b&1)){
      return query(a/2, (b-1)/2, false);
    }
    else if(a&1 and b&1){
      return f(query(a/2, (b-2)/2, false), tree[b]);
    }
    else if(!(a&1) and !(b&1)){
      return f(query(a/2, (b-1)/2, false), tree[a]);
    }
    else if(!(a&1) and b&1){
      return f(f(query(a/2, (b-2)/2, false), tree[a]), tree[b]);
    }
    else{
      throw 1;
    }
  }
};

int main(){
  long N;
  std::cin >> N;
  std::vector<std::pair<long,long>> XD(0);
  SegmentTree<unsigned long> R(N,
                               [](unsigned long a, unsigned long b){
                                 return std::max(a,b);
                               },
                               0ul);
  std::vector<long> d(N+1,0);
  for(long i = 0; i < N; ++i){
    std::pair<long, long> XDi;
    std::cin >> XDi.first;
    std::cin >> XDi.second;
    XD.push_back(XDi);
  }
  std::sort(XD.begin(), XD.end(),
            [](const auto& a, const auto& b){
              return a.first < b.first;
            });
  std::vector<long> X(N);
  std::vector<long> D(N);
  for(int i = 0; i < N; ++i){
    X[i] = XD[i].first;
    D[i] = XD[i].second;
  }
  R.update(N-1, N-1);
  for(long i = N-2; i >= 0; --i){
    auto it = std::lower_bound(X.begin()+i, X.end(), X[i] + D[i]);
    long index = it - X.begin() - 1;
    R.update(i, std::max((unsigned long)i, R.query(i, index)));
  }
  d[N] = 1;
  d[N-1] = 2;
  for(long i = N-2; i >= 0; --i){
    d[i] = (d[i+1] + d[R[i] + 1])%998244353;
  }
  std::cout << d[0] << std::endl;
  return 0;
}

Measured memory_bytes: 13036
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int> > > shi_by_p(N);
  int kami[M], shimo[M];
  for(int i=0; i<M; i++){
    int p, y;
    cin >> p >> y;
    kami[i] = p;
    p--;
    shi_by_p[p].push_back(make_pair(y, i));
  }
//  for(int i=0; i<shi_by_p.size(); i++) for(auto j: shi_by_p[i]) sort(j.begin(), j.end());
//  for(auto j: shi_by_p) for(auto i: j) cout << i.first << endl;
//  for(auto j: shi_by_p) sort(j.begin(), j.end(), greater<pair<int, int> >());  
  for(int i=0; i<shi_by_p.size(); i++) sort(shi_by_p[i].begin(), shi_by_p[i].end()); 
//  for(auto j: shi_by_p) for(auto i: j) cout << i.first << endl;
  for(int i=0; i<N; i++){
    if(shi_by_p[i].size() == 0) continue;
    for(int j=0; j<shi_by_p[i].size(); j++){
      auto tmp = shi_by_p[i][j];
      shimo[tmp.second] = j+1;
    }
  }
  for(int i=0; i<M; i++) cout << setfill('0') << right << setw(6) << kami[i] << setfill('0') << right << setw(6) << shimo[i] << endl;
  
  return 0;
}

Measured memory_bytes: 7808
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    A, B = map(int, input().split())
    ans = max(A, B)
    if max(A, B) == A:
        A -= 1
    else:
        B -= 1
    ans += max(A, B)
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3944
#include<stdio.h>
int main(){
	
	while(1){
	
		int H , W , counth , countw;
		
		scanf("%d %d", &H , &W);
		
		if(H == 0 && W == 0){
		
			break;
		}
		
		for(counth = 0 ; counth < H  ; counth++){
			
			if(counth == 0 || counth == H - 1){
				for(countw = 0 ; countw <= W - 1  ; countw++){
					printf("#");
				}
			}
			
			else {
				for(countw = 0 ; countw <= W - 1  ; countw++){
				
				if(countw == 0 || countw == W-1){
					
					printf("#");
				}
				
				else {
					printf(".");
				}
			
				}
			}
			printf("\n");
		}
		
		printf("\n");
	
	}
	return 0;
}

//?¨????????????????????¢???????????????¨??????()??????
// int ??´??°
// char ??????
// double ???????°???°???
/*d = a / b;
r = a % b;
f = 1.0 * a / b;
// f = (double)a / b;*/

Measured memory_bytes: 572
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
const lli MAX=1e9+7;

int main()
{
    fast;
    string s;
    cin>>s;
    if(s=="RRR") cout<<3;
    else if(s=="RRS" || s=="SRR") cout<<2;
    else if(s=="SSS") cout<<0;
    else cout<<1;
    return 0;
}

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 2; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll d,n;
	cin>>d>>n;
	if(d==0){
		(n==100)?cout<<"101\n":cout<<n<<"\n";
	}else if(d==1){
		(n==100)?cout<<(n+1)*100<<"\n":cout<<n*100<<"\n";
	}else {
		(n==100)?cout<<(n+1)*10000:cout<<n*10000<<"\n";
	}
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

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

int main() {

	int N, M;
	int A[1234], B[1234];
	int s[1234] = {};

	scanf("%d %d", &N, &M);

	REP(i, N) scanf("%d", &A[i]);
	REP(j, M) scanf("%d", &B[j]);

	REP(j, M) REP(i, N)
		if (A[i] <= B[j]) {
			s[i]++;
			break;
		}

	printf("%d\n", distance(s, max_element(s, s + N)) + 1);

	return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M,X; cin>>N>>M>>X;
	vector<int> C(N);
	int A[N][M];
	for (int i=0; i<N; i++) {
		cin>>C[i];
		for (int j=0; j<M; j++)
			cin>>A[i][j];
	}

	int ret=INT_MAX;
	for (int bt=0; bt<(1<<N); bt++) {
		int cur=0;
		for (int i=0; i<N; i++)
			if(bt&(1<<i))
				cur+=C[i];
		vector<int> v(M,0);
		for (int i=0; i<N; i++)
			if(bt&(1<<i))
				for (int j=0; j<M; j++)
					v[j]+=A[i][j];
		bool ok=true;
		for (int i=0; i<M; i++)
			if(v[i]<X)
				ok=false;
		if(ok)
			ret=min(ret,cur);
	}
	cout<<(ret==INT_MAX ? -1 : ret)<<"\n";
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (auto &v : vec)
    cin >> v;
  sort(vec.begin(), vec.end());
  *vec.rbegin() /= 2;
  cout << accumulate(vec.begin(), vec.end(), 0) << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(){
    int i, j, n, a, res=0;

    scanf("%d", &n);

    for(i=0; i<n; i++){

        scanf("%d", &a);

        for(j=2; j*j<=a; j++){
            if(a==1){
                a=0; 
                break;
            }else if(a==2){
                break;
            }else if(a%j==0){
                a=0;
                break;
            }
        }

        if(a!=0) res++;
        
    }

    printf("%d\n", res);

}



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

#define REP(i, a, b) for (auto i = (a); i < (b); i++)
#define REPR(i, a, b) for (auto i = (a-1); i >= (b); i--)

using namespace std;

void solve()
{
    double n, x;
    int t; cin >> n >> x >> t;

    cout << ((int) ceil(n / x)) * t << "\n";
}

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

    int t = 1; // cin >> t;

    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 3676
using System;
using System.Linq;
using CompLib.Util;
using System.Threading;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        long[] ab = new long[] { sc.NextInt(), sc.NextInt() };
        long[] cd = new long[] { sc.NextInt(), sc.NextInt() };
        long ans = long.MinValue;
        for (int i = 0; i < 2; i++)
        {
            for (int j = 0; j < 2; j++)
            {

                ans = Math.Max(ans, ab[i] * cd[j]);
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27548
def main(inputs):
    outputs = ''
    table = [[[0]*10 for i in range(3)] for i in range(4)]
    for input in inputs:
        b, f, r, v = map(int, input.split())
        table[b-1][f-1][r-1] += v
    for i in range(len(table)):
        if i != 0:
            outputs += '#'*20 + '\n'
        for j in range(len(table[i])):
            for r in range(len(table[i][j])):
                outputs += ' {}'.format(str(table[i][j][r]))
            outputs += '\n'
    return outputs


if __name__ == "__main__":
    n = int(input())
    inputs = [input() for i in range(n)]
    print(main(inputs), end='')



Measured memory_bytes: 5612
import math
 
A,B,H,M=map(int,input().split(" "))
 
hour=[A*math.cos(math.radians(H*30+M/2)),A*math.sin(math.radians(H*30+M/2))]
minute =[B*math.cos(math.radians(M*6)),B*math.sin(math.radians(M*6))]
if (hour[0]>=0 and minute[0]>=0) or (hour[0]<0 and minute[0]<0):
    a=minute[0]-hour[0]
else:
    a=abs(minute[0])+abs(hour[0])
    
if (hour[1]>=0 and minute[1]>=0) or (hour[1]<0 and minute[1]<0):
    b=minute[1]-hour[1]
else:
    b=abs(minute[1])+abs(hour[1])    
print('{:.16f}'.format(math.sqrt(pow(a,2)+pow(b,2))))

Measured memory_bytes: 9560
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private final static byte MASK_RIGHT = 0x0F; //右4bit数値化用マスク
	private final static int STRIP_LENGTH = 10; //短冊1行の長さ
	private static int[] punchTape = new int[100]; //10*10の方眼紙を短冊にしてくっつけた紙テープ

	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 512);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	/**
	 *都合の良い滴下
	 */
	private static void droppingInk(int x, int y, int size) {
		sinking(x, y - 1);
		sinking(x - 1, y);
		sinking(x, y);
		sinking(x + 1, y);
		sinking(x, y + 1);
		if (size == 1) {
			return;
		}

		sinking(x - 1, y - 1);
		sinking(x + 1, y - 1);
		sinking(x - 1, y + 1);
		sinking(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		sinking(x, y - 2);
		sinking(x - 2, y);
		sinking(x + 2, y);
		sinking(x, y + 2);
	}

	/**
	 * 床は汚さないようにする
	 */
	private static void sinking(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			punchTape[x * STRIP_LENGTH + y]++;
		}
	}

	/**
	 *紙の染みを数え、損害を報告する
	 */
	private static void calcResult() {
		int white = 0;//綺麗な部分
		int max = 0;//一番ひどい汚れ
		for (int cell : punchTape) {
			if (cell == 0) {
				white++;
			} else if (cell > max) {
				max = cell;
			}
		}
		System.out.println(white);
		System.out.println(max);
	}
}

Measured memory_bytes: 16840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  =sc.nextInt();
        int [] x = new int[n];
        long min  = (long)1e18;
        for(int i = 1;i<=n;++i)
            min += Math.abs(x[i-1] = sc.nextInt() - i);
        min  = (long)1e18;
        int lo = (int)-1e9;
        int hi = (int)1e9;
        while(lo<=hi){
            int mid = (lo + hi) / 2;
            long sum = 0;
            long sum2 = 0;
            for(int i = 0;i<n;++i) {
                sum += Math.abs(x[i] - mid);
                sum2 += Math.abs(x[i] - mid +1);
            }
            if(sum<sum2){
                min = Math.min(sum2,sum);
                lo = mid + 1;
            }
            else{
                min = Math.min(sum,sum2);
                hi = mid - 1;
            }
            if(min == 15)
                System.out.println(mid);

        }
        System.out.println(min);

    }
}

Measured memory_bytes: 87492
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

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

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

    vector<int> B(N);
    for (int i = 0; i < N; i++) {
        B[A[i] - 1] = i + 1;
    }

    cout << B[0];
    for (int i = 1; i < N; i++) {
        cout << " " << B[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 1536
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    A,B,H,M = LI()

    ta = (H / 12 + M / 60 / 12) * 2 * math.pi
    tb = M / 60 * 2 * math.pi
    xa = A * math.sin(ta)
    ya = A * math.cos(ta)
    xb = B * math.sin(tb)
    yb = B * math.cos(tb)
    d = math.sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb))
    print(d)

if __name__ == '__main__':
    main()

Measured memory_bytes: 69496
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>nums(N + 1);
		for (int i = 0; i < N + 1; ++i) {
			int a; cin >> nums[i];
		}
		int ans = -1;
		for (int j = 0; j < N + 1; ++j) {
			vector<int>anums(nums);
			auto it=anums.erase(anums.begin() + j);
			
				set<int>sas;
				for (int k = 0; k < N - 1; ++k) {
					sas.emplace(anums[k + 1] - anums[k]);
				}
				if (sas.size() == 1) {
					ans = nums[j]; break;
				}
			
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
/*
 * S
*/

#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <cassert>

using namespace std;

int main() {
  string S;
  cin >> S;
  long mod = 1000000000 + 7;

  int len = S.length();
  vector< vector <int> > v(len, vector<int>(13, 0));

  // i = 0
  if (S.at(0) == '?') {
    for (int i = 0; i < 10; i++) {
      v.at(0).at(i) = 1;
    }
  }
  else {
    int num = S.at(0) - '0';
    v.at(0).at(num) = 1;
  }

  for (int i = 1; i < len; i++) {
    if (S.at(i) == '?') {
      for (int j = 0; j < 13; j++) {
        int prev = v.at(i-1).at(j);
        for (int k = 0; k < 10; k++) {
          int key = (j * 10 + k) % 13;
          v.at(i).at(key) = (v.at(i).at(key) + prev) % mod;
        }
      }
    }
    else {
      int num = S.at(i) - '0';

      for (int j = 0; j < 13; j++) {
        int prev = v.at(i-1).at(j);
        int key = (j * 10 + num) % 13;
        v.at(i).at(key) = (v.at(i).at(key) + prev) % mod;
      }
    }
  }

  cout << v.at(len-1).at(5) << endl;
}


Measured memory_bytes: 8960
using System;
class Program
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        int ret = 0;
        if ((b % a) == 0)
        {
            ret = a + b;
        }
        else
        {
            ret = b - a;
        }

        //出力
        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main {
	
	static void aryExchng(int[] a,int[] b){
		for(int i=0; i < ((a.length > b.length) ? b.length:a.length); i++){
			int t = a[i];
			a[i] = b[i];
			b[i] = t;
		}
	}
	
	//[配列]の[idx]箇所を削除して、前に詰めた配列を返却.要素数が減る.
		static int[] arrayRmvOf(int[] a, int idx){
			aryRmv(a,idx);
			int[] temp = new int[a.length-1];
			aryExchng(a,temp);
			return temp;
		}
		
		static void aryRmv(int[] a, int idx){
			for(int i=idx; i<a.length-1; i++){
				a[i] = a[i+1];
			}
			a[a.length-1] = 0;
		}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] read = new int[100];
		int i = 0;
		while(sc.hasNext())	read[i++] = sc.nextInt();
		int[] a = new int[i];
		aryExchng(read,a);
		
		for(int j=0; j<a.length; j++){
			if(a[j] == 0){
				System.out.println(a[j-1]);
				a = arrayRmvOf(arrayRmvOf(a,j-1),j-1);
				j = -1; continue;
			}
				
		}			
			
	}		
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = func(h);
        System.out.println(ans);
    }

    private static long func(long h) {
        if (h == 1) return 1;
        
        return 2 * func(h/2) + 1;
    }
}

Measured memory_bytes: 21844
MAX_V = 100100
MAX_N = 101
INF = pow(2, 62)

N, W = map(int, input().split())
w = [0 for _ in range(N)]
v = [0 for _ in range(N)]
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[INF for _ in range(MAX_V)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for sum_v in range(MAX_V):
        # print(i, sum_v, sum_v - v[i] >= 0)
        if sum_v - v[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])
        # print(dp[i + 1][sum_v])

ans = max([i for i in range(len(dp[N])) if dp[N][i] <= W])
# for l in dp:
#     print([n for n in l if not n == INF])

print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

ll A[500];
ll S[500];
ll DP[500][500];

int main(){
    int N;
    cin >> N;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
        S[i] = a;
        if(i == 0) continue;
        S[i] += S[i-1];
    }

    for(int j = 1; j < N; j++){
        for(int i = j-1; i >= 0; i--){
            if(j - i == 1) {
                DP[i][j] = A[i] + A[j];
                continue;
            }
            ll tmp = LLONG_MAX;
            ll sum = (i == 0) ? S[j] : S[j] - S[i-1];
            for(int k = i; k < j; k++){
                chmin(tmp, DP[i][k] + DP[k+1][j] + sum);
            }
            DP[i][j] = tmp;
        }
    }

    //for(int i = 0; i < N; i++){
    //    printf("%lld ", DP[0][i]);
    //}
    //printf("\n");

    ll ans;
    ans = DP[0][N-1];
    cout << ans << endl;
    return 0;
}


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

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

	int N, M, Q;
	scanf("%d %d %d", &N, &M, &Q);

	vector<int> A(Q);
	vector<int> B(Q);
	vector<int> C(Q);
	vector<int> D(Q);

	vector<int> S(10);

	for (int i = 0; i < Q; i++) {
		scanf("%d %d %d %d", &A[i], &B[i], &C[i], &D[i]);
	}

	S[0] = 1;
	int max_score = 0;
	for (int i_1 = 1; i_1 <= M; i_1++) {
		S[1] = i_1;
		for (int i_2 = i_1; i_2 <= M; i_2++) {
			S[2] = i_2;
			for (int i_3 = i_2; i_3 <= M; i_3++) {
				S[3] = i_3;
				for (int i_4 = i_3; i_4 <= M; i_4++) {
					S[4] = i_4;
					for (int i_5 = i_4; i_5 <= M; i_5++) {
						S[5] = i_5;
						for (int i_6 = i_5; i_6 <= M; i_6++) {
							S[6] = i_6;
							for (int i_7 = i_6; i_7 <= M; i_7++) {
								S[7] = i_7;
								for (int i_8 = i_7; i_8 <= M; i_8++) {
									S[8] = i_8;
									for (int i_9 = i_8; i_9 <= M; i_9++) {
										S[9] = i_9;
										int score = 0;
										for (int j = 0; j < Q; j++) {
											// cout << S[B[j] - 1] - S[A[j] - 1]
											//      << " " << C[j] << "\n";
											if (S[B[j] - 1] - S[A[j] - 1] ==
											    C[j]) {
												score += D[j];
											}
										}
										// if (score != 0) {
										// 	cout << score << "\n";
										// }
										max_score = max(max_score, score);
									}
								}
							}
						}
					}
				}
			}
		}
	}

	cout << max_score;
}


Measured memory_bytes: 3668
n, m = map(int, input().split())
h = list(map(int, input().split()))
dist = [[] for i in range(n)]
ans = 0
for i in range(m):
    a, b = map(int, input().split())
    dist[a - 1].append(b - 1)
    dist[b - 1].append(a - 1)
def higher(n):
    flag = True
    for i in dist[n]:
        if h[n] <= h[i]:
            flag = False
    return flag
for i in range(n):
    if higher(i):
        ans += 1
print(ans)

Measured memory_bytes: 92912
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var time = new long[5];
            for (var i = 0; i < 5; ++i)
                time[i] = Sarray()[0];
            var neck = time.Min();
            WriteLine((N + neck - 1) / neck + 4);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28212