akhauriyash/Code-Regression huggingface dataset:
/*input
1
58
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
bitset<4000010> dp;
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    int sum=0;

    REP(i,n){
        cin>>arr[i],sum+=arr[i];
    }
    dp=1;
    REP(i,n){
        dp|=dp<<arr[i];
    }
    int i;
    for(i=(sum+1)/2;!dp[i];i++);
    cout<<i;
}


Measured memory_bytes: 5096
a, b, c = map(int, input().split())

# 偶数の辺があれば、そこをぶった切ればよい
if a * b * c % 2 == 0:
	print(0)
	exit()

# 全部奇数である場合を考える

minsize = min(a * b, b * c, c * a)

print(minsize)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  vector<int> xs(n), ys(m);
  for(int i=0;i<n;i++){cin>>xs.at(i);}
  for(int i=0;i<m;i++){cin>>ys.at(i);}
  for(int z=y;z>x;z--){
    bool xok=0,yok=0;
    for(int j=0;j<n;j++){
      if(xs.at(j)>=z){
        break;
      } else if(j==n-1){xok=1;}
    }
    for(int j=0;j<m;j++){
      if(ys.at(j)<z){
        break;
      } else if(j==m-1){yok=1;}
    }
    if(xok&&yok){
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long l = sc.nextLong();
			long r = sc.nextLong();
			long sub = r - l;

			if (2019 < sub) {
				System.out.println(0);
				return;
			}

			long result = 2020;
			for (long i = l; i < r; i++) {
				if (i % 2019 == 0) {
					System.out.println(0);
					return;
				}
				for (long j = i + 1; j <= r; j++) {
					if ((i * j) % 2019 < result) {
						result = (i * j) % 2019;
					}
				}
			}

			System.out.println(result);
		}
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ld p = acos(-1) ;
	ll r ; cin >> r ;
	cout << fixed << setprecision(20) ;
	cout << 2.0*r*p << endl ;
}


Measured memory_bytes: 3788
def main():
    vertex, query = map(int, input().split())
    cnt = [0 for _ in range(vertex)]
    for _ in range(query):
        a, b = map(lambda x: int(x) - 1, input().split())
        cnt[a] += 1
        cnt[b] += 1
    print("YES" if all(cnt[i] % 2 == 0 for i in range(vertex)) else "NO")


if __name__ == '__main__':
    main()



Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int X;
    cin >> X;
    bool ok = 0;
    for(int i = 0;;i++){
        int cost = i*1.08;
        if(cost == X){
            cout << i << "\n";
            ok = 1;
            break;
        }
        if(cost > X){
            cout << ":(" << "\n";
            break;
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define rrep(x, y) for(int x = (y); x >= 0; x--)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define RREP(x, z, y) for(int x = (y); x >= (z); x--)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define MOD = 1000000007; 
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(e) cout << "L" << __LINE__ << ": " << #e << " = " << e << endl
#define debug_echo_dp(dp, N) { cout << "[ "; rep(i, N) cout << dp[i] << " ";  cout << "]" << endl; }
#else
#define debug_echo(e)
#define debug_var(e)
#define debug_echo_dp(dp, N)
#endif

int main(){
  int n; cin >> n;
  vec(int) p(n);
  rep(i,n) cin >> p[i];
  int cnt;

  RREP(i,1,n){
    cnt = count_if(all(p),[&](int j){return i <= j;}); 
    if(cnt >= i){
      cout << i << endl; 
      return 0;
    }
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define intpow(a, n) (int)pow((long double) a, (long double) n)
#define int long long

int S(int i){
    string s = to_string(i);
    int ret = 0;
    rep(i, s.length()) ret += s[i] - '0';
    return ret;
}

signed main(){
    int n; cin >> n;
    cout << (n % S(n) == 0 ? "Yes" : "No") << endl;
}

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

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

long long MOD = 1000000000 + 7;

template<typename T>
map<T, ll> prime_factorize(T x){
  map<T, ll> res;

  while(x%2==0){
    x/=2;
    res[2]++;
  }

  for(ll i=3;i*i<=x;i+=2){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

map<ll, ll> merge(map<ll,ll> m1, map<ll,ll> m2){
  map<ll,ll> m;
  for(auto x: m1){
    if(m2.count(x.first) != 0){
      m[x.first] = min(m1[x.first], m2[x.first]);
    }
  }
  return m;
}


ll mpow(ll x, ll n){
  if(n == 0)
    return 1;

  if(n % 2 == 0)
    return mpow(x * x, n / 2);
  else
    return x * mpow(x, n - 1);
}

int main(){
  cout << setprecision(10);
  ll N,P;
  cin >> N >> P;

  map<ll,ll> m = prime_factorize(P);

  ll ans = 1;
  for(auto x: m){
    if(x.second >= N){
      ll pow_num = x.second / N;
      ans *= mpow(x.first, pow_num);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
using int64 = long long;
 
int main()
{
  string s;
  cin >> s;
  for(int i = 0; i < (1 << 3); i++) {
    int cur = s[0] - '0';
    string v;
    v += s[0];
    for(int j = 1; j < 4; j++) {
      if((i >> (j - 1)) & 1) {
        cur += s[j] - '0';
        v += "+";
        v += s[j];
      } else {
        cur -= s[j] - '0';
        v += "-";
        v += s[j];
      }
    }
    if(cur == 7) {
      cout << v << "=7" << endl;
      return(0);
    }
  }
 
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
    
    Scanner s = new Scanner(System.in);
    int E = s.nextInt();   
    int Y = s.nextInt();

    if (E == 0){
            if (Y <= 1911){
                System.out.print("M");
                System.out.println(Y - 1867);
            }else if(Y <= 1925){
                System.out.print("T");
                System.out.println(Y - 1911);
            }else if(Y <= 1988){
                System.out.print("S");
                System.out.println(Y - 1925);
            }else{
                System.out.print("H");
                System.out.println(Y - 1988);
            }
        } else if(E == 1){
            System.out.println(1867 + Y);
        }else if(E == 2){
            System.out.println(1911 + Y);
        }else if(E == 3){
            System.out.println(1925 + Y);
        }else{
            System.out.println(1988 + Y);
        }
    }
}

Measured memory_bytes: 26216
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, K = map(int, input().split())
a = list(map(int, input().split()))
#dp[i]...石がi個でゲームを始めたとき、1:'first'の勝ち、2:'second'の勝ち。
dp = [0] * (K + 1)
dp[0] = 2

for i in range(1, K + 1):
	dp[i] = 2
	
	for x in a:
		if i - x >= 0 and dp[i - x] == 2:
			dp[i] = 1

if dp[K] == 1:
	print('First')
else:
	print('Second')
	

Measured memory_bytes: 43216
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#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; }
typedef long long ll;
int main()
{
  ll n; cin >> n;
  vector<ll> f(n+1, 1);
  for (ll i = 2; i <= n; ++i) {
    ll x = i;
    while(x <= n) {
      f[x]++;
      x += i;
    }
  }
  ll res = 0;
  for (ll i = 1; i <= n; ++i) {
    res += i * f[i];
  }
  cout << res << "\n";
  
  return 0;
}


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

typedef long long ll;

int main(){
    //freopen("in.txt","r",stdin);
    int n;
    cin>>n;
    ll ans = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k=1; k<=n; k++){
                int a = __gcd(i, j);
                int b = __gcd(a, k);
                ans += b;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  stack<char> ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B') ans.push(s[i]);
    else {
      if (!ans.empty()) ans.pop();
    }
  }

  int loop = ans.size();
  string answer = "";
  rep(i,loop) {
    char c = ans.top();
    answer += c;
    ans.pop();
  }
  reverse(answer.begin(), answer.end());
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3592
N, K = map(int, input().split())
A = list(map(int, input().split()))

# Kの連続する数列ひとつだけ黒か白に統一されている縛りがある
# ほかは任意なので、正は黒に、負は白にぬればよい

CumS = [0] * (N+1)
CumSPos = [0] * (N+1)

for i in range(N):
  CumS[i+1] = CumS[i] + A[i]
  CumSPos[i+1] = CumSPos[i] + (A[i] if A[i] > 0 else 0)

ans = (-1) * float("inf")
# i : 統一されてるシークエンスの始まりindex。1-indexed
for i in range(1,N+1): #1-index
  if i+K-1 > N:
    break
  work = 0
  work += CumSPos[i-1] # pos -> black, neg -> white
  work += max(CumS[i+K-1] - CumS[i-1], 0) # black or white
  work += CumSPos[N] - CumSPos[i+K-1]  # pos -> black, neg -> white
  ans = max(ans, work)
  #print(i,work, CumSPos[i-1], max(CumS[i+K-1] - CumS[i-1], 0), CumSPos[N] - CumSPos[i+K-1])
  
print(ans)

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

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int cnt = 0;
    int cur = 1;
    for (auto a : A) {
        if (a != cur) {
            cnt++;
        } else {
            cur++;
        }
    }
    if (cur != 1) {
        cout << cnt << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

int main()
{
    int p, q, r;

    scanf("%d %d %d", &p, &q, &r);

    printf("%d\n", min(p + q, min(p + r, q + r)));

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  long long K;
  cin >> N >> K;
  int a[N], b[N];
  pair<int,int> p[N];
  long long cnt = 0;
  for(int i=0; i<N; i++){
    cin >> a[i] >> b[i];
    p[i] = pair<int,int>(a[i], b[i]);
  }
  sort(p, p+N);
  for(int i=0; i<N; i++){
    cnt += p[i].second;
    if(cnt >= K){
      cout << p[i].first << endl;
      break;
    }
  }
  return 0;
}

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


int main()
{
    int x;cin>>x;
    if(x <= 3) {
        cout << 1 << endl;
        return 0;
    }
    int m = 0;
    for(int i = 2; i <=31 ;i++){
        for(int j = 2; j <= 9; j++){
            if(x >= pow(i,j)){
                m = max((int)pow(i ,j), m);
            }else continue;
        }
    }
    cout << m << endl;
    
    
    
    return 0;
}

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

int main()
{
    char ch;
    int counter[25];
    for(int i=0; i<26; i++)
    {
        counter[i] = 0;
    }
    int num = 0;

    while(cin>>ch)
    {
        if ('a' <= ch && ch <= 'z')
        {
            num = ch - 'a';
            counter[num]++;
        }
        else if ('A' <= ch && ch <= 'Z')
        {
            num = ch - 'A';
            counter[num]++;
        }
    }

    for (int i=0; i<26;i++)
    {
         printf("%c : %d\n", 97 + i, counter[i]);
         
    }
       

    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
using ll=long long;


int main(){
    int n; cin>>n;
    cout<<"ABC"<<n<<endl;
    return 0;
}


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

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> M(N, 0);
    int all = 0;
    int min_val = 1 << 30;
    for (int i = 0; i < N; ++i)
    {
        cin >> M[i];
        all += M[i];
        min_val = min(min_val, M[i]);
    }
    int diff = X - all;
    int ans = N + diff / min_val;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;


void solve(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    Vl A(n);
    rep(i, 0, n) cin >> A[i];

    ll od = 0;
    rep(i, 0, n){
        if(A[i]%2 == 0) od ++;
    }

    ll sum = pow(3, n);
    ll odsum = pow(2, od);

    cout << sum - odsum << "\n";
}


int main() {
    solve();
}


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

using namespace std;

int main() {
  int N;
  char S[100];
  char T[100];
  int i,j;
  int matched = 0;
  
  cin >> N;

  for(i=0; i<N; i++){
    cin>> S[i];
  }
  for(i=0; i<N; i++){
    cin >> T[i];
  }
  
  for(i=0;i<N;i++){    
    for(j=0;j<N-i;j++){
      if(S[i+j]!=T[j]){
	matched = 0;
	break; 
      }
      matched = 1;
    }
    if (matched == 1) break;
  }

  cout <<N+i;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int h[100];
int dfs(int l, int r) {
  int m  = 1000000;
  if (l == r) {
    //cout << l << ',' << r << ':' << h[l] << endl;
    return h[l];
  }
  for (int i=l; i<=r; i++) {
    if (h[i] < m) {
      m = h[i];
    }
  }
  //cout << l << ',' << r << ':' << m << endl;
  int ret = m;
  for (int i=l; i<=r; i++) {
    h[i] -= m;
  }
  int prev = l;
  while (prev <= r && h[prev] == 0) prev++;
  while (prev <= r) {
    int i = prev + 1;
    while (i <= r && h[i] > 0) i++;
    ret += dfs(prev, i-1);
    prev = i+1;
  }
  return ret;
}
int main() {
  int N;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> h[i];
  }
  cout << dfs(0, N-1) << endl;
}

Measured memory_bytes: 256
import heapq


def dijkstra(start: int, graph: list) -> list:
    """dijkstra法: 始点startから各頂点への最短距離を求める
    計算量: O((E+V)logV)
    """
    INF = 10 ** 18
    n = len(graph)
    dist = [INF] * n
    dist[start] = 0
    q = [(0, start)] # q = [(startからの距離, 現在地)]
    while q:
        d, v = heapq.heappop(q)
        if dist[v] < d:
            continue
        for nxt_v, cost in graph[v]:
            if dist[v] + cost < dist[nxt_v]:
                dist[nxt_v] = dist[v] + cost
                heapq.heappush(q, (dist[nxt_v], nxt_v))
    return dist


n, m, s, t = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]

graph_y = [[] for i in range(n)]
graph_s = [[] for i in range(n)]
for u, v, a, b in info:
    u -= 1
    v -= 1
    graph_y[u].append((v, a))
    graph_y[v].append((u, a))
    graph_s[u].append((v, b))
    graph_s[v].append((u, b))
    
s -= 1
t -= 1
dist_y = dijkstra(s, graph_y)
dist_s = dijkstra(t, graph_s)

ans = 10 ** 18
ret = [10 ** 15] * n
for i in range(n)[::-1]:
    tmp = dist_y[i] + dist_s[i]
    ans = min(ans, tmp)
    ret[i] -= ans
for i in ret:
    print(i)
    

Measured memory_bytes: 124760
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>

using namespace std;


int main(){

	
	double ax, ay, bx, by;

	cin >> ax >> ay >> bx >> by;

	double distance = sqrt(pow(ax - bx, 2) + pow(ay - by, 2));

	printf("%.7lf\n", distance);
	

	//system("pause");
    return 0;
}




Measured memory_bytes: 3284
#include <stdio.h>

int main(){
    int N, max, max_i;
    scanf("%d", &N);

    int a[N], b[N];
    for(int i = 0; i < N; i++){
        a[i] = i + 1;
        b[i] = 0;
    }

    for(int i = 0; i < N; i++){
        while(1){
            if(a[i] % 2 == 0){
                a[i] /= 2;
                b[i]++;
            }
            else{
                break;
            }
        }
    }

    max = b[0];
    max_i = 0;
    for(int i = 0; i < N; i++){
        if(max < b[i]){
            max = b[i];
            max_i = i;
        }
    }

    printf("%d\n", max_i + 1);
    return 0;
}

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

int main() {
    int K; cin >> K;
    queue<int64_t> que;
    for(int i = 1; i < 10; ++i) que.push(i);
    while(--K) {
        auto now = que.front(); que.pop();
        int lst = now % 10;
        for(int i = max(0, lst - 1); i <= min(9, lst + 1); ++i)
            que.push(10 * now + i);
    }
    cout << que.front() << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
//#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back

void solve()
{
    int n, m; cin>>n>>m;
    unordered_map<int, bool> chk;
    int c = 0;
    int lf = 0, rg = n-1;
    int f = 0;
    while(c<m)
    {
        int delta = rg - lf;
        if (delta<=n/2 &&n%2==0 &&f==0)
        {
            f=1;
            --rg;
            continue;
        }
        chk[delta] = chk[n-delta] = 1;
        cout << lf + 1 << ' ' << rg  + 1 << '\n';
        ++c;
        ++lf, --rg;
    }

}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


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

ll r[101010];

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

	int n, m;
	cin >> n >> m;

	vector<ll> w(n), v(n);
	for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];

	for (int i = 1; i <= m; ++i) r[i] = -1e9;
	for (int i = 0; i < n; ++i) {
		for (int u = m; u >= w[i]; --u) {
			r[u] = max(r[u], r[u - w[i]] + v[i]);
		}
	}
	ll mx = 0;
	for (int i = 0; i <= m; ++i) mx = max(mx, r[i]);
	cout << mx << '\n';
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    sort(begin(a), end(a));
    if (n % 2 == 0) {
        long long ans = 0; {
            for (int i = 0; i < n / 2 - 1; i++) ans -= a[i] * 2;
            ans -= a[n / 2 - 1];
            ans += a[n / 2];
            for (int i = n / 2 + 1; i < n; i++) ans += a[i] * 2;
        }
        cout << ans << endl;
    } else {
        long long ans1 = 0; {
            for (int i = 0; i < n / 2 - 1; i++) ans1 -= a[i] * 2;
            ans1 -= a[n / 2 - 1];
            ans1 -= a[n / 2];
            for (int i = n / 2 + 1; i < n; i++) ans1 += a[i] * 2;
        }
        long long ans2 = 0; {
            for (int i = 0; i < n / 2; i++) ans2 -= a[i] * 2;
            ans2 += a[n / 2];
            ans2 += a[n / 2 + 1];
            for (int i = n / 2 + 2; i < n; i++) ans2 += a[i] * 2;
        }
        cout << max(ans1, ans2) << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>

using namespace std;

int main ()
{
  string card[3];

  cin >> card[0];
  cin >> card[1];
  cin >> card[2];

  auto round = 0;

  while(!card[round].empty()) {
    switch(round) {
      case 0 : round = card[0][0] - 'a'; card[0].erase(0,1); break;
      case 1 : round = card[1][0] - 'a'; card[1].erase(0,1); break;
      case 2 : round = card[2][0] - 'a'; card[2].erase(0,1); break;
    }
  }

  printf("%c\n", round + 'A');
}


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

int main(){
	using ll = long long int ;
	ll h ; cin >> h ;
	ll cnt = 0 ;
	ll two = 1 ; 
	while(1){
		cnt += two ;
		if(cnt>=h) break ;
		two *= 2 ;
	}
	cout << two*2-1 << endl ;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
 		Scanner sc = new Scanner(System.in);
 		String s = sc.next();
 		int count =0;
 		int idxA =0;
 		for(int i=0; i<s.length(); i++){
 			if(s.charAt(i)=='A'){
 				idxA = i;
 				break;
 			}
 		}
 		int idxZ = s.length()-1;
 		for(int j = s.length()-1; j>=0; j--){
 			if(s.charAt(j) =='Z'){
 				idxZ = j;
 				break;
 			}
 		}
 		System.out.println(idxZ - idxA + 1);
 	}
} 

Measured memory_bytes: 26452
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=1001000,P=1e9+7;
int n,x,a[N],s[N],t[N],f[3][N],g[N],q[3][N],L[3],R[3];
char S[N];
bool ok0(int l,int r){return (s[r]-s[l-1])%3==0;}
bool ok1(int l,int r){return t[r]>t[l];}
void chk(int&x){x-=P;x+=(x>>31)&P;}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%s",S+1);
	n=strlen(S+1);
	FOR(i,1,n) a[i]=S[i]=='a'?1:2;
	FOR(i,1,n) s[i]=a[i]+s[i-1],t[i]=(a[i]==a[i-1])+t[i-1];
	if(!t[n]) return puts("1"),0;
	ROF(i,n,0){
		FOR(j,1,2){
			x=(s[i]+j)%3;f[j][i]=n+1;
			if(L[x]==R[x]) continue;
			while(L[x]+1<R[x] && ok1(i+1,q[x][L[x]+1])) L[x]++;
			if(ok1(i+1,q[x][L[x]])) f[j][i]=q[x][L[x]];
			if(a[i+1]==j) f[j][i]=i+1;
			chk(g[i]+=g[f[j][i]]);
			if(f[j][i]<=n && ok0(f[j][i]+1,n)) chk(++g[i]);
		}
		q[s[i]%3][R[s[i]%3]++]=i;
		//cout<<i<<':'<<f[1][i]<<' '<<f[2][i]<<' '<<g[i]<<'\n';
	}
	cout<<g[0]<<'\n';
}

Measured memory_bytes: 20992
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-7
long long mod = 1e9 +7;
typedef long long ll;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;


int main()
{

    em3
    int n , h[100005] , ans[100005];
    cin >> n;
    for(int i = 0 ; i < n ; i++)
        cin >> h[i];
    ans[0] = 0, ans[1] = abs(h[1] - h[0]);
    for(int i = 2 ; i < n ; i++)
        ans[i] = min(ans[i - 1] + abs(h[i] - h[i - 1]) , ans[i - 2]+abs(h[i] - h[i - 2]));

    cout << ans[n - 1] << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 100

int main(){
  int n,i,j,u,k,v,a[MAX][MAX];

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      a[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      a[i][v-1] = 1;
    }
  }

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

  return 0;
}

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

int n,q, ans = 0;
int a[100000];


int binary_search(int k){
    int left = 0, right = n,mid;
    while(left < right){
        mid = (left+right)/2;
        if(a[mid] == k){
            return 1;
        }else if(k < a[mid]){
            right = mid;
        }else{
            left = mid +1;
        }
    }
    return 0;
}

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; ++i){
        scanf("%d", &a[i]);
    }
    scanf("%d", &q);
    for(int i=0; i<q; ++i){
        int t;
        scanf("%d",&t);
        if(binary_search(t))++ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3508
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-6
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FDR(i,a,n) for(int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mdsad
# define rch p<<1|1,mdsad+1,r
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline int Scan() {
     int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=200005;
//Code begin...

int vis[26];
char s[N];
struct Node{int len, id, c;}dp[N], ans;

int main ()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    FDR(i,len,1) {
        dp[i].len=dp[vis[0]].len+1; dp[i].id=vis[0]; dp[i].c=0;
        FOR(j,1,25) if (dp[i].len>dp[vis[j]].len+1) dp[i].len=dp[vis[j]].len+1, dp[i].id=vis[j], dp[i].c=j;
        vis[s[i]-'a']=i;
    }
    FOR(i,0,25) if (!vis[i]) {printf("%c\n",i+'a'); return 0;}
    ans.len=dp[vis[0]].len; ans.id=vis[0]; ans.c=0;
    FOR(i,1,25) if (ans.len>dp[vis[i]].len) ans.len=dp[vis[i]].len, ans.id=vis[i], ans.c=i;
    while (ans.id) putchar(ans.c+'a'), ans.c=dp[ans.id].c, ans.id=dp[ans.id].id;
    putchar(ans.c+'a');
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2816
N = int(input())
T, A = map(int, input().split(" "))
H = list(map(int, input().split(" ")))

cand = -1
cand_at = 10**10

for i in range(N) :
    temp_at = T - H[i] * 0.006
    if abs(A - temp_at) <= cand_at :
        cand = i + 1
        cand_at = abs(A - temp_at)
        
print(cand)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s0;
  cin >> s0;
  int s1, s2, s3;
  
  s1 = s0 / 100;
  s2 = (s0 % 100) / 10;
  s3 = s0 % 10;
  
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
/*
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?lang=jp&id=2331
?????????: A Way to Invite Friends
?????°:
19:34:14 ??????????????????
19:38:21 ??\????????????????????????????§£?????????
19:39:29 ?????§???????±???????????????????????????¢?´¢??§??????????????????
19:46:53 ????????¢?´¢????????????
19:47:16 WA
19:48:34 ???????????????????????´?????????????????????
19:49:41 WA
19:50:47 ??¨?????????????????£????????????Case #10????????????
19:52:03 ?????°????°?????????´????????????????????¨???????????????????????????????????????????????????
19:54:34 possible???????????§???????????¨???????¨?????????????????????????????????????
19:56:34 ????????¨??¢?´¢??§?????????????????§??????
19:59:24 ??¨??¢?´¢
*/
#include <iostream>

