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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll a(n,-1);
  bool ok=true;
  rep(i,m){
    ll s,c; cin>>s>>c;
    s--;
    if(a[s]!=-1 && a[s]!=c) ok=false;
    a[s]=c;
  }
  if(!ok || n>1 && a[0]==0){
    cout<<-1<<endl;
    return 0;
  }
  ll ans=0;
  rep(i,n){
    if(a[i]==-1){
      if(i==0 && n!=1) a[i]=1;
      else a[i]=0;
    }
    ans=ans*10+a[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
int main(){ //srand((unsigned)time(NULL));
  string str;
  cin >> str;
  ll x;
  cin >> x;
  for (int i = 0; i < x; i++) {
    string n;
    cin >> n;
    if(n == "print"){
      ll a,b;
      cin >> a >> b;
      for (int l = a; l <= b; l++) {
        cout << str[l];
      }cout << endl;
    }else if(n == "reverse"){
      ll a,b;
      cin >> a >> b;
      vector<char>q;
      for (int l = a; l <= b; l++) {
        q.push_back(str[l]);
      }
      for (int l = a; l <= b; l++) {
        str[l] = q.back();
        q.pop_back();
      }
    }else{
      ll a,b,count=0;
      string c;
      cin >> a >> b >> c;
      for (int l = a; l <= b; l++) {
        str[l] = c[count];
        count++;
      }
    }
  }
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
// #define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
// #define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
// #define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("b1.in","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define PRIME           1000000007
#define MAX         50000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define pi          3.14159265358979323

// int n;
// const int N=1e6+5;
// vector<bool> prime(N);
// void sieve(){
//     for(int i=0;i<=N;i++)prime[i]=true;
//     prime[0]=prime[1]=false;
//     for(int i=2;i*i<=N;i++){
//         if(prime[i] and i*i<=N){
//             for(int j=i*i;j<=N;j+=i){
//                 prime[j]=false;
//             }
//         }
//     }
// }
// const int N=1e3+5;
// int a[N];

struct cmp { 
    bool operator() (pii a,pii b){
        return ((a.F-a.F/2)*a.S)<((b.F-b.F/2)*b.S);
    }
};
// priority_queue<pii,vector<pii>,cmp> q;
const int N=2e5+1;

vector<int> edge[N];
vector<bool> vis(N);
int cnt;

void dfs(int v){
    vis[v]=true;
    cnt++;
    for(int x:edge[v]){
        if(!vis[x])dfs(x);
    }
}
void Anon_mouS(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        edge[x].pb(y);
        edge[y].pb(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            cnt=0;
            dfs(i);
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}
int32_t main(){
    fastio;
    int q=1;
    // sieve();
    // cin>>q;
    for(int it=1;it<=q;it++){
        // cout<<"Case #"<<it<<": ";
        Anon_mouS();
    }
    return 0;   
}

Measured memory_bytes: 20772
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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; }

int main(){
	int n;cin>>n;
	ll ans;
	for(int i = 0; i < n; i++) {
		ll a;cin>>a;
		if(i == 0){
			ans = __gcd(a,a);
		}
		else{
			ans = __gcd(ans,a);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
n = int(input())
v = list(map(int, input().split()))
v.sort()
x = n
while x > 1:
    v.append((v[0] + v[1]) / 2)
    v.pop(0)
    v.pop(0)
    v.sort()
    x = len(v)
print(v[0])

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int s,count=0,visited[1000000]={};
    scanf("%d",&s);
    visited[s]=1;
    while(1){
        count++;
        if (s%2==0){
            s/=2;
        } else {
            s=s*3+1;
        }
        if (visited[s]==1){
            printf("%d\n",count+1);
            break;
        }
        
        visited[s]=1;
    }
    return 0;    
}


Measured memory_bytes: 4096
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = input()
check1 = [None] * n
check1[0] = 'S'
check1[1] = 'S'
check2 = [None] * n
check2[0] = 'S'
check2[1] = 'W'
check3 = [None] * n
check3[0] = 'W'
check3[1] = 'S'
check4 = [None] * n
check4[0] = 'W'
check4[1] = 'W'
def check(lst):
    for i in range(1,n):
        if lst[i] == 'S':
            if s[i] == 'o':
                if i + 1 == n:
                    if lst[0] != lst[i-1]:
                        return False, lst
                else:
                    lst[i+1] = lst[i-1]
            else:
                if i + 1 == n:
                    if lst[0] == lst[i-1]:
                        return False, lst
                else:
                    if lst[i-1] == 'S':
                        lst[i+1] = 'W'
                    else:
                        lst[i+1] = 'S'
        else:
            if s[i] == 'o':
                if i + 1 == n:
                    if lst[0] == lst[i-1]:
                        return False, lst
                else:
                    if lst[i-1] == 'S':
                        lst[i+1] = 'W'
                    else:
                        lst[i+1] = 'S'
            else:
                if i + 1 == n:
                    if lst[0] != lst[i-1]:
                        return False, lst
                else:
                    lst[i+1] = lst[i-1]
    else:
        if s[0] == 'o' and lst[0] == 'S':
            if lst[-1] != lst[1]:
                return False, lst
        elif s[0] == 'o' and lst[0] == 'W':
            if lst[-1] == lst[1]:
                return False, lst
        elif s[0] == 'x' and lst[0] == 'S':
            if lst[-1] == lst[1]:
                return False, lst
        elif s[0] == 'x' and lst[0] == 'W':
            if lst[-1] != lst[1]:
                return False, lst
        return True, lst

f1, check1 = check(check1)
if f1:
    print(''.join(check1))
    quit()
f2, check2 = check(check2)
if f2:
    print(''.join(check2))
    quit()
f3, check3 = check(check3)
if f3:
    print(''.join(check3))
    quit()
f4, check4 = check(check4)
if f4:
    print(''.join(check4))
    quit()
print(-1)
            

Measured memory_bytes: 72684
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
	long long int ans, n,m;
	cin>>n>>m;
	if(n==1)
	{
		if(m==1)
		ans=1;
		else if(m==2)
		ans=0;
		else
		ans=m-2;
	}
	else if(n==2)
	{
		ans=0; 
	}
	else if(n==3)
	{
		if(m==1)
		ans=1;
		if(m==2)
		ans=0;
		if(m>=3)
		ans=m-2;
	}
	else 
	{
		if(m==1)
		ans=n-2;
		if(m==2)
		ans=0;
		if(m>=3)
		ans=(m-2)*(n-2);
	}
	cout<<ans<<endl;
	return 0;
	
	
	
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 510, M = 200010;

int n, m, k;
int f[N][N];
int L[N][N], R[N][N];

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < m; i ++ )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		L[l][r] ++ , R[r][l] ++ ;
	}
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
		{
			L[i][j] += L[i][j - 1];
			R[i][j] += R[i][j - 1];
		}
	
	for (int len = 1; len <= n; len ++ )
		for (int l = 1; l + len - 1 <= n; l ++ )
		{
			int r = len + l - 1;
			if (r > l + 1) f[l][r] += f[l + 1][r - 1];
			f[l][r] += L[l][r] - L[l][l - 1];
			f[l][r] += R[r][r] - R[r][l - 1];
			f[l][r] -= L[l][r] - L[l][r - 1];
		}
	
	while (k -- )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", f[l][r]);
	}
	return 0;
}

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

	int h,w;

	string s[2002] = {};

	vector<int> brokx[2002];
	vector<int> broky[2002];

int count_yoko(int x, int y) {


	if (brokx[x].size() == 0) {
		return w;
	}
	auto iter = lower_bound(brokx[x].begin(), brokx[x].end(), y);
	if (iter == brokx[x].begin()) {
		return brokx[x][0];
	} else if (iter == brokx[x].end()) {
		return w - *(iter-1) -1;
	} else {
		return *iter - *(iter-1) - 1; 
	}


}

int count_tate(int x, int y) {

	if (broky[y].size() == 0) {
		return h;
	}
	auto iter = lower_bound(broky[y].begin(), broky[y].end(), x);
	if (iter == broky[y].begin()) {
		return broky[y][0];
	} else if (iter == broky[y].end()) {
		return h - *(iter-1) -1;
	} else {
		return *iter - *(iter-1) - 1; 
	}


}

int main(){

	cin >> h>> w;

	rep(i,h) {
		cin >> s[i];
		// brok[i].push_back(-1);
		rep(j,w) {
			if (s[i][j] == '#') {
				brokx[i].push_back(j);
				broky[j].push_back(i);

			}
		}
	}

	int cnt = 0;
	

	rep(i,h) {
		rep(j,w) {
			if (s[i][j] == '#') {
				continue;
			}
			cnt = max(cnt, count_tate(i,j) + count_yoko(i,j) -1);
			if (cnt == h+w-1) {
				break;
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 40320
import sys
sys.setrecursionlimit(100000000)
def dfs(cur,par,d):
    dist[cur]=d
    for nx,nx_dist in G[cur]:
        if nx==par:continue
        dfs(nx,cur,d+nx_dist)

n=int(input())
G=[[] for i in range(n)]
dist=[0]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    G[a-1].append([b-1,c])
    G[b-1].append([a-1,c])
q,k=map(int,input().split())
k-=1
dfs(k,-1,0)
for i in range(q):
    x,y=map(int,input().split())
    x-=1
    y-=1
    print(dist[x]+dist[y])

Measured memory_bytes: 137944
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for(auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(all(__VA_ARGS__),0LL)
#define dsum(...) accumulate(all(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(all(a)); }
template<class T> inline auto min(const T& a){ return *min_element(all(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
#define MOD 1000000007;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***----
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

typedef pair<ll,ll> P;
vector<vector<ll>> DYX{{-1,0},{1,0},{0,-1},{0,1}};

signed main(){
  int N;cin>>N;
  int a,ans=-1,idx=1;
  REP(i,0,N){
    cin>>a;
    if(a==idx){
      idx++;
    }
    else{
      ans++;
    }
  }
  print((idx==1?-1:ans+1))

}


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

int main()
{
  int N, l ,r;
  int cnt = 0;
  
  cin >> N;
  
  for (int i=0; i<N; i++)
  {
    cin >> l >> r;
    cnt += r - l + 1;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3592
import java.util.*;

class Main{
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      long    n    = scan.nextLong();
      long    m    = scan.nextLong();

      if(n >= 3 && m >= 3){
         System.out.println((n - 2) * (m - 2));
         }
      else if(n == 2 || m == 2){
              System.out.println(0);
              }
      else if(n == 1 && m == 1){
              System.out.println(1);
              }
      else{
          System.out.println((Math.max(n, m) - 2));
          }
   }
}


Measured memory_bytes: 23252
n = int(input())
d = dict()
for i in range(n):
    s = input()
    t = sorted(s)
    t = "".join(t)
    try:
        d[t] += 1
    except:
        d[t] = 1
ans = 0
for i in d.keys():
    ans += (d[i] * (d[i]-1))//2
print(ans)


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

int main()
{
    int l,r,d;
    cin >> l>> r >> d;
    int ans = 0;
    for (int i=l; i<=r; i++){
        if(i%d==0)ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#define REL
#endif
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

//#pragma GCC optimize("Ofast")
//#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

#define endl '\n'

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

mt19937 gen(34);
//mt19937_64 gen(41);

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("rps2.in", "r", stdin);
	//freopen("rps2.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//----------------------------------------------//
	ll n;
	cin >> n;
	ll res = n * (n + 1) / 2;
	ll m = n / 3;
	res -= m * (m + 1) / 2 * 3;
	ll k = n / 5;
	res -= k * (k + 1) / 2 * 5;
	ll p = n / 15;
	res += p * (p + 1) / 2 * 15;
	cout << res;
	//----------------------------------------------//

	return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;

int main(){
  int h, n; cin >> h >> n;
  int a;
  for(int i = 0; i < n; i++){
    cin >> a;
    h -= a;
  }
  if(h > 0) cout << "No\n";
  else cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t H, W;
  cin >> H >> W;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<vector<int64_t>> horizon(H);
  vector<vector<int64_t>> vertical(W);
  vector<vector<bool>> is_open(H, vector<bool>(W, true));

  for (int64_t r = 0; r < H; ++r) {
    string s;
    cin >> s;
    for (int64_t c = 0; c < W; ++c) {
      const char ch = s.c_str()[c];
      if (ch == '#') {
        horizon[r].push_back(c);
        vertical[c].push_back(r);
        is_open[r][c] = false;
      }
    }
  }

  for (int64_t r = 0; r < H; ++r) {
    horizon[r].push_back(-1);
    horizon[r].push_back(W);
    sort(horizon[r].begin(), horizon[r].end());
  }
  for (int64_t c = 0; c < W; ++c) {
    vertical[c].push_back(-1);
    vertical[c].push_back(H);
    sort(vertical[c].begin(), vertical[c].end());
  }

  int64_t result = 0;
  for (int64_t r = 0; r < H; ++r) {
    for (int64_t c = 0; c < W; ++c) {
      if (is_open[r][c]) {
        auto itr1 = lower_bound(vertical[c].begin(), vertical[c].end(), r);
        const int64_t top = *itr1;
        --itr1;
        const int64_t bottom = *itr1;

        auto itr2 = lower_bound(horizon[r].begin(), horizon[r].end(), c);
        const int64_t right = *itr2;
        --itr2;
        const int64_t left = *itr2;
        const int64_t temp = (top - bottom - 1) + (right - left - 1) - 1;
        result = max(result, temp);
      }
    }
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 70984
#53b
s = input()
a=0
b=0
for i in range(len(s)):
    if s[i]=='A':
        a=i
        break
s=s[::-1]
for j in range(len(s)):
    if s[j]=='Z':
        b=j
        break

print(len(s)-a-b)
            

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define in auto&it
#define out auto it
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
const double pi = acos(-1);
#define err(x) cerr<<#x<<" = "<<x<<'\n';
int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif
	fastio
	double d,t,s;
	cin>>d>>t>>s;
	if(d/s<=t) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3736
solver::[Int]->Int
solver xs = let h = head xs in minimum (if  h /= 0 then [(check_tot 0 h (tail xs))
                                                       ,(check_tot (abs (h-1)) 1 (tail xs))
                                                       ,(check_tot (abs (h+1)) (-1) (tail xs))]
                                                  else [(check_tot (abs (h-1)) 1 (tail xs))
                                                      ,(check_tot (abs (h+1)) (-1) (tail xs))])

main::IO()
main=do
  _<-getLine
  datc<-getLine
  print (solver (map read (words datc)))
--おそい。Step_sumを作る事無く、シーケンシャルにいく

--今のカウント手数、ここまでの修正されたトータル（これはゼロでない事が保証される）、食べるリスト。
check_tot::Int -> Int -> [Int] -> Int
check_tot st _   [] = st
check_tot st tot xs
      | (tot > 0)&&((tot+(head xs))>=0) = let dec = (tot+(head xs))+1 in check_tot (dec+st) (-1) (tail xs)
      | (tot > 0)&&((tot+(head xs)) <0) = check_tot st (tot+(head xs)) (tail xs)
      | (tot < 0)&&((tot+(head xs)) >0) = check_tot st (tot+(head xs)) (tail xs)
      | (tot < 0)&&((tot+(head xs))<=0) = let inc = 1-(tot+(head xs)) in check_tot (inc+st)   1  (tail xs)

Measured memory_bytes: 38268
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	ll A, B, Q;
	cin >> A >> B >> Q;
	A += 2; B += 2;
	vll s(A), t(B), x(Q);
	rep(i, A - 2) cin >> s[i + 1];
	rep(i, B - 2) cin >> t[i + 1];
	rep(i, Q) cin >> x[i];
	s[0] = -INF; s.back() = INF;
	t[0] = -INF; t.back() = INF;

	
	rep(q, Q) {
		ll ns[2], nt[2];
		auto its = lower_bound(all(s), x[q]);
		ns[0] = s[its - s.begin()]; ns[1] = s[its - s.begin() - 1];
		auto itt = lower_bound(all(t), x[q]);
		nt[0] = t[itt - t.begin()]; nt[1] = t[itt - t.begin() - 1];
		
		ll ans = INF;
		rep(i, 2) {
			rep(j, 2) {
				ll d1 = abs(ns[i] - x[q]) + abs(nt[j] - ns[i]);
				ll d2 = abs(nt[i] - x[q]) + abs(ns[j] - nt[i]);
				ans = min({ ans, d1, d2 });
			}
		}
		cout << ans << endl;
	}
}

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

int main() {
    int n;
    int a[330000];
    cin >> n;
    for(int i = 0; i < 3 * n; ++i) cin >> a[i];
    
    sort(a, a + 3 * n, greater<int>());
    
    long long int ans = 0;
    for(int i = 0; i < n; ++i) ans += a[2*i+1];
    
    cout << ans << endl;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = A; i <= B; i++) {
		string s = to_string(i);
		if (s.at(0) == s.at(4) && s.at(1) == s.at(3)) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    lst = [list(map(int, input().split())) for _ in range(M)]
    p = list(map(int, input().split()))
    ans = 0

    for i in range(2 ** N):  # スイッチの状態をビット全探索
        switch = [0] * N
        flag = True

        for j in range(N):  # スイッチの状態を1パターン決める 1:ON, 0:OFF
            if ((i >> j) & 1):
                switch[j] = 1

        for j in range(M):  # 各電球について条件を満たすか確認
            cnt = 0  # 各電球についてonになっているスイッチの数
            for k in lst[j][1:]:
                if switch[k - 1] == 1:
                    cnt += 1

            if cnt % 2 != p[j]:  # 1つでも点灯しない電球があったら現在のスイッチの状態はだめ
                flag = False
                break

        if flag == True:  # すべての電球が点灯する
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);cout.tie(0);

   ll a,c,d,e,x,y,i,j,k,l;
   cin>>a>>c>>d>>e;

   x=a*e;
   y=a*d;
   i=c*e;
   j=c*d;
   cout<<max(x,max(y,max(i,j)))<<endl;

   return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n;cin>>n;
    ll ans=LINF;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
            ans=min(ans,i+n/i-2);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main (){
	int n,x;
	while(cin >>n){
		int max=0,sum = 0;
		for (int i = 0;i<n;i++){
			cin >> x; 
			if (x>max)
				max = x;
			sum +=x;
		}
		sum -= max/2;
		cout << sum << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
signed main(){
    IOS;
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
      int maxprev=0;
    int ans=0;
      for(int i=0;i<n;i++){
        if(v[i]<maxprev)ans+=maxprev-v[i];
        else maxprev=v[i];
      }
      cout<<ans;
}

Measured memory_bytes: 4772
import math
#試し割法
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
def main():
    N, P = map(int, input().split())
    ans = 1
    soinsu = factorize(P)
    # print(soinsu)
    di = {}
    for i in soinsu:
        if i not in di:
            di[i] = 1
        else:
            di[i] += 1
    for k,v in di.items():
        kosu = v//N

        if kosu > 0:
            ans *= (k ** kosu)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38512
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var h = long.Parse(Console.ReadLine());

        var k = 0L;
        var n = 1L;
        while (n <= h)
        {
            k += n;
            n *= 2;
        }
        
        Console.WriteLine(k);
    }
}


Measured memory_bytes: 13140
import scala.math._
import scala.annotation._
import scala.collection._
import scala.collection.{mutable => mut}
import scala.util.control.Breaks.{breakable,break}

object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)

    val a, b = sc.nextInt
    println(if(b % a == 0) a + b else b - a)
  }
}

Measured memory_bytes: 25556
# https://atcoder.jp/contests/abc148/tasks/abc148_b
import sys


def main():
    num = int(input())
    (s, t) = input().split(" ")
    for i in range(num):
        sys.stdout.write(s[i])
        sys.stdout.write(t[i])
    sys.stdout.write("\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;

int main(void) {
	int n, c = 3;
	char s[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == 'Y')
			c = 4;
	}
	if (c == 3)
		cout << "Three" << endl;
	else
		cout << "Four" << endl;
}

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

using namespace std;

typedef unsigned long long ll;

int main()
{
    int   n ; ll  h;
    cin >> h >> n;
    int a[n] ;

    for(int i=0;i<n;i++)
        cin >> a[i];


    sort(a,a+n);
    int i=0;
    ll s=0;
    while((s<h)&&(i<n))
    {
        s=s+a[i];
        i++;
    }
    if(s>=h) cout<<"Yes";
    else cout <<"No";

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0){
      break;
    }
    int H = 101;
    int W = 101;
    for (int i = 1; i <= 150; i++){
      for (int j = i + 1; j <= 150; j++){
        if (i * i + j * j > h * h + w * w || i * i + j * j == h * h + w * w && i > h){
          if (H * H + W * W > i * i + j * j || H * H + W * W == i * i + j * j && H > i){
            H = i;
            W = j;
          }
        }
      }
    }
    cout << H << ' ' << W << endl;
  }
}


Measured memory_bytes: 3044
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	int l,r;
	rep(i,s.size())if(s[i]=='Z')r=i;
	rep(i,s.size())if(s[s.size()-1-i]=='A')l=s.size()-1-i;
	cout<<r-l+1<<endl;
}








Measured memory_bytes: 640
a,b = map(int,input().split())
bo = []
bo.append("."*(b+2))
for i in range(a):
    s = input()
    s = "." + s + "."
    s = list(s)
    bo.append(s)
bo.append("."*(b+2))

dx = [-1,-1,-1,1,1,1,0,0]
dy = [-1,0,1,-1,0,1,1,-1]

for i in range(1,a+1):
    for j in range(1,b+1):
        cnt = 0
        if bo[i][j] == "#":
            continue
        for k in range(8):
            ch = bo[i-dx[k]][j-dy[k]]
            if ch == "#":
                cnt += 1
        bo[i][j] = str(cnt)

for i in range(1,a+1):
    print("".join(bo[i][1:-1]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define maxn 505

using namespace std;

int n, m;
char s[maxn][maxn], a[maxn][maxn], b[maxn][maxn];

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1;i <= n;i++) scanf("%s", s[i] + 1); 
	for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) a[i][j] = b[i][j] = '.';
	for(int i = 1;i <= n;i++) a[i][1] = b[i][m] = '#';
	for(int i = 1;i <= n;i++){
		for(int j = 2;j < m;j++) (i & 1) ? a[i][j] = '#' : b[i][j] = '#';
	}
	for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) if(s[i][j] == '#') a[i][j] = b[i][j] = '#';
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++) printf("%c", a[i][j]);
		puts("");
	}
	puts("");
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++) printf("%c", b[i][j]);
		puts("");
	}
}

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

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
char b[200000], ok[100000]{ 1 };
deque<int>que;

void bfs(int u, int t) {
	que.emplace_back(u);
	while (!que.empty()) {
		int p = que.front(); que.pop_front();
		for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.emplace_back(v);
				}
			}
			else if (!~d[v]) {
				d[v] = d[p] + 1; que.emplace_back(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(&n); reader(&m); reader(&q);
	rep(i, m) {
		reader(&u[i]); reader(&v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	memset(d, -1, sizeof(d));
	d[0] = 0; bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(&r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

Measured memory_bytes: 13620
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s;
    cin>>s;
    string t=s.substr(0,2);
    string u=s.substr(2);
    if("00"<t&&t<="12"){
        if("00"<u&&u<="12")cout<<"AMBIGUOUS"<<endl;
        else cout<<"MMYY"<<endl;
    }
    else {
       if("00"<u&&u<="12")cout<<"YYMM"<<endl;
        else cout<<"NA"<<endl; 
    }
    return 0;
}

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

int main()
{
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    ll t = X / D;
    ll p = K - t;
    if (K>=t)
    {
        if (p % 2 == 0)
            cout << X - t * D;
        else
            cout << (t + 1) * D - X;
    }
    else
    {
        cout << X - K * D;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define xx first
#define yy second

using namespace std;

ll a[5], b[5];
ll dp[50000000 + 5];
ll n;

inline ll calc (ll* x, ll* y, ll t) {
	for (int i = 0; i <= t; ++i) {
		dp[i] = 0;
		for (int j = 1; j <= 3; ++j) {
			if (i >= x[j]) {
				dp[i] = max (dp[i], dp[i - x[j]] + y[j]);
			}
		}
	}
	for (int i = 0; i < t; ++i) {
		dp[t] = max (dp[t], dp[i] + t - i);
	}
	return dp[t];
}

int main () {
	#ifdef wll
	freopen ("testdata.in", "r", stdin);
	#endif
	scanf ("%lld", &n);
	for (int i = 1; i <= 3; ++i) {
		scanf ("%lld", &a[i]);
	}
	for (int i = 1; i <= 3; ++i) {
		scanf ("%lld", &b[i]);
	}
	n = calc (a, b, n);
	n = calc (b, a, n);
	printf ("%lld\n", n);
	return 0;
}
















Measured memory_bytes: 196864
#include <bits/stdc++.h>
using namespace std;
const int N = 1003, M = 11;

int n;
char a[N][N];

int stgt(int i)
{
    set<char> q;
    for (int j = 0; j < n; ++j)
    {
        if (a[i][j] == '.')
            continue;
        q.insert(a[i][j]);
    }
    return q.size();
}
int stgs(int j)
{
    set<char> q;
    for (int i = 0; i < n; ++i)
    {
        if (a[i][j] == '.')
            continue;
        q.insert(a[i][j]);
    }
    return q.size();
}

int z;
bool rec(int x, int y)
{
    if (x == n)
    {
        bool z = true;
        for (int j = 0; j < n; ++j)
        {
            if (stgs(j) != 3)
            {
                z = false;
                break;
            }
        }
        return z;
    }
    if (y == n - 1)
    {
        if (stgt(x) == 3 && rec(x + 1, 0))
            return true;
    }
    else
    {
        if (stgt(x) <= 3 && rec(x, y + 1))
            return true;
    }
    if (a[x][y] == '.' && y + 1 < n && a[x][y + 1] == '.')
    {
        a[x][y] = ('a' + z);
        a[x][y + 1] = ('a' + z);
        z = (z + 1) % 26;
        if (y == n - 1)
        {
            if (stgt(x) == 3 && rec(x + 1, 0))
                return true;
        }
        else
        {
            if (stgt(x) <= 3 && rec(x, y + 1))
                return true;
        }
        a[x][y] = '.';
        a[x][y + 1] = '.';
    }
    if (a[x][y] == '.' && x + 1 < n && a[x + 1][y] == '.')
    {
        a[x][y] = ('a' + z);
        a[x + 1][y] = ('a' + z);
        z = (z + 1) % 26;
        if (y == n - 1)
        {
            if (stgt(x) == 3 && rec(x + 1, 0))
                return true;
        }
        else
        {
            if (stgt(x) <= 3 && rec(x, y + 1))
                return true;
        }
        a[x][y] = '.';
        a[x + 1][y] = '.';
    }
    return false;
}

char u[M][M][M];
void pre()
{
    for (n = 4; n <= 7; ++n)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
                a[i][j] = '.';
        }
        rec(0, 0);
        //for (int i = 0; i < n; ++i)
        //    printf("%s\n", a[i]);
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                u[n][i][j] = a[i][j];
            }
        }
    }
}

int main()
{
    pre();
    scanf("%d", &n);
    if (n == 2)
    {
        printf("-1\n");
        return 0;
    }
    if (n == 3)
    {
        printf(".aa\n");
        printf("a..\n");
        printf("a..\n");
        return 0;
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            a[i][j] = '.';
        }
        a[i][n] = 0;
    }
    int m = n;
    while (m > 7)
    {
        for (int i = m - 4; i < m; ++i)
        {
            for (int j = m - 4; j < m; ++j)
            {
                a[i][j] = u[4][i - (m - 4)][j - (m - 4)];
            }
        }
        m -= 4;
    }
    for (int i = 0; i < m; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            a[i][j] = u[m][i][j];
        }
    }
    for (int i = 0; i < n; ++i)
        printf("%s\n", a[i]);
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Data {
    ll c;
    ll s;
    ll f;
};

Data D[505];

int main() {
    ll N;
    cin >> N;
    REP(i, N - 1) {
        cin >> D[i].c >> D[i].s >> D[i].f;
    }

    REP(i, N) {
        ll t = 0;
        FOR(j, N - 1, i) {
            t = std::max(t, D[j].s);
            ll a = t / D[j].f;
            ll b = t % D[j].f;
            if (b > 0)
                a++;
            t = a * D[j].f;
            t += D[j].c;
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int sum = 0;
  rep(i,n) sum ^= a[i];

  vector<int> c(n);
  rep(i,n) {
    c[i] = sum ^ a[i];
  }

  for(auto val: c) cout << val << " ";
  cout << "\n";

  
  return 0;
}


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

int main(){
 	int ar[3];
  	cin>>ar[0]>>ar[1]>>ar[2];
  	sort(ar, ar+3);
  	if(ar[0] == 5 && ar[1] == 5 && ar[2] == 7){
     	cout<<"YES"<<endl; 
    }else{
		cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int ti = clock();
    int D; cin >> D;
    vector<ll> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(26));
    rep(i, D)rep(j, 26) cin >> s[i][j];
    vector<ll> t(D);
    rep(i, D) t[i] = 26-i%26;
    ll ans = 0;
    vector<ll> last(26);
    vector<ll> t_ans(ALL(t));
    for (int d = 1; d <= D; d++) {
        for (int i = 1; i <= 26; i++) {
            if (t[d-1] == i) {
                ans += s[d-1][i-1];
                last[i-1] = d;
            }
            else {
                ans -= c[i-1]*(d-last[i-1]);
            }
        }
    }
    ll tmp;
    while ((double)(clock() - ti)/CLOCKS_PER_SEC <= 1.98) {
        rep(i, D) t[i] = rand()%26 + 1;
        last.clear();
        last.resize(26);
        tmp = 0;
        for (int d = 1; d <= D; d++) {
            for (int i = 1; i <= 26; i++) {
                if (t[d-1] == i) {
                    tmp += s[d-1][i-1];
                    last[i-1] = d;
                }
                else {
                    tmp -= c[i-1]*(d-last[i-1]);
                }
            }
        }
        if (tmp > ans) {
            swap(ans, tmp);
            rep(i, D) t_ans[i] = t[i];
        }
    }
    rep(i, D) cout << t_ans[i] << endl;
  	//cout << ans << endl;
}


Measured memory_bytes: 3752
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main() {
    int n,ans=0;
    cin >> n;
    int x[n];
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n-1;i++){
        for (int j=n-1; j>i; j--) {
            if(x[j]<x[j-1]){
                swap(x[j], x[j-1]);
                ans++;
            }
        }
    }
    for (int i=0; i<n; i++) {
        if(i==0)cout<< x[i];
        else cout <<" "<< x[i];
    }
    cout << endl << ans << endl;
    
}




Measured memory_bytes: 3092
#include<stdio.h>
int main()
{
  int a,b,c,t;
  scanf("%d%d%d",&a,&b,&c);
  if(a<b)
  t=a,a=b,b=t;
  if(a<c)
    t=a,a=c,c=t;
  if(b<c)
    t=b,b=c,c=t;
  printf("%d\n",b+c);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  int sec, sec_m, sec_s, h, m, s;
  scanf("%d", &sec);

  h = sec / (60 * 60);
  sec_m = sec % (60 * 60);

  m = sec_m / 60;
  sec_s = sec_m % 60;

  s = sec_s;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000000
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)
		    r=(r*a)%m;
		b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

int main(){
    ll n,k,s; cin>>n>>k>>s;
    vi arr(n,mod);
    if(s==mod)
    {
        rep(i,0,n-k)arr[i] = 1;
    }
    else
    {
        rep(i,0,k)arr[i] = s;
    }
    for(auto x:arr)cout<<x<<" ";

    return 0;
}


Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String n = in.next();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < 4; i++){
            map.put(n.charAt(i), map.get(n.charAt(i)) == null ? 1: map.get(n.charAt(i))+1 );
        }
        if (map.size()== 2) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

#define NIL -1
#define MAX 25

class Node{
public:
  int key;
  Node* parent;
  Node* left;
  Node* right;

  Node(){
    parent = NULL;
    left = NULL;
    right = NULL;
  }
};

Node* root = NULL;

void preOrder(Node* n){
  printf(" %d",n->key);
  if(n->left != NULL) preOrder(n->left);
  if(n->right != NULL) preOrder(n->right);
};

void inOrder(Node* n){
  if(n->left != NULL) inOrder(n->left);
  printf(" %d",n->key);
  if(n->right != NULL) inOrder(n->right);
}

void insert(int k){
  Node* n = root;
  Node* new_node = new Node;
  new_node->key = k;

  if(root == NULL){
    root = new_node;
    return;
  }

  while(true){
    if(k < n->key){
      if(n->left != NULL) n = n->left;
      else{
        n->left = new_node;
        new_node->parent = n;
        return;
      }
    }
    else{
      if(n->right != NULL) n = n->right;
      else{
        n->right = new_node;
        new_node->parent = n;
        return;
      }
    }
  }
}

int main(){

  int n;
  scanf("%d", &n);

  char c[10];
  int key;
  for(int i=0; i<n; i++){
    scanf("%s",c);
    if(c[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      inOrder(root); printf("\n");
      preOrder(root);printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 26628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  if (n-k<=0) cout<<x*n<<endl;
  else cout<<x*k+y*(n-k)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const LL INF=(LL)1<<50;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

LL t[220000];
LL dp[220000][3];

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>t[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<3;j++)dp[i][j]=-INF;
	}
	dp[0][0]=t[0],dp[1][1]=t[1],dp[2][2]=t[2];
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			if(dp[i][j]==-INF)continue;
			dp[i+2][j]=max(dp[i+2][j],dp[i][j]+t[i+2]);
			if(j<2)dp[i+3][j+1]=max(dp[i+3][j+1],dp[i][j]+t[i+3]);
			if(j==0)dp[i+4][2]=max(dp[i+4][2],dp[i][0]+t[i+4]);
		}
	}
	LL s;
	if(n%2==1)s=max(max(dp[n-3][0],dp[n-2][1]),dp[n-1][2]);
	else s=max(dp[n-2][0],dp[n-1][1]);
	cout<<s<<endl;
}

Measured memory_bytes: 9876