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

struct Strongly_Connected_Component {
  int n, k;
  vector<vector<int>> G, reverseG;
  vector<int> vs, cmp;
  vector<bool> used;
  Strongly_Connected_Component(int newv = 1) {
    n = newv;
    G.resize(n);
    reverseG.resize(n);
    used.resize(n, 0);
    cmp.resize(n);
  }

  bool add(int from, int to) {
    G[from].push_back(to);
    reverseG[to].push_back(from);
    return 1;
  }
  void dfs(int v) {
    used[v] = true;
    for (auto to : G[v])
      if (!used[to]) dfs(to);
    vs.push_back(v);
  }
  void rdfs(int v) {
    used[v] = true;
    cmp[v] = k;
    for (auto to : reverseG[v])
      if (!used[to]) rdfs(to);
  }
  int solve() {
    used.assign(n, 0);
    vs.clear();
    for (int v = 0; v < n; ++v)
      if (!used[v]) dfs(v);
    used.assign(n, 0);
    k = 0;
    for (int i = (int)vs.size() - 1; i >= 0; --i)
      if (!used[vs[i]]) {
        rdfs(vs[i]);
        ++k;
      }
    return k;
  }
  vector<vector<int>> make_graph(bool dosolve = 1) {
    if (dosolve) solve();
    vector<vector<int>> res(k);
    for (int i = 0; i < n; ++i)
      for (int to : G[i])
        if (!issame(i, to)) res[cmp[i]].push_back(cmp[to]);
    for (auto& v : res) {
      sort(v.begin(), v.end());
      v.erase(unique(v.begin(), v.end()), v.end());
    }
    return res;
  }
  vector<vector<int>> make_list(bool dosolve = 1) {
    if (dosolve) solve();
    vector<vector<int>> res(k);
    for (int i = 0; i < n; ++i) res[cmp[i]].push_back(i);
    return res;
  }
  bool issame(int l, int r) { return cmp[l] == cmp[r]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  Strongly_Connected_Component scc(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    scc.add(a, b);
  }
  auto v = scc.make_list();
  cout << v.size() << endl;
  for (auto l : v) {
    cout << l.size();
    for (auto p : l) cout << " " << p;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 79576
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  long long n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;

  long long ans = 4;
  long long minv = min({a, b, c, d, e});

  ans += (n+minv-1) / minv;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,n) for(i=0; i<n; i++)

int main(void){
	int i;
	int a[3];
	rep(i,3) scanf("%d", &a[i]);
	if((a[0]==a[1] && a[0]==a[2] && a[1]==a[2]) || (a[0]!=a[1] && a[0]!=a[2] && a[1]!=a[2])){
		puts("No");
	}else{
		puts("Yes");
	}
	return 0;
}

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

const long long INF = 1e+15;

struct edge
{
    int from;
    int to;
    int cost;
    edge(int x, int y, int z): from(x), to(y), cost(z) {}
};


void bellmanFord( int s, vector<long long>& d, vector<edge>& E, vector<bool>& isPartOfRing )
{
    d[s] = 0;
    for( int i = 0; i < d.size(); ++i ){
        for( int j = 0; j < E.size(); ++j ){
            edge e = E[j];
            if( e.from == INF ) continue;
            if( d[e.to] > d[e.from]+e.cost ){
                d[e.to] = d[e.from]+e.cost;
                if( i == d.size()-1 )  isPartOfRing[e.to] = true;
            }
        }
    }
}


int main()
{
    int N, M;
    cin >> N >> M;
    vector<edge> E(M, edge(0,0,0));
    for (int i = 0; i < M; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        E[i] = edge(a, b, -c);
    }
    

    vector<long long> d(N, INF);
    vector<bool> isPartOfRing(N, false);
    bellmanFord(0, d, E, isPartOfRing);
    if( isPartOfRing[N-1] ) cout << "inf" << endl;
    else cout << -d[N-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> w(n);
	vector<ll> s(n);
	vector<ll> v(n);
	REP(i, n) cin >> w[i] >> s[i] >> v[i];
	vector<pll> idx(n);
	REP(i, n) {
		idx[i].first = w[i] + s[i];
		idx[i].second = i;
	}
	sort(ALL(idx));
	vector<vector<ll>> dp(n, vector<ll>(50050, -1));
	dp[0][0] = 0;
	dp[0][w[idx[0].second]] = v[idx[0].second];
	FOR(i, 1, n) REP(j, 50050) {
		dp[i][j] = dp[i - 1][j];
		ll wei = j - w[idx[i].second];
		if(wei < 0 || wei > s[idx[i].second] || dp[i - 1][wei] == -1) continue;
		dp[i][j] = max(dp[i][j], dp[i - 1][wei] + v[idx[i].second]);
	}
	ll ans = 0;
	REP(i, 50050) ans = max(ans, dp[n - 1][i]);
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 392704
#include <iostream>
#include <map>
#include <iterator>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	map<char,int> mp;
	string w;
	cin >> w;
	
	for (size_t i = 0; i < w.size(); ++i) {
		mp[w[i]] += 1;
	}
	auto itr = mp.begin();
	string is_beaut = "Yes";
	for (itr; itr != mp.end(); ++itr) {
		if (itr->second % 2 != 0) is_beaut = "No";
	}
	
	cout << is_beaut << endl;
	return 0;
}

Measured memory_bytes: 256
l=[[] for i in range(9)]
l[1]=[""]
l[2]=["0","1"]
for i in range(3,9):
    for s in l[i-1]:
        l[i].append("0"+s)
        if s[0]!="1":
            l[i].append("1"+s)

mod=1000000007
s=input().split()
h,w,k=int(s[0]),int(s[1]),int(s[2])
res=[[0]*(w) for i in range(h+1)]
res[0][0]=1
for i in range(h):
    for s in l[w]:
        s="0"+s+"0" #どの縦棒から見ても左右が参照できるように両端に0をつけておく
        for j in range(w):
            if s[j]=="0" and s[j+1]=="0": #直進
                res[i+1][j]+=res[i][j]
                res[i+1][j]%=mod
            if s[j]=="0" and s[j+1]=="1": #左列に移る
                res[i+1][j+1]+=res[i][j]
                res[i+1][j+1]%=mod
            if s[j]=="1" and s[j+1]=="0": #右列に移る
                res[i+1][j-1]+=res[i][j]
                res[i+1][j-1]%=mod
print(res[h][k-1])

Measured memory_bytes: 42736
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//ここから下
int v,e,r;
edge es[2145];
int d[1145];
bool  shortest_path(int s){
    rep(i,0,v)d[i]=inf;
    d[s]=0;
    int count=0;
    while(true){
        count++;
        if(count==v)return true;
        bool update=false;
        rep(i,0,e){
            edge e=es[i];
            if(d[e.from]!=inf&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;update=true;
            }
        }
        if(!update)break;
    }
    return false;
}
signed main(){
    cin>>v>>e>>r;
    if(v==1){
        cout<<0<<endl;
        return 0;
    }
    rep(i,0,e){
        int a,b,c;cin>>a>>b>>c;
        es[i]=edge{a,b,c};
    }
    if(shortest_path(r)){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    rep(i,0,v){
        if(d[i]==inf)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
    return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair <int,int>> vec (M);
	for(int i = 0;i < M;i++){
		cin >> vec.at(i).first;
		cin >> vec.at(i).second;
		swap(vec.at(i).first,vec.at(i).second);
	}
	int count = 0;
	vector<bool> pb (M,false);
	sort(vec.begin(), vec.end());
	for(int i = 0;i < M;i++){
		if(pb.at(i)){
			continue;
		}
		else{
			count++;
			for(int j = 0;j < M;j++){
				if(pb.at(j) == false && vec.at(j).second < vec.at(i).first){
					pb.at(j) = true;
				}
			}
		}
	}
	cout << count << endl;
}

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

typedef long long ll;


int main(int argc, char const *argv[])
{
	string s;
	cin >> s;

	int k = s.size() - 1;

	if(s[k] == '2' || s[k] == '4' || s[k] == '5' || s[k] == '7' || s[k] == '9'){
		printf("hon\n");
	}
	else if(s[k] == '0' || s[k] == '1' || s[k] == '6' || s[k] == '8'){
		printf("pon\n");
	}
	else{
		printf("bon\n");
	}
}

Measured memory_bytes: 3624
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node {
	int p, l, r;
};

struct Node t[MAX];

int n, d[MAX];

void print(int u){
	int i, c;
	printf("node %d: ",u);
	printf("parent = %d, ",t[u].p);
	printf("depth = %d, ",d[u]);
	
	if( t[u].p == NIL) printf("root, ");
	else if(t[u].l == NIL) printf("leaf, ");
	else printf("internal node, ");
	
	printf("[");
	
	for(i = 0, c = t[u].l; c != NIL; i++, c= t[c].r){
		if(i)printf(", ");
		printf("%d",c);
	}
	printf("]\n");
}	
int rec(int u, int p){
	d[u] = p;
	if(t[u].r != NIL) rec(t[u].r, p);
	if(t[u].l != NIL) rec(t[u].l, p+1);
}
	
int main(){
	int i, j, d, v, c, l, r;
	scanf("%d", &n);
	for(i = 0; i < n; i++) t[i].p = t[i].l = t[i].r = NIL;
	
	for(i = 0; i < n; i++){
		scanf("%d %d",&v, &d);
		for(j = 0; j < d; j++){
			scanf("%d", &c);
			if(j == 0) t[v].l = c;
			else t[l].r = c;
			l = c;
			t[c].p = v;
		}
	}
	for(i = 0; i < n; i++){
		if(t[i].p == NIL) r = i;
	}
	
	rec(r, 0);
	
	for(i = 0; i < n; i++) print(i);
	
	return 0;
}
		


Measured memory_bytes: 6464
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  lint all = 0;
  vector<lint> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    all ^= a[i];
  }

  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      cout << (all ^ a[i]) << endl;
    } else {
      cout << (all ^ a[i]) << " ";
    }

  }
  return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  double ans = 0;
  for (i64 i = 0; i < n; i++)
    for (i64 j = i + 1; j < n; j++)
    {
      i64 k = n - 1;
      while (k == i || k == j)
        k--;
      i64 l = k - 1;
      while (l == i || l == j)
        l--;
      ans = max(ans, (double)(a[k] + a[l]) / (a[j] - a[i]));
    }
  cout << fixed << setprecision(6) << ans << endl;
  return 0;
}



Measured memory_bytes: 3272
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String tmp = Integer.toString(N);
		long s = 0;
		for(int i = 0;i<tmp.length();i++){
			s += Integer.parseInt(tmp.substring(i, i+1));
		}
		
