akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){ int n,m,div;
			int t[100];
			int h[100];
		while(1){
			cin >> n >>m ;
			if ((n == 0) && (m==0) ) break;
			int st=0,sh=0;
			for (int i = 0;i <n ;i++) {
				cin >>t[i];
				st += t[i];
			}
			for (int j = 0;j <m ;j++) {
				cin >>h[j];
				sh += h[j];
			}
			if ((st+sh)%2) cout << -1 <<endl;
			else {	int frag = 0;
					div =st- (st+sh)/2;
						for(int i = 0;i < n; i++){
							for(int j=0 ;j< m; j++){
								if (t[i]-h[j] == div){
									cout << t[i] <<" "<< h[j] <<endl;
									frag =1;
									break;
								}
								
							}
						if (frag) break;
						}
						if (frag == 0)cout <<-1 <<endl;
			}
		}
		return 0;
}

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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<int> H(N);

    for(int i = 0; i < N; i ++){
        cin >> H[i];
    }
    for(int i = N - 2; i >= 0; i --){
        if(H[i] <= H[i + 1]){
            // 問題なし
        }else{
            H[i] --;

            if(H[i] > H[i + 1]){
                cout << "No" << endl;

                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    k = min(k, 100LL);
    vec a = ivec(n);

    rep (t, k) {
        vec imos(n);
        rep (i, n) {
            int l = max(0LL, i - a[i]);
            int r = min(n - 1, i + a[i]);
            imos[l]++;
            if (r + 1 < n) imos[r + 1]--;
        }
        For(i, 1, n - 1) imos[i] += imos[i - 1];
        a = imos;
    }
    print(a);

    return 0;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) ||S.at(2) == S.at(1)||S.at(2) == S.at(3)){
    cout <<"Bad"<<endl;
    return 0;
  }
  cout << "Good"<< endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int N;
int h[100010];
int F[100010];
int A(int i) {
	if (F[i] >= 0) return F[i];
	if (i == 1) return abs(h[1] - h[0]);
	if (i == 0) return 0;
	F[i] = min(A(i - 2) + abs(h[i - 2] - h[i]), A(i - 1) + abs(h[i - 1] - h[i]));
	return F[i];
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		F[i] = -1;
	}
	cout << A(N - 1) << endl;
}

Measured memory_bytes: 4096
mod = 1000000007

N = int(input())
C = []
for i in range(N):
    c = int(input())
    if i == 0 or C[-1] != c:
        C.append(c)
cases = [1] * (len(C) + 1)
indexes = dict()
for i in range(1, 1 + len(C)):
    c = C[i - 1]
    if c not in indexes:
        cases[i] = cases[i - 1]
    else:
        cases[i] = (cases[i - 1] + cases[indexes[c]]) % mod
    indexes[c] = i
print(cases[len(C)])


Measured memory_bytes: 81240
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	ll k, a, b;
	cin >> k >> a >> b;
	a--;
	if(a / k == b / k) cout << "NG\n";
	else cout << "OK\n";
}



Measured memory_bytes: 3616
a,b=map(int,input().split())
e=[]
for i in range(a):
    c,d=map(int, input().split())
    e+=[[c,d]]
e.sort()
a=i=j=0
while i < b:
    a+=(e[j][0]*e[j][1])
    i+=e[j][1]
    j+=1
print(a-((i-b)*e[j-1][0]))

Measured memory_bytes: 19996
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	
    	int ans = a - 2*b;
    	
    	if(ans < 0) {
    		ans = 0;
    	}
    	
    	System.out.println(ans);

	}

}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int  no;
    cin>>no;
    long long int n=no,sum=0;
    while(no!=0)
    {
        sum=sum+no%10;
        no=no/10;
    }
    if(n%sum==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

long n, m;
long a[100000];
long cnt[51];

long dp[2][51];
long solve() {
  const long inf = 1e18;
  for (int p : { 0, 1 }) {
    for (int k = 0; k <= 50; ++k) {
      dp[p][k] = -inf;
    }
  }
  
  dp[1][50] = 0;
  for (int k = 49; k >= 0; --k) {
    int e = (m >> k) & 1;
    for (int p : { 0, 1 }) {
      if (dp[p][k + 1] == -inf) continue;
      for (int d : { 0, 1 }) {
        if (p == 1 && e == 0 && d == 1) continue;
        bool np = p && e == d;
        long del = (d ? n - cnt[k] : cnt[k]) << k;
        dp[np][k] = max(dp[np][k], dp[p][k + 1] + del);
      }
    }
  }
  return max(dp[0][0], dp[1][0]);
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int k = 0; k < 50; ++k) {
    for (int i = 0; i < n; ++i) {
      if ((a[i] >> k) & 1) ++cnt[k];
    }
  }
  
  cout << solve() << endl;
}

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

