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

const int MX = 1E6 + 5, MOD = 998244353;

int n, u;
long long ans = 0, f[MX], inv[MX], sum[MX];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    inv[1] = 1;
    for (int i = 2; i < MX; i++) {
        inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
    }
    cin >> n;
    while (n--) {
        cin >> u;
        (ans -= u) %= MOD;
        (sum[u] += u) %= MOD;
    }
    for (int i = MX - 1; i >= 1; i--) {
        long long tot = 0;
        for (int j = i; j < MX; j += i) {
            (tot += sum[j]) %= MOD;
            (f[i] -= f[j]) %= MOD;
        }
        (f[i] += tot * tot % MOD) %= MOD;
        (ans += f[i] * inv[i]) %= MOD;
    }
    (ans *= inv[2]) %= MOD;
    cout << (ans + MOD) % MOD;
}


Measured memory_bytes: 23680
#include <iostream>
using namespace std;
int main(){
    int a[4]={},b[4]={};
    int x=0,y=0;
    for(int i=0;i<4;i++){
        cin>>a[i];
        x+=a[i];
    }
    for(int j=0;j<4;j++){
        cin>>b[j];
        y+=b[j];
    }
    
    if(x>=y)cout<<x<<endl;
    else cout<<y<<endl;
    
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;
const int mx = 1e6+5;

void solve() {
    li n;
    cin >> n;
    li a[n];
    for(li i=0;i<n;i++) {
        cin >> a[i];
    }
    li res = 0;
    vector<bool> vis(mx,false);
    vector<bool> dp(mx,false);
    for(auto i : a) {
        if(vis[i])
            dp[i]=true;
        vis[i]=true;
        if(dp[i])
            continue;
        for(li j= 2*i;j<mx;j+=i) {
            dp[j]=true;
        }
    }
    for(auto i : a) {
        if(!dp[i])
            res++;
    }
    cout << res << endl;
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 5272
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    P = [int(p) for p in input().split()]
    P_ans = [i+1 for i in range(N)]
    
    ans = "NO"
    
    if P == P_ans:
        ans = "YES"
    
    for i in range(N-1):
        for j in range(i+1,N):
            P_swap = [p for p in P]
            P_swap[i],P_swap[j] = P_swap[j],P_swap[i]
            if P_ans == P_swap:
                ans = "YES" 
                break
            
    print(ans)
        
    
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

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

Measured memory_bytes: 256
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


int root(int[] uf, int u) {
  return (uf[u] < 0) ? u : (uf[u] = uf.root(uf[u]));
}
bool connect(int[] uf, int u, int v) {
  u = uf.root(u);
  v = uf.root(v);
  if (u == v) return false;
  if (uf[u] > uf[v]) swap(u, v);
  uf[u] += uf[v];
  uf[v] = u;
  return true;
}


int H, W;
string[] S;

void main() {
  try {
    for (; ; ) {
      H = readInt();
      W = readInt();
      S = new string[H];
      foreach (x; 0 .. H) {
        S[x] = readToken();
      }
      auto uf = new int[H * W];
      uf[] = -1;
      foreach (x; 0 .. H) foreach (y; 0 .. W) {
        if (x > 0 && S[x - 1][y] != S[x][y]) {
          uf.connect((x - 1) * W + y, x * W + y);
        }
        if (y > 0 && S[x][y - 1] != S[x][y]) {
          uf.connect(x * W + (y - 1), x * W + y);
        }
      }
      auto cnt = new int[][](H * W, 2);
      foreach (x; 0 .. H) foreach (y; 0 .. W) {
        ++cnt[uf.root(x * W + y)][(S[x][y] == '#') ? 1 : 0];
      }
      long ans;
      foreach (u; 0 .. H * W) {
        if (uf[u] < 0) {
          ans += 1L * cnt[u][0] * cnt[u][1];
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 8444
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc079 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        public main(this: TaskA): void {
            const n: number[] = this.args[0][0].split('').map(Number);
            if (n[0] === n[1] && n[1] === n[2]) {
                console.log('Yes');
            } else if (n[1] === n[2] && n[2] === n[3]) {
                console.log('Yes');
            } else {
                console.log('No');
            }
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}



Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <random>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 998244353 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll n,x,m ;
	cin >> n >> x >> m ;
	if(n<=1e6){
		ll ans = 0 ;
		for(int i=1;i<=n;i++){
			ans += x ;
			x = x*x%m ;
		}
		cout << ans << endl ;
		return 0 ;
	}
	vll rem ;
	ll ans = 0 ;
	ll last ;
	vector<bool> use(m,false) ;
	for(int i=1;i<=m+10;i++){
		if(x==0){
			cout << ans << endl ;
			// cout << "zero" << endl ;
			return 0 ;
		}
		last = x ;
		if(use[x]) break ;
		ans += x ;
		rem.push_back(x) ;
		use[x] = true ;
		x = x*x%m ;
	}
	ans = 0 ;
	ll pos = 0 ;
	for(int i=0;i<rem.size();i++){
		if(last!=rem[i]){
			ans += rem[i] ;
			n-- ;
			pos++ ;
		}else{
			break ;
		}
	}
	ll sum=0,cnt=0 ;
	for(int i=pos;i<rem.size();i++){
		sum += rem[i] ;
		cnt++ ;
	}
	ans += n/cnt*sum ;
	n %= cnt ;
	for(int i=0;i<n;i++) ans += rem[pos+i] ;
	cout << ans << endl ;
}

Measured memory_bytes: 3796
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin>>n;
		ll int arr[n+1];
		for(ll int i=0;i<=n;i++)
		{
			cin>>arr[i];
		}
		pii dp[n+1];
		dp[n]={arr[n],arr[n]};
		for(ll int i=n-1;i>=0;i--)
		{
			pii p;
			ll int low=(dp[i+1].F+1)/2;
			p.F=low;
			p.S=dp[i+1].S;
			p.F+=arr[i];
			p.S+=arr[i];
			dp[i]=p;
			// debug() << fuck(dp[i]) ;
		}
		if(dp[0].F>1 || dp[0].S<1)
		{
			cout<<-1<<endl;
			return 0;
		}
		ll int ans[n+1];
		ans[0]=1;
		for(ll int i=1;i<=n;i++)
		{
			ll int prev=ans[i-1]-arr[i-1];
			if(dp[i].F>prev*2 || dp[i].S<prev)
			{
				cout<<-1<<endl;
				return 0;
			}
			ll int cur=min(2*prev,dp[i].S);
			// debug() << fuck(cur) ;
			ans[i]=cur;
		}
		ll int sm=0;
		for(ll int i=0;i<=n;i++)
		{
			sm+=ans[i];
		}
		cout<<sm<<endl;
	}
	return 0;
}

Measured memory_bytes: 6772
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    A_list = [int(input()) for _ in range(N)]
    A_odered = collections.deque(sorted(A_list))
    res_list = collections.deque([A_odered.popleft()])
    res_list.appendleft(A_odered.pop())
    res = abs(res_list[0] - res_list[1])

    while len(A_odered) >= 1:
        temp_def1 = abs(res_list[0] - A_odered[-1])
        temp_def2 = abs(res_list[-1] - A_odered[-1])
        temp_def3 = abs(res_list[0] - A_odered[0])
        temp_def4 = abs(res_list[-1] - A_odered[0])

        max_deff = max(temp_def1, temp_def2, temp_def3, temp_def4)
        if temp_def1 == max_deff:
            res += temp_def1
            res_list.appendleft(A_odered.pop())
        elif temp_def2 == max_deff:

            res += temp_def2
            res_list.append(A_odered.pop())
        elif temp_def3 == max_deff:
            res += temp_def3
            res_list.appendleft(A_odered.popleft())
        else:
            res += temp_def4
            res_list.append(A_odered.popleft())
    # print(res_list)
    print(res)
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 8880
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	string s;
	cin >> s;
	
	int ans = 0;
	int tmp = 0;
	for(int i=0;i<s.length();i++){
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') tmp++;
		else{
			ans = max(ans,tmp);
			tmp = 0;
		}
	}
	ans = max(ans, tmp);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
  if(b == 0) return a;
  gcd(b,a%b);
}


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

  vector<ll> dp0(N);//dp0[i]はA[0]~A[i]までのgcd
  vector<ll> dp1(N);//dp1[i]はA[i]~A[N-1]までのgcd
  dp0[0] = A[0];
  dp1[N-1] = A[N-1];
  for(int j = 1;j<=N-1;j++){
    dp0[j] = gcd(dp0[j-1],A[j]);
    dp1[N-1-j] = gcd(dp1[N-j],A[N-1-j]);
 }
  
  vector<ll> ans(N);//ans[i]はA[i]以外の要素のgcd
  ans[0] = dp1[1];
  ans[N-1] = dp0[N-2];
  for(int i = 1;i<=N-2;i++){
    ans[i] = gcd(dp0[i-1],dp1[i+1]);
  }
  sort(ans.begin(),ans.end());
  cout <<ans[ans.size()-1] << endl;

}

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

int main() {
  string s;cin>>s;
  int n=s.size();
  rep(bit,1<<(n-1)){
    int cnt=s[0]-'0';
    string t;
    t+=s[0];
    rep(i,n-1){
      if(bit&(1<<i)){
        cnt+=s[i+1]-'0';
        t+='+';
        t+=s[i+1];
      }
      else{
        cnt-=s[i+1]-'0';
        t+='-';
        t+=s[i+1];
      }
    }
    if(cnt==7){
      cout<<t<<"=7"<<endl;
      return 0;
    }
  }
}
      

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>
#define INF 1000000007
const int m=998244353;
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}



int32_t main(){
	
	//FIO();
	string s;cin>>s;
	vi dp((int)s.length());
	dp[0]=(s[0]=='R'?1:0);
	for(int i=1; i<(int)s.length(); i++){
		if(s[i]!='R')dp[i]=0;
		else
			dp[i]=dp[i-1]+1;
	}
	
	int mx=dp[0];
	for(auto x:dp)
		mx=max(mx,x);
	cout<<mx;

	return 0;
	
		
}


			

Measured memory_bytes: 3632
#include <stdio.h>
int main(void) {
    int num[31]={0},i,temp;
    for (i=0; i<28; i++) {
        scanf("%d\n",&temp);
        num[temp]++;
    }
    for (i=1; i<=30; i++) {
        if (num[i]==0) printf("%d\n",i);
    }
    return 0;
}


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

map<string,lli>mp;

int main()
{
   lli query;
   scanf("%lld", &query);
   while(query--)
   {
       int c;

       scanf("%d", &c);
       if(c==0)
       {
            char key[25];
            scanf("%s", &key);
            lli value;
            scanf("%lld", &value);
            bool exists = (mp.find(key) != mp.end());
            if(exists==0)mp.insert(pair<string,lli>(key,value));
            else
            {
                mp.erase(key);
                mp.insert(pair<string,lli>(key,value));
            }
       }
       else if(c==1)
       {
            char str[25];
            scanf("%s", &str);
            bool exists = (mp.find(str)!= mp.end());
            if(exists!=0)printf("%lld\n",mp.at(str));
            else printf("0\n");
       }
       else if(c==2)
       {
            char str[25];
            scanf("%s", &str);
            mp.erase(str);
       }
   }
   return 0;
}



Measured memory_bytes: 26000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
string s;

void f(ll n) {
    n--;
    if(n/26 > 0) {
        s += 'a' + n % 26;;
        f(n/26);
    }
    else {
        s += 'a' + n % 26; 
    }

}
 
int main() {

    ll n;
    cin >> n;

    f(n);
    reverse(all(s));

    cout<<s<<endl;

 return 0;
}

Measured memory_bytes: 3636
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str1 = br.readLine();
      String str2[] = str1.split(" ");
      int a = Integer.parseInt(str2[0]);
      int b = Integer.parseInt(str2[1]);
      int c = a*b;
      int d = 2*(a+b);
      System.out.println( c + " " + d );

   }
}

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

