akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

const int MAX = 50;
int n, m;
int a[MAX], b[MAX];
bool G[MAX][MAX];
bool visited[MAX];

void dfs(int v) {
    visited[v] = true;
    for(int v2 = 0; v2 < n; v2++) {
        if(!G[v][v2]) {
            continue;
        }
        if(visited[v2]) {
            continue;
        }

        dfs(v2);
    }
}

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

    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;  b[i]--;
        G[a[i]][b[i]] = G[b[i]][a[i]] = true;
    } 

    int ans = 0;

    rep(i, m) {
        G[a[i]][b[i]] = G[b[i]][a[i]] = false;
        rep(j, n) {
            visited[j] = false;
        }

        dfs(0);

        bool bridge = false;
        rep(j, n) {
            if(!visited[j]) {
                bridge = true;
            }
        }

        if(bridge) {
            ans += 1;
        }

        G[a[i]][b[i]] = G[b[i]][a[i]] = true;
    }
    
    cout << ans;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main()
{
  int N, ans=0;
  cin >> N;
  string S[N];
  bool check;
  for (int i = 0; i < N; ++i) {
    cin >> S[i];
  }
  // for (int i = 0; i < N; ++i) {
  //   for (int j = 0; j < N; ++j) {
  //     cout << S[i][j] << "\n";
  //   }

  // }

  for (int k = 0; k < N; ++k) {
    check = 1;
    for (int i = 0; i < N && check == 1 ; ++i) {
      for (int j = i+1; j < N && check == 1; ++j) {
        if (!( S[i][(j+k)%N] == S[j][(i+k)%N])) {
          check = 0;
          // cout << i << j << "\n";
        }
      }
    }
    if (check == 1) {
      ans += N;
    } 
  }
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 384
s = input()
f1 = False
f2 = False
f3 = False
if s[0] == 'A':
    f1 = True
f2_index = None
for i in range(len(s)):
    if s[i] == 'C' and i >= 2 and i <= len(s) - 2:
        f2 = True
        f2_index = i
        break
for j in range(len(s)):
    if j != 0 and j != f2_index:
        if s[j].islower():
            f3 = True
        else:
            f3 = False
            break
if f1 and f2 and f3:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define repl(i,x,n) for(long long i=(long long)(x);i<(long long)(n);i++)
#define rep(i,x,n) for(long i=long(x);i<long(n);i++)
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long a,b,k,c=0,d=1;
    cin>>k>>a>>b;
    if(b<=a+1){
        cout<<k+1;
        return 0;
    }
    if(k<a+1)
    {
        cout<<k+1;
        return 0;
    }
    k-=(a+1);
    c=b;
    while(k>=2)
    {
        c-=a;
        c+=b;
        k-=2;
    }
    cout<<c+k;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

struct path{
	int x;
	int y;
	int z;
	
};

int main() {
	
	int N,M;
	cin>>N>>M;
	int route[1000][1000];
	fx(N){
		fy(N){
			if(x==y){
				route[x+1][y+1]=0;
			}else{
				route[x+1][y+1]=INT_MAX/2;
			}
		}
	}
	vector<path> paths;
	fx(M){
		int a,b,c;
		cin>>a>>b>>c;
		route[a][b]=c;
		route[b][a]=c;
		path p;
		p.x=a;p.y=b;p.z=c;
		pb(paths,p)
	}
	
	fy(N){
	fx(N){
	fz(N){
		route[x+1][z+1]=min(route[x+1][z+1],route[x+1][y+1]+route[y+1][z+1]);
	}
	}
	}
	int ans=0;
	fw(M){
		if(route[paths.at(w).x][paths.at(w).y]<paths.at(w).z){
			ans++;
		}
	}
	ce(ans)
	
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define WHITE 0
#define BLACK 1
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
string s;
int k;
int INFi=1000000000;
ll INFl=1000000000000000;

struct UnionFind{
    vector<int> par;//初期化
    vector<int> rank;//高さ
    UnionFind(int n=0):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);//経路圧縮
    }
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        if(rank[rx]<rank[ry]) rank[rx]=ry;
        else rank[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
struct edge{int from,to,cost;};
vector<edge> es(100); //辺の集合
vector<int> d(100,INFi);//最短距離
int V,E;//頂点数、辺数

int main(){
    ll a,b,x;cin>>a>>b>>x;
    ll ans;
    if(a==0) ans=b/x+1;
    else ans=b/x-(a-1)/x;
    cout<<ans<<endl;
    return 0;
}




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

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    vector<bool> found(26, false);
    for(char c : s){
        found.at(c - 'a') = true;
    }
    for(char i = 0; i < found.size(); ++i){
        if(!found.at(i)){
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
K = int(input()) - 1
nums = [str(i) for i in range(1,10)]
while True:
    # print(nums)
    if K < len(nums):
        print(nums[K])
        break
    else:
        K -= len(nums)

    que = []
    for n in nums:
        if n[-1] > "0":
            que.append(n + str(int(n[-1]) - 1))
        if n[-1] < "9":
            que.append(n + str(int(n[-1]) + 1))
        que.append(n + n[-1])
    que.sort()
    nums = que

Measured memory_bytes: 15636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

using namespace __gnu_pbds;
using namespace std;
const int mod = 1e9 + 7;
// const int mod=998244353;
//const int mod=1e9+9;
//const int INF=4e18+10;
const int INF = 4e18 + 10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) \
int n;      \
cin >> n;
#define readv(x, n)   \
vector<int> x(n); \
for (auto &i : x) \
    cin >> i;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template <typename T1, typename T2>
void set_min(T1 &a, T2 b)
{
    a = min(a, (T1)b);
}

int multiply(int a, int b, int in_mod) { return (a * b) % in_mod; }
int mult_identity(int a) { return 1; }


auto power(auto a, int b, int in_mod)
{
    auto prod = mult_identity(a);
    auto mult = a % in_mod;
    while (b != 0)
    {
        if (b % 2)
        {
            prod = multiply(prod, mult, in_mod);
        }
        mult = multiply(mult, mult, in_mod);
        b /= 2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod - 2, in_mod);
}


void solve()
{
    int n, k;
    cin>>n>>k;
    readv(a,n);
    int pos;
    for(int i= 0;i<n;i++)
        if(a[i] == 1)
            pos = i;

    pos++;
    int left = pos -1 ;
    int right = n - pos;

    int mx = max(left, right);
    int mn = min(left, right);
    int ans = mx / (k-1) + (mx%(k-1) + mn  + k-2)/(k-1);
    cout<<ans<<endl;
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

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

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<":\n";
        //cout<<"Trip #"<<test<<": ";
        // cout<<endl;
        solve();
        // solveB();

        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  string s;
  cin >> s;
  if (s.at(0) != 'A') cout << "WA" << endl;
  else {
    int cnt = 0;
    for (int i = 2; i < s.size() - 1; i++) {
      if (s.at(i) == 'C') cnt++;
    }
    if (cnt != 1) cout << "WA" << endl;
    else {
      for (ll i = 0; i < 26; i++) {
        if (s.at(1) == alp.at(i)) break;
        if (i == 25) {
          cout << "WA" << endl;
          return 0;
        }
      }
      for (ll i = 0; i < 26; i++) {
        if (s.at(s.size() - 1) == alp.at(i)) break;
        if (i == 25) {
          cout << "WA" << endl;
          return 0;
        }
      }
      cout << "AC" << endl;
    }
  }
}

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

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

const int MAXN = 20000, MAXM = 16, MAXS = 255;
int dp[MAXS + 10][MAXN + 10];
int c[MAXM + 1], x[MAXN + 10];
int main()
{

    int n, m;
    while(cin >> n >> m && n)
    {
        memset(dp, -1, sizeof(dp));
        REP(m) cin >> c[i];
        REP(n) cin >> x[i];

        dp[128][0] = 0;

        for(int i =0; i < n; i++)
        {
            for(int s = 0; s <= 255; s++)if(dp[s][i] != -1)
            {
                for(int j = 0; j < m; j++)
                {
                    int nexty = s + c[j];
                    if(nexty < 0) nexty = 0;
                    if(nexty > MAXS) nexty = MAXS;
                    
                    if(dp[nexty][i + 1] ==-1)
                        dp[nexty][i + 1] = dp[s][i] + (nexty - x[i]) * (nexty - x[i]);
                    else
                        dp[nexty][i + 1] = min(dp[nexty][i + 1],
                                dp[s][i] + (nexty - x[i]) * (nexty - x[i]) );
                }
            }
        }
        //rep(i, 255) cout << dp[i][n] << endl;

        int ans = (1 << 30);
        REP(MAXS + 1)if(dp[i][n] != -1) ans = min(ans, dp[i][n]);
        cout << ans << endl;

    }
    return 0;
}

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

int main() {
  long long int a,b,c,r;
  cin>>a>>b;
  c=__gcd(a,b);
   r=(a*b)/c;
   cout<<r<<endl;

   return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private class DisjointSet {

		private int[] parent;
		private int[] rank;
		private int[] weight;
		
		public DisjointSet(int size) {
			parent = new int[size];
			rank = new int[size];
			weight = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			parent[x] = x;
			rank[x] = 0;
			weight[x] = 0;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}

		private int findSet(int x) {
			if (x != parent[x]) {
				int tmp = findSet(parent[x]);
				weight[x] += weight[parent[x]];
				parent[x] = tmp;
			}
			return parent[x];
		}
		
		public void relate(int x, int y, int z) {
			link(findSet(x), findSet(y), z - weight[x] + weight[y]);
		}

		private void link(int x, int y, int cost) {
			if (rank[x] > rank[y]) {
				parent[y] = x;
				weight[y] -= cost;
			} else {
				parent[x] = y;
				weight[x] += cost;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}

		public int sum(int x) {
			int sum = 0;
			int now = x;
			while (now != parent[now]) {
				sum += weight[now];
				now = parent[now];
			}
			return sum;
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c, x, y, z;
			c = Integer.parseInt(st.nextToken());
			x = Integer.parseInt(st.nextToken());
			y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				z = Integer.parseInt(st.nextToken());
				ds.relate(x, y, z);
			} else if (c == 1) {
				if (!ds.same(x, y)) {
					System.out.println("?");
				} else {
					System.out.println(ds.sum(x) - ds.sum(y));
				}
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 78908
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,m;
  cin>>a>>b>>m;
  vint re(a);
  vint de(b);
  int min=INF;
  rep(i,a){
    cin>>re[i];             
  }
  rep(i,b){
    cin>>de[i];
  }
  int x,y,c;
  rep(i,m){
    cin>>x>>y>>c;
    x--; y--;
    if(min>re[x]+de[y]-c){
      min=re[x]+de[y]-c;
    }
  }
  sort(all(re));
  sort(all(de));
  if(min>re[0]+de[0]){
    min=re[0]+de[0];
  }
  cout<<min;
  return(0);
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a*b >= -1000000 && a*b <= 1000000){
        if(a < b)
            printf("a < b\n");
        else if(a > b)
            printf("a > b\n");
        else
            printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b; cin >> a >> b;
    cout << 2 * b - a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int wa[100010];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int ac=0,pena=0;
	for(int i=0;i<m;i++){
		int p;
		char s[9];
		scanf("%d%s",&p,s);
		if(wa[p]!=-1){
			if(s[0]=='A'){
				ac++;
				pena+=wa[p];
				wa[p]=-1;
			}else{
				wa[p]++;
			}
		}
	}
	printf("%d %d",ac,pena);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
    int n; cin >> n;
    string s;
    string res;
    cin >> s;
    for (auto c : s) {
        if ((c + n) > 'Z') {
            res += 'A' + (c + n - 'Z' - 1);
        }
        else {

        res += (c + n);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

signed main()
{
	int N, K;
	cin >> N >> K;

	int ans = 0;
	if (K % 2 == 0)
	{
		int a = K / 2;
		int b = (N - a);
		if (b >= 0)
		{
			int c = (int)(b / K) + 1;
			ans += pow(c, 3);
		}
	}

	{
		int a = K;
		int b = (N - a);
		if (b >= 0)
		{
			int c = (int)(b / K) + 1;
			ans += pow(c, 3);
		}
	}
	
	cout << ans << endl;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	int ans = ((n+999)/1000)*1000-n;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
import bisect

def solve(n, a, b, c):
    a = sorted(a)
    b = sorted(b)
    c = sorted(c)
    res = 0
    for x in b:
        i = bisect.bisect_left(a, x)
        k = bisect.bisect_right(c, x)
        res += i * (n-k)
    return res

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
print(solve(n, a, b, c))

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

a,b = [0],[0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans = 0
j = M
for i in range(N + 1):
  if(a[i] > K):
    break
  while(a[i] + b[j] > K):
    j -= 1
  ans = max(ans, i+j)
print(ans)

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    string t;
    int n = s.size();
    for(int i=0;i<n;i++){
        if(s[i] != 'x'){
            t.push_back(s[i]);
        }
    }
    int m = t.size();
    for(int i=0;i<(m+1)/2;i++){
        if(t[i] != t[m-i-1]){
            cout << -1 << endl;
            return 0;
        }
    }

    int l = 0;
    int r = n-1;
    int ans = 0;
    while(l < r){
        if(s[l] == s[r]){
            l++;r--;
        }else if(s[l] == 'x'){
            l++;
            ans++;
        }else if(s[r] == 'x'){
            r--;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;

  string t = "";
  rep(i, s.size()) if (s[i] != 'x') t += s[i];
  bool tp = true;
  rep(i, t.size()) if (t[i] != t[t.size()-1-i]) tp = false;
  if (!tp) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> num_x(t.size()+1, 0);
  int ni = 0;
  rep(i, s.size()) {
    if (s[i] == 'x') ++num_x[ni];
    else ++ni;
  }

  int ans = 0;
  for (int i = 0; i < (int)t.size()-i; ++i) {
    ans += abs(num_x[i] - num_x[t.size()-i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3948
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
#define wis(x) "[" << #x << " : " << x << "] " << 
typedef long long ll;

const int MAXN = 2e5 + 10, MOD = 1e9 + 7, INF = 1e9 + 5;

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << '\n';
}


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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
template <typename T> T pow(T a, long long b) {
	assert(b >= 0);
	T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}
using num = modnum<998244353>;

const int MAXN = 1.1e5;
int N;
int D[MAXN];

num go() {
	map<int, int> cnt;
	for (int i = 0; i < N; i++) {
		cnt[D[i]]++;
	}
	if (D[0] != 0) return 0;
	if (cnt[0] != 1) return 0;
	num ans = 1;
	for (int i = 1; i <= N; i++) {
		ans *= pow(num(cnt[i-1]), cnt[i]);
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> D[i];
	}
	cout << go() << '\n';

	return 0;
}


Measured memory_bytes: 5376
c = [list(map(int,input().split())) for _ in range(3)]
if c[0][0]+c[1][1]+c[2][2]\
==c[0][2]+c[1][1]+c[2][0]\
==c[0][0]+c[1][2]+c[2][1]\
==c[0][1]+c[1][0]+c[2][2]:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 9120
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        for(int i = 0; i < s.length(); i++){
            char a = s.charAt(i);
            for(int j = 0; j < s.length(); j++){
                char b;
                if(i == j){
                    continue;
                }
                b = s.charAt(j);
                if(a == b){
                    count++;
                    break;
                }
            }
        }
        if(count == 0){
            System.out.println("yes");
        }else{
            System.out.println("no");
        }
	}
}

Measured memory_bytes: 22868
N, A, B = map(int, input().split())
S = input()
vec_yn = ["No"] * len(S)
passed = 0
passed_oversea = 0
for i in range(len(S)):
    if S[i]=='a':
        if passed < A+B:
            vec_yn[i] = "Yes"
            passed+=1
        else:
            pass
    elif S[i]=='b':
        if passed < A+B and passed_oversea < B:
            vec_yn[i] = "Yes"
            passed+=1
            passed_oversea+=1
        else:
            pass
    else:
        pass

for i in range(len(S)):
    print(vec_yn[i])


Measured memory_bytes: 75852
#include<stdio.h>
#include<limits.h>
#define N 500000
void Merge(int[],int,int,int);
void MergeSort(int[],int,int);
int c;
int main(){
  int x,i,A[N];
  scanf("%d",&x);
  for(i = 0 ; i < x ; i++)
    scanf("%d",&A[i]);
  MergeSort(A,0,x);
  for(i = 0 ; i < x-1 ; i++)
    printf("%d ",A[i]);
  printf("%d\n",A[i]);
  printf("%d\n",c);
  return 0;
}

void Merge(int A[],int left,int mid,int right){
  int p1,p2,i,j,k;
  p1 = mid - left;
  p2 = right - mid;
  int L[p1 + 1],R[p2 + 1];
  for(i = 0 ; i < p1 ; i++)
    L[i] = A[left + i];
  for(i = 0 ; i < p2 ; i++)
    R[i] = A[mid+i];
    L[p1] = INT_MAX;   
    R[p2] = INT_MAX;   
    i = 0;
    j = 0;
    for(k = left ; k < right ; k++){
      c++;
      if(L[i] <= R[j]){
	A[k] =L[i];
	i = i+1;
      }
      else{
	A[k] = R[j];
	j = j+1;
      }
    }
}       


void MergeSort(int A[],int left,int right){
  int mid;  
  if(left+1<right) {
    mid=(left+right)/2;
    MergeSort(A,left,mid);    
    MergeSort(A,mid,right);    
    Merge(A,left,mid,right);    
  }
}

Measured memory_bytes: 4504
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

string S;

int mem[300000][2];
int from[300000][2];

int main(void)
{
    cin >> S;
    
    memset(mem, -1, sizeof(mem));

    mem[0][0] = 0;
    mem[0][1] = 0;
    int size = S.size();
    REP(i, size) {
        const char c = S[i];
        REP(k, 2) if (mem[i][k] != -1) {
            int cur = mem[i][k];
            if (i == 0) {
                if (S[0] == '?' || S[0] == 'P') {
                    mem[1][0] = 0;
                    from[1][0] = k;
                }
                if (S[0] == '?' || S[0] == 'D') {
                    mem[1][1] = 1;
                    from[1][1] = k;
                }
            }
            else {
                if (S[i] == '?' || S[i] == 'P') {
                    if (cur > mem[i+1][0]) {
                        mem[i+1][0] = cur;
                        from[i+1][0] = k;
                    }
                }
                if (S[i] == '?' || S[i] == 'D') {
                    int next = (k == 0 ? 2 : 1) + cur;
                    if (next > mem[i+1][1]) {
                        mem[i+1][1] = next;
                        from[i+1][1] = k;
                    }
                }
            }
        }
    }

    string ret(size, ' ');
    int n = size;
    int k = (mem[size][0] > mem[size][1] ? 0 : 1);
    while(n > 0) {
        ret[n-1] = (k == 0 ? 'P' : 'D');
        k = from[n][k];
        n--;
    }
    
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 7644
#include<stdio.h>
#include<math.h>
using namespace std;

struct Point 
{
    double x, y;
};

void koch(int n, Point a, Point b)
{
    if ( n == 0 ) return;
    Point s, u, t;
    double th = M_PI * 60.0 / 180.0;
    s.x = (2.0*a.x + 1.0*b.x)/3.0;

    s.y = (2.0*a.y + 1.0*b.y)/3.0;

    t.x = (1.0*a.x + 2.0*b.x)/3.0;

    t.y = (1.0*a.y + 2.0*b.y)/3.0;

    u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;

    u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

    koch(n-1,a,s);

    printf("%.8f %.8f\n", s.x,s.y);

    koch(n-1,s,u);

    printf("%.8f %.8f\n", u.x,u.y);

    koch(n-1,u,t);

    printf("%.8f %.8f\n", t.x,t.y);

    koch(n-1,t,b);

}

int main() 
{
    Point a, b;
    int n;
    scanf("%d", &n);
    
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    printf("%.8f %.8f\n",a.x,a.y);

    koch(n,a,b);

    printf("%.8f %.8f\n",b.x,b.y);

    return 0;
    
}

Measured memory_bytes: 1068
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin >> a;
    int b[a];
    for(int i=0; i<a; i++){
        cin >>b[i];
        
    }
    for(int i=0; i<a-1; i++){
        cout << b[a-i-1] << " ";
        
    }
    cout << b[0] << endl;
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    string A(b, '0' + a);
    string B(a, '0' + b);
    cout << min(A, B) << endl;
    return 0;
}

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

int main() {
    int k,n[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k ;
    cout << n[k-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

std::vector<int> GetInput() {
    int n = 0;
    std::vector<int> values;
    std::cin >> n;
    values.resize(n, 0.0);

    for (auto it = values.begin(); it < values.end(); it++) {
        std::cin >> *it;
    }
    return values;
}

void Display(std::vector<int> value) {
    int n = value.size();
    for (int i = 0; i < n; i++) {
        std::cout << value[i];
        if(i == n-1) {
            std::cout << std::endl;
        }
        else {
            std::cout << " ";
        }
    }
}

void InsertionSort(std::vector<int>& values) {
    for (int i = 1; i < values.size(); i++) {
        Display(values);
        int j = i - 1;
        int target_value = values[i];
        while(j >= 0 && target_value < values[j]) {
            values[j+1] = values[j];
            j--;
        }
        values[j+1] = target_value;
    }
    Display(values);
}

void BubbleSort(std::vector<int>& values) {
    int flag = 1;
    int change_count = 0;
    while (flag) {
        flag = 0;
        for (int i = 0; i < values.size(); i++) {
            if (values[i] < values[i-1]) {
                std::swap(values[i], values[i-1]);
                flag = 1;
                change_count++;
            }
        }
    }
    Display(values);
    std::cout << change_count << std::endl;
}

int main(int argc, char const* argv[])
{
    std::vector<int> values = GetInput();
    BubbleSort(values);

    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll n;
    cin>>n;
    ll a[n],b[n];
    ll i;
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    ll mini,maxi;
    if(n%2==1)
    {
        mini = a[(n+1)/2-1];
        maxi = b[(n+1)/2-1];
    }
    else{
        mini = a[n/2-1]+a[n/2];
        maxi = b[n/2-1]+b[n/2];
    } 
    cout<<maxi-mini+1<<"\n";
    

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e7 + 5;

int cnt[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) 
        for (int j = i; j <= n; j += i) 
            ++cnt[j];

    ll ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += 1ll * i * cnt[i];
    cout << ans << endl;
}


Measured memory_bytes: 42676
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n, l, t;
    cin >> n >> l >> t;

    vector<int> x(n), w(n);
    rep(i, n) cin >> x[i] >> w[i];

    int cnt = 0;
    for(int i = 1; i < n; i++){
        if(w[0] == w[i]){
            continue;
        }
        int diff;
        if(w[0] == 1){
            diff = (x[i] - x[0]);
        }else{
            diff = (x[0] + l - x[i]);
        }

        if(diff > t * 2){
            continue;
        }
        cnt += 1 + (t * 2 - diff) / l;
    }
    cnt %= n;

    rep(i, n){
        if(w[i] == 1){
            x[i] += t % l;
        }else{
            x[i] += l;
            x[i] -= t % l;
        }
        x[i] %= l;
    }

    if(n == 1){
        cout << x[0] << endl;
        return 0;
    }

    int id;
    if(w[0] == 1){
        id = cnt;
    }else{
        id = (n - cnt) % n;
    }
    int base = x[0];

    sort(ALL(x));
    int start = 0;
    rep(i, n){
        if(x[i] == base){
            start = i;
            if(w[0] == 1 && x[(i+1)%n] == base){
                start++;
            }
            break;
        }
    }

    rep(i, n){
        cout << x[(n+start-id)%n] << endl;
        (start += 1) %= n;
    }

    return 0;
}


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

int main() {
	
	double r;
	cin >> r;
	double a,b;
	a = M_PI*r*r;
	b = M_PI*r*2;
	printf ("%.6f", a );
	printf (" ");
	printf ("%.6f\n", b);
	return 0;
}


Measured memory_bytes: 3288
#include<cstdio>
using ll = long long;
ll const p=1e9+7;
ll dp[100001];
int a[100000];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)scanf("%d",&a[i]);
    int ai=0;
    dp[0]=1;
    if(a[ai]==1){
        dp[1]=0;
        ai++;
    }else{
        dp[1]=1;
    }
    for(int i=2;i<=n;i++){
        if(a[ai]==i){
            dp[i]=0;
            ai++;
        }else{
            dp[i]=(dp[i-1]+dp[i-2])%p;
        }
    }
    printf("%lld\n",dp[n]);
    return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  string s;cin>>s;
  ll x=0;
  ll m=s.size();
  rep(i,0,m-1){
    if(s[i]!=s[i+1])x++;
  }
  cout<<min(n-1,n-1-(x-2*k))<<endl;
  return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val inputs = readLine()!!.split(" ").map { it.toInt() }.toMutableList()

    if(inputs.sum() == 0 ){
        println(0)
        return
    }
    
    var cnt = 0
    while (true) {
        var inFlag = false
        for (i in 0 until n) {
            if (inputs[i] > 0 && !inFlag) {
                inFlag = true
                inputs[i] -= 1
            } else if (inputs[i] > 0 && inFlag) {
                inputs[i] -= 1
            } else if (inputs[i] == 0 && inFlag) {
                break
            }
        }
        cnt += 1
        
        if (inputs.sum() == 0) {
            break
        }
    }

    println(cnt)
}

Measured memory_bytes: 36100
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 2000
#define MOD 1000000007
int n,k,ans1,ans2;
int a[MAXN+1];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		if(a[i]>a[j])ans1++;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		if(a[i]>a[j])ans2++;
	int Comb=(1LL*k*(k-1)/2)%MOD;
	printf("%d",((1LL*ans1*k)%MOD+(1LL*Comb*ans2)%MOD)%MOD);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    vector<ll> a(26, 0);
    for (ll i = 0; i < s.size(); i++)
    {
        a[s[i] - 'a']++;
    }

    for (auto e : a)
    {
        if (e > 1)
        {
            cout << "no" << endl;
            exit(0);
        }
    }

    cout << "yes" << endl;
}

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

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

    uint64_t a[87] = { 2, 1 };
    for (int i = 2; i <= n; i++) {
        a[i] = a[i - 1] + a[i - 2];
    }
    cout << a[n] << endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        N: usize,
        M: usize,
        ab: [(usize1, usize1); M],
    }
    let mut edges = Vec::new();
    for i in 0..N {
        edges.push(vec![]);
    }

    for i in 0..M {
        let a = ab[i].0;
        let b = ab[i].1;
        edges[a].push(b);
        edges[b].push(a);
    }

    use std::collections::HashSet;
    let mut visited = HashSet::new();
    visited.insert(0);

    println!("{}", dfs(&edges, &mut visited, 0));
}

fn dfs(edges: &Vec<Vec<usize>>, visited: &mut std::collections::HashSet<usize>, v: usize) -> usize {
    if visited.len() == edges.len() {
        return 1;
    }

    let mut cnt = 0;
    for &to in &edges[v] {
        if !visited.contains(&to) {
            let mut cl = visited.clone();
            cl.insert(to);
            cnt += dfs(edges, &mut cl, to);
        }
    }

    cnt
}


Measured memory_bytes: 4352
#%%
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
tmp = 0
flag = True
if a[0] != 0:
    flag = False

for i in range(n-1):
    if a[i+1] > a[i]:
        pass
    else:
        ans += a[i]
    if a[i+1] - a[i] > 1:
        flag = False
    
ans += a[n-1]

if flag:
    print(ans)
else:
    print(-1)


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

using namespace std;

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using ll = long long;
int cnt(ll A) {
    int ret = 0;
    while (A) {
        if (A % 2 == 1) break;
        ret++;
        A >>= 1;
    }
    return ret;
}

void f(ll A, ll B, ll C) {
    int cnt = 0;
    while (1) {
        printf("%lld %lld %lld\n", A, B, C);
        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) break;
        ll t1 = A / 2;
        ll t2 = B / 2;
        ll t3 = C / 2;
        A = t2 + t3;
        B = t3 + t1;
        C = t1 + t2;
        cnt++;
    }
    cout << cnt << endl;
}

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
        cout << "0" << endl;
        return 0;
    }
    if (A == B && B == C && C == A) {
        cout << "-1" << endl;
        return 0;
    }
    // f(A, B, C);
    int a = cnt(A);
    int b = cnt(B);
    int c = cnt(C);
    int ans = min({a, b, c});
    if (a == b && b == c && c == a) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[101],b[101],s=0;
	cin>>n;
	for(int i=1;i<=n-1;i++)
		cin>>b[i];
	s=b[1]+b[n-1];
	for(int i=1;i<=n-2;i++){
		s+=min(b[i],b[i+1]);
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long X,Y,Z,A,B,C;
int N;
long cx[1000],cy[1000],cz[1000],cxy[1000],cxyz[1000];
main()
{
	cin>>X>>Y>>Z>>A>>B>>C>>N;
	for(int i=0;i<X;i++)cx[(i>A?i-A:A-i)%N]++;
	for(int i=0;i<Y;i++)cy[(i>B?i-B:B-i)%N]++;
	for(int i=0;i<Z;i++)cz[(i>C?i-C:C-i)%N]++;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)cxy[(i+j)%N]+=cx[i]*cy[j];
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)cxyz[(i+j)%N]+=cxy[i]*cz[j];
	for(int i=0;i<N;i++)cout<<cxyz[i]<<(i+1==N?"\n":" ");
}


Measured memory_bytes: 3140
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int> > v;
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	sort(v.begin(), v.end());
	int cnt = 0;
	long long int ans = 0;
	priority_queue<int> qu;
	for(int i = m - 1; i >= 0; i--){
		int tmp = m - i;
		while(cnt < n && v[cnt].first <= tmp){
			qu.push(v[cnt].second);
			cnt++;
		}
		if(qu.empty()) continue;
		ans += qu.top();
		qu.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 1908
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] h = new int[N];
    for (int i = 0; i < N; i++) {
      h[i] = sc.nextInt();
    }

    int[] dp = new int[N];
    for (int i = 0; i < N; i++) dp[i] = 1100000000;
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 1; j <= K; j++) {
        if (i + j < N) dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(h[i + j] - h[i]));
      }
    }
    System.out.println(dp[N - 1]);
  }
}

Measured memory_bytes: 52524