using namespace std;

int N;
int a[114514];
int b[114514];

// is it possible to hang out WITH n people?
bool isPossible(int n)
{
	if(n > 100000) return false;
	if(n <= 0) return true;
	int count=0;
	for(int i=0; i<N; i++){
		if((a[i] <= n+1) && (n+1 <= b[i])){
			count++;
		}
	}
	return(count >= n); // true if n people exists
}

int main()
{
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> a[i] >> b[i];
	}

	int i = 100000;
	while(i>0){
		if(isPossible(i)){
			cout << i << endl;
			return 0;
		}
		i--;
	}
	cout << 0 << endl;
	
}

Measured memory_bytes: 3864
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int n, a, b; cin >> n >> a >> b;
    string s; cin >> s;
    
    int sum = 0;
    int b_sum = 0;
    rep(i,n) {
        if (s[i] == 'a' && sum < a + b) {
            cout << "Yes" << endl;
            ++sum;
        }
        else if (s[i] == 'b' && sum < a + b && b_sum + 1 <= b) {
            cout << "Yes" << endl;
            ++b_sum;
            ++sum;
        }
        else {
            cout << "No" << endl;
        }
    }

    
    return 0;
}






Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> vec(9);
    for (int i = 0; i < 9; ++i) {
        cin >> vec[i];
    }
    vector<int> check(3);
    rep(i, 3) {
        check[i] = vec[i] + vec[3 + (i+4) % 3] + vec[6 + (i+2)%3];
    }
    if (check[0] == check[1] && check[0] == check[2]) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
}