		if(N%s==0)
			System.out.println("Yes");
		else
			System.out.println("No");}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    int n;
    cin>>n;
    map<int,int>m;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        m[a]=i;
    }
    map<int,int>nm;
    int id=0;
    for(auto c:m)
    {
        nm[c.first]=id;
        id++;
    }
    int cnt=0;
    for(auto c:m)
    {
        if(abs(nm[c.first]-c.second)%2!=0)
            cnt++;
    }
    cout<<cnt/2<<endl;
    return 0;
}

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

const long long mod = 2019;

int main()
{
    long long L, R;
    cin >> L >> R;
    long long cnt = 0;
    long long minv = 1e8;
    for(long long i = L; i < R; i++)
    {
        for(long long j = i+1; j <= i+1+2019 && j <= R; j++)
        {
            long long tmp = (i*j) % mod;
            if(tmp < minv) minv = tmp;
            cnt++;
            if(cnt > 10000000) break;
        }
        if(cnt > 10000000) break;
    }
    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
    int a, b;
    char op;
    scanf("%d %c %d", &a, &op, &b);
    if (op == 43){
        printf("%d\n", a+b);
    }
    else if (op == 45){
        printf("%d\n", a-b);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N,i,j,a,key;

  scanf("%d",&N);

  int data[N];
  
  for(i=0; i<N; i++){
    scanf("%d",&data[i]);
  }

   for(i=1; i<N+1; i++){
     key = data[i];
     j = i-1;

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

     while(j>=0 && data[j] > key){
       data[j+1] = data[j];
       j--;
       data[j+1] = key;
     }
   }
   return 0;
}
    



Measured memory_bytes: 2072
using System;
using System.Collections.Generic;
class Program{
	static List<int>[] li;
	static int[] h;
	static int[] d;
	static int ans=0;
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		li=new List<int>[s[0]+1];
		d=new int[3];
		d[0]=int.MaxValue;
		h=new int[s[0]+1];
		for(int i=1;i<=s[0];i++){li[i]=new List<int>();}
		for(int i=0;i<s[1];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			li[q[0]].Add(q[1]);
			li[q[1]].Add(q[0]);
		}
		for(int i=1;i<=s[0];i++){
			if(d[0]>li[i].Count){
				d[0]=li[i].Count;
				d[1]=i;
				if(d[0]==2&&(li[li[i][0]].Count>2||li[li[i][1]].Count>2)){d[2]=1;}
			}
			else if(d[0]==2&&li[i].Count==2&&(li[li[i][0]].Count>2||li[li[i][1]].Count>2)){d[2]=1;}
		}
		h[d[1]]=-1;
		fu(d[1],1);
		Console.WriteLine(ans);
		int[] v=new int[ans];
		v[ans-1]=d[2];
		for(int i=ans-2;i>=0;i--){
			d[2]=h[d[2]];
			v[i]=d[2];
		}
		Console.WriteLine(String.Join(" ",v));
	}
	static void fu(int a,int b){
		for(int i=0;i<li[a].Count&&ans==0;i++){
			if(h[li[a][i]]==0){
				h[li[a][i]]=a;
				fu(li[a][i],b+1);
				if(ans==0){h[li[a][i]]=0;}
			}
		}
		if(ans==0){
			bool l=false;
			for(int i=0;i<li[d[1]].Count;i++){
				if(h[li[d[1]][i]]==0){
					l=true;
					break;
				}
			}
			if(!l){ans=b;d[2]=a;}
		}
	}
}

