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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n,t;
    cin >> n >> t;
    int s[n];
    rep(i,n) cin >> s[i];
    ll ans=t;
    for(int i=1;i<n;i++){
        if(s[i]-s[i-1]>t){
            ans+=t;
        }else{
            ans=ans-(t-(s[i]-s[i-1]));
            ans+=t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> check(N + 1, 0);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        check[min(a, b)]++;
        check[max(a, b)]--;
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += check[i];
        if (ans % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

#include <bits/stdc++.h>

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

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> f(N + 1, 0);
    for (ll i = 1; i <= N; ++i)
    {
        ll k = 1;
        while(i * k <= N)
        {
            f[i * k]++;
            k++;
        }
    }

    ll ans = 0;
    for (ll i = 1; i <= N; ++i)
    {
        ans += i * f[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 81404
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int n;
int t[30];

void dfs(int k, int d) {
  if(k == 0) {
    REP(i, 0, d) {
      cout << t[i];
      if(i + 1 != d) cout << " ";
    }
    cout << endl;
  } else {
    int len = d == 0 ? k : min(t[d - 1], k);
    for(int i = len; i > 0; i--) {
      t[d] = i;
      dfs(k - i, d + 1);
    }
  }
}

int main(void) {
  while(cin >> n, n != 0) {
    dfs(n, 0);
  }

  return 0;
}

Measured memory_bytes: 1160
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int a[1 << 17],b[1 << 17];

int32_t main(){_
    //freopen("input","r",stdin);
    int n;
    cin >> n;
    int x = 0;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }
    for(int i = 1;i <= n;i++)
    {
        cin >> b[i];
    }
    for(int i = 1;i <= n;i++)
    {
        if(a[i] < b[i]) x += (b[i] - a[i]) / 2;
        else x += b[i] - a[i];
    }
    if(x >= 0) rc("Yes");
    rc("No");
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int H, W;
    vector<vector<int>> grid;
    string line;
    cin >> H >> W;

    grid.resize(H);
    for(int i=0; i<H; i++) {
        cin >> line;
        for(int j=0; j<W; j++) {
            if(line[j] == '#') {
                grid[i].push_back(1);
            } else {
                grid[i].push_back(0);
            }
        }
    }

    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(grid[i][j] == 1) {
                bool isOK = false;
    
                if(i > 0 && grid[i-1][j] == 1) {
                    isOK = true;
                } else if(i < H-1 && grid[i+1][j] == 1) {
                    isOK = true;
                } else if(j > 0 && grid[i][j-1] == 1) {
                    isOK = true;
                } else if(j < W-1 && grid[i][j+1] == 1) {
                    isOK = true;
                }
                
                if(isOK == false) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

#define int long long

const int inf = 2e18;


int32_t main() {
    string a, b;
    cin >> a >> b;
    int n = a.length(), m = b.length();

    int dp[n + 1][m + 1];
    memset(dp, 0, sizeof dp);

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(a[i - 1] == b[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    int i = n, j = m;
    string ans;

    while(i > 0 and j > 0) {
        if(a[i - 1] == b[j - 1]) {
            ans += a[i - 1];
            i--, j--;
        }
        else {
            if(dp[i - 1][j] > dp[i][j - 1]) {
                i--;
            }
            else {
                j--;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    
    cout << ans << endl;
}



Measured memory_bytes: 70656
def resolve():
    N = int(input())
    AC = WA = TLE = RE = 0
    for i in range(N):
        s = input()
        if s == "AC":
            AC += 1
        elif s == "WA":
            WA += 1
        elif s == "TLE":
            TLE += 1
        elif s == "RE":
            RE += 1

    print(f"AC x {AC}")
    print(f"WA x {WA}")
    print(f"TLE x {TLE}")
    print(f"RE x {RE}")
resolve()

Measured memory_bytes: 74700
#include <bits/stdc++.h>
#include <set>
#include <queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define readVarll(nam) ll nam; cin >> nam

#define DEV_VAL 1000000007
ll mulbig(ll a, ll b)
{
  return (a * b) % DEV_VAL; 
}

ll addbig(ll a, ll b)
{
  return (a + b) % DEV_VAL;
}

int main()
{
  ll n;
  cin >> n;
  ll mydata[n];
  rep(i, n) cin >> mydata[i];

  ll ans = 0;
  ll tmpadd = mydata[0];
  reps(i, 1, n)
  {
    ans = addbig(ans, mulbig(tmpadd, mydata[i]));
    tmpadd = addbig(tmpadd, mydata[i]);
  }

  cout << fixed << ans << endl;

  return 0;
}

Measured memory_bytes: 5076
n = int(input())
t = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
result = 1
for i in range(n):
    h_max, h_min = min(t[i], a[i])+1, 1

    if i != n-1:
        if a[i] > a[i+1]:
            h_min = a[i]
    else:
        h_min = a[n-1] 

    if i != 0:
        if t[i-1] < t[i]:
            h_min = t[i]
    else:
        h_min = t[0]


    result = result * max(h_max - h_min, 0) % (10**9+7)
print(result)

Measured memory_bytes: 18624
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn has753(s: usize) -> bool {
    let s = s.to_string();
    return s.find('3').is_some() && s.find('5').is_some() && s.find('7').is_some();
}

fn main() {
    input! {
        n: usize,
    }

    let mut q = vec![0];
    let mut ans = 0;
    for i in 0..10 {
        let mut nq = vec![];
        for &x in &q {
            let n3 = x * 10 + 3;
            let n5 = x * 10 + 5;
            let n7 = x * 10 + 7;
            if n3 <= n && has753(n3) {
                ans += 1;
            }
            if n5 <= n && has753(n5) {
                ans += 1;
            }
            if n7 <= n && has753(n7) {
                ans += 1;
            }
            nq.push(n3);
            nq.push(n5);
            nq.push(n7);
        }
        q = nq;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
H, W, A, B = map(int, input().split())
ans = 0

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = maximum = max(H - A + W - 2, W + A - B - 2)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(W - B):
    #前半の経路
    P = 10 ** 9 + 7
    prev = cmb(H - A + B - 1 + i, H - A - 1, P) % P
    latter = cmb(A - 1 + W - B - 1 - i, A - 1, P) % P
    ans += (prev * latter) % P
    ans = ans % P
print(ans)






Measured memory_bytes: 26016
import heapq
n,m=map(int,input().split())
a=list(map(lambda i:int(i)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
    x=heapq.heappop(a)*(-1)
    heapq.heappush(a,(x//2)*(-1))
print((-1)*sum(a))

Measured memory_bytes: 14180
#include <cstdlib>
#include <cstdio>

int main(){
  int age,price;
  scanf("%d %d",&age,&price);

  if(age >= 13){ printf("%d\n",price);   return 0;}
  if(age >=  6){ printf("%d\n",price/2); return 0;}
  printf("%d\n",0);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    string N; cin >> N;
    int sumN = 0;
    for (int i = 0; i < N.size(); ++i) sumN += N[i] - '0';
    if (stoi(N) % sumN == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}




Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> A;
    cin >> B;
    cin >> C;

    if(B*C>=A) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=INF,a[100],b[100],c,d,cmpp,m,h,w,x,y,sum=0,pos,g,anss;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>g;
      rep(i,n)cin>>a[i]>>b[i];

        for(int bit=0;bit<(1<<n);bit++){
          cnt=0;anss=0;
          map<ll,ll> mp;
        rep(i,n){
          if(bit&(1<<i)){
            cnt+=(i+1)*100*a[i]+b[i];
            anss+=a[i];
            mp[i]++;
          }
        }
        if(cnt<g){
          rrrep(i,n-1,0){
            if(mp[i]==0){
              pos=(g-cnt)/((i+1)*100);
              if((g-cnt)%((i+1)*100)!=0)pos++;
              if(pos<=a[i]){
                anss+=pos;
                break;
              }
              else{
                anss+=INF;
                break;
              }
            }
          }
        }
        ans=min(ans,anss);
        }
        Cout(ans);
      
     

       
return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_d

//بسم الله الرحمن الرحيم
//اللہ کے نام سے شروع جو بڑا مہربان اور نہایت رحم والا ہے
//Allah in the name of The Most Affectionate, the Merciful
//अल्लाह के नाम से जो दयालु और कृपाशील है
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<ctime>

using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ull unsigned ll
#define pb push_back

#define endl '\n'
#define mod 1000000007

#define FOR(i,k,n) for(int i=k; i<n; i++)
#define ROF(i,k,n) for(int i=k; i>=n; i--)
#define MEMSET(t) memset(t,0,sizeof(t));
#define time clock_t tStart
#define Start clock()
#define Time printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC)

// int dp[1000];
// ll maxVal(int w[], ll v[], int n, int W, int wtSum)
// {
//   //  cout<<wtSum<<" "<<n<<endl;
//     if(n==0) return 0;
//     if(dp[n]!=-1) return dp[n];

//     if(wtSum+w[n-1]>W)  return dp[n]= maxVal(w,v,n-1,W, wtSum);
//     //if( W > wtSum+w[n-1]); 

//     return dp[n]=max( maxVal(w,v,n-1,W, wtSum), v[n-1]+maxVal(w,v,n-1,W,  wtSum + w[n-1]) ); 

// }

//method 2
ll dptable(int w[], ll v[], int n, int W, int S)
{
    ll dp[n+1][W+1];

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

    FOR(i,1,n+1){
        FOR(j,1,W+1){
            if(w[i-1]<=j) {
                dp[i][j] = max( dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]] );  
            } 
            else dp[i][j] = dp[i-1][j];
        }
    }
    return dp[n][W];
}
//1
int main()
{
    fastio;
    int t=1; //cin>>t;
    while(t--)
    {
        int n,W; cin>>n>>W;

        int w[n];
        ll v[n];

        FOR(i,0,n) cin>>w[i]>>v[i];
      //  memset(dp,-1,sizeof(dp));
        //cout<<maxVal(w,v,n,W, 0);
        cout<<dptable(w,v,n,W, 0);
    }
    return 0;
}   

Measured memory_bytes: 82544
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		long[] A = new long[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}
		long sum = 0;
		long temp = A[0];
		
		for (int i = 1; i < N; i++) {
			if (A[i] < temp) {
				sum += temp - A[i];
			}
			else {
				temp = A[i];
			}
		}
		// 結果の出力
		System.out.println(sum);
		
		sc.close();
	}
}


Measured memory_bytes: 61516
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( int i = (t); i >= (s); -- i )
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 500 + 5 ; 
const int M = 100 + 5 ; 
int T, n, A[N], flag, b[M] ;
char s[N] ;  
void solve( int l, int r, int type ) {
	if( type == 0 ) {
		rep( j, l, r ) {	
			int x = A[j] ; 
			for( int i = 60; i >= 0; -- i ) {
				int u = ( 1ll << i ) ; 
				if( u & x ) x ^= b[i] ;   
			}
			if( x ) flag = 1 ; 
		}
	}
	else {
		rep( j, l, r ) {	
			int x = A[j] ; 
			for( int i = 60; i >= 0; -- i ) {
				int u = ( 1ll << i ) ; 
				if( u & x ) {
					if( !b[i] ) b[i] = x, x = 0 ; 
					else x ^= b[i] ;   
				}
			}
		}
	}
} 
signed main()
{
	T = gi() ; 
	while( T-- ) {
		n = gi() ;
		rep( i, 1, n ) A[i] = gi() ; 
		scanf("%s", s + 1 ) ; s[0] = '5' ; 
		int lst = n ; flag = 0 ; 
		for( int i = n; i >= 1; -- i ) {
			if( s[i] != s[i - 1] ) {
				if( s[i] == '0' ) solve(i, lst, 1) ;
				else solve(i, lst, 0) ;
				lst = i - 1 ; 
			}
		} 
		if( flag ) puts("1") ;
		else puts("0") ; 
		rep( i, 0, 65 ) b[i] = 0 ;
	}
	return 0 ;
}

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

int main() {
    
    int m, f, r;
    
    while(1) {
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        
        if(m == -1 || f == -1) {
            cout << "F" << endl;
        }
        else if (m + f >= 80) {
            cout << "A" << endl;
        }
        else if (m + f >= 65) {
            cout << "B" << endl;
        }
        else if (m + f >= 50) {
            cout << "C" << endl;
        }
        else if (m + f >= 30 && r >=50) {
            cout << "C" << endl;
        }
        else if (m + f >= 30) {
            cout << "D" << endl;
        }
        else {
            cout << "F" << endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3100
N = int(input())
S = []
for _ in range(N): 
    S.append(input())
AC = S.count('AC')
WA = S.count('WA')
TLE = S.count('TLE')
RE = S.count('RE')
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Measured memory_bytes: 16284
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] nums = new long[n]; 

		for(int i = 0; i < n; i++){
			nums[i] = sc.nextLong();
			if(nums[i] == 0) {
				System.out.println(0);
				return;
			}
		}
		
		long ans = nums[0];
		for(int i = 1; i < n; i++){
			try{
				long ai = nums[i];
				ans = Math.multiplyExact(ans,ai);
				if((long)Math.pow(10, 18) < ans) {
					System.out.println(-1);
					return;
				}
			}catch (Exception e){
				System.out.println(-1);
				return;
			}
		}
		
		System.out.println(ans);
		
		sc.close();
	}

}

Measured memory_bytes: 61096
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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

gcd_from_right = [0] * N
gcd_from_right[-1] = A[-1]
for i in reversed(range(N-1)):
    gcd_from_right[i] = gcd(A[i], gcd_from_right[i+1])

ans = gcd_from_right[1]
gcd_from_left = A[0]
for i in range(1, N-1):
    ans = max(ans, gcd(gcd_from_left, gcd_from_right[i+1]))
    gcd_from_left = gcd(gcd_from_left, A[i])
ans = max(ans, gcd_from_left)
print(ans)


Measured memory_bytes: 14332
#include <bits/stdc++.h>
#include<string>
    
using namespace std;
            
    #define ll long long
    #define do long double
    #define ff first
    #define ss second
    #define pb push_back
    #define mp make_pair
    #define inf LONG_LONG_MAX
    #define mod 998244353
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N=200010;
ll spf[N];
bool prime[N];
void ini()
{
	for(ll i=0;i<N;i++)
	{
		prime[i]=true;
		spf[i]=i;
	}
	prime[0]=prime[1]=false;
	for(ll i=2;i*i<N;i++)
	{
		if(prime[i])
		{
			for(ll j=i*i;j<N;j+=i)
			{
				prime[j]=false;
				if(spf[j]==j)
				{
					spf[j]=i;
				}
			}
		}
	}

}

void solve()
{
	ll n,m,i,j,k,a,b;
	ini();
	vector<ll> v(N);
	j=0;

	for(i=0;i<N;i++)
	{
		if(prime[i])
		{
			v[j]=i;
			j++;
		}
		//cout<<i<<" "<< prime[i]<<" "<<j<<"\n";
	}
	v.resize(j);
	cin>>k;
	ll x=lower_bound(v.begin(),v.end(),k)-v.begin();
	cout<<v[x];

	
}



int main()
{
    FAST
    ll n,m,i,j;
    ll q;
    q=1;

    while(q--)
    	solve();
	

}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>

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

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
int main()
{
    int l;
    cin >> l;
    double x = l / 3.0;
    printf("%f\n", x * x * x);
    return 0;
}

Measured memory_bytes: 3692
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll W;
    cin >> W;
    priority_queue<int> v[4];
    int h;
    rep(i, n) {
        int w, vv;
        cin >> w >> vv;
        if(!i) {
            h = w;
            v[0].push(vv);
        }
        else {
            v[w-h].push(vv);
        }
    }

    vvi dp(4, vi(n+1, 0));
    int ans = 0;
    rep(k, 4) {
        int sum = 0;
        while(!v[k].empty()) {
            int now = v[k].top();
            v[k].pop();
            sum++;
            dp[k][sum] = dp[k][sum-1] + now;
        }
        rep(i, n) {
            dp[k][i+1] = max(dp[k][i+1], dp[k][i]);
        }
    }
    rep(i, n+1) {
        rep(j, n+1-i) {
            rep(k, n+1-i-j) {
                rep(l, n+1-i-j-k) {
                    if(ll(i+j+k+l)*h+j+k*2+l*3 > W or ans >= (ll)dp[0][i]+dp[1][j]+dp[2][k]+dp[3][l]) continue;
                    ans = dp[0][i]+dp[1][j]+dp[2][k]+dp[3][l];
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
H,W=map(int,input().split())
a=[list(map(str,input())) for i in range(H)]

ans=[['#' for i in range(W+2)]for j in range(H+2)]

for i in range(W):
    for j in range(H):
        ans[j+1][i+1]=a[j][i]
    
for j in range(H+2):
    print("".join(ans[j]))

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
string s, t;
signed main() {
    cin >> N >> s >> t;
    int ans = 0;
    reps(i, N) {
        bool flg = true;
        rep(j, i) {
            flg &= s[N - i + j] == t[j];
        }
        if (flg) { ans = i; }
    }
    ans = 2 * N - ans;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  1000005
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,w,n,a;
    vector<ll>v;
    cin>>h>>w;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a;
        v.pb(a);
    }
    ll q,e;
    ll k=0;
    ll vv[h][w];
    for(ll i=0;i<h;i++){
        if(i%2){
            q=w-1;
            e=-1;
        }
        else{
            q=0;
            e=1;
        }
        for(ll j=q;j<w&&j>=0;j+=e){
            vv[i][j]=k+1;
            v[k]--;
            if(v[k]==0)
                k++;
        }
    }
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cout<<vv[i][j]<<" ";
        }
        cout<<endl;
    }


    return 0;
}



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

int div(int n)
{
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(n%i==0)
            cnt++;
    return cnt;
}


int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
        if(i%2==1&&div(i)==8)
           ans++;

    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include<string>
#include<vector>
#define ll long long
using namespace std;
char st[200010];
ll countmax = 0;
void search(int now,ll count,bool turnflag){
  
  /*for(int i=0;i<20;i++){
    cout << st[i];
    if(i==now){
      cout <<"n";
    }
  }
  cout << endl;
  cout << now << " " << count <<  endl;*/
  ll j=0,k,a;
  ll count2=0;
      if(st[now]=='A'&&st[now+1]=='B'&&st[now+2]=='C'){
        int preA=0;
          for(a=1;now-a>=0;a++){
            if(st[now-a]=='A'){
              preA+=1;
            }else{
              break;
            }
          }
        count2=1;
        for(j=0;st[now+2+j*2+1]=='B'&&st[now+2+j*2+2]=='C';j++){
          count2+=1;
        }
        if(j>=1){
          count +=count2*a;
          for(int i = now-preA;i<now-preA+count2*2;i+=2){
            //cout <<"fdgd";
            st[i]='B';
            st[i+1]='C';
          }
          for(int i=now-preA+count2*2;i<now+1+count2*2;i++){
            st[i]='A';
          }
          //cout << "ggg";
          search(now+1+j*2,count,true);
          return;
        }
        if(count2 ==1){
        /*st[now] ='B';
        st[now+1] ='C';
        st[now+2] = 'A'; */
          //cout << "ddd";
          int count3=0;
          for(j=0;st[now+j*3]=='A'&&st[now+j*3+1]=='B'&&st[now+j*3+2]=='C';j++){
            count3+=1;
          }
          count += (preA)*count3;
          //cout << count;
          count += (count3+1)*(count3)/2;
          for(k=0;k<count3;k++){
            st[now +k*2-preA] ='B';
            st[now+k*2+1-preA]='C';
          }
          //cout <<"f"; 
          for(k=now+count3*2-preA;k<now+(count3)*3;k++){
            st[k]='A';
          }
          search(k,count,true);
        }
        return;
      }
  if(st[now]=='A'||st[now]=='B'||st[now]=='C'){
    search(now+1,count,turnflag);
  }else{
    if(turnflag==true){
      search(0,count,false);
    }else{
      countmax=max(countmax,count);
      return;
    }
  }
  return;
}
int main(void){
  fgets(st, 200003, stdin);
  search(0,0,false);
  cout << countmax;
	return 0;
}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    int tryt=pow(2,m);
    cout << tryt*(n*100+m*1800) << "\n";

    return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, r);
  out(r * r);
}


Measured memory_bytes: 256
from itertools import product
n = int(input())
product_list = []
for i in range(3, len(str(n))+1):
    product_list += list(product("753", repeat=i))  # iの長さの重複順列
#print(product_list)
count = 0
for item in product_list:
    if "3" not in item:
        continue
    if "5" not in item:
        continue
    if "7" not in item:
        continue
    item_int = int("".join(item))
    if item_int <= n:
        count += 1
print(count)

Measured memory_bytes: 45548
#include "bits/stdc++.h"
using namespace std;

int main(){
	
	int N, K;
	char tmp;
	string S;
	
	cin >> N >> K;

	for (int i = 0 ; i < N ; i++){
			cin >> tmp;
			S[i] = tmp;
			if (i == K-1){
				if (S[i]=='A'){
					S[i]='a';
				}else if (S[i]=='B'){
					S[i]='b';
				}else{
					S[i]='c';
				}
			}
	}
	for (int i = 0 ; i < N ; i++){
		cout << S[i];
	}
	

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>
#include <cctype>
#include <random>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 998244353;

vector<ll> dp(2 * 100000 + 1, -1);
vector<ll> popcount(2 * 100000 + 1, 0);

int pcnt(int x) {
	return __builtin_popcount(x);
}

int f(int x) {
	if (x == 0) return 0;
	return f(x % pcnt(x)) + 1;
}

int main()
{
	ll n;
	cin >> n;
	string s;
	cin >> s;
	vector<ll> x(n);
	// 0,1変換
	for (ll i = 0; i < n; i++)
	{
		x[i] = s[i] - '0';
	}
	// xのpopcount
	ll pc = 0;
	for (ll i = 0; i < n; i++)
	{
		pc += x[i];
	}
	vector<ll> ans(n);
	for (ll b = 0; b < 2; b++)
	{
		ll npc = pc;
		if (b == 0) npc++; else npc--;
		if (npc <= 0) continue;
		// xのnpc
		ll r0 = 0;
		for (ll i = 0; i < n; i++)
		{
			r0 = (r0 * 2) % npc;
			r0 += x[i];
		}
		ll k = 1;
		for (ll i = n - 1; i >= 0; --i) {
			if (x[i] == b) {
				int r = r0;
				if (b == 0) r = (r + k) % npc;
				else r = (r - k + npc) % npc;
				ans[i] = f(r) + 1;
			}
			k = (k * 2) % npc;
		}
	}

	for (ll i = 0; i < n; i++)
	{
		cout << ans[i] << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll a,b,c;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>a>>b>>c;
    ll ans= b+min(c,a+b+1);
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    char s[10];
    int len,i,j,k;
    long g=0,tmp;
    scanf("%s",s);
    len = strlen(s);
    // printf("%f\n",pow(2,len-1));
    for(i=0;i<pow(2,len-1);i++){
        // printf("-------------------------%d回目\n",i+1);
        char siki[20]={'\0'};
        siki[0]=s[0];
        for(j=0;j<len-1;j++){
            if(i&(1<<j)){
                // printf("True\n");
                sprintf(siki,"%s%c%c",siki,'+',s[j+1]);
            }
            else{
                // printf("False\n");
                sprintf(siki,"%s%c",siki,s[j+1]);
            }
        }/*
        for(j=0;siki[j]!=0;j++){
            printf("%c",siki[j]);
        }*/
        printf("\n");
        tmp=0;
        for(j=0;siki[j]!='\0';j++){
            if(siki[j]!='+')
                tmp=tmp*10+(siki[j]-'0');
                // printf("tmp=%d\n",tmp);
            else{
                g+=tmp;
                tmp=0;
            }
        }
        g+=tmp;
    }
    printf("%ld\n",g);
    return 0;
}

Measured memory_bytes: 128
//////////////////////////////
// Check before you submit!!!

const long long MOD = 1e9+7;
// const long long MOD = 998244353;
/////////////////////////////

#include <bits/stdc++.h>
#ifdef _ATCODER_LIBRARY
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;

#define DEBUG(x);
#ifdef _DEBUG
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
#define GLIBCXX_DEBUG
#define GLIBCXX_DEBUG_PEDANTIC
#endif

using ll = long long;
using P = pair<ll, ll>;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N; cin >> N;
	string res = "AB";
	if (N <= 999) res += 'C';
	else res += 'D';
	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    string s , t;
    cin >> s;
    cin >> t;
    int counter = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i]==t[i]){
            counter++;
        }
    }
    cout << counter;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a[101000];
    long long k,m,n;
    cin>>a;
    n=strlen(a);
    for(int i=0;i<n;i++)
    {
        if(a[i]=='e')
        {
            if(a[i+1]=='r'&&a[i+2]=='a'&&a[i+3]=='s'&&a[i+4]=='e')
            {
                if(a[i+5]=='r')
                {
                    i+=5;
                }
                else
                {
                    i+=4;
                }
            }
        }
        else if(a[i]=='d')
        {
            if(a[i+1]=='r'&&a[i+2]=='e'&&a[i+3]=='a'&&a[i+4]=='m')
            {
                if(a[i+5]=='e'&&a[i+6]=='r'&&a[i+7]=='a'&&a[i+8]=='s'&&a[i+9]=='e')
                {
                    i+=4;
                }
                else
                {
                    if(a[i+5]=='e'&&a[i+6]=='r')
                    {
                        i+=6;
                    }
                    else
                    {
                        i+=4;
                    }
                }
            }
        }
        else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] ans = new int[n + 1];
        for (int i = 0; i < k * 2; i++) {
            int tmp = sc.nextInt();
            ans[tmp]++;
        }
        for (int i = 1; i <= n; i++) {
            System.out.println(ans[i]);
        }
    }
}

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

int main() {
  ios::sync_with_stdio(false);
  int n;
  long long a, b;
  while(cin >> n >> a >> b) {
    vector<long long> h(n);
    for(int i = 0; i < n; ++i) {
      cin >> h[i];
    }

    long long hi = 1LL << 32;
    long long lo = 0;
    long long ans = hi;
    while(lo < hi) {
      long long k = (hi - lo) / 2LL + lo;
      long long r = 0;
      for (int i = 0; i < n; ++i) {
        if (h[i] < b * k) {
          continue;
        }
        long long t = (h[i] - b * k + (a - b - 1LL)) / (a - b);
        r += t;
      }
      if (r <= k) {
        hi = k;
        ans = min(ans , k);
      } else {
        lo = k + 1;
      }
    }
    cout << ans << endl;
  }
}


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

const int N = 100054, M = N * 2;

int n, E = 0;
int to[M], first[N], next[M];
int p[N], dep[N], deg[N];
int cnt = 0, a[N], b[N];
bool on_diam[N];
int D1, D2, ret;

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E, ++deg[u];
	to[++E] = u, next[E] = first[v], first[v] = E, ++deg[v];
}

void dfs(int x) {
	int i, y;
	if (dep[x] > dep[ret]) ret = x;
	for (i = first[x]; i; i = next[i])
		if ((y = to[i]) != p[x])
			p[y] = x, dep[y] = dep[x] + 1, dfs(y);
}

int main() {
	int i, j, u, v, s = 0, *ans;
	scanf("%d", &n);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	ret = 1,  dep[ret] = p[ret] = 0, dfs(ret), D1 = ret;
	ret = D1, dep[ret] = p[ret] = 0, dfs(ret), D2 = ret;
	for (u = D2; u; u = p[u]) on_diam[u] = true;
	for (i = 1; i <= n; ++i) if (!(on_diam[i] || on_diam[p[i]])) return puts("-1"), 0;
	for (u = D2; u; u = p[u]) a[cnt++] = s += std::max(deg[u] - 1, 1);
	assert(s == n);
	for (i = 0; i < cnt - 1; ++i) b[i] = n - a[cnt - 2 - i], b[cnt - 1] = n;
	ans = (std::lexicographical_compare(a, a + cnt, b, b + cnt) ? a : b);
	putchar(49);
	for (i = 0; i < cnt - 1; printf(" %d", ans[i++] + 1))
		for (j = ans[i] + 2; j <= ans[i + 1]; ++j) printf(" %d", j);
	putchar(10);
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std ; 
#define ll long long
#define flp(i ,a ,b) for(int  i = a ; i<b ; i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define blp(i, a , b) for(int  i = a ; i>=b ; i--)
#define lol 1000000007

 
long long binpow(long long a, long long b, long long m) {
	a %= m;
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}


int main()
{	

	int n ; 
	cin>>n ; 
	int a[n][3]  , dp[n][3]; 
	flp(i,0,n)
	{
		flp(j,0,3)
		{
			cin>>a[i][j] ; 
		}
	}
	memset(dp,0, sizeof dp);
	int ans = INT_MIN ; 
	dp[0][0] =a[0][0];
	dp[0][1] =a[0][1];
	dp[0][2] =a[0][2];
	ans = max(dp[0][0] , dp[0][1]) ; 
	ans = max(ans, dp[0][2]) ; 
	flp(i,1,n)
	{
		flp(j,0,3)
		{
			if(j==0)
			{
				dp[i][j] = max(dp[i-1][1] , dp[i-1][2]) + a[i][j] ;
				ans = max(ans , dp[i][j]) ; 
			}
			else if(j==1)
			{
				dp[i][j] = max(dp[i-1][0] , dp[i-1][2]) + a[i][j] ;
				ans = max(ans , dp[i][j]) ; 
			}

			else
			{
				dp[i][j] = max(dp[i-1][0] , dp[i-1][1]) + a[i][j] ;
				ans = max(ans , dp[i][j]) ; 
			}
		}
	}
	cout<<ans<<"\n"; 


}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)

template<class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}


void _main() {
        int k; cin >> k;
        string str; cin >> str;
        if (str.size() > k) {
                int times = str.size() - k;
                while (times--) str.pop_back();
                str += "...";
        }

        cout << str;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3640
using System;

namespace SheepAndWolves
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var result = GetSafety(input);

            Console.WriteLine(result);
        }

        private static string GetSafety(int[] result)
        {
            return result[0] > result[1] ? "safe" : "unsafe";
        }
    }
}



Measured memory_bytes: 27492
A, B, C, D = map(int, input().split())

q1, mod1 = divmod(A, D)
q2, mod2 = divmod(C, B)

if mod1 > 0:
    q1 += 1
else:
    pass
if mod2 > 0:
    q2 += 1
else:
    pass

if q1 >= q2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
program main
    use iso_fortran_env
    implicit none
    integer(int32) :: i, j, n
    integer(int32) :: k, h, w, ans
    integer(int32), allocatable :: nh(:), nw(:)
    character(1), allocatable :: c(:,:)

    read *, h, w, k
    allocate( c(h, w) )
    allocate( nh(h) )
    allocate( nw(w) )
    ans = 0

    do i = 1, h
        read "(*(a1))", c( i, 1:w )
    enddo

    do j = 0, 2**w - 1
        nw = pack( [(n, n = 1, w)], [(btest(j, n), n = 0, w-1)] )

        do i = 0, 2**h - 1
            nh = pack( [(n, n = 1, h)], [(btest(i, n), n = 0, h-1)] )

            if (( count( c(nh, nw) == "#" ) ) == k) then
                ans = ans + 1
            endif
        
        enddo
    enddo

    print *, ans

end program main

Measured memory_bytes: 2924
/**
 *   author: sahushivam
 *   created: 01 September 2019 (Sunday)  17:44:57
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,a,b) for(ll i = a; i<b; i++)
#define MOD 1000000009
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> arr(n);
    for(ll i=0;i<n;i++) cin>>arr[i];
    ll c=0;
    ll maxi=0;
    for(ll i=n-1;i>0;i--)
    {
      if(arr[i]<=arr[i-1])
        c++;
      else
        c=0;
      maxi=max(c,maxi);
    }
    cout<<maxi;

return 0;
}

Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

import Data.Int

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ x, y, z, k ] <- map fromIntegral <$> readInts
	[ as, bs, cs ] <- map ( reverse . sort . map ( fromIntegral ) ) <$> replicateM 3 readInts
	mapM_ print $ solve as bs cs k

solve as bs cs kk = runST $ do
	let
		x = length as
		y = length bs
		z = length cs
	as' <- newListArray ( 0, x - 1 ) as :: ST s ( STUArray s Int Int64 )
	bs' <- newListArray ( 0, y - 1 ) bs :: ST s ( STUArray s Int Int64 )
	cs' <- newListArray ( 0, z - 1 ) cs :: ST s ( STUArray s Int Int64 )
	res <- newSTRef []
	forM_ [ 0 .. x - 1 ] $ \i -> do
		forM_ [ 0 .. y - 1 ] $ \j -> do
			forM_ ( takeWhile ( \k -> ( i + 1 ) * ( j + 1 ) * ( k + 1 ) <= kk ) [ 0 .. z - 1 ] ) $ \k -> do
				a <- readArray as' i
				b <- readArray bs' j
				c <- readArray cs' k
				modifySTRef res ( a + b + c : )
	modifySTRef res ( take kk . reverse . sort )
	readSTRef res

Measured memory_bytes: 14716