typedef long long ll;

int main() {
    int n;
    int total = 0;
    cin >> n;
    vector<int>s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        total += s[i];
    }
    if (total % 10 != 0) {
        cout << total << endl;
        return 0;
    } else {
        sort(s.begin(), s.end());
        for (int i = 0; i < n; i++) {
            if (s[i] % 10 != 0) {
                cout << total - s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
}


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

int main(){
    int N;  cin >> N;
    int ans = 0;
    for(int i=1; i<=N; i++){
        if(i%2==0) continue;
        int cnt = 0;
        for(int j=1; j<=i; j++){
            if(i%j==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if((c-1)/b<=(a-1)/d)cout<<"Yes";else cout <<"No";
    return 0;
}


Measured memory_bytes: 3636
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second

void solve()
{
  string s;
  cin >> s;
  int x1=0,y1=0,x2=0,y2=0;
  f(i,s.length())
  {
    if(s[i]=='N')
      x1=1;
    if(s[i]=='S')
      x2=1;
    if(s[i]=='E')
      y1=1;
    if(s[i]=='W')
      y2=1;
  }
  if(x1==x2 && y1==y2)
    cout << "Yes";
  else
    cout << "No";
  return;
}

signed main()
{
  FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,ans,p[15];
vector<int> g[15];
bool b[15];
bool check(){
	int sum;
	for(int i=0;i<m;i++){
		sum=0;
		for(int j=0;j<g[i].size();j++)sum+=b[g[i][j]];
		if(sum%2!=p[i]%2)return false;
	}
	return true;
}
void dfs(int x){
	if(x>=n){
		if(check())ans++;
		return ;
	}
	dfs(x+1);
	b[x]=true;
	dfs(x+1);
	b[x]=false;
}
int main(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int x,y;
		cin >> x;
		for(int j=0;j<x;j++){
			cin >> y;
			g[i].push_back(--y);
		}
	}
	for(int i=0;i<m;i++)cin >> p[i];
	dfs(0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  //define N and sum each number of N
  int N;
  cin >>N;
  
  int sum,x;
  sum = N % 10;
  x = 10;
  
  for(int i; i<8; i++){
    sum += (N%(x*10) - N%x)/x;
    x *= 10;
  }
  
  //Check out if N can be divided by sum
  if(N % sum ==0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int INF=1e10;

int main(){
	int x;
	cin >> x;
	if (x == 0) cout << 1<<endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 3620
N = int(input())
S = input()
L = ["A", "B", "C",
	 "D", "E", "F",
	 "G", "H", "I",
	 "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
	 "X", "Y", "Z"]
for x in S:
	i =( L.index(x)+N) % 26
	print(L[i],end="")

Measured memory_bytes: 4468
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
typedef pair< pairint , string> P;
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
bool pairCompare(const P& firstElof, const P& secondElof)
{
  if(firstElof.first.first!= secondElof.first.first)    return firstElof.first.first< secondElof.first.first;
else if(firstElof.first.second != secondElof.first.second)    return firstElof.first.second< secondElof.first.second;
else return false;
}
signed main() {
double x=0,y=0,z=0,w=0,n=0,m=0;
int a[4]={0,0,0,0},b[4]={0,0,0,0};
while(std::cin >> x>>y){
if(x>=1.1)a[0]++;
else if(x>=0.6)a[1]++;
else if(x>=0.2)a[2]++;
else a[3]++;

if(y>=1.1)b[0]++;
else if(y>=0.6)b[1]++;
else if(y>=0.2)b[2]++;
else b[3]++;
}
printf("%d %d\n%d %d\n%d %d\n%d %d\n",a[0],b[0],a[1],b[1],a[2],b[2],a[3],b[3]);
}



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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    int N; cin >> N;
    map<int, int> m;
    rep(i, N) {
        int a; cin >> a;
        m[a]++;
    }
    
    int ans = 0;
    int MAX = 1000000+1;
    vector<int> f(MAX);
    for (const auto& p : m) {
        int a = p.first;
        int c = p.second;
        if (c >= 2) f[a] = 1;
        for (int d = a+a; d <= MAX; d += a) {
            f[d] = 1;
        }
        if (f[a] == 0) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 16376
M = list(map(int,input().split()))

flag = 1

while True:
    if M[2] > 0:
        M[2] = M[2]-M[1]
        flag = flag * -1
        if M[2] <= 0:
            break
    else:
        break
    if M[0] > 0:
        M[0] = M[0]-M[3]
        flag = flag * -1
        if M[0] <= 0:
            break
    else:
        break
    
#print(M[0])
#print(M[2])
#print(flag)

if flag == -1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    bool res = true;
    rep(i,n-1) {
        if (a[i] == a[i+1]) res =false;
    }
    if (!res) cout << "NO" << endl;
    else cout << "YES" << endl;

}

Measured memory_bytes: 1792
# ライブラリのインポート
#import re #正規表現
#import sys
#import heapq
#import collections
#import math

def main():
    n = int(input())
    for x in range(n):
        gx ,gy = map(int,input().split())
        p = int(input())
        Y = [[0 for i in range(gy+1)] for j in range(gx+1)]
        for i in range(gx+1):
            Y[i][0] += 1
        for i in range(gy+1):
            Y[0][i] += 2
        for i in range(p):
            a, b, c, d = map(int,input().split())
            if a == c:
                if b > d: Y[a][b] += 1
                else: Y[c][d] += 1
            else:
                if a > c: Y[a][b] += 2
                else: Y[c][d] += 2
        Z = [[0 for i in range(gy+1)] for j in range(gx+1)]
        for i in range(gx+1):
            for j in range(gy+1):
                s = Y[i][j]
                if (i,j) == (0,0):  Z[0][0] = 1
                elif s == 3: Z[i][j] = 0
                elif s == 2: Z[i][j] = Z[i][j-1]
                elif s == 1: Z[i][j] = Z[i-1][j]
                else: Z[i][j] = Z[i-1][j] + Z[i][j-1]
        print(Z[gx][gy]) if Z[gx][gy]>0 else print("Miserable Hokusai!")








    
    


    
if __name__ == '__main__':
    main()



Measured memory_bytes: 5628
#include <stdio.h>
#define MIN -1e9

int Maxmum(int a,int b){
    return ( (a>b) ? a : b );
}

int Minimum(int a,int b){
    return ((a<b) ? a : b); 
}

int main(){
    int t;
    scanf("%d",&t);
    int maxtmp,mintmp;
    int r[t];
    for(int i=0; i<t; i++) scanf("%d",&r[i]);

    mintmp = r[0];
    maxtmp = MIN;

    for(int i=1; i<t; i++){
        maxtmp = Maxmum(maxtmp,r[i]-mintmp);
        mintmp = Minimum(mintmp,r[i]);
    }

    printf("%d\n",maxtmp);

    return 0;
}



Measured memory_bytes: 2636
#include<bits/stdc++.h>
using namespace std;
    long long stu[510],memo[510][510],m,n,sum,a,b;
int main(){


    while(1){

    cin >> n >> m;
    if(n==0)break;

    for(int i=0;i<m;i++){
        cin >> a >> b;
        if(a==1&&stu[b]==0){
            stu[b]=1;
            sum++;
        }else memo[a][b]=5;
    }

    for(int i=2;i<n+1;i++){
        for(int j=2;j<n+1;j++){

            if(memo[i][j]==5){
                if(stu[i]==1&&stu[j]==0){
                        stu[j]=2;
                        sum++;
                }
            }

        }
    }
    for(int i=2;i<n+1;i++){
        for(int j=2;j<n+1;j++){

            if(memo[i][j]==5){
                if(stu[i]==0&&stu[j]==1){
                        stu[i]=2;
                        sum++;
                }
            }

        }
    }

     cout << sum << endl;

     for(int i=0;i<n+1;i++){
        for(int j=0;j<n+1;j++){
            memo[i][j]=0;
        }
     }
     for(int i=0;i<n+1;i++){
            stu[i]=0;
     }
     sum=0;

    }
return 0;
    }

Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var a = ReadArrayInt();
            var max = a[0];
            var maxidx = 0;
            var min = a[0];
            var minidx = 0;
            for (int i = 1; i < N; i++)
            {
                if (a[i] > max)
                {
                    max = a[i];
                    maxidx = i;
                }
                else if (a[i] < min)
                {
                    min = a[i];
                    minidx = i;
                }
            }

            var cnt = 0;
            var ope = new List<int[]>();

            if (max >= 0 && min >= 0)
            {
                for (int i = 0; i < N - 1; i++)
                {
                    ope.Add(new int[] { i + 1, i + 2 });
                    cnt++;
                }
            }
            else if (max <= 0 && min <= 0)
            {
                for (int i = N; i > 1; i--)
                {
                    ope.Add(new int[] { i, i - 1 });
                    cnt++;
                }
            }
            else
            {
                if (Math.Abs(max) >= Math.Abs(min))
                {
                    for (int i = 0; i < N; i++)
                    {
                        ope.Add(new int[] { maxidx + 1, i + 1 });
                        cnt++;
                    }
                    for (int i = 0; i < N - 1; i++)
                    {
                        ope.Add(new int[] { i + 1, i + 2 });
                        cnt++;
                    }
                }
                else
                {
                    for (int i = 0; i < N; i++)
                    {
                        ope.Add(new int[] { minidx + 1, i + 1 });
                        cnt++;
                    }
                    for (int i = N; i > 1; i--)
                    {
                        ope.Add(new int[] { i, i - 1 });
                        cnt++;
                    }
                }                
            }

            Console.WriteLine(cnt);
            foreach (var o in ope) Console.WriteLine(o[0] + " " + o[1]);

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)

int days[11] = {0, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19};

void solve()
{
	int y, m, d;
	cin >> y >> m >> d;

	int ans = 0;

	if (d != 1)
	{
		if ((y % 3) == 0)
		{
			ans += 20 - d + 1;
		}
		else
		{
			ans += days[m] - d + 1;
		}
		d = 1;
		m++;
		if (m == 11)
		{
			y++;
			m = 1;
		}
	}

	if (m != 1)
	{
		rep(mm, m, 11)
		{
			if ((y % 3) == 0)
				ans += 20;
			else
				ans += days[mm];
		}
		m = 1;
		y++;
	}

	rep(yy, y, 1000)
	{
		if ((yy % 3) == 0)
			ans += 20 * 10;
		else
			ans += 20 * 10 - 5;
	}

	cout << ans << endl;
}

int main()
{
	int n; cin >> n;
	rep(nn, 0, n) solve();
}

Measured memory_bytes: 3080
#include <stdio.h>
int main(void) {
int A,B,C,K,P=0;
scanf("%d%d%d%d",&A,&B,&C,&K);
if(K<=A)
P=K;
else if(K<=A+B)
P=A;
else
P=A-(K-A-B);
printf("%d\n",P);
return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;


typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef vector<ii> vii; 
typedef vector<ff> vff;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    int rem = 1;
    int count = 0;
    while(rem<b){
        rem += (a-1);
        // cout<<rem<<endl;
        count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
import Data.Array
import Control.Applicative
type Pair = (Int,Int)

main = do
    [n,wmax] <- map read . words <$> getLine
    weights <- sequence $ replicate n ((\[x,y] -> (x,y)) . map read . words <$> getLine)
    print $ solve wmax weights

solve :: Int -> [Pair] -> Int
solve wmax weights = (g wmax weights) ! wmax

type DP = Array Int Int

g :: Int -> [Pair] -> DP
g wmax = foldl (addPair wmax) dp0 
    where dp0 = array (0,wmax) (zip [0..wmax] (repeat 0))

addPair :: Int -> DP -> Pair -> DP
addPair wmax before pair = array (0,wmax) $ zip [0..wmax] [ addPi index before pair | index <- [0..wmax] ]

addPi :: Int -> DP -> Pair -> Int
addPi index dp (v,w) = max before after
    where before = dp ! index
          after = if (index - w) >= 0 then dp ! (index - w) + v else -1



Measured memory_bytes: 81944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
int n,ans;
char a,b;
signed main(){
	n=read();
	cin>>a;ans=1;
	for(int i=2;i<=n;i++){
		cin>>b;if(a!=b) ans++;
		a=b;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var result = 0
    for(i in 1..n step 2){
        var count = 0
        for(j in 1..n){
            if(i % j == 0) count++
        }
        if(count == 8)
            result++
    }
    println(result)
}

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

int main() {
  int n; cin >> n;
  vector<int> a = vector<int>(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int ans = 1;
  int cnt = 1;
  for(int i=1; i<n; i++){
    if(a[i] != a[i-1]){
      ans++;
      cnt = 1;
    }
    else{
      if(cnt % 2 == 1){
        ans--;
        cnt++;
      }
      else{
        ans++;
        cnt++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MAX_V = 1e6+1;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

int main() {
  int N;
  cin >> N;
  cout << (N <= 999 ? "ABC" : "ABD") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
 
ll N;
string s[1007];
ll t[1007];
string X;

int main() {
    cin >> N;
    for(ll i=0; i<N; i++) {
        cin >> s[i];
        cin >> t[i];
    }
    cin >> X;

    bool flag = false;
    ll ans = 0;
    for(ll i=0; i<N; i++) {
        if (flag) {
           ans += t[i];
           
        }
        if (s[i].compare(X) == 0) {
            flag = true;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            int p = sc.nextInt();
            if ((n | p) == 0) {
                break;
            }
            int w = p;
            int t = 0;
            int[] s = new int[n];
            while (true) {
                if (w == 0) {
                    w = s[t % n];
                    s[t % n] = 0;
                } else {
                    s[t % n]++;
                    w--;
                }
                if (w == p) {
                    break;
                }
                t ++;
            }
            System.out.println(t % n);
        }
    }
}

Measured memory_bytes: 26760
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		byte[] cc = sc.next().getBytes();
		int n = cc.length;
		int dp0 = 0, dp1 = 1;
		for (int i = 0; i < n; i++) {
			int d = cc[i] - '0';
			int dq0 = Math.min(dp0 + d, dp1 + 10 - d);
			int dq1 = Math.min(dp0 + d + 1, dp1 + 10 - d - 1);
			dp0 = dq0;
			dp1 = dq1;
		}
		println(dp0);
	}
}


Measured memory_bytes: 46728
N,L = map(int, input().split())

azilist = range(L,L+N)
eatindex = -1

for i,a in enumerate(azilist):
    if i == len(azilist)-1:
        break
    else:
        b=abs(a)
        c=abs(azilist[i+1])
        if b<c:
            eatindex=i
            break
print(sum(azilist) - azilist[i])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n,d;
    cin>>n>>d;
    ll cnt=0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        ll dist=((1LL*x*x)+(1LL*y*y));
        //cout<<dist<<" ";
        ll r=1LL*d*d;
        if(dist<=r){
            cnt++;
        }
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
	char c[19];
	scanf("%s", &c);
	rep(i, 19) {
		if (i == 5 or i == 13)
			printf(" ");
		else
			printf("%c", c[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n, k;
#include <cassert>
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

  cin >> n >> k;
  vector<int> a(n);
  vector<int> p;
  vector<int> m;

  REP(i, n) {
    cin >> a[i];
    if(a[i] < 0) m.push_back(a[i]);
    else p.push_back(a[i]);
  }

  int P = p.size();
  int M = m.size();
  bool ok = false;

  if(P > 0) {
    if(n == k) ok = (M % 2 == 0);
    else ok = true;
  } else {
    ok = (k % 2 == 0);
  }

  mint ans = 1;

  if(!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    REP(i, k) ans *= a[i];
  } else {
    sort(p.begin(), p.end());
    sort(m.rbegin(), m.rend());
    if(k % 2 == 1) {
      ans *= p.back();
      p.pop_back();
    }
    vector<ll> t;
    while(p.size() >= 2) {
      ll x = p.back(); p.pop_back();
      x *= p.back(); p.pop_back();
      t.push_back(x);
    }
    while(m.size() >= 2) {
      ll x = m.back(); m.pop_back();
      x *= m.back(); m.pop_back();
      t.push_back(x);
    }
    sort(t.rbegin(), t.rend());
    REP(i, k/2) ans *= t[i];
  }
  cout << ans << endl;
}


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

int main() {
    int n; cin >> n;
    long long dp[n+1][3] = {0};
    for (int i = 1; i <= n; i++) {
        long long a[3]; cin >> a[0] >> a[1] >> a[2];
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                dp[i][k] = max(dp[i][k], dp[i-1][j]+a[k]);
            }
        }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
    return 0;
}

Measured memory_bytes: 2560
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    val l = Array.fill(n)(0)
    val r = Array.fill(n)(0)
    
    for(i <- 0 until n-1) l(i+1) = gcd(l(i), A(i))
    for(i <- n-1 until 0 by-1) r(i-1) = gcd(r(i), A(i))
    
    (0 until n).foldLeft(1) { (acc, i) =>
      Math.max(acc, gcd(l(i), r(i)))
    }
  }

  def gcd(x: Int, y: Int): Int = {
    if(y == 0) x
    else gcd(y, x % y)
  }

  println(solve())

}



Measured memory_bytes: 65628
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<vector<int>> G;
void input(){
    fast_io();
    cin >> N >> M;
    G.resize(N);
    for (int i = 0; i < M; i++)
    {
        int a,b ; cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
}

bool solve(){
    set<int> se;
    for(int u:G[0]){
        se.insert(u);
    }
    for(int u:G[N-1]){
        if(se.find(u)!=se.end()) return true;
    }
    return false;
}   

int main()
{
    input();
    cout << (solve()?"POSSIBLE":"IMPOSSIBLE") << endl;;
    return 0;
}

Measured memory_bytes: 16624
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;


const int INF = 1e9;
int V, E, r;
int d[100010];

struct edge{
    int to, cost;
    edge(int to, int cost): to(to), cost(cost){}
};
vector<edge> G[100010];


// void dijkstra(int s){
//     memset(d, INF, sizeof(d));
//     d[s] = 0;
//     priority_queue<P, vector<P>, greater<P> > q;
//     q.push(P(0, s));
//     while(!q.empty()){
//         P p = q.top(); q.pop();
//         int now = p.second;
//         if(d[now] < p.first) continue;
//         rep(i, 0, G[now].size()){
//             int next = G[now][i].to;
//             if(d[now] + G[now][i].cost < d[next]){
//                 d[next] = d[now] + G[now][i].cost;
//                 q.push(P(d[next], next));
//             }
//         }
//     }
// }

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > q;//P
    fill(d, d + V, INF);//INF
    d[s] = 0;
    q.push(P(0, s));

    while(!q.empty()){
        P p = q.top(); q.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        rep(i, 0, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                q.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

signed main(){
    cin >> V >> E >> r;
    int s, t, a;
    rep(i, 0, E){
        cin >> s >> t >> a;
        G[s].push_back(edge(t, a));
    }
    dijkstra(r);
    rep(i, 0, V){
        if(d[i] == INF) cout << "INF"  << endl;
        else cout << d[i] << endl;
    }
}

Measured memory_bytes: 19440
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, x; cin >> n >> x;
  vector<int> m(n);
  REP(i, n) {
    cin >> m[i];
    x -= m[i];
  }
  sort(ALL(m));
  cout << n + x / m.front() << '\n';
  return 0;
}


Measured memory_bytes: 256
n=int(input())

s=[int(x) for x in input().split()]

q=int(input())

t=[int(y) for y in input().split()]



cou=0

for i in range(q):
    left=0
    right=n
    key=t[i]
    while left<right:
        cen=(left+right)//2
        if s[cen]==key:
            cou+=1
            break
        elif s[cen]>key:
            right=cen
        else:
            left=cen+1

print(cou)


Measured memory_bytes: 16896
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=200 +117;
const int MM=200 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int k,n;
int mod;
LL dp[NN][NN]={};
LL cp[NN][NN]={};
int main(){
	//open();
	n=read();
	k=read();
	mod=read();
	for(int i=0;i<=n+1;++i){
		cp[i][0]=1;
		for(int j=1;j<=i;++j){
			cp[i][j]=(cp[i-1][j-1]+cp[i-1][j])%mod;
		}
	}
	for(int j=k;j>=0;--j)dp[1][j]=dp[1][j+1]+1;
	for(int i=2;i<=n+1;++i){
		for(int j=k;j>=0;--j){
			LL res=0;
			for(int c=1;c<i;++c){
				res+=(dp[i-c][j]-dp[i-c][j+1])*dp[c][j+1]%mod*cp[i-2][c-1];
				res%=mod;
			}
			dp[i][j]=(dp[i][j+1]+res)%mod;
		}
	}
	LL ans=(dp[n+1][0]-dp[n+1][1])%mod;
	ans=(ans+mod)%mod;
	printf("%lld\n",ans);
	close();
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          //入力を受け取る
          long N = int.Parse(Console.ReadLine());
          var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          var sum = 0L;
          for(int i = 0; i< N ; i++){
            sum += CountDivide2(a[i]);
          }
          Console.WriteLine(sum);
        }
  
  static int CountDivide2(long n){
    int count = 0;
    while(n%2 == 0){
      count++;
      n = n/2;
    }
    return count;
  }
  
}


Measured memory_bytes: 14304
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG
 
// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
 
const int MOD = 1000000007;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep_(i,n) for(int i=0;i<(int)(n-1);i++)
#define rep__(i,n) for(int i=n-1;i>=0;i--)
 
int main(void) {
    string s;
    int q;
    cin >> s >> q;
    
    int t, f;
    string c;
    bool flg = false;
    rep(i, q) {
        cin >> t;
        if(t == 1) {
            flg = !flg;
        } else {
            cin >> f >> c;
            if(f == 1) {
                if(flg) s += c;
                else s.insert(0, c);
            } else {
                if(flg) s.insert(0, c);
                else s += c;
            }
        }
    }
    
    if(flg) {
        reverse(s.begin(), s.end());
        cout << s;
    } else {
        cout << s;
    }
    
    return 0;
}


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


int main() {
  int N, c = 0;
  cin >> N;
  
  vector<int> L(2 * N);
  
  for (int i=0; i < 2 * N; i++){
    cin >> L.at(i);
  }
  
  sort(L.begin(), L.end());
  
  for (int i=0; i < N ; i++){
    c += L.at(2 * i);
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using usize = std::size_t;
using u64 = std::uint64_t;

static constexpr u64 mod = 1000000007;

int main() {
  usize n, m;
  std::cin >> n >> m;
  u64 k;
  std::cin >> k;

  const auto mul = [&](std::vector<u64> &a, const std::vector<u64> &b) {
    std::vector<u64> c(n * 2, 0);
    for (usize i = 0; i != n; ++i) {
      for (usize j = 0; j != n; ++j) {
        c[i + j] = (c[i + j] + a[i] * b[j]) % mod;
      }
    }
    for (usize i = 0; i != n; ++i) {
      a[i] = (c[i] + c[n + i]) % mod;
    }
  };

  std::vector<u64> v(n, 0);
  v[0] += 1;
  for (usize i = 0; i != m; ++i) {
    usize p;
    std::cin >> p;
    p %= n;
    v[p] += 1;
  }

  std::vector<u64> ans(n, 0);
  ans[0] = 1;

  while (k != 0) {
    if (k % 2 != 0) {
      mul(ans, v);
    }
    mul(v, v);
    k /= 2;
  }

  for (const auto e : ans) {
    std::cout << e << "\n";
  }

  return 0;
}


Measured memory_bytes: 3132
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a > 0 && b > 0 )
			System.out.println("Positive");
		else if (a <= 0 && b >= 0)
			System.out.println("Zero");
		else if((Math.abs(a)+Math.abs(b) )% 2 == 0)
			System.out.println("Negative");
			else 
				System.out.println("Positive");

	}

}


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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
    }

    rep(i, N){
        ll tmp;
        ll r1;
        if(i==0){
            tmp = 0;
            rep(j, N){
                if(j%2==0){
                    tmp += A[j];
                }else{
                    tmp -= A[j];
                }
            }
            r1 = tmp;
            cout << tmp << " ";
        }else{
            tmp = 2*A[i-1] -tmp;
            cout << tmp << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <functional>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vec;
typedef pair<int, int> P;
#define rep(n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define out(a) cout << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 100000000

int w, h, res = 1;
char f[25][25];
int dy[] = { 1,0,-1,0 }, dx[] = { 0,1,0,-1 };
int used[25][25] = { 0 };
void dfs(int y, int x) {
	for (int i = 0; i < 4; i++) {
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (0 <= ny&&ny < h && 0 <= nx&&nx < w&&f[ny][nx] == '.'&&used[ny][nx] == 0) {
			used[ny][nx] = 1;
			res++;
			dfs(ny, nx);
		}
	}
	return;
}

int main() {
	while (true) {
		cin >> w >> h;
		res = 1;
		if (w == 0 && h == 0) return 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> f[i][j];
				used[i][j] = 0;
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (f[i][j] == '@') {
					used[i][j] = 1;
					dfs(i, j);
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  map<int,int> cnt;
  REP(i,n){
    int a; cin>>a;
    cnt[a]++;
  }
  int ans = 0;
  for(pii P : cnt){
    if(P.first <= P.second){
      ans += P.second - P.first;
    }else{
      ans += P.second;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4736
#include <stdio.h>
typedef const char *state;

int expr(state *p);
int term(state *p);
int factor(state *p);
int number(state *p);

int expr(state *p) {
  int val = term(p);
  while (1) {
    if (**p == '+') {
      (*p)++;
      val += term(p);
    } else if (**p == '-') {
      (*p)++;
      val -= term(p);
    } else {
      break;
    }
  }
  return val;
}

int term(state *p) {
  int val = factor(p);
  while (1) {
    if (**p == '*') {
      (*p)++;
      val *= factor(p);
    } else if (**p == '/') {
      (*p)++;
      val /= factor(p);
    } else {
      break;
    }
  }
  return val;
}

int factor(state *p) {
  if (**p == '(') {
    (*p)++;
    int val = expr(p);
    (*p)++;
    return val;
  }
  return number(p);
}

int number(state *p) {
  int val = 0;
  while ('0' <= **p && **p <= '9') {
    val *= 10;
    val += **p - '0';
    (*p)++;
  }
  return val;
}

int main() {
  int n;
  char s[101];
  scanf("%d", &n);
  while (n--) {
    scanf("%s", s);
    state p = s;
    printf("%d\n", expr(&p));
  }
}

Measured memory_bytes: 1744
N,L = map(int,input().split())
aji = [L+i for i in range(N)]
#print(aji)
total = sum(aji)
#print(total)

eat = 1000
j=0
for i in range(N):
  if eat > abs(aji[i]):
    eat = abs(aji[i])
    # eat  は正の値

if min(aji) >0:
  print(total-eat)
else:
  print(total+eat)

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

int main() {
  int N, K;
  cin >> N >> K;
  int sum=1;
  
  for(int i=0; i<N; i++){
    if(sum*2 > sum+K) sum+=K;
    else sum*=2;
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 3636
a,b,c = gets.split.map(&:to_i)
puts ((a-b)*(a-c)<0) ? \
((b-c<0) ? [b,a,c].join(" ") : [c,a,b].join(" ")) : \
((b-c>0) ? ((a-c>0) ? [c,b,a].join(" ") : [a,c,b].join(" ")) : ((a-c>0) ? [b,c,a].join(" ") : [a,b,c].join(" ")))

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

int main(){
	string s;
	int count=0;
	cin>>s;
	unordered_map<int,int> mp;
	for(int i=0; i<4; i++){
        if(mp.find(s[i])==mp.end()){
        	mp[s[i]]=1;
        	count++;
		}
	}
	if(count==2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3640