Measured memory_bytes: 37384
import itertools

n = int(input())
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))

R = []
if n >= 3:
    for i, j, k in itertools.combinations(xy, 3):
        if (j[0] - i[0]) * (k[0] - i[0]) + (j[1] - i[1]) * (k[1] - i[1]) <= 0:
            r = ((j[0] - k[0]) ** 2 + (j[1] - k[1]) ** 2) ** 0.5 / 2
            R.append(r)
        elif (i[0] - j[0]) * (k[0] - j[0]) + (i[1] - j[1]) * (k[1] - j[1]) <= 0:
            r = ((i[0] - k[0]) ** 2 + (i[1] - k[1]) ** 2) ** 0.5 / 2
            R.append(r)
        elif (i[0] - k[0]) * (j[0] - k[0]) + (i[1] - k[1]) * (j[1] - k[1]) <= 0:
            r = ((i[0] - j[0]) ** 2 + (i[1] - j[1]) ** 2) ** 0.5 / 2
            R.append(r)
        else:
            x1 = j[0] - i[0]
            x2 = k[0] - i[0]
            y1 = j[1] - i[1]
            y2 = k[1] - i[1]
            cos = (x1 * x2 + y1 * y2) /(((x1 ** 2 + y1 ** 2) ** 0.5) * ((x2 ** 2 + y2 ** 2) ** 0.5))
            sin = (1 - cos ** 2) ** 0.5
            r = (((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5) / 2 / sin
            R.append(r)
else:
    r = ((xy[0][0] - xy[1][0]) ** 2 + (xy[0][1] - xy[1][1]) ** 2) ** 0.5 / 2
    R.append(r)
print(max(R))

Measured memory_bytes: 3700
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

def main():
    N, M = LI()
    A = LI()
    BandC = []
    for i in range(M):
        BandC.append(LI())
 
    A = sorted(A)
    BandC = sorted(BandC, key=lambda x: x[1], reverse=True)
 
    BandC_counter = 0
    BandC_position = 0
    BandC_sum = 0
    for A_position in range(N):
        if A[A_position] > BandC[BandC_position][1]:
            break
        BandC_sum += BandC[BandC_position][1]
        BandC_counter += 1
        if BandC_counter >= BandC[BandC_position][0]:
            BandC_position += 1
            BandC_counter = 0
            if BandC_position >= len(BandC):
                A_position += 1
                break
    else:
        A_position += 1
 
    print(BandC_sum + sum(A[A_position:]))

main()

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

int main(){
  static bool cmp[1000000] = {true};
  // cout << cmp[3] << cmp[2] << cmp[5]<<endl;
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
        cmp[i*j]=true;
      }
    }
    npr[i] = npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout << npr[n] << endl;
  }
  return 0;
}