int isprime(int x){
  int i;
  if(x == 2)return true;
  
  if(x < 2 || x%2==0)return false;
  
  i = 3;
  
  while(i*i <=x){
    if(x%i==0)return false;
    i = i + 2;
  }
  return true;
}

int main(){
  int i,n,cnt=0;
  cin >> n;
  for(i = 0;i < n; i++){
    // cout << "i " << i <<endl;
    int prime;
    cin >> prime;
    bool ans = isprime(prime);
    if(ans == 1)cnt++;
  }
   cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;

void insert(int);
void preorder(Node);
void inorder(Node);

int main(){
  int n, i, k;
  char I[10];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", I);
    if (I[0]=='i'){
      scanf("%d", &k);
      insert(k);
    } else {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;
    
 
  if (y == NIL)
    root=z;
  else if (z->key < y->key)
    y->left=z;
  else
    y->right=z;
}

void inorder(Node tree){
  if( tree != NIL){
    inorder(tree->left);
    printf(" %d",tree->key);
    inorder( tree->right);
  }
}

void preorder(Node tree){
  if( tree != NIL){
    printf(" %d",tree->key);
    preorder(tree->left);
    preorder(tree->right);
  }
}

Measured memory_bytes: 24036
n = int(input())
a = list(map(int, input().split()))

if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > (10**18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)

Measured memory_bytes: 21696
#include<stdio.h>
#include<string.h>
int map[100][100];
int main(){
	int n,m,i,a,b,j,sum;
	scanf("%d%d",&n,&m);
	memset(map,0,sizeof(map));
	for(i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		map[a][b]++;
		map[b][a]++;
	}
	for(i=1;i<=n;i++){
		sum=0;
		for(j=1;j<=n;j++){
			sum+=map[i][j];
		}
		printf("%d\n",sum);
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int count = 0;
  for (int i=0; i<3; i++){
    string digit = s.substr(i, 1);
    if (digit=="1"){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[128][2];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) REP(j, 2) scanf("%d", a[i]+j);
	REP(i, n-2){
		bool ok = true;
		REP(j, 3){
			if(a[i+j][0] != a[i+j][1]) ok = false;
		}
		if(ok) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}


Measured memory_bytes: 3760
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# f_inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	S = input()
	S = S[:-1]
	ans = ""
	for i in S:
		ans += "x"

	print(ans)

if __name__ == "__main__":
	main()


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




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	string s;
	cin >> s;
	int ans = 1e6;
	rep(i, s.size() - 2) {
		int a = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
		ans = min(ans, (abs(a - 753)));
	}
	cout << ans << endl;
	return 0;
}













Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s[i];
    sort(all(s));

    int sum = 0;
    rep(i, n) {
        sum += s[i];
    }

    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    
    rep(i, n) {
        if (s[i] % 10 != 0) {
            sum -= s[i];
            cout << sum << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

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

int N, ans, a[100];
double ave;

int main()
{
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", a + i);
    for (int i = 0; i < N; i++) ave += a[i];
    ave /= N;
    ans = 0;
    for (int i = 1; i < N; i++) if ((a[i] - ave)*(a[i] - ave) < (a[ans] - ave)*(a[ans]-ave)) ans = i;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

int a[10];
int b[10];
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;

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

	for (int x = 0; x <= 999; x++) {
		string s = to_string(x);
		if (s.size() != n)continue;
		bool f = true;
		if (x == 702) {
			int ttt = 0;
		}
		for (int i = 0; i < m; i++) {
			if (a[i] >= s.size() || s[a[i]] != b[i] + '0') f = false;
		}
		if (f) {
			cout << x << endl;
			return 0;
		}

	}
	cout << -1;

	return 0;
}

/*


*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;

  for(char i:s){
    if(i == '7'){cout<<"Yes"<<endl; return 0;}
  }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 3616
n,m = gets.chomp.split(" ").map{|item| item.to_i}
c = gets.chomp.split(" ").map{|item| item.to_i}
t = Array.new(n,50000)
t.unshift(0)
for i in 0..(m-1) do
  for j in c[i]..n do
    t[j] = (t[j] <= t[j-c[i]]+1) ? t[j] : t[j-c[i]]+1
  end
end
print("#{t[n]}\n")

Measured memory_bytes: 9248
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      if(n%2==0){
      	for(int i = n-1;i >= 1;i-=2)System.out.print(a[i]+" ");
        for(int i = 0;i <= n-2;i+=2)System.out.print(a[i]+" ");
        System.out.println("");
      }else{
      	for(int i = n-1;i >= 0;i-=2)System.out.print(a[i]+" ");
        for(int i = 1;i <= n-2;i+=2)System.out.print(a[i]+" ");
        System.out.println("");
      }
    }
}

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

const int maxn = 100010;
vector<int> g[maxn];

bool vis[maxn];

vector<int> ans0, ans1;

void extend(int u, vector<int>& ans) {
	ans.push_back(u);
	while(true) {
		int v = -1;
		for(auto x: g[u]) if(!vis[x]) { v = x; break; }
		if(v == -1) break;
		ans.push_back(v);
		vis[u = v] = true;
	}
}

int main() {
	int n, m, u, v;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; ++i) {
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vis[u] = vis[v] = true;
	extend(u, ans0);
	extend(v, ans1);
	printf("%lu\n", ans0.size() + ans1.size());
	reverse(begin(ans0), end(ans0));
	for(auto x: ans0) printf("%d ", x);
	for(auto x: ans1) printf("%d ", x);
	return 0;
}


Measured memory_bytes: 6904
#include<iostream>
#include<algorithm>
using namespace std;
long long n,ans,a[5];
bool f=1;
main(){
    cin>>n;
    for(int i=0;i<5;i++){
        cin>>a[i];
        if(a[i]<n)f=0;
    }
    if(f){
        cout<<5<<endl;
        return 0;
    }
    sort(a,a+5);
    cout<<(n+a[0]-1)/a[0]+4<<endl;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

vector<long long> from_left, from_right;

int first_gte(vector<long long> &vec, long long val, int right)
{
	int left = 0;
	while (left < right)
	{
		int m = (left + right) / 2;
		if (vec[m] >= val)
		{
			right = m;
		}
		else
		{
			left = m + 1;
		}
	}
	return left;
}

int main()
{
#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);

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

	from_left.push_back(0);
	for (int i = 0; i < n; i++)
	{
		from_left.push_back(from_left.back() + arr[i]);
	}

	from_right.push_back(0);
	for (int i = n - 1; i >= 0; i--)
	{
		from_right.push_back(from_right.back() + arr[i]);
	}

	long long total_sum = from_left.back();
	long long best = total_sum;
	long long left_sum = arr[0] + arr[1];
	for (int i = 2; i + 1 < n; i++)
	{
		int left_idx = first_gte(from_left, (left_sum + 1LL) / 2LL, i);
		vector<pair<long long, long long>> vv_left;
		if (left_idx > 0)
			vv_left.push_back({ from_left[left_idx-1], left_sum - from_left[left_idx-1] });
		vv_left.push_back({ from_left[left_idx], left_sum - from_left[left_idx] });
		if (left_idx + 1 < i)
		{
			vv_left.push_back({ from_left[left_idx + 1], left_sum - from_left[left_idx + 1] });
		}

		long long right_sum = total_sum - left_sum;
		int right_idx = first_gte(from_right, (right_sum + 1LL) / 2LL, n - i + 1);
		vector<pair<long long, long long>> vv_right;
		if (right_idx > 0)	
			vv_right.push_back({ from_right[right_idx - 1], right_sum - from_right[right_idx - 1] });
		vv_right.push_back({ from_right[right_idx], right_sum - from_right[right_idx] });
		if (right_idx + 1 < (n - i + 1))
		{
			vv_right.push_back({ from_right[right_idx + 1], right_sum - from_right[right_idx + 1] });
		}

		for (auto x : vv_left)
		{
			
			for (auto y : vv_right)
			{
				long long minv = min(x.first, x.second), maxv = max(x.first, x.second);
				minv = min(minv, y.first); minv = min(minv, y.second);
				maxv = max(maxv, y.first); maxv = max(maxv, y.second);
				if (minv == 0)
					continue;
				best = min(best, maxv - minv);
			}
		}

		left_sum += arr[i];
	}

	cout << best;
	return 0;
}

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

// TOP FRONT RIGHT LEFT BACK BOTTOM 
string list[24] = {
	"012345","024135","031425","043215","103254","120534",
	"135024","152304","201453","215043","240513","254103",
	"304152","310542","345012","351402","402351","425031",
	"430521","453201","513240","521430","534120","542310"
};

bool used[8];
string data[8];
char puzzle[6][8];

// ô:number , ï:face ÉÎµÄ¢éÏÈtH[}bgBIíèÍ-1B
int connect[8][8] = {
	{-1},
	{0,3,-1},
	{1,1,-1},
	{0,1,2,2,-1},
	{0,5,-1},
	{1,5,4,3,-1},
	{2,5,5,1,-1},
	{3,5,4,1,6,2,-1}
};

bool ok(char a,char b){
	return ( a != b ) && ( toupper(a) == toupper(b) );
}

bool backTrack(int s){
	if(s == 8) return true;
	
	for(int d = 0 ; d < 8 ; d++){
		if(used[d] != 0) continue;
		used[d] = true;
		for(int i = 0 ; i < 24 ; i++){
			for(int j = 0 ; j < 6 ; j++)
				puzzle[s][j] = data[d][list[i][j]]	;
			
			bool f = true;
			for(int j = 0 ; connect[s][j] != -1 ; j += 2){
				int pos  = connect[s][j];
				int face = connect[s][j+1];
				f &= ok(puzzle[pos][5-face], puzzle[s][face]);
			}
			if(f)if(backTrack(s+1))return true;
		}
		used[d] = false;
	}
	return false;
}
int main(){
	for(int i = 0 ; i < 24 ; i++)
		for(int j = 0 ; j < 6 ; j++)
			list[i][j] -= '0';

	while(cin >> data[0] , data[0] != "0"){
		for(int i = 1 ; i < 8 ; i++)
			cin >> data[i];
		memset(used,0,sizeof(used));
		cout << (backTrack(0)?"YES":"NO") << endl;
	}
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
use = [False]*n
mx = max(a)
if mx < 0:
    use[a.index(mx)] = True
else:
    evn = sum(max(i, 0) for i in a[::2])
    odd = sum(max(i, 0) for i in a[1::2])
    mx = max(evn, odd)
    for i in range(int(evn<odd), n, 2):
        if a[i] > 0:
            use[i] = True
print(mx)
beg = 0
while not use[beg]:
    beg += 1
res = [1]*beg
end = n-1
while beg < end:
    if use[end]:
        if use[end-2]:
            a[end-2] += a[end]
            res.append(end-beg)
            end -= 2
            use[end] = True
        else:
            res.append(end-beg-1)
            a[end-2] = a[end]
            end -= 2
            use[end] = True
    else:
        res.append(end-beg+1)
        end -= 1
print(len(res))
for i in res:
    print(i)

Measured memory_bytes: 3316
object Main {

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

    def combinationTable(n: Int): Array[Array[Long]] = {
      val C = Array.fill(n+1, n+1)(1L)
      (2 to n) foreach { i =>
        (1 until i) foreach { j =>
          C(i)(j) = C(i-1)(j-1) + C(i-1)(j)
        }
      }
      C
    }


    // 品物の中で, 大きい順にA個選べば良い？
    // 同じ平均になる選び方が何通りあるか?
    // 最後に取った数と同じものが何個あるか？で決まる？

    val N, A, B = sc.nextInt()

    val C = combinationTable(N)
    val V = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)
    val ave = V.take(A).sum / A.toDouble

    println(ave)
    if (V.takeWhile(_ == V(0)).length >= A) {
      val length = V.takeWhile(_ == V(0)).length
      println((A to Math.min(length, B)).foldLeft(0L)((b, n) =>
        b + C(length)(n)
      ))
    } else {
      val b = V.take(A)
      val r = b.count(_ == V(A-1))
      val n = V.count(_ == V(A-1))
      println(C(n)(r))
    }
  }

}


Measured memory_bytes: 27296
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 N              PIC 9(10).
01 S              PIC X(50).
01 cnt            PIC 9(10).
01 ans            PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT S.
  INSPECT S TALLYING cnt FOR ALL "ABC".
  MOVE cnt TO ans.
  DISPLAY ans.
  STOP RUN.


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

int main() {
  int ae[5], k;

  for (int i = 0; i < 5; i++) cin >> ae[i];
  cin >> k;

  string ans;
  if (ae[4] - ae[0] <= k)
    ans = "Yay!";
  else
    ans = ":(";

  cout << ans << endl;

  return 0;
}


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

int main() {
  int N, A , B;
  
  cin >> N >> A >> B ;
  
  int a = A*N;
  int b = B;

  if(a <= b ){
    cout << a << endl;
  }
  else{
    cout << b << endl;
  }

  // ここにプログラムを追記
}


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

int bubbleSort(int a[],int n){

    int c = 0;
    for(int i=0;i<n-1;i++){
        for(int j=n-1;j>0;j--){
            if(a[j]<a[j-1]){
                int tmp = a[j];
                a[j]=a[j-1];
                a[j-1]=tmp;
                c++;
            }
        }
    }

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

    return c;
}

int main(void){

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

    int c = bubbleSort(a,n);

    cout<<c<<endl;

    return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    int h, w;
    cin >> h >> w;

    vector<vi> a(h, vi(w, 0));
    rep(i, h) rep(j, w) cin >> a[i][j];

    vector<vector<bool>> b(h, vector<bool>(w, false));

    vector<vector<int>> v(h * w, vector<int>(4, -1));

    int cnt = 0;
    for (int i = 0; i < h; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; j++) {
                if (a[i][j] % 2 == 1) {
                    if (j == w - 1) {
                        if (i != h - 1) {
                            v[cnt][0] = i + 1;
                            v[cnt][1] = j + 1;
                            v[cnt][2] = i + 1 + 1;
                            v[cnt][3] = j + 1;
                            cnt++;

                            a[i][j]--;
                            a[i + 1][j]++;
                        }
                    } else {
                        v[cnt][0] = i + 1;
                        v[cnt][1] = j + 1;
                        v[cnt][2] = i + 1;
                        v[cnt][3] = j + 1 + 1;
                        cnt++;

                        a[i][j]--;
                        a[i][j + 1]++;
                    }
                }
            }
        } else {
            for (int j = w - 1; j >= 0; j--) {
                if (a[i][j] % 2 == 1) {
                    if (j == 0) {
                        if (i != h - 1) {
                            v[cnt][0] = i + 1;
                            v[cnt][1] = j + 1;
                            v[cnt][2] = i + 1 + 1;
                            v[cnt][3] = j + 1;
                            cnt++;

                            a[i][j]--;
                            a[i + 1][j]++;
                        }
                    } else {
                        v[cnt][0] = i + 1;
                        v[cnt][1] = j + 1;
                        v[cnt][2] = i + 1;
                        v[cnt][3] = j -1 + 1;
                        cnt++;

                        a[i][j]--;
                        a[i][j - 1]++;
                    }
                }
            }
        }
    }

    cout << cnt << endl;
    rep(i, cnt) {
        cout << v[i][0] << " " << v[i][1] << " " << v[i][2] << " " << v[i][3] << endl;
    }
    //cout << endl;
}

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

int n;
long long x,pre[300005],R,L,mid,ans,pre2[300005];
int cnt[300005];

bool cek(long long x, int k){
	if(x==0) return 1;
//	printf("%lld %d\n",x,k);
	long long butuh = x*k;
	long long tmp = x*(pre2[300000]-pre2[x]) + pre[x];
//	printf(">> %lld %lld\n",butuh,tmp);
	if(tmp>=butuh) return 1;
	return 0;
}

int main(){
	scanf("%d",&n);
	for(int i =0;i<n;i++){
		scanf("%lld",&x);
		cnt[x]++;
	}
	for(int i= 1;i<=300000;i++){
		if(cnt[i]!=0){
			pre[cnt[i]]++;
		}
	}
	
	for(int i =1;i<=300000;i++){
		pre2[i] = pre2[i-1]+pre[i];
		pre[i] = (pre[i]*i)+pre[i-1];
		
//		printf("pre[%d] = %lld\n",i,pre[i]);
	}
	
	for(int k= 1;k<=n;k++){
		L = 0; R = n/k;
		ans = 0;
		while(L<=R){
			mid = (L+R)/2;
			if(cek(mid,k)){
				ans = max(mid,ans);
				L = mid+1;
			} else {
				R = mid-1;
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  vector<pair<int, int>> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  vector<int> t(D);
  
  cin >> D;
  for(int i = 0; i < 26; i++){
    cin >> c.at(i).first;
    c.at(i).second = 0;
  }
  
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> s.at(i).at(j);
    }
  }
  
  cout << endl;
  for(int i = 0; i < D; i++){
    cin >> t.at(i);
  }
  
  int Pl = 0;
  int Mi = 0;
  for(int i = 0; i < D; i++){
    Pl += s.at(i).at(t.at(i)-1);
    c.at(t.at(i)-1).second = i + 1;
      for(int j = 0; j < 26; j++){
        Mi += c.at(j).first*(i+1 - c.at(j).second);
      }
    Pl -= Mi;
    Mi = 0;
    cout << Pl << endl;
  }    
}


Measured memory_bytes: 7564
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int R, G;
    io.read(R, G);
    cout << G + G - R;
    return 0;
}

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

using namespace std;
using ll=long long;

int main()
{
    string s;cin >>s;
    int co=0,cu=0;
    for(int i=0;i<(int)s.size();i++){
        if(s[i]=='0')co++;
        if(s[i]=='1')cu++;
    }
    cout <<min(co,cu)*2<< endl;
   return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<double> v(n); for (auto&& e : v) cin >> e;
  sort(begin(v), end(v));
  double res = v[0];
  for (int i = 1; i < n; ++i) {
    res = (res + v[i]) / 2;
  }
  cout << fixed << setprecision(15) << res << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    cout << (A==B &&  A==C ? "Yes" : "No") <<  endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.math.*;
import java.io.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = Math.abs(sc.nextLong());
        long K = sc.nextLong();
        long D = sc.nextLong();

        long straight = X/D;
        if(straight >= K) System.out.println(X-K*D);
        else{
            X %= D;
            K -= straight;
            if(K%2==0) System.out.println(X);
            else System.out.println(D-X);
        }

    }
}


Measured memory_bytes: 35688
#include<stdio.h>
#include<string.h>

int main(){

	int H,W = 0;
	scanf("%d %d",&H,&W);

	char	C[2*H][W];

	for(int i=0; i<H; i ++){
		scanf("%s",C[i]);	
		printf("%s\n",C[i]);
		printf("%s\n",C[i]);
	}

	return 0;


}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int H, W, i, j;

  while(1){
  scanf("%d %d", &H, &W);
  if(H == 0 && W == 0)break;
  
  
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      printf("#");
     }
    printf("\n");
  }
  printf("\n");
 }
  return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,x,l,ans=1,n,m; cin>>N;
  vector<vector<ll>> A(N,vector<ll>(2,0));
  for(int i=0; i<N; i++){
    cin>>x>>l;
    A[i][0]=x-l;
    A[i][1]=x+l;
  }
  std::sort(A.begin(), A.end(), [](auto& y, auto& z){return y[0] < z[0];});
  ll a=A[0][0], b=A[0][1];
  for(int i=1; i<N; i++){
    a=A[i][0];
    if(b<=a){
      ans++, b=A[i][1];
    }
    if(b>A[i][1]) b=A[i][1];
//    cout<<"i:"<<i<<" a:"<<a<<" b:"<<b<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5760