Measured memory_bytes: 256
h, w = map(int, input().split())
ans = 10**9
if h % 3 == 0 or w % 3 == 0:
    ans = 0
else:
    for width in range(1, w):
        left = width * h
        if h % 2 == 0:
            right_up   = (w-width)*(h//2)
            right_down = right_up
        else:
            right_up   = (w-width)*(h//2+1)
            right_down = (w-width)*(h//2)
        ans = min(ans, max(left, right_up, right_down) - min(left, right_up, right_down))
    for height in range(1, h):
        up = w * height
        if w % 2 == 0:
            down_left  =  (w//2)*(h-height)
            down_right =  down_left
        else:
            down_left  =  (w//2)*(h-height)
            down_right =  (w//2+1)*(h-height)
        ans = min(ans, max(up, down_left, down_right) - min(up, down_left, down_right))
    ans = min(ans, min(h, w))
print(ans)


Measured memory_bytes: 9252
S = input()

flag = True

for i in range(len(S)):
    # 奇数文字
    if i%2==0:
        if S[i]=="R" or S[i]=="U" or S[i]=="D":
            pass
        else:
            flag = False
            break
    else:
        if S[i]=="L" or S[i]=="U" or S[i]=="D":
            pass
        else:
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll f(ll x){
    ll cnt=0;
    while(x){
        ll cn=0;
        rep(i,60){
            if((1LL<<i)&x){
                cn++;
            }
        }
        x%=cn;
        cnt++;
    }
    return cnt;
}
ll rui(ll a,ll b,ll m){
    ll res=1;
    ll x=a;
    while(b){
        if(b&1)res=res*x%m;
        x=x*x%m;
        b/=2;
    }
    return res;
}
signed main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll cnt=0;
    rep(i,n){
        if(s[i]=='1')cnt++;
    }
    vector<ll>ans(n);
    vector<ll>a(2);
    ll b=0;
    reverse(all(s));
    rep(i,n){
        if(s[i]=='1')b=(b+rui(2,i,cnt+1))%(cnt+1);
    }
    a[1]=b;
    b=0;
    if(cnt==1){

    }else{
        rep(i,n){
            if(s[i]=='1')b=(b+rui(2,i,cnt-1))%(cnt-1);
        }
        a[0]=b;
    }
    rep(i,n){
        if(s[i]=='1'){
            if(cnt==1){
                ans[i]=0;
            }else{
                ans[i]++;
                ll b=a[0];
                //cout<<b<<' ';
                b=(b-rui(2,i,cnt-1))%(cnt-1);
                //cout<<b<<endl;
                if(b<0)b+=cnt-1;
                ans[i]+=f(b);
            }
        }else{
            ans[i]++;
            ll b=a[1];
            //cout<<b<<' ';
            b=(b+rui(2,i,cnt+1))%(cnt+1);
            //cout<<b<<endl;
            ans[i]+=f(b);

        }
    }
    for(int i=n-1;i>=0;i--){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 5240
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll sum = 0;
    rep(i, n) sum += a[i];
    map<int, int> m;
    rep(i, n) {
        m[a[i]]++;
    }
    int q;
    cin >> q;
    int b, c;
    rep(i, q) {
        cin >> b >> c;
        sum -= m[b] * b;
      	//cout<<"#"<<sum<<endl;
      	sum-=m[c]*c;
        m[c] += m[b];
        m[b] = 0;
        sum += c * m[c];
        cout << sum << endl;
    }
}

Measured memory_bytes: 10064
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>
#include <iomanip>
#include <stack>

using namespace std;
using namespace boost::multiprecision;

string S;

void solve() {
	cin >> S;
	int N = S.size();   //元文字列長さ
	S += string("DE");
	long long ans = 0;
	int counter = 0;
	int pos = 0;
	while (pos <= N) {
		if (S[pos] == 'A') {
			counter++;
			pos++;
		}
		else if (S[pos] == 'B' && S[pos + 1] == 'C') {
			ans += (long long)counter;
			pos += 2;
		}
		else {
			counter = 0;
			pos++;
		}
	}
	cout << ans << endl;
	return;
}

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


int main() {
	
	int x;
	cin >> x;
	set <int> beki;
	for(int i=1; i<=x; i++){
		for(int j=2; j<=10; j++){
			if(pow(i,j)>x) break;
			beki.insert(pow(i,j));
		}
	}
	for(int i=x; i>=1; i--){
		if(beki.count(i)){
			cout << i << endl;
			break;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yn(int o){
    if (o == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

int main() {
    int n, k; cin >> n >> k;
    vector<int> ar(n);
    rep(i,n) cin >> ar[i];
    rep(i,n-k){
        if (ar[i] < ar[i+k]) yn(1);
        else yn(0);
    }
}

Measured memory_bytes: 4048
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
gi = lambda : list(map(int,input().split()))
d, t, s = gi()
dur = d // s
if d % s:
	dur += 1
if dur > t:
	print("No")
else:
	print("Yes")

Measured memory_bytes: 9164
N = int(input())
A = list(int(x) for x in input().split())

ans = 0
for i in range(N):
    if i == N - 1:
        break
    if A[i] > A[i+1]:
        sa = A[i] - A[i+1]
        A[i+1] += sa
        ans = ans + sa

print(ans)


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

int main() {
  int boo = 1;
  string str; cin >> str;
  
  for (int i = 0; i < str.size(); i++) {
    
    if (i % 2 == 0 && str.at(i) == 'L') {
      boo = 0;
    }
    
    if (i % 2 == 1 && str.at(i) == 'R') {
      boo = 0;
    }
  }
  
  if (boo == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n;
    string s, dot;
    dot = "...";
    cin >> n >> s;
    if(s.length() > n){
        s.erase(n,s.length());
        cout << s + dot << endl;
    }
    else cout << s << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = (x - a) % b;
        System.out.println(ans);
    }
}

Measured memory_bytes: 35652
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    string s,t;
    cin>>s;
    t="ABC";
    int ans=0;
    rep(i,0,n-2){
        string u=s.substr(i,3);
        if(u==t)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize(3)
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;
int parent[200005],value[200005];
int maxn=1;

int find(int a){
    if(parent[a]==a){
        return a;
    }
    else{
        return find(parent[a]);
    }
}

void freedom(int n){
    for(int i=1;i<=n;i++){
        parent[i]=i;
        value[i]=1;
    }
    return ;
}

void unionxy(int a,int b){
    if(find(a)==find(b)){
        return ;
    }
    else{
        value[find(a)]+=value[find(b)];
        maxn=max(maxn,value[find(a)]);
        parent[find(b)]=find(a);
        parent[b]=parent[find(b)];
        parent[a]=parent[find(a)];
    }
}

int main()
{
    int n,m;cin>>n>>m;
    freedom(n);
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        unionxy(a,b);
    }
    cout<<maxn<<endl;
}


Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
long long n,m,l,r,x,dp[222222],ddp[222222],tree[888888],lazy[888888];
vector<pair<long long,long long> > v[222222];
void push(long long node,long long x)
{
	tree[node]+=x;
	lazy[node]+=x;
}
void pushdown(long long node)
{
	if (lazy[node])
	{
		push(node<<1,lazy[node]);
		push((node<<1)|1,lazy[node]);
		lazy[node]=0;
	}
}
void pushup(long long node)
{
	tree[node]=max(tree[(node<<1)|1],tree[node<<1]);
}
void update(long long beg,long long en,long long l,long long r,long long node,long long x)
{
	if (l>en || r<beg) return;
	if (l>=beg && r<=en)
	{
		push(node,x);
		return;
	}
	pushdown(node);
	long long mid=(l+r)>>1;
	update(beg,en,l,mid,node<<1,x);
	update(beg,en,mid+1,r,(node<<1)|1,x);
	pushup(node);
}
long long query(long long beg,long long en,long long l,long long r,long long node)
{
	if (l>en || r<beg) return -1e9;
	if (l>=beg && r<=en) return tree[node];
	pushdown(node);
	long long mid=(l+r)>>1;
	return max(query(beg,en,l,mid,node<<1),query(beg,en,mid+1,r,(node<<1)|1));
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for (long long i=1;i<=m;i++)
	{
		scanf("%lld%lld%lld",&l,&r,&x);
		v[r].push_back(make_pair(l,x));
	}
	for (long long i=1;i<=n;i++)
	{
		dp[i]=ddp[i-1];
		for (long long j=0;j<v[i].size();j++)
		{
			long long l=v[i][j].first,val=v[i][j].second;
			dp[i]+=val;
			update(l,i-1,1,n,1,val);
		}
		update(i,i,1,n,1,dp[i]);
		ddp[i]=max(0ll,query(1,i,1,n,1));
	}
	printf("%lld\n",ddp[n]);
	return 0;
} 

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

int main() {
    string S;
    cin >> S;
    ll N = S.length();
    vector<ll> cnt(26, 0);
    for (char& c : S) {
        cnt[c - 'a']++;
    }

    ll ans = N * (N - 1) / 2;
    for (ll& c : cnt) {
        ans -= c * (c - 1) / 2;
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 640
T = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

b = ( T[0] * A[0] + T[1] * A[1] ) - ( T[0] * B[0] + T[1] * B[1] )
if b == 0
  puts "infinity"
else
  a = T[0] * ( A[0] - B[0] )
  if a * b > 0
    puts 0
  else
    c = ( a / b ) * -2
    if a % b != 0
      c -= 1
    end
    puts c
  end
end

Measured memory_bytes: 1788