Measured memory_bytes: 7864
#include<iostream>
#include<set>
#include<math.h>
using namespace std;
#define N 100010
#define MAX 450
int n;
bool can;
set<int> S[MAX];
set<int>::iterator it;
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>n)
    {
        can=false;
        int k;//分成k个集合 每个集合k-1个元素
        for(int i=1;i<=sqrt(2*n);i++)
        {
            if(i*(i+1)==2*n)
            {
                k=i+1;
                can=true;
                break;
            }
        }
        if(!can)
        {
            cout<<"No"<<endl;
            continue;
        }
        else
        {
            for(int i=1;i<=k;i++) S[i].clear();
            int cnt=1;
            for(int i=1;i<=k-1;i++)
            {
                for(int j=i+1;j<=k;j++)
                {
                    S[i].insert(cnt);
                    S[j].insert(cnt);
                    cnt++;
                }
            }
            //构造集合输出...
            cout<<"Yes"<<endl;
            cout<<k<<endl;//k个集合
            for(int i=1;i<=k;i++)
            {
                cout<<S[i].size();
                for(it=S[i].begin();it!=S[i].end();it++)
                {
                    cout<<" "<<*it;
                }
                cout<<endl;
            }
        }
    }
    
}

Measured memory_bytes: 10752
import java.util.*;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = sc.nextInt();
      int[] p = new int[N];
      int sum = 0;
      for (int i = 0; i < N; i++) {
        int tmp = sc.nextInt();
        p[i] = tmp;
        sum +=tmp;
      }
      Arrays.sort(p);
      sum -= p[N-1]/2;

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


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    int N;
    cin>>N;
    vector<ll> A(N+1);
    vector<ll> sumA(N+1,0);
    ll sum=0;
    REP(i,N+1){
        cin>>A[i];
        sum+=A[i];
    }
    sumA[0]=sum-A[0];
    REP2(i,1,N+1){
        sumA[i]=sumA[i-1]-A[i];
    }
    vector<ll> cnt_v(N+1,0);
    vector<ll> cnt_ha(N+1,0);
    ll num;
    cnt_v[0]=1;
    cnt_ha[0]=A[0];

    if(A[0]>=2){
        cout<<-1<<endl;
        return 0;
    }
    if(A[0]==1){
        if(N==0){
            cout<<1<<endl;
            return 0;
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    REP2(i,1,N+1){
        num=2*(cnt_v[i-1]-cnt_ha[i-1]);
        if(A[i]>num){
            cout<<-1<<endl;
            return 0;
        }
        cnt_v[i]=min(sumA[i]+A[i],num);
        cnt_ha[i]=A[i];
    }
    ll ans=0;
    REP(i,N+1){
        ans+=cnt_v[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)

using namespace std;
const int maxn = 3e5+7;

map<LL,int>vis;
int n;
struct Lpart
{
    int id;LL val;
    Lpart(int id,LL val):id(id),val(val){}
    Lpart(){}
    bool operator < (const Lpart &rhs) const
    {
        return val>rhs.val;
    }
};

struct Rpart
{
    int id;LL val;
    Rpart(int id,LL val):id(id),val(val){}
    Rpart(){}
    bool operator < (const Rpart &rhs) const
    {
        return val<rhs.val;
    }
};

priority_queue<Lpart>Lq;
priority_queue<Rpart>Rq;

LL a[maxn],lsum[maxn],rsum[maxn];

void getlsum()
{
    LL sum=0;
    for (int i=1;i<=3*n;i++)
    {
        Lq.push(Lpart(i,a[i]));
        if (Lq.size()==n+1)
        {
            sum-=Lq.top().val;Lq.pop();
        }
        sum+=a[i];lsum[i]=sum;
    }
}

void getrsum()
{
    LL sum=0;
    for (int i=3*n;i>=1;i--)
    {
        Rq.push(Rpart(i,a[i]));
        if (Rq.size()==n+1)
        {
            sum-=Rq.top().val;Rq.pop();
        }
        sum+=a[i];rsum[i]=sum;
    }
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=3*n;i++) scanf("%lld",&a[i]);
    getlsum();
    getrsum();
    LL ans=-1e18;
    for (int i=n;i<=2*n;i++)
    {
        ans=max(ans,lsum[i]-rsum[i+1]);
    }
    printf("%lld\n",ans);
    return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long int ll;

void solve()
{
	ll n;
	cin >> n;
	string s;
	map<string, int> mp;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;


}



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

#ifndef ONLINE_JUDGE
	freopen("1input.txt", "r", stdin);
	freopen("1output.txt", "w", stdout);
#endif

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

	while (t--)
	{
		solve();
		cout << "\n";
	}

	return 0;
}

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

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

	int w, h, n; cin >> w >> h >> n;
	vector<vector<int>> grid(w, vector<int>(h));
	for(int i = 0; i < n; i++){
		int x, y, a; cin >> x >> y >> a;
		if(a == 1){
			for(int i = 0; i < x; i++){
				for(int j = 0; j < h; j++){
					grid[i][j] = 1;
				}
			}
		}
		if(a == 2){
			for(int i = x; i < w; i++){
				for(int j = 0; j < h; j++){
					grid[i][j] = 1;
				}
			}
		}
		if(a == 3){
			for(int i = 0; i < w; i++){
				for(int j = 0; j < y; j++){
					grid[i][j] = 1;
				}
			}
		}
		if(a == 4){
			for(int i = 0; i < w; i++){
				for(int j = y; j < h; j++){
					grid[i][j] = 1;
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < w; i++){
		for(int j = 0; j < h; j++){
			if(grid[i][j] == 0) ans++;
		}
	}
	cout << ans << endl;
	return 0;	
}
  

Measured memory_bytes: 256
n,m = [int(x) for x in input().split(' ')]

info = {
    
}

for i in range(m):
    p,s = [x for x in input().split(' ')]
    if p not in info:
        if s == "WA":
            info[p] = [0, 1]
        elif s == "AC":
            info[p] = [1,0]
    else:
        if s == "WA":
            if info[p][0] == 0:
                info[p][1] += 1
        elif s == "AC":
            if info[p][0] == 0:
                info[p][0] = 1
    
ac = 0
wa = 0

for a in info.values():
    ac += a[0]
    if a[0] > 0:
        wa += a[1]

print(ac, wa)




Measured memory_bytes: 25284
#include<cstdio>
using namespace std;
char str[1000];
int main(){
	scanf("%s",str+1);
	for(int i=1;i<=5;i++)
		if(str[i]=='A'&&str[i+1]=='C')
		{
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
	return 0;
}


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

int main(){
    string S;
    cin >> S;
    int S_int;
    S_int = stoi(S);
    int front,back;
    front = S_int / 100;
    back = S_int % 100;
    if (1 <= back && back <= 12 && (front >= 13 || front == 0)){
        cout << "YYMM" << endl;
    } 
    else if (1 <= front && front <= 12 && (back >= 13 || back == 0)){
        cout <<"MMYY" << endl;
    }
    else if (1 <= front && front <= 12 && 1 <= back && back <= 12){
        cout << "AMBIGUOUS" << endl;
    }
    else {
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
# input
N, M = map(int, input().split())
s = [0]*M
c = [0]*M

if(M==0 and N==1):
    print("0")
elif(M==0 and N>1):
    ans_print = "1"
    for i in range(N-1):
        ans_print += "0"
    print(ans_print)
else:
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    ans = [-1]*N
    b = True

    for i in range(M):
        if(ans[s[i]-1] != -1 and ans[s[i]-1] != c[i]):
            b = False
        else:
            ans[s[i]-1] = c[i]

    for i in range(len(ans)):
        if(i==0 and ans[i]==-1):
            ans[i] = 1
        elif(ans[i] == -1):
            ans[i] = 0
    
    if(N > 1 and ans[0]==0):
        b = False
        
    if(b):
        ans_print = ""
        for i in range(len(ans)):
            ans_print += str(ans[i])
        print(ans_print)
    else:
        print("-1")

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
      // 整数の入力
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
      
      	String answer = "";
      	for(int i=0;i<N;i++){
          answer = answer + String.valueOf(S[i]);
          answer = answer + String.valueOf(T[i]);
        }
      	
      	System.out.println(answer);

      
      	
	}
}

Measured memory_bytes: 21844
n = int(input())
w = list(map(int, input().split()))

best = 999999
sum_of_all = sum(w)

for i in range(1, len(w)):
    zenhan = sum(w[:i])
    sa = abs(2*zenhan - sum_of_all)
    if sa < best:
        best = sa
    else:
        break
    
print(best)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;




int main() {
	int n;
	cin >> n;
	vector<ll> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}


	sort(l.begin(), l.end());
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (l[i] == l[j]) {
				continue;
			}

			for (int k = j + 1; k < n; k++) {
				if (l[k] >= l[i] + l[j]) {
					break;
				}

				if (l[k] == l[j]) {
					continue;
				}

				cnt++;
			}
		}
	}
	cout << cnt << endl;

}


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

using namespace std;

#define int long long
#define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll v[100], w[100];
ll dp[101][101001];

signed main() {
    LCIN(N, W);
    REP(i, N) cin >> w[i] >> v[i];
    REP(i, N) REP(j, W + 1) {
        if(j - w[i] < 0)
            dp[i + 1][j] = dp[i][j];
        else
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
    }
    cout << dp[N][W] << "\n";
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main()
{
    int n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(p==2)
    {
        lli ans=0;
        for(int i=s.length()-1;i>-1;i--)
        {
            int t=s[i]-'0';
            if(t%2==0)
                ans+=i+1;
        }
        cout << ans << endl;
    }
    else if(p==5)
    {
        lli ans=0;
        for(int i=s.length()-1;i>-1;i--)
        {
            int t=s[i]-'0';
            if(t%5==0)
                ans+=i+1;
        }
        cout << ans << endl;
    }
    else
    {
        int rarr[n];
        int t=s[n-1]-'0',prem=t%p,power=10;
        rarr[n-1]=prem;
        for(int i=s.length()-2;i>-1;i--)
        {
            t=s[i]-'0';
            prem=(power*t+prem)%p;
            rarr[i]=prem;
            power=(power*1LL*10)%p;
        }
        // for(int i=0;i<n;i++)
        //     cout << rarr[i] << " ";
        // cout << endl;
        int nnum[p];
        for(int i=0;i<p;i++)
            nnum[i]=0;
        nnum[rarr[0]]=1;
        lli ans=0;
        for(int i=1;i<n;i++)
        {
            ans+=nnum[rarr[i]];
            nnum[rarr[i]]+=1;
        }
        ans+=nnum[0];
        cout << ans << endl;
    }
}

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

int main() {
  string S;
  cin >> S;
  for (auto i = 0; i < (int)S.size()-1; i++) {
    if (S[i] == S[i+1]) {
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }
  for (auto i = 0; i < (int)S.size()-2; i++) {
    if (S[i] == S[i+2]) {
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << endl;
    if(N-A-B >= 0) cout << 0 << endl;
    else cout << A+B-N << endl;

    return 0;
}

/*

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

/*

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

/*

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

/*

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

/*

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[5][5],A,b,c;
int main()
{
	cin>>A>>b>>c;
	a[1][1]=A;a[1][2]=b;a[2][2]=c;
	for(int i=max(max(A+b,A+c),b+c);i<=300;i++)
	{
		a[1][3]=i-a[1][1]-a[1][2];
		a[3][2]=i-a[1][2]-a[2][2];
		a[3][3]=i-a[1][1]-a[2][2];
		a[2][3]=i-a[1][3]-a[3][3];
		a[3][1]=i-a[3][2]-a[3][3];
		a[2][1]=i-a[2][2]-a[2][3];
		if(a[3][1]+a[2][2]+a[1][3]==i&&a[2][1]+a[2][2]+a[2][3]==i)
		{
			for(int j=1;j<=3;j++)
			{
				for(int k=1;k<=3;k++)
					cout<<a[j][k]<<' ';
				cout<<endl;
			}
			break;
		}
	}
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const ll inf = 1e17;
const ll mod = 1e9 + 7;
const int N = 200005;

void solve(){
	int n;
	cin >> n;
	map<string, int> mp;
	while(n--){
		string s;
		cin >> s;
		mp[s]++;
	}
	cout <<"AC x " << mp["AC"] << endl;
	cout <<"WA x " << mp["WA"] << endl;
	cout <<"TLE x " << mp["TLE"] << endl;
	cout <<"RE x " << mp["RE"] << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


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

int main(){
	char arr[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	char k;
	cin>>k;
	int c = -1;
	for (int i = 0; i<26; i++){
		c++;
		if (arr[i] == k){
			break;
		}
	}
	cout<<arr[c+1];
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = n - 1; i >= 0; --i)


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; ++i){
        if(i % 3 != 0 && i % 5 != 0){ ans += i; }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using std::swap;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

int main() {
    int A, B;
    std::cin >> A >> B;
    if(A>9||B>9){
        std::cout << -1 << std::endl;
    }
    else{
        std::cout << A*B << std::endl;
    }
    return 0;
}

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

odd = []
even = []
for i in range(n):
    if i%2 == 0:
        odd.append(s[i])
    else:
        even.append(s[i])
    
if n%2 == 1:
    ans = odd[::-1] + even
else:
    ans = even[::-1] + odd
    
ans_str=[str(a) for a in ans]
print(" ".join(ans_str))



Measured memory_bytes: 35876
/*
 * Author:  ry 
 * Created Time:  2017/12/30 20:02:21
 * File Name: 2.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <time.h>
using namespace std;
const int eps = 1e6+5;
const double pi = acos(-1.0);
const int inf = 1<<29;
#define Max(a,b) a>b?a:b
#define Min(a,b) a>b?b:a
#define ll long long

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int a;
    
    cin >> a;
    cout << 48 - a << endl;

    return 0;
}



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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

bool f2(ll v) {
  if (v <= 2) {
    return true;
  }

  bool ans = true;
  for (ll i = 2; i * i <= v; ++i) {
    if (v % i == 0) {
      ans = false;
      break;
    }
  }

  return ans;
}

vector<ll> f(ll v) {
  vector<ll> ans;
  for (ll i = 2; i * i <= v; ++i) {
    if (v % i == 0) {
      ans.push_back(i);
      if (i * i != v)
        ans.push_back(v / i);
    }
  }
  return ans;
}

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

  ll N;
  cin >> N;
  vector<ll> y = f(N);
  y.push_back(N);

  vector<ll> p;
  for (ll i : y) {
    if (f2(i)) {
      p.push_back(i);
    }
  }

  vector<ll> p2(p);
  for (ll v : p) {
    ll v2 = v * v;
    if (v2 < 0) {
      continue;
    }
    while (v2 < N) {
      p2.push_back(v2);
      v2 *= v;
      if (v2 < 0) {
        break;
      }
    }
  }
  sort(p2.begin(), p2.end());

  ll ans = 0;
  ll c = 0;
  ll idx_mx = p2.size();
  while (N > 1 && c < idx_mx) {
    bool flg = false;
    for (int i = 0; i < idx_mx; ++i) {
      if (p2.at(i) == -1) {
        continue;
      }
      if (N % p2.at(i) == 0) {
        N /= p2.at(i);
        p2.at(i) = -1;
        flg = true;
        break;
      }
    }
    if (!flg) {
      break;
    }

    ++c;
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3664
/**
 * @author pr4shan7 (प्रशांत)
 */
// everything has a cost!

#ifdef _MAVERICK
#define _DEBUG
#else
#pragma GCC optimize("O2", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx,avx2,fma")
// #pragma GCC reset_options
#endif

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'
// #define cerr cout
// #define int long long
// #define double long double

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef unordered_set<int> usi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef set<int> si;
typedef long long ll;
#define pb push_back
#define x first
#define y second
#define cai static_cast<int>
#define cad static_cast<double>
#define cal static_cast<long long>
#define all(z) z.begin(), z.end()
#define tr(cont, itm) for (auto&& itm : cont)
#define rep(in, beg, sz) for (int in = beg; in < sz; in++)
#define rrep(in, sz, beg) for (int in = sz - 1; in >= beg; in--)
#define rtr(cont, itr) for (auto itr = cont.end() - 1; itr >= cont.begin(); itr--)

#ifdef _DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

template <typename... T> inline void debug_out(const T&...);
#else
#define debug(...) 42
#endif

template <typename T> inline istream& operator>>(istream& in, vector<T>& ar);
template <typename T> inline ostream& operator<<(ostream& out, const vector<T>& ar);
template <typename T> constexpr inline T pow(long long, long long, const T);

const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;

// beautiful things don't ask for attention



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

#ifdef _MAVERICK
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif

	ll n,m; cin >> n>>m;
	ll ways=(n*(n-1))/2 + (m*(m-1)/2);
	cout << ways;

	return 0;
}


#ifdef _DEBUG
template <typename... T>
inline void debug_out(const T&... args) { ((cerr << ' ' << args), ...); cerr << endl; }
#endif

template <typename T>
inline istream& operator>>(istream& in, vector<T>& ar) {
	for (auto& i : ar) in >> i;
	return in;
}

template <typename T>
inline ostream& operator<<(ostream& out, const vector<T>& ar) {
	for (int i = 0; i < ar.size() - 1; i++) out << ar[i] << ' ';
	out << ar[ar.size() - 1];
	return out;
}

template <typename T>
constexpr inline T pow(long long a, long long b, const T mv) {
	long long res = 1;
	a %= mv;
	while (b) {
		if (b & 1)
			res = (res * a) % mv;
		b >>= 1;
		a = (a * a) % mv;
	}
	return res;
}

// get busy living or get busy dying


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import Counter
N = int(input())
A = tuple(map(int, input().split()))
c = Counter(A)

pairs = []
for k, v in c.items():
    if v >= 4:
        pairs.extend([k]*2)
    elif v >= 2:
        pairs.append(k)

if len(pairs) >= 2:
    a, b = sorted(pairs, reverse=True)[:2]
    print(a*b)
else:
    print(0)

Measured memory_bytes: 18472
fn main() {
  let (n, m) = {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
  
    let mut m = String::new();
    std::io::stdin().read_line(&mut m).unwrap();
    (n.trim_right().chars().collect::<Vec<char>>(), m.trim_right().chars().collect::<Vec<char>>())
  };

  let count =  n.iter().zip(m.iter())
    .fold(0, |acc, (n, m)| acc + (n == m) as u8);
 
  print!("{}", count);
}

Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#define maxn 1005
#define _ 0
using namespace std;
struct nod
{
	int nex,id;
	nod(int a,int b)
	{
		nex=a;
		id=b;
	}
	nod(){}
};
int n,m,tim;
int vis[maxn];
int bel[maxn][maxn][2];
int u[maxn*maxn],v[maxn*maxn];
vector<nod> edge[maxn];
void dfs(int now,int fa,int b,int f)
{
//	cerr<<now<<" "<<fa<<" "<<b<<" "<<f<<endl;
	vis[now]=tim; bel[fa][now][f]=b;
	int len=edge[now].size();
	for(int i=0;i<len;i++)
		if(vis[edge[now][i].nex]!=tim)
			dfs(edge[now][i].nex,fa,b,f);
}
void solve(int now)
{
	tim++; vis[now]=tim;
	int len=edge[now].size();
	for(int i=0;i<len;i++)
		if(vis[edge[now][i].nex]!=tim)
			dfs(edge[now][i].nex,now,edge[now][i].id,0);
 
	reverse(edge[now].begin(),edge[now].end());
 
	tim++; vis[now]=tim;
	for(int i=0;i<len;i++)
		if(vis[edge[now][i].nex]!=tim)
			dfs(edge[now][i].nex,now,edge[now][i].id,1);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u[i],&v[i]);
		edge[u[i]].push_back(nod(v[i],i));
	}
	for(int i=1;i<=n;i++)
		solve(i);
	for(int i=1;i<=m;i++)
	{
		if( (bel[v[i]][u[i]][0]!=0) ^ _ ^ (bel[u[i]][v[i]][0]!=i || bel[u[i]][v[i]][1]!=i) )
			printf("diff\n");
		else
			printf("same\n");
	}
}


Measured memory_bytes: 18688
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>

ll n;
vector<ll>t;

int main(){
    cin>>n;

    ll ans=100000000000000000LL;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            t.pb(i);
            t.pb(n/i);
            ans=min(ans,i+n/i);
        }
    }
    cout<<ans-2<<endl;
    /*
    sort(t.begin(),t.end());
    ll ans=100000000000000000LL;
    ll tmp=1;
    for(int i=0;i<t.size();i++)cout<<t[i]<<endl;
    for(int i=0;i<t.size();i++){
        ans=min(ans,tmp+n/tmp);
        cout<<tmp<<" "<<n/tmp<<endl;
        tmp*=t[i];
    }
    */
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005



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

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

        int x=0;
        int j;
        for(i=0; i<n; i++){
            int req=a[i]-temp[i];
            ans+=req;
            while(req--){
                temp[i]++;
                for(j=i+1; j<n; j++){
                    if(temp[j]<a[j]){
                        temp[j]++;
                    }
                    else{
                        break;
                    }
                }
            }
        }
        cout << ans << '\n';

        

}


Measured memory_bytes: 256