akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<limits.h>
using namespace  std;
typedef long long int ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define filla(a,k,n) memset(a,k,sizeof(a[0])*n)
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	ll dp[n]={0};
	if(n>1)
	{
		dp[1] = abs(a[0]-a[1]);
		for(ll i=2;i<n;i++)
		{
			dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

a,b,c,d = map(int,stdin.readline().rstrip().split())

ma = -10**18

for i in (a,b):
    for j in (c,d):
        ma = max(ma,i*j)

print(ma)

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

int gcd(int x, int y){
    if(x<y){
        int tmp = y;
        y = x;
        x = tmp;
    }
    while(y>0){
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}


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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if(y+r<=H && x+r<=W && x-r>=0 && y-r>=0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main(){
    long int n,power=1;
    cin >> n;
    for(int i=2;i<=n;i++){
        power*=i;
        if(power>1000000000){power%=(1000000000+7);}
    }
    power%=(1000000000+7);
    cout << power << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

int main() {
	string s[3];
	repi(i, 0, 3) rd(s[i]);
	if (s[0][s[0].length() - 1] == s[1][0] && s[1][s[1].length() - 1] == s[2][0]) wrln("YES");
	else wrln("NO");
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc128/tasks/abc128_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, k: usize,
        gems: [i32; n]
    };

    let mut answer = 0;
    for i in 0..n {
        for j in i..n+1 {
            let mut removed = vec![];
            let mut hand = 0;
            for k in 0..n {
                if i <= k && k < j {
                } else {
                    hand += gems[k];
                    removed.push(gems[k]);
                }
            }
            // debug!(i, j, hand, removed);
            removed.sort();
            if k < removed.len() {
                continue;
            }
            let left_ops = k-removed.len();
            answer = max(answer, hand);
            for i in 0..min(removed.len(), left_ops) {
                hand -= removed[i];
                answer = max(answer, hand);
            }
        }
    }
    println!("{}", answer);
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int dp[100005];
void solve(){
	int n,k;
	cin>>n>>k;
	int a[n];
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) dp[i]=hell;
	dp[0]=0;
	rep(i,1,n) {
		rep(j,1,k+1) {
			dp[i]=min(dp[i],(i-j>=0)?dp[i-j]+abs(a[i-j]-a[i]):hell);
		}
	}
	cout<<dp[n-1]<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
    // cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 5216
N = int(input())
A = list(map(int,input().split()))
#%%
bi = [[0]*20 for _ in range(N)]

state = [False]*20

for i,a in enumerate(A):
    tmp = a
    idx = 0
    while tmp>0:
        bi[i][idx] = tmp%2
        tmp >>= 1
        idx += 1

ans = 0
left = 0
right = 1

def upt(state,b):
    for i in range(20):
        if b[i]:
            state[i] = True
    return state
    
def rmv(state,b):
    for i in range(20):
        if b[i]:
            state[i] = False
    return state

def judge(state,b):
    for i in range(20):
        if state[i] and b[i]:
            return False
    return True

state = upt(state,bi[0])
#%%
while right<N:
    if judge(state,bi[right]):
        state = upt(state,bi[right])
        right += 1
    else:
        ans += right-left
        state = rmv(state,bi[left])
        left += 1

L = right - left
ans += L*(L+1)//2

print(ans)

Measured memory_bytes: 123084
#include <iostream>
using namespace std;
 
int main(){
    double v;
    while( cin >> v ){
        double t, y;
        t = v / 9.8;
        y = 4.9 * t * t;
        int floar = (y + 5) / 5 + 1;
        cout << floar << endl;
    }
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s,t,u;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  cin>>u;
  if(u==s)
    a--;
  else
    b--;
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char n;
int a,b;
int main()
{
    cin>>a>>b;
    for(int s=0;s<a;s++)
    {
        cin>>n;
        if(n<'0'||n>'9')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cin>>n;
    if(n!='-')//判断第a+1
    {
        cout<<"No"<<endl;
        return 0;

    }
    for(int s=0;s<b;s++)
    {
        cin>>n;
        if(n<'0'||n>'9')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl; 
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main  implements Runnable {

    public static void main(String[] args) {

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
		//long n = Long.parseLong(sc.next());
    	int[] ar = new int[3];
    	ar[0]=Integer.parseInt(sc.next());
    	ar[1]=Integer.parseInt(sc.next());
    	ar[2]=Integer.parseInt(sc.next());
    	Arrays.parallelSort(ar);
		//int p = Integer.parseInt(sc.next());
		//int q = Integer.parseInt(sc.next());
		//int r = Integer.parseInt(sc.next());
		//int a = Integer.parseInt(sc.next())-1;
		//int b = Integer.parseInt(sc.next())-1;
		//int c = Integer.parseInt(sc.next())-1;
		//int d = Integer.parseInt(sc.next())-1;
		//String s = sc.next();
		//int k = Integer.parseInt(sc.next());
		//int m = Integer.parseInt(sc.next());
		//int x2000 = Integer.parseInt(sc.next());
		//int t = Integer.parseInt(sc.next());
		//int k = 0;
		//int k = Integer.parseInt(sc.next());
		///String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//int atmp[] = new int[h];
		//int max= 0;
		//int blackar[][] = new int[h*w][2];
		//int p=0;
		//ArrayList<MyClass> lists = new ArrayList<>();;
		//lists = new ArrayList;
		PrintWriter out = new PrintWriter(System.out);
		out.println(ar[0]+ar[1]);

		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }

}

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

int main() {
    int N,a,b,c,d;
    cin >> N;
    vector<vector<int> > vec(12,vector<int>(10));
    
    for(int i = 0; i < 12; i++){
        for(int j = 0; j < 10 ;j++){
            vec.at(i).at(j) = 0;
        }
    }
    
    for(int i = 0; i < N; i++){
        cin >> a >> b >> c >> d;
        vec.at(a*3-2+b-1-1).at(c-1) += d;
    }
    
    for(int i = 0; i < 12; i++){
        for(int j = 0; j < 10 ;j++){
            cout << " " << vec.at(i).at(j) ;
        }
        
        cout << endl;
        
        if(i%3 == 2 && i < 11){
            cout << "####################"  << endl;
        }
    }
}


Measured memory_bytes: 3148
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	r := 15 - len(s)
	w := 0
	for _, v := range s {
		if v == 'o' {
			w++
		}
	}
	if r+w >= 8 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 6)

def dfs(v):
    check[v] = True
    for u, w in T[v]:
        if check[u]:
            continue
        dist[u] = dist[v] + w
        dfs(u)

N = int(input())
T = [[] for _ in range(N+1)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    T[u].append((v, w))
    T[v].append((u, w))

dist = [0] * (N + 1)
check = [False] * (N + 1)
dfs(1)

print(*[d % 2 for d in dist[1:]], sep="\n")

Measured memory_bytes: 84440
I=lambda:map(int,input().split());n,m=I();d=[0]+[9**9]*2**n
while m:
 m-=1;a,_=I();s=sum(1<<c-1for c in I())
 for j in range(2**n):d[s|j]=min(d[s|j],d[j]+a)
print(d[-2]%9**9or-1)

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

long long gcd(long long x,long long y){return y?gcd(y,x%y):x;}

int main(void){
  int n, g, ans=0;
  
  cin >> n;
  for (int a=1; a<=n; a++){
    for (int b=1; b<=n; b++){
      g = gcd(a,b);
      for (int c=1; c<=n; c++){
        ans += gcd(g,c);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main()
{
  uint64_t N, X;
  cin >> N >> X;
  vector<uint64_t> v {X};
  for (auto i = 0; i < N; i++) {
    uint64_t x;
    scanf("%lu", &x);
    v.push_back(x);
  }
  sort(begin(v), end(v));
  vector<uint64_t> distance;
  for (auto i = 1; i < v.size(); i++) {
    distance.push_back(v[i] - v[i - 1]);
  }
  sort(begin(distance), end(distance));
  uint64_t n {distance[0]};
  for (auto i = 0; i < distance.size(); i++) {
    n = __gcd(n, distance[i]);
  }
  cout << n << endl;
}


Measured memory_bytes: 2548
#!/usr/bin python3
# -*- coding: utf-8 -*-

#最小全域木　クラスカル法
# 重み付き無向グラフで、それらの全ての頂点を結び連結するような木の最小のコストを求める
# 辺の重みの小さい順にみて、連結成分が閉路にならない辺を追加していく
# つなぐ頂点が同じ連結成分にないことをUnion Find Tree でみる

INF = float('inf')

class UnionFind():
    def __init__(self, n):      #初期化
        self.n = n
        # 親
        self.parents = [i for i in range(n)]
        # 木の深さ
        self.ranks = [0] * n

    def find(self, x):          #親を出力
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.ranks[x] < self.ranks[y]:
            self.parents[x] = y
        else:
            self.parents[y] = x
            if self.ranks[x]==self.ranks[y]:
                self.ranks[x] += 1

    def same(self, x, y):       #xとyが同じグループかどうか
        return self.find(x) == self.find(y)

def kruskal(n, edges):
    uf = UnionFind(n)
    ret = 0
    for w, u, v in edges:
        if not uf.same(u, v):
            ret += w
            uf.unite(u, v)
    return ret

def main():
    N = int(input())
    #リストの作成
    L = [None]*N
    for i in range(N):
        x, y = map(int,input().split())
        L[i]=(x, y, i)
    Edges = []
    for i in range(2):
        L.sort(key=lambda x:x[i])
        for j in range(N-1):
            Edges.append( (L[j+1][i]-L[j][i], L[j][2], L[j+1][2]) )
    Edges.sort()

    print(kruskal(N, Edges))

if __name__ == '__main__':
    main()

Measured memory_bytes: 48716
N, M = gets.split.map(&:to_i)
ABs = N.times.map{gets.split.map(&:to_i)}
CDs = (1 .. M).map{|i| [i, *gets.split.map(&:to_i)]}

ABs.each{|a, b| puts CDs.map{|i, c, d| [(a - c).abs + (b - d).abs, i]}.min.last}

Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys

def find_array(N: int, Y: int):
    for a in range(N + 1):
        for b in range(N - a + 1):
            c = N - a - b
            if a * 10000 + b * 5000 + c * 1000 == Y:
                return [a, b, c]
    return [-1, -1, -1]

def solve(N: int, Y: int):
    array = find_array(N, Y)
    print(' '.join(map(str,array)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);


	ll x, d, k;
	cin >> x >> k >> d;

	if(x > 0)
		x = -x;

	ll lo = 0, hi = min(k, (ll)1e18 / d), opt = -1;

	while(lo <= hi){
		ll mid = (lo + hi) >> 1ll;
		ll pos = x + mid * d;
		if(pos <= 0){
			opt = mid;
			lo = mid + 1;
		}
		else hi = mid - 1;
	}

	vector<ll> vals;

	ll s1 = x + opt * d;
	vals.push_back(s1);
	
	if(opt < k)
		vals.push_back(s1 + d);
	else
		vals.push_back(s1 - d);

	ll rem = k - opt;
	cout << abs(vals[rem % 2]) << endl;
	
	return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;
        
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] pArray = new int[n];
        int answer = 0;

        for (int i = 0; i < n; i++) {
            pArray[i] = sc.nextInt();
        }

        for (int i = 0; i < 100; i++) {
            // x ± iがpArrayの中に存在しなかったらそれを答えとする
            boolean existFlag = false;
            for (int j = 0; j < n; j++) {
                if (pArray[j] == x - i) {
                    existFlag = true;
                }
            }
            if (!existFlag) {
                answer = x - i;
                break;
            }
            boolean existFlag2 = false;
            for (int j = 0; j < n; j++) {
                if (pArray[j] == x + i) {
                    existFlag2 = true;
                }
            }
            if (!existFlag2) {
                answer = x + i;
                break;
            }
        }

        System.out.println(answer);
    }
}

Measured memory_bytes: 35816
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> P(N, 0);
	for (int i = 0; i < N; i++)
	{
		cin >> P[i];
		P[i]--;
	}

	int result = 0;
	for (int i = 0; i < N - 1; i++)
	{
		if (P[i] == i)
		{
			swap(P[i], P[i + 1]);
			result++;
		}
	}

	if (P[N - 1] == N - 1)
	{
		result++;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <unordered_map>
#include <queue>

int a[2][4] , stx , sty , nx;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
std::unordered_map <int , int> st;
struct node{
    int x;
    int step;
};
void fx(int y){
    for(int i = 0;i < 2;i++){
        for(int j = 0;j < 4;j++){
            a[i][j] = y % 8;
            y = (int)(y / 8);
            if(a[i][j] == 0){
                stx = j , sty = i; 
            }
        }
    }
}
bool f(int k){
    if(stx + dirc[k][0] < 0 || stx + dirc[k][0] >= 4 || sty + dirc[k][1] < 0 || sty + dirc[k][1] >= 2){
        return false;
    }
    nx = 0;
    int tmp = 1;
    for(int i = 0;i < 2;i++){
        for(int j = 0;j < 4;j++){
            if(i == sty && j == stx){
                nx += tmp * a[sty + dirc[k][1]][stx + dirc[k][0]];
            }else if(i == sty + dirc[k][1] && j == stx + dirc[k][0]){
                nx += 0;
            }else{
                nx += tmp * a[i][j];
            }
            tmp *= 8;
        }
    }
    return true;
}
int main(){
    st[16434824] = 0;
    node nod;
    nod.x = 16434824 , nod.step = 0;
    std::queue <node> que;
    que.push(nod);
    while(!que.empty()){
        nod = que.front();
        que.pop();
        fx(nod.x);
        for(int i = 0;i < 4;i++){
            if(f(i)){
                if(st.find(nx) == st.end()){
                    st[nx] = nod.step + 1;
                    node nod1;
                    nod1.x = nx , nod1.step = nod.step + 1;
                    que.push(nod1);
                }
            }
        }
    }
    while(std::cin >>a[0][0]>>a[0][1]>>a[0][2]>>a[0][3]>>a[1][0]>>a[1][1]>>a[1][2]>>a[1][3]){
        int mark = 0 , tmp = 1;
        for(int i = 0;i < 2;i++){
            for(int j = 0;j < 4;j++){
                mark += tmp * a[i][j];
                tmp *= 8;
            }
        }
        std::cout << st.at(mark) << "\n";
    }
}


Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")



#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const int D = 310;
const double EPS = 1e-9;


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

ll dp[MX][D];
deque<ll> mx[D];


ll get(int i) {
    if (mx[i].empty())
        return 0;
    return mx[i].front();
}

void add(int i, ll x) {
    while (mx[i].size() && mx[i].back() < x)
        mx[i].ppb;
    mx[i].pb(x);
}

void del(int i, ll x) {
    if (mx[i].size() && mx[i].front() == x)
        mx[i].pop_front();
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
       
    int n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    fi(0, n) {
        ll a;
        cin >> a;
        fj1(min(i + 1, k) + 1, 1) {
            if (i >= m)
                del(j, dp[i - m][j]);
            dp[i][j] = a * j + get(j - 1);
            add(j, dp[i][j]);
        }
        maxe(ans, dp[i][k]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 246072
<?php
fscanf(STDIN, "%d %d", $a, $b);

if($a == 1){
    $a = 14;
}
if($b == 1){
    $b = 14;
}

if($a > $b){
    echo ("Alice");
} elseif ($a < $b) {
    echo("Bob");
} else {
    echo("Draw");
}


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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}

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

int main() {
    FAST
    ll a;
    cin>>a;
    ll sum=100;
    ll c=0;
    while(sum<a)
    {
        ll inc=sum*0.01;
        sum+=inc;
        c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        static long pow(long a , long b , long m){
            long res = 1;
            a%=m;
            while (b>0){
                if ((b&1)==1)res*=a%m;
                a = a*a%m;
                b>>=1;
            }
            return res;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out){
            int n  = in.nextInt();
            int m = in.nextInt();
            int[] wr = new int[n+1];
            boolean[] ac = new boolean[n+1];
            for (int i = 0; i <m ; i++) {
                int p = in.nextInt();
                String s = in.next();
                if (!ac[p]){
                    if (s.equals("WA"))wr[p]++;
                    else ac[p]=true;
                }
            }
            int na = 0;
            int pen = 0;
            for (int i = 1; i <=n ; i++){
                if (ac[i]){
                    pen+=wr[i];
                    na++;
                }
            }
            System.out.println(na+" " +pen);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 41420
#include <cmath>
#include <iostream>
#include <vector>

int main() {
	int D, N;
	std::cin >> D >> N;

	int result;

	result = N * std::pow(100, D);
	if(N == 100) {
		result += std::pow(100, D);
	}
	
	std::cout << result << std::endl;

	return 0;
}

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

using namespace std;

int maxvalue(int, int);
int N, W, v[100], w[100], dp[101][10101];
int main(void){
  scanf("%d %d", &N, &W);
  for(int i = 0; i < N; ++i){
    scanf("%d %d", v + i, w + i);
  }

  for(int i = N - 1; i >= 0; --i){
    for(int j = 0;j <= W; ++j){
      if(j < w[i]){
        dp[i][j] = dp[i + 1][j];
      }else{
        dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      }
    }
  }

  printf("%d\n", dp[0][W]);
  return 0;
}



Measured memory_bytes: 7144
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int i=1,n=sc.nextInt();
		while(i<=n){
			int x=i;
			if(x%3==0){
				System.out.printf(" %d",i);
			}else{
				while(x>=1){
					if(x%10==3){
						System.out.printf(" %d",i);
						break;
					}
					x/=10;
				}
			}
			i++;
		}
		System.out.printf("\n");
	}
};



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

using namespace std;

const int INF = 1 << 30;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  vector<int> dp(H + 1, INF);
  dp[0] = 0;
  for (int h = 0; h < H; h++) {
    for (int i = 0; i < N; i++) {
      dp[min(h + A[i], H)] = min(dp[min(h + A[i], H)], dp[h] + B[i]);
    }
  }
  cout << dp[H] << '\n';
  return 0;
}


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

int main(){
    int n;
    string s;

    cin >> n >> s;

    int left = 0, right = 0, stack = 0, closed = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '('){
            right++;
        }else if(s[i] == ')'){
            left++;
            if(right > 0)  right--, left--;
        }
    }

    left -= closed;
    right -= closed;

    for(int i = 0; i < left; i++)   cout << '(';
    cout << s;
    for(int i = 0; i < right; i++)  cout << ')';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int X;
  cin>>X;
  int N=pow(X,0.2);
  for(int i=0;i<=N;i++)
    for(int j=i;j<=N;j++)
      if(i*i*i*i*i+j*j*j*j*j==X){
        cout<<i<<' '<<0-j<<endl;
        return 0;
      }
  int M=0;
  while(M*M*M*M*M-(M-1)*(M-1)*(M-1)*(M-1)*(M-1)<=X)
    M++;
  for(int i=0;i<=M;i++)
    for(int j=0;j<=i;j++)
      if(i*i*i*i*i-j*j*j*j*j==X){
        cout<<i<<' '<<j<<endl;
        return 0;
      }
}

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

#define AMAX 100001


struct card{
  char mark;
  int value;
  int cnt;
};

card a[AMAX];
int partion(int q, int r){
  int x = a[r].value;
  int i = q-1;
  for(int j = q; j < r; j++){
    if(a[j].value <= x){
      i = i + 1;
      swap(a[i],a[j]);
    }
  }
  swap(a[i+1],a[r]);
  return i+1;
}


void quicksort(int p, int r){

  if(p < r){
    int q;
    q = partion(p,r);
    quicksort(p,q-1);
    quicksort(q+1,r);
  }
}

int main(){

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

  for(int i = 0; i < n; i++){
    scanf(" %c %d",&a[i].mark,&a[i].value);
    a[i].cnt = i;
  }

  quicksort(0,n-1);
  int junge = 0;

  for(int i = 1; i < n; i++){
    if(a[i-1].value == a[i].value&&a[i-1].cnt>a[i].cnt)junge=1;
  }
  if(junge == 1) printf("Not stable\n");
  else  printf("Stable\n");

  for(int i = 0; i < n; i++){
    printf("%c %d\n",a[i].mark,a[i].value);
  }

}

Measured memory_bytes: 2368
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	return 0;
}


Measured memory_bytes: 3576
//cool
#include <iostream>
#include <fstream>
#include <set>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int lli;
typedef int ll;
#define lp(i, wwww) for(int i=0; i<wwww; i++)
#define lp2(i, a, b) for(int i=a; i<b; i++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define clean(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pb push_back

ll n, d, a[12][12], ans;

ll main(){
	IOS;
	cin >> n >> d;
	for (int i=0; i<n; i++){
		for (int j=0; j<d; j++){
			cin >> a[i][j];
		}
	}
	for (int ww=0; ww<n; ww++){
		for (int w=ww+1; w<n; w++){
			ll cnt=0;
			for (int i=0; i<d; i++){
				cnt+= ((a[w][i]-a[ww][i])*(a[w][i]-a[ww][i]));
			}
			ll s= sqrt(cnt);
			if (s*s == cnt){
				ans++;
			}
		}
	}
	cout << ans;
	return 0;
}


	


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

int main() {
	ll n, h[30], ans, k;
	ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> h[i];
	for (int i = 0; i < n; i++) {
		k = 0;
		for (int j = 0; j < i; j++) {
			if (h[j] <= h[i])k++;
		}
		if (i == k)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
a1 = [0]
for i in range(n):
    a1.append(a1[-1]+a[i])
def sumArea(l,r):
    return a1[r] - a1[l]

ans = inf
for i in range(1,n):
    ans = min(ans,abs(sumArea(0,i)-sumArea(i,n)))
print(ans)

Measured memory_bytes: 118672
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int[] T = new int[N];
		for(int i=0; i<N; i++)
			T[i] = sc.nextInt();
		
		Arrays.sort(T);
		int ans = 0;
		int num = 0;
		int first = T[0];
		for(int i=0; i<=N; i++) {
			if(i==N || first+K<T[i] || C<=num) {
				ans++;
				if(i<N) {
					first = T[i];
					num = 1;
				}
			} else {
				num++;
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 50672
#include <stdio.h>
#include <assert.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF (1<<28)
inline void cmin(int &a, int b) { if (a > b) a = b; }

int W, H, F, M, O, C[12][12], A[12][12];
int dp[12][12][12][2][64];

int main() {
    for (;;) {
        scanf("%d%d", &W, &H);
        if (W == 0 || H == 0) return 0;
        assert (3 <= W && W <= 10);
        assert (3 <= H && H <= 10);
        scanf("%d%d%d", &F, &M, &O);
        assert (1 <= F && F <= 10000);
        assert (3 <= M && M <= 50);
        rep (i, H) rep (j, W) {
            int c;
            scanf("%d", &c);
            if (c < 0) C[i][j] = -c, A[i][j] = 0;
            if (c >= 0) C[i][j] = 0, A[i][j] = c;
        }
        if (O <= 1) {
            puts("NA");
            continue;
        }
        rep (i, H) rep (j, W) rep (k, W) rep (l, 2) rep (m, M+1) {
            dp[i][j][k][l][m] = INF;
        }
        rep (i, W) dp[0][i][0][0][min(M, O-1+A[0][i])] = C[0][i];
        rep (k, H-1) rep (w, W) rep (i, W-w) rep (si, 2) rep (m, M+1) {
            const int j = i+w;
            if (i > 0) {
                const int d = si ? w+1 : 1;
                if (d < m) cmin(dp[k][i-1][w+1][0][min(M, m-d+A[k][i-1])],
                                dp[k][i][w][si][m] + C[k][i-1]);
            }
            if (j < W-1) {
                const int d = si ? 1 : w+1;
                if (d < m) cmin(dp[k][i][w+1][1][min(M, m-d+A[k][j+1])],
                                dp[k][i][w][si][m] + C[k][j+1]);
            }
            for (int x = i; x <= j; x++) {
                const int d = si ? j-x+1 : x-i+1;
                if (d < m) cmin(dp[k+1][x][0][0][min(M, m-d+A[k+1][x])],
                                dp[k][i][w][si][m] + C[k+1][x]);
            }
        }
        int ans = INF;
        rep (i, W) rep (m, M+1) cmin(ans, dp[H-1][i][0][0][m]);
        if (ans > F) puts("NA");
        else printf("%d\n", ans);
    }
}

Measured memory_bytes: 1640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]


def dfs(cur, a, b, c):
    INF = float("inf")
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return INF
    ret = dfs(cur + 1, a, b, c)
    ret_a = dfs(cur + 1, a + L[cur], b, c) + 10
    ret_b = dfs(cur + 1, a, b + L[cur], c) + 10
    ret_c = dfs(cur + 1, a, b, c + L[cur]) + 10
    return min(ret, ret_a, ret_b, ret_c)


def main():

    print(dfs(0, 0, 0, 0))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
using namespace std; 
int main(){
   string S;
   cin>>S;
   int a=0;
   for(int i=0;i<S.size()-3;i++){
      if(S.at(i+2)=='C') 
         a++;
      }
   int b=0;
   const string rk="abcdefghijklmnopqrstuvwxyz";
   for(int j=0;j<S.size();j++){
      if(rk.find(S.at(j))==string::npos)
         b++;
      }
   if(S.at(0)!='A')
   cout<<"WA"<<endl;
   else if(a!=1)
      cout<<"WA"<<endl; 
  else if(b!=2)
      cout<<"WA"<<endl;
   else
      cout<<"AC"<<endl;
}

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

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

int main(){
  int X; cin >> X;
  while(1){
    if(prime(X)){
      cout << X << endl;
      return 0;
    }
    X++;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define PI 3.14159265
ll exponent(ll x,ll n,ll m)
{  if(n==0)
    return 1;
    if(n%2!=0)
    {
        return (x*exponent(((x%m)*(x%m))%m,(n-1)/2,m))%m;
    }
    else
    return exponent(((x%m)*(x%m))%m,n/2,m);
}
ll find(ll fact[],ll invfact[],ll n,ll a,ll r)
{
    if(r>a)
        return 0;
    ll ans=fact[a];
    ans=(ans%mod*invfact[r]%mod)%mod;
    ans=(ans%mod*invfact[a-r]%mod)%mod;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(NULL);
    string s;
    ll n;
    cin>>n>>s;
    ll cnt=0;
    for(int i=0;i<=(s.size()-3);i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            cnt+=1;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>

using namespace std;
int N;
vector<int> v;

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

    int cnt = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if (v[i] > v[j]) {
                cnt++;
            }
        }
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < N - 1; i++) {
        cout << v[i] << " ";
    }
    cout << v[N - 1] << endl;
    cout << cnt << endl;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Linq;

namespace arc067_b
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long ret = 0;
            for (int i = 1; i < a[0]; i++)
            {
                ret += Math.Min(a[2], (x[i] - x[i - 1]) * a[1]);
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 20832
#include <bits/stdc++.h>
#define ll long long
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll tyo=(ll)1e12*2;
using namespace std;

int main(){
  ll N,A,B,ans=0;
  cin>>N>>A>>B;
  ans+=(N/(A+B))*A;
  ans+=min(N%(A+B),A);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $q);
fscanf(STDIN, "%s", $s);
$x[1] = 0;
for ($i = 1; $i < $n; $i++) {
	if ($s[$i-1] == 'A' && $s[$i] == 'C') {
		$x[$i+1] = $x[$i] + 1;
	} else {
		$x[$i+1] = $x[$i];
	}
}
while ($q--) {
	fscanf(STDIN, "%d %d", $l, $r);
	$t[] = $x[$r] - $x[$l];
}
echo implode("\n", $t);

Measured memory_bytes: 15472
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n=sc.nextLong();
        long m=1;
        long ans=0;
        while(true){
            if(m>=(n-m)/m){
                System.out.println(ans);
                return;
            }else if((n-m)%m==0){
                ans+=(n-m)/m;
            }
            m++;
        }
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  char now = ' ';
  rep (i, s.size()) {
    if (s[i] != now) {
      ans++;
      now = s[i];
    }
  }
  P(ans);

  return 0;
}





Measured memory_bytes: 512
function Main(input) {
  input = input.trim().split("\n");
  var K = parseInt(input[0], 10);
  var S = input[1];

  if (S.length <= K) {
    console.log(S);
    return;
  } else {
    var sa = S.substr(0, K);
    sa = sa + "...";
    console.log(sa);
    return;
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

  long a = 2;
  long b = 1;
  long c = 0;
  for(int i = 2; i <= n; i++){
    c = a + b;
    a = b;
    b = c;
  }
  if(n == 1)
    c = 1;
  cout << c << endl;
}


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

using namespace std;
typedef long long ll;
const ll INF = 1e15;
struct edge{int from, to; ll cost;

  edge (int f, int t, ll c) : from(f), to(t), cost(c) {}

};

int N,M;
vector<edge> e;
ll dist[1001];

int main() {
  cin >> N >> M;

  for(int i = 0; i < M; i++) {
    int a,b;
    ll c;
    cin >> a >> b >> c;
    a--; b--;
    e.push_back(edge(a,b,-c));
  }

 
  fill(dist,dist+N,INF);
  bool is = true;
  dist[0] = 0;
  int C = 0;
  for(int j = 0; j < N; j++) {
    for(int i = 0; i < e.size(); i++) {
      if(dist[e[i].from] == INF) continue;

      if(dist[e[i].to] > dist[e[i].from] + e[i].cost){
	dist[e[i].to] = dist[e[i].from] + e[i].cost;
	is = true;
	//	cout <<dist[e[i].to]<<endl;
	
      }
    }
  }
  ll heiro = dist[N-1];

   for(int j = 0; j < N; j++) {
    for(int i = 0; i < e.size(); i++) {
      if(dist[e[i].from] == INF) continue;

      if(dist[e[i].to] > dist[e[i].from] + e[i].cost){
	dist[e[i].to] = dist[e[i].from] + e[i].cost;
	is = true;
	//	cout <<dist[e[i].to]<<endl;
	
      }
    }
  }

   if(heiro <= dist[N-1]) {
     cout <<-dist[N-1] <<endl;
   }
   else cout <<"inf"<<endl;

}

  
  
  


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AOJ_console
{
    class _1_6_A
    {
        static void Main()
        {
            Console.ReadLine();
            Console.WriteLine(Console.ReadLine().Split(' ').Reverse<string>().Aggregate((ans, x) => ans + " " + x).Trim());
        }
    }
}

Measured memory_bytes: 9332