akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static string C;
        static int LW;
        static int RR;
        static int N;

        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());
            //var NA = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            C = Console.ReadLine();
            LW = -1;
            RR = N;
            var count = 0;

            while (LW < RR)
            {
                NextLW();
                NextRR();
                //if(fif && LW >= RR)
                //{
                //    break;
                //}
                //else
                //{
                //    fif = false;
                //}
                if (LW >= RR)
                {
                    break;
                }
                count++;
            }

            Console.WriteLine(count);
        }

        static void NextLW()
        {
            LW++;
            while (LW < N && C[LW] == 'R')
            {
                LW++;
            }
        }

        static void NextRR()
        {
            RR--;
            while (RR >= 0 && C[RR] == 'W')
            {
                RR--;
            }
        }
    }


}


Measured memory_bytes: 28312
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,S;cin>>N>>S;
  vector<long long>A(N);
  long long K=0;
  for(int X=0;X<N;X++){
    cin>>A[X];
    K+=A[X];
  }
  sort(A.begin(),A.end());
  if(K<S){
    cout<<N-1<<endl;
  }
  else{
    int Y;long long M=0;
    for(Y=0;Y<N;Y++){
      M+=A[Y];
      if(M>S){
        break;
      }
    }
    cout<<Y<<endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    vector<int> flag(N+1);
    rep(i,N){
        cin >> a[i+1];
    }
    int cnt = 0;
    flag[1] = 1;
    int ix=1;
    while(1){
        cnt++;
        if(flag[a[ix]]){
            cout << -1 << endl;
            return 0;
        }
        if(a[ix]==2){
            cout << cnt << endl;
            return 0;
        }
        flag[a[ix]]=1;
        ix = a[ix];
    }
    return 0;
}

Measured memory_bytes: 1024
def calcCoin(num, price, coin)
    if price >= coin then
        num += price/coin
        price -= coin * (price/coin)
    end
    return num, price
end
loop do
    x = gets.to_i
    break if x == 0
    num = 0
    y = 1000 - x
    [500,100,50,10,5,1].each do |coin|
        num, y = calcCoin(num, y, coin)
    end
    puts num
end


Measured memory_bytes: 6864
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/detail/standard_policies.hpp>

// common
#define endl     "\n"
#define M_PI     3.14159265358979323846

// fast input output
#define fast_io  ios_base::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL)

// fixed float field
#define fix_prec cout.setf( std::ios::fixed, std:: ios::floatfield ); cout.precision(9);

// vector
#define vi       vector<int>
#define vvi      vector<vector<int>>
#define vpii     vector<pair<int,int>>
#define pb(v,x)  v.push_back(x)

// pair
#define pii      pair<int,int>
#define mp(a,b)  make_pair(a,b)
#define F        first
#define S        second

// sort
#define all(x)   x.begin(),x.end()

// bound
#define lb(v,x)  lower_bound(v.begin(),v.end(),x)
#define ub(v,x)  upper_bound(v.begin(),v.end(),x)

using namespace std;
//using namespace __gnu_pbds;

//typedef tree < int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
typedef long long int lli;
typedef unsigned long long int ulli;

// constants
lli const mod  = 1e9;
lli const modl = 1e18;

void solve()
{
	vi a(3);
	int i;
	for(i=0;i<3;i++)
		cin>>a[i];
	sort(all(a));
	cout<<a[0]+a[1];
}

int main()
{
  fast_io;
  fix_prec;
  int t=1;
  //cin>>t;
  while(t--)
  {
    solve();
    cout<<endl;     
  }
  return 0;	
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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(int argc, char const *argv[]) {
  int n, m, x;
  cin >> n >> m >> x;
  vector<ll> c(n);
  vector<vector<ll>> a(n, vector<ll>(m));
  rep(i,n){
      cin >> c[i];
      rep(j,m) cin >> a[i][j];
  }
  ll ans = INF;
  for (int bit = 0; bit < (1 << n); bit++) {
    ll cost = 0;
    vector<int> now(m, 0);
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {//i番目の参考書を使う
        cost += c[i];
        rep(j, m) now[j] += a[i][j];
      }
    }
    bool f = true;
    rep(j, m) if (now[j] < x) f = false;
    if (f) chmin(ans, cost);
  }
    if(ans!=INF) cout << ans << endl;
    else
      puts("-1");
    return 0;
}


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

struct vec{
    double x,y;
    vec operator-(vec b){
        vec& a = *this;
        vec c;
        c.x=a.x-b.x;c.y=a.y-b.y;
        return c;
    }
};

const double eps = 0.0000001;

double inner_product(vec& a, vec& b){
    return a.x*b.x+a.y*b.y;
}

double outer_product(vec& a, vec& b){
    return a.x*b.y-a.y*b.x;
}

int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = outer_product(ab,ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(inner_product(ab,ac)<0){
        return 2; //C-A-B
    }else{
        if(inner_product(ab,ab)<inner_product(ac,ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

int main(void){
    vec p0,p1,p2,v1,v2;
    int q;
    cin >> p0.x >> p0.y >> p1.x >> p1.y;
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> p2.x >> p2.y;
        switch(ccw(p0,p1,p2)){
            case 1:
                cout << "COUNTER_CLOCKWISE" << endl;
                break;
            case -1:
                cout << "CLOCKWISE" << endl;
                break;
            case 2:
                cout << "ONLINE_BACK" << endl;
                break;
            case -2:
                cout << "ONLINE_FRONT" << endl;
                break;
            case 0:
                cout << "ON_SEGMENT" << endl;
                break;
            default:
                ;
        }
    }
    return 0;
}

Measured memory_bytes: 3180
#include <cstdio>  
#include <algorithm>  
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
#define maxn (int)1e5+500
char a[55][55];
int vis[55][55];
int p[4][2] = {1,0,-1,0,0,1,0,-1};
int ans,n,m;
struct node
{
	int x, y, s;
};
int bfs(int x, int y)
{
	memset(vis, 0, sizeof(vis));
	queue<node>q;
	node xx;
	xx.x = x, xx.y = y, xx.s = 1;
	q.push(xx);
	while (!q.empty())
	{
		node t = q.front(); q.pop();
		if (t.x == n&&t.y == m) return t.s;
		if (!vis[t.x][t.y])
		{
			vis[t.x][t.y] = 1;
			for (int i = 0; i < 4; i++)
			{
				int xx = t.x + p[i][0];
				int yy = t.y + p[i][1];
				if (xx >= 1 && xx <= n&&yy >= 1 && yy <= m&&a[xx][yy] == '.'&&vis[xx][yy]==0)
				{
					node tt;
					tt.x = xx, tt.y = yy, tt.s = t.s + 1;
					q.push(tt);
				}
			}
		}
	}
	return -1;
}
int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		ans = n*m;
		for (int i = 1; i <= n; i++)
		{
			scanf("%s", a[i] + 1);
			for (int j = 1; j <= m; j++)
				if (a[i][j] == '#')
					ans--;
		}
		int kk=-1;
		if (a[1][1] == '#' || a[n][m] == '#')
			kk = -1;
		else 
			kk=bfs(1, 1);
		if (kk == -1)
			ans = -1;
		else
			ans -= kk;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
ll n,d,a[105];
multiset<ll> st;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=0;i<n;i++)cin>>a[i],d=max(d,a[i]),st.insert(a[i]);
    ll lowest=d+1;
    for(ll i=0;i<=d;i++){
        ll cur=max(i,d-i);
        if(!st.count(cur))return cout<<"Impossible" , 0;
        st.erase(st.find(cur));
        lowest=min(lowest,cur);
    }

    if(!st.empty() && (*st.begin())<=lowest)cout<<"Impossible" , 0;
    else cout<<"Possible" , 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string u = "keyence";
int main(){
	int i,j,k;
	string s;
	cin >> s;
	for(i=0;i<s.size();i++){
		for(j=0;j<s.size();j++){
			if(i>j) continue;
			string t;
			for(k=0;k<i;k++){
				t.push_back(s[k]);
			}
			for(k=j;k<s.size();k++){
				t.push_back(s[k]);
			}
			if(t.size()!=7){
				continue;
			}
			for(k=0;k<t.size();k++){
				if(t[k]!=u[k]) break;
				if(k==6){
					cout << "YES" << endl;
					return 0;
				}
			}
		}
	}
	cout << "NO" << endl;
}

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

int main(){
	stack<char> s;
	char c;
	while( cin.get(c)){
		if( c == '\n')
			break;
		s.push(c);
	}
	while( !s.empty()){
		cout << s.top();
		s.pop();
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 1132
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int w, h, x, y, r;
            string[] str = Console.ReadLine().Split(' ');
            w = int.Parse(str[0]);
            h = int.Parse(str[1]);
            x = int.Parse(str[2]);
            y = int.Parse(str[3]);
            r = int.Parse(str[4]);
            if (x + r > w || y + r > h || x - r < 0 || y - r < 0)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }

}

Measured memory_bytes: 8840
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4],s2,s1,s;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	s2=(a[2]-a[1])/2+(a[2]-a[0])/2;
	s1=(a[2]-a[1])%2+(a[2]-a[0])%2;
	s=s2+s1/2;
	if(s1%2!=0)
		s+=2;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	s=RD()
	n=len(s)

	dp=[[0]*4 for _ in range(n+1)]
	dp[0][0]=1


	for i,ss in enumerate(s):
		if s[i]=="A":
			dp[i+1][0]=dp[i][0]
			dp[i+1][1]=dp[i][0]+dp[i][1]
			dp[i+1][2]=dp[i][2]
			dp[i+1][3]=dp[i][3]
		elif s[i]=="B":
			dp[i+1][0]=dp[i][0]
			dp[i+1][1]=dp[i][1]
			dp[i+1][2]=dp[i][1]+dp[i][2]
			dp[i+1][3]=dp[i][3]
		elif s[i]=="C":
			dp[i+1][0]=dp[i][0]
			dp[i+1][1]=dp[i][1]
			dp[i+1][2]=dp[i][2]
			dp[i+1][3]=dp[i][2]+dp[i][3]
		else:
			dp[i+1][0]=dp[i][0]*3
			dp[i+1][1]=dp[i][0]+dp[i][1]*3
			dp[i+1][2]=dp[i][1]+dp[i][2]*3
			dp[i+1][3]=dp[i][2]+dp[i][3]*3

		for j in range(4):
			dp[i+1][j]%=10**9+7


	print(dp[-1][-1])











if __name__ == "__main__":
	main()


Measured memory_bytes: 86956
//
//  main.cpp
//  all_pairs_shortest_path
//
//  Created by ???????????? on 2017/11/13.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <climits>

//#define INF 200000000

using namespace std;

static const int MAX = 100;
static const long long INF = (1LL<<32);

long long A[MAX][MAX];


void initA(int num){
    for(int i = 0; i < num; i++){
        for(int j = 0; j < num; j++){
            if(i == j) A[i][j] = 0;
            else A[i][j] = INF;
        }
    }
}

void warshallFloyd(int numVertex){
    for(int k = 0; k < numVertex; k++){
        for(int i = 0; i < numVertex; i++){
            if (A[i][k] == INF) continue;
            for (int j = 0; j < numVertex; j++){
                if (A[k][j] == INF) continue;
                A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
            }
        }
    }
}

bool isNegativeCycle(int num){
    for(int i = 0; i < num; i++){
        if(A[i][i] != 0){
            return true;
        }
    }
    return false;
}

void printA(int num){
    if  (isNegativeCycle(num)) {
        cout << "NEGATIVE CYCLE" << endl;
        return;
    }
    else{
        for(int i = 0; i < num; i++){
            for(int j = 0; j < num; j++){
                if(j) cout << " ";
                
                if(A[i][j] == INF) cout << "INF";
                else cout<<A[i][j];
            }
            cout<<endl;
        }
    }
}

int main(int argc, const char * argv[]) {
    int numVertex, numEdge;
    scanf("%d %d", &numVertex, &numEdge);
    
    initA(numVertex);
//    int T[numVertex][numVertex];
    int x, y, distance;
    for (int i = 0; i < numEdge; i++){
        scanf("%d %d %d", &x, &y, &distance);
        A[x][y] = distance;
    }
    warshallFloyd(numVertex);
    
    printA(numVertex);
    
//    std::cout << "Hello, World!\n";
    return 0;
}

Measured memory_bytes: 3320
h, w = map(int, input().split())
a = [input() for _ in range(h)]
MOD = 10**9+7

dp = [[0]*(w+1) for _ in range(h+1)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if i+1 < h and a[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
            if dp[i+1][j] >= MOD:
                dp[i+1][j] %= MOD
        if j+1 < w and a[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
            if dp[i][j+1] >= MOD:
                dp[i][j+1] %= MOD
print(dp[h-1][w-1])

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC143D()
{
	int N;
	cin >> N;
	vi L(N);
	for (auto& x : L)
		cin >> x;
	sort(L.begin(), L.end());
	L.push_back(100000000);

	ll ct = 0;
	for (int i = 0; i < N; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			int c = L[i] + L[j];
			auto p = lower_bound(L.begin() + j + 1, L.end(), c);
			auto x = distance(L.begin() + j + 1, p);
			ct += x;
		}
	}
	cout << ct << endl;
}
int main()
{
	ABC143D();
	return 0;
}


Measured memory_bytes: 256
type Condition = (Int, Int, Int, Int)

main = do
  [n, m, q] <- readIntegers
  conditions <- readConditions q
  let sequences = probableSequences 1 m n
  print $ foldl max 0 $ map (evaluateSequence conditions) sequences

readIntegers :: IO [Int]
readIntegers = (map read . words) <$> getLine::IO [Int]

readConditions :: Int -> IO [Condition]
readConditions n
  | n <= 0 = return []
  | otherwise = do
    [a, b, c, d] <- readIntegers
    next <- readConditions (n - 1)
    return ((a, b, c, d) : next)

probableSequences :: Int -> Int -> Int -> [[Int]]
probableSequences _ _ 0 = [[]]
probableSequences mMin mMax n = concat $ map (\m -> map (m:) $ probableSequences m mMax (n - 1)) [mMin..mMax]

evaluateSequence :: [Condition] -> [Int] -> Int
evaluateSequence conditions sequence = foldl (+) 0 $ map (scoreForCondition sequence) conditions

scoreForCondition :: [Int] -> Condition -> Int
scoreForCondition sequence (a, b, c, d) =
  if sequence !! (b - 1) - sequence !! (a - 1) == c
    then d
    else 0


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

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

  vector<int64_t> price(n);
  vector<char> buy_sel(n,0);
  for(int i=0;i<n;i++){
    cin >> price[i];
  }
  if(price[0]<=price[1]){
    buy_sel[0] = 1;
  }
  for(int i=1;i<n-1;i++){
    if(price[i]<=price[i+1]){
      buy_sel[i] = 1;
    }
    else if(price[i]>price[i+1]){
      buy_sel[i] = -1;
    }
  }
  buy_sel[n-1] = -1;

  int64_t money = 1000;
  int64_t stock = 0;
  for(int i=0;i<n;i++){
    if(1==buy_sel[i]){
      stock += money/price[i];
      money = money%price[i];
    }
    else if(-1==buy_sel[i]){
      money += stock*price[i];
      stock = 0;
    }
  }
  if(stock>0){
  	money += stock*price[n-1];
  	stock = 0;
  }

  cout << money << endl;

  return 0;
}



Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
typedef int Int;
#define int long long
#define INF 0x3f3f3f3f
#define maxn 200005
int a[maxn];
map<int,int>vis;
Int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]-=i;
        //cout<<a[i]<<' ';
        vis[a[i]]++;
    }
    //cout<<endl;
    sort(a+1,a+n+1);
    int sum=0;
    int tmp=1;
    int val=0;
    if(n%2)
    {
        val=a[(n+1)/2];
    }
    else
    {
        val = (a[n / 2 + 1] + a[n / 2]) / 2;
    }
   // cout<<val<<endl;
    for(int i=1;i<=n;i++)
    {
        sum+=abs(a[i]-val);
    }
    cout<<sum<<endl;   
     return 0;
}

Measured memory_bytes: 14336
if __name__ == "__main__":
    n, m = map(int, input().split())

    ans = 0
    if n > 2 and m > 2:
        ans = (n-2) * (m-2)
    elif n == 1 and m == 1:
        ans = 1
    elif n == 1:
        ans = m - 2
    elif m == 1:
        ans = n - 2

    print(ans)


Measured memory_bytes: 2940
n = int(input())
A = []
B = []
for i in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if n % 2 == 1:
    print(B[n//2]-A[n//2]+1)
else:
    m = (A[n//2]+A[n//2-1])
    M = (B[n//2]+B[n//2-1])
    print(M-m+1)

Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    sort(a.begin(),a.end());
    cout << a.at(0)+a.at(1) << endl;
    
}


Measured memory_bytes: 256
# B - Grid Compression

H, W = map(int, input().split())
A = []
for i in range(H):
    A.append(list(str(input())))

h = [0] * H
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            h[i] += 1
            continue

w = [0] * W
for j in range(W):
    for i in range(H):
        if A[i][j] == '#':
            w[j] += 1
            continue

for i in range(H):
    ans = ''
    if h[i] == 0:
        continue
    for j in range(W):
        if w[j] == 0:
            continue
        else:
            ans += A[i][j]
    print(ans)


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

int main() {
        string s;
        int n[4];
        cin >> s;

        for(int i=0; i<4; i++) n[i]= s[i] - '0';

        for(int mask=0; mask<(1<<3); mask++){
                int num=n[0];
                for(int i=1; i<4; i++){
                        if(mask>>(i-1) & 1)num+=n[i];
                        else num-=n[i];
                }
                if(num==7){
                        cout << n[0];
                        for(int i=1; i<4; i++){
                                if(mask>>(i-1) & 1) cout << "+" <<n[i];
                                else cout << "-" <<n[i];
                        }
                        cout << "=" << 7 << endl;
                        return 0;
                }
        }
        return 0;
}


Measured memory_bytes: 256
n=int(input())
da=list(map(int,input().split()))
ans=0
da=sorted(da)
for i in range(1,n-1):
    for j in range(i):
        ok,ng=0,0
        ok+=i
        ng+=n
        while ng-ok!=1:
            mi=(ok+ng)//2
            if da[mi]<da[i]+da[j]:
                ok=0
                ok+=mi
            else:
                ng=0
                ng+=mi
        ans+=ok-i
print(ans)

Measured memory_bytes: 43028
N, M = map(int, input().split())
H = list(map(int, input().split()))

g = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)


d = [[0, -1]]
ans = 0
is_visit = [False] * N
def search(node):
    global is_visit
    global ans
    d = [node]
    while d:
        node = d.pop()
        h = H[node]
        children = g[node]
        res = True
        for child in children:
            _h = H[child]
            res *= h > _h
            if not is_visit[child]:
                is_visit[child] = True
                d.append(child)
        
        ans += res


for i in range(N):
    if not is_visit[i]:
        is_visit[i] = True
        search(i)

print(ans)

Measured memory_bytes: 30628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<long long int> v;
  int count = 0;
  for(int i = 0;i < n;i++)
  {
    long long int a;
    cin >> a;
    if(a < 0)
    {
      a = a * (-1);
      count++;
    }
    v.push_back(a);
  }
  long long int sum = 0;
  if(count % 2 == 0)
  {
    for(int i = 0;i < n;i++)
    {
      sum += v.at(i);
    }
  }
  else
  {
    sort(v.begin(),v.end());
    for(int i = 1;i < n;i++)
    {
      sum += v.at(i);
    }
    sum = sum - v.at(0);
  }
  cout << sum << "\n";

  return 0;
}

Measured memory_bytes: 1400
import sys


input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	dd = dict()
	
	v = int(input())
	dd[v] = 0
	ll=[0]*n
	ll[0]=1
	for i in range(1, n):
		v = int(input())
		if v not in dd or dd[v] == i-1:
			ll[i] = ll[i-1]
			dd[v] = i
		else:
			ll[i] = (ll[i-1] + ll[dd[v]])%mod
			dd[v] = i
	return ll[-1]
			
		
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

 int main() {
     ll N, sum = 0;
     cin >> N;

     vector<ll> A(N + 2, 0);

     rep(i, 1, N + 1) cin >> A.at(i);

     rep(i, 0, N + 1) sum += abs(A.at(i + 1) - A.at(i));

     rep(i, 1, N + 1) cout << sum - abs(A.at(i) - A.at(i - 1)) - abs(A.at(i + 1) - A.at(i)) + abs(A.at(i + 1) - A.at(i - 1)) << endl;
 }


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

int main() {
	int a,b,c,d;

	cin >> a >> b >> c >> d ;
	
	int l = a+b;
	int r = c + d;
	
	if (l>r) {
		cout << "Left" << endl;
	}
	else if (l==r) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG

int A,B;
int f(int x,int y){
    if(y%x==0)return x+y;
    else return y-x;
}

signed main(){
    cin>>A>>B;
    cout<<f(A,B)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>

using namespace std;

int main(){

int h,w;
  
  cin >> h >> w;
  
  string s[h];
 
  for(int i=0;i<h;i++){
   cin >> s[i];
  }
  
  int l[h][w]={0},r[h][w]={0},d[h][w]={0},u[h][w]={0};
  
  for(int i=0;i<h;i++){
   for(int j=0;j<w;j++){
   if(s[i][j]!='#'){
     if(j==0){
     l[i][j]=1;
     }
     else{
     l[i][j]=l[i][j-1]+1;
     }
   }
    else{
     l[i][j]=0;
    } 
   
   }   
   }
  
  for(int i=0;i<h;i++){
   for(int j=0;j<w;j++){
   if(s[i][w-1-j]!='#'){
     if(j==0){
     r[i][w-1-j]=1;
     }
     else{
     r[i][w-1-j]=r[i][w-j]+1;
     }
   }
    else{
     r[i][w-1-j]=0;
    } 
   
   }   
   }
  
  for(int j=0;j<w;j++){
  for(int i=0;i<h;i++){
   if(s[i][j]!='#'){
     if(i==0){
     u[i][j]=1;
     }
     else{
     u[i][j]=u[i-1][j]+1;
     }
   }
    else{
     u[i][j]=0;
    } 
   
   }   
   }
  
    for(int j=0;j<w;j++){
  for(int i=0;i<h;i++){
    if(s[h-1-i][j]!='#'){
     if(i==0){
     d[h-1-i][j]=1;
     }
     else{
     d[h-1-i][j]=d[h-i][j]+1;
     }
   }
    else{
     d[h-1-i][j]=0;
    } 
   
   }   
   }
  
  int res=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
  res=max(res,l[i][j]+r[i][j]+d[i][j]+u[i][j]-3);
    }
  }
  
   cout << res << endl;
  
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, t, p;
	while (cin >> m >> n >> t >> p, n) {
		vvi v(n, vi(m, 1));
		REP(adfad, t) {
			int d, c;
			cin >> d >> c;
			if (d == 1) {
				int k = max(m - c, c);
				vvi t(n, vi(k));
				REP(i, n) {
					REP(j, k) {
						int tmp = 0;
						if (j < c)tmp += v[i][c - j - 1];
						if (c + j < m)tmp += v[i][c + j];
						t[i][j] = tmp;
					}
				}
				m = k;
				v = t;

			}
			else {
				int k = max(n - c, c);
				vvi t(k, vi(m));
				REP(i, k) {
					REP(j, m) {
						int tmp = 0;
						if (i < c)tmp += v[c - i - 1][j];
						if (i + c < n)tmp += v[c + i][j];
						t[i][j] = tmp;
					}
				}
				n = k;
				v = t;
			}
		}
		REP(i, p) {
			int x, y;
			cin >> x >> y;
			cout << v[y][x] << endl;
		}
	}
}


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

int main()
{
  int n;
  cin >> n;
  
  if (n == 1) cout << 1 << endl;
  else if (n >= 2 && n < 4) cout << 2 << endl;
  else if (n >= 4 && n < 8) cout << 4 << endl;
  else if (n >= 8 && n < 16) cout << 8 << endl;
  else if (n >= 16 && n < 32) cout << 16 << endl;
  else if (n >= 32 && n < 64) cout << 32 << endl;
  else if (n >= 64 && n <= 100) cout << 64 << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    for(int T = 0; T < t ; T++){
        ll n;
        cin >> n;
        ll a[n], cnt[10000001] = {0};
        for(int i = 0 ; i < n ; i++){
            cin >> a[i];
            cnt[a[i]]++;
        }
        bool ok = true;
        for(ll i = 2; i <= 1e6; i++){
            ll ans = 0;
            for(ll j = i; j <= 1e6; j += i){
                ans += cnt[j];
            }
            if(ans > 1){
                ok = false;
                break;
            }
        }
        if(ok == true)
            cout << "pairwise coprime" << endl;
        else{
            ll gh = a[0];
            for(int i = 1; i < n; i++)
                gh = __gcd(gh, a[i]);
            if(gh == 1)
                cout << "setwise coprime" << endl;
            else
                cout << "not coprime" << endl;
        }
    }
    return 0;
}


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

int n, a[220000], b[220000];
int main(){
  cin >> n;
  rep(i, n){
    cin >> a[i];
    b[i] = a[i];
  }
  
  sort(b, b + n);
  int mid1, mid2;
  rep(i, n){
    if(i == n / 2 - 1){
      mid1 = b[i];
    }
    if( i == n / 2){
      mid2 = b[i];
    }
  }
  
  rep(i, n){
    if(a[i] <= mid1){
      cout << mid2 << endl;
    }else{
      cout << mid1 << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3712
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func gcd(a, b int) int {
    if b == 0 {
        return a
    }
    return gcd(b, a%b)
}

func primeSet(n int) []int {
  if n == 1 { return []int{} }
  for i := 2; i * i <= n; i++ {
    if n % i > 0 { continue }
    P := append([]int{i}, primeSet(n / i)...)
    if len(P) > 1 && P[0] == P[1] {
      return P[1:]
    }
    return P
  }
  return []int{n}
}

func main() {
  AB := NextIntVec()
  GCD := gcd(AB[0], AB[1])
  Write(len(primeSet(GCD)) + 1)
  Output()
}

Measured memory_bytes: 640
// A - Connection and Disconnection
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll opeCounter(string &S, int K){
	string T=S; while(--K) T += S;
	ll c = 0;
	for(int i=1; i<T.size(); ++i) if(T[i-1] == T[i]) c++, i++;
	return c;
}

int main(){
  string S; int K; cin>>S>>K;
	ll s1 = opeCounter(S, 1);
	ll s2 = opeCounter(S, 2);
	int i = 0;
	for(i=1; i<S.size() && S[0]==S[i]; ++i);
	bool allSame = i==S.size();
  cout<< (allSame? S.size() * K / 2: (s2 - s1) * (K - 1) + s1) <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int k,n,i,j,sum,a,b;
	cin >> n >> k;
		int l[n];
	for(i=0;i<n;i++)cin >> l[i];
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(l[i]>l[j]){
				a=l[i];
				l[i]=l[j];
				l[j]=a;
			}
		}
	}
	b=n-k;
	sum=0;
	for(i=b;i<n;i++)sum=sum+l[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[10005],ans=0,n;
    cin>>n;
    for(int i=1;i<=2*n;i++)
       cin>>a[i];
    sort(a+1,a+1+2*n);    
    for(int i=1;i<=2*n;i+=2)
        ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int a,b,c,d,e,f,g,h,i;
  a=s[0]-'0';
  b=s[1]-'0';
  c=s[2]-'0';
  d=s[3]-'0';
  e=s[5]-'0';
  f=s[6]-'0';
  g=s[8]-'0';
  h=s[9]-'0';
  i=a*10000000+b*1000000+c*100000+d*10000+e*1000+f*100+g*10+h;
  if(i<=20190430)cout<<"Heisei"<<endl;
  else cout<<"TBD"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace Problem_B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var blue = new Dictionary<string, int>();
            var red = new Dictionary<string, int>();
            for (var i = 0; i < n; i++)
            {
                var word = Console.ReadLine();
                if (blue.ContainsKey(word)) blue[word] += 1;
                else blue.Add(word, 1);
            }

            var m = int.Parse(Console.ReadLine());
            for (var i = 0; i < m; i++)
            {
                var word = Console.ReadLine();
                if (red.ContainsKey(word)) red[word] += 1;
                else red.Add(word, 1);
            }
            var total = 0;
            foreach (var e in blue)
            {
                if (red.ContainsKey(e.Key))
                {
                    total = Math.Max(total, e.Value - red[e.Key]);
                }
                else
                {
                    total = Math.Max(total, e.Value);
                }
            }
            Console.WriteLine($"{total}");
        }
    }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int64_t n, a, b; cin >> n >> a >> b;
    int64_t y = n%(a+b);
    cout << (y>a ? a : y)+(n/(a+b))*a;
    return 0;
}

Measured memory_bytes: 256
INF = float('inf')


def dijkstra(source):
    distance[source] = 0
    parent[source] = -1

    while True:
        mincost = INF
        for i in range(n):
            if color[i] != 'black' and distance[i] < mincost:
                mincost = distance[i]
                u = i

        if mincost == INF:
            break

        color[u] = 'black'

        for v in range(n):
            if color[v] != 'black' and adjMat[u][v] != INF:
                if distance[u] + adjMat[u][v] < distance[v]:
                    distance[v] = distance[u] + adjMat[u][v]
                    parent[v] = u
                    color[v] = 'gray'


n = int(input())
color = ['white'] * n
parent = [-1] * n
distance = [INF] * n

adjMat = [[INF] * n for _ in range(n)]
for i in range(n):
    inputList = list(map(int, input().split()))
    adjRow = inputList[0::2][1:]
    weightRow = inputList[1::2][1:]
    for v, weight in zip(adjRow, weightRow):
        adjMat[i][v] = weight

dijkstra(0)

for index, distance in enumerate(distance):
    print(('{} {}').format(index, distance))

Measured memory_bytes: 7856
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans,a[301];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+2*n);
	for(int i=1;i<=2*n;i+=2) ans+=a[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3828
#include <stdio.h>
main()
{
	int A,B,C;
	do
	{
	scanf("%d %d %d",&A,&B,&C);
	}while(A<1||A>10||B<1||B>10||C<1||C>10);
	if ((A==7&&B==5&&C==5)||(A==5&&B==7&&C==5)||(A==5&&B==5&&C==7))
	printf("YES");
	else
	printf("NO");
	return 0;
 } 

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

using namespace std;

int main() {
  int N, d[100009], mid;
  cin >> N;
  mid = N / 2;
  
  for (int i = 1; i <= N; i++) cin >> d[i];
  sort(d + 1, d + N + 1);
  cout << d[mid + 1] - d[mid] << endl;
  
  return 0;
}

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

int main() {
    int N, M, cnt = 0; cin >> N >> M;
    vector<int> bucket(M+10, 0);
    for (int i = 0; i < N; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int a; cin >> a;
            bucket.at(a-1)++;
        }
    }
    for (int i = 0; i <= M; i++) {
        if (bucket.at(i) == N) cnt++;
    }
    cout << cnt << endl;
}

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


l = []

nc = n

while nc > 0:
    if nc % 26 == 0:
        l.append(26)
    else:
        l.append(nc % 26)
    nc -= 1
    nc //= 26

ans = ''

for i in range(len(l)):
    ans += chr(l[-(1+i)] + 96)

print(ans)


Measured memory_bytes: 9180
var fact: Array<Int> = Array(repeating: 0, count: 3020)
var factinv: Array<Int> = Array(repeating: 0, count: 3020)
var inv: Array<Int> = Array(repeating: 0, count: 3020)
var a1: Array<Int> = Array(repeating: 0, count: 0)
var ans: Array<Int> = Array(repeating: 0, count: 3020)
func init_nCk(n: Int, MOD: Int){
    fact[0] = 1;
    fact[1] = 1;
    factinv[0] = 1;
    factinv[1] = 1;
    inv[1] = 1;
    for i in 2...n + 5 {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv [MOD % i] * (MOD / i) % MOD;
        factinv[i] = factinv[i - 1] * inv[i] % MOD;
    }
}
func nCk(n: Int, k: Int, MOD: Int) -> Int {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (factinv[k] * factinv[n - k] % MOD) % MOD;
}
func readInts() -> [Int]{
    return readLine()!.split(separator: " ").map{Int($0)!};
}
let p = Int(readLine()!)!;
let a = readInts();
var count = 0;
for i in 0..<p {
    let aa = a[i];
    if aa == 1 {
        a1.append(i);
        count += 1;
    }
}
init_nCk(n: p - 1,MOD: p);
ans[0] = count;
for i in 0..<count {
    var x = 1;
    for j in 0..<p {
        let J = p - 1 - j;
        ans[J] -= nCk(n: p - 1, k: J, MOD: p) * x - p * p;
        ans[J] %= p;
        x *= -1 * a1[i];
        x %= p;
    }
}
for i in 0..<p {
    print(ans[i], terminator: "");
    if i < p - 1 {
        print(" ", terminator: "");
    }
}

Measured memory_bytes: 8516
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
  string s,t, u;
  cin >> s >> t;
  int snum, tnum;
  cin >> snum >> tnum;
  cin >> u;
  if(s==u)
    snum--;
  if(t==u)
    tnum--;

  cout << snum << " " << tnum << endl;
		 


  return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
//using vi = vector<int>;
//using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
//using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	if(n % 2 == 0 ){

		cout << n << endl;
	}
	else{
		cout << n*2 << endl;
	}

	
	system("pause");



	


}
	


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    int ans = 0;
    int maxa = 0;
    while (N--) {
        int a, b; cin >> a >> b;
        if (maxa < a) {
            ans = a + b;
            maxa = a;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    int n;
    cin>>n;
    int tmp=n;
    int sum=0;
    while(1){
        if(tmp == 0) break;
        sum += tmp%10;
        tmp = tmp/10;
    }
    if(n%sum==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 888
[h,n] = [int(i) for i in input().split()]
ab = []
for i in range(n):
    ab.append([int(j) for j in input().split()])
dp =[0] * 10001 + [10 ** 10] * 10000
for i in range(10001,20001):
    for ls in ab:
        dp[i] = min(dp[i],dp[i-ls[0]]+ls[1])
print(dp[10000+h])


Measured memory_bytes: 41744
tmp = input().split(" ")
N = int(tmp[0])
tmp = input().split(" ")
A = [int(i) for i in tmp]
nofb = [0]*N
for i in range(N,1,-1):
  #print("社員番号",i,"が送る尊敬の眼差し",A[i-2])
  boss = A[i-2]
  nofb[boss-1] += 1
for i in range(N):
  print(nofb[i])

Measured memory_bytes: 34092
from collections import Counter
s = input()
k = int(input())

# 全部同じ
C = Counter(s)
if len(C) == 1:
    print(len(s) * k // 2)
    exit()

# 両端が異なる
if s[0] != s[-1]:
    aida = 0
    cnt = 0
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            cnt += 1
        else:
            tmp = cnt // 2
            if cnt % 2 != 0:
                aida += tmp + 1
            else:
                aida += tmp
            cnt = 0
    tmp = cnt // 2
    if cnt % 2 != 0:
        aida += tmp + 1
    else:
        aida += tmp


    print(aida * k)

# 両端が同じ
else:
    # 先端の個数
    cnt = 1
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            cnt += 1
        else:
            break
    # 末端の個数
    cnt2 = 1
    for i in range(len(s)-1,-1,-1):
        if s[i] == s[i-1]:
            cnt2 += 1
        else:
            break

    # 先端で書き換える個数
    syoko = cnt // 2

    # 末端＋先端で書き換える個数
    sotogawa = (cnt + cnt2) // 2

    # 先端と末端の間で書き換える個数
    aida = 0
    cnt3 = 0
    #print(s[cnt : len(s)-cnt2])
    for i in range(cnt+1,len(s)-cnt2+1):
        if s[i] == s[i-1]:
            cnt3 += 1
        else:
            tmp = cnt3 // 2
            if cnt3 % 2 != 0:
                aida += tmp + 1
            else:
                aida += tmp
            cnt3 = 0

    saikuru = aida + sotogawa
    print(syoko + saikuru * k - saikuru + aida + cnt2//2)






Measured memory_bytes: 9488
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll b['Z' + 1] = {};
    REP(i, in())++b[in<string>()[0]];
    ll m = b['M'], a = b['A'], r = b['R'], c = b['C'], h = b['H'];
    cout << m * a * (r + c + h) + (m + a) * (r * c + c * h + h * r) + r * c * h;
    /*
    m a r
    m a c
    m a h
    m r c
    m r h
    m c h
    a r c
    a r h
    a c h
    r c h
    */
    /*
    m*(a*(r+c+h)+rc+rh+ch)+
    a*(rc+rh+ch)+
    r*ch
    */
    /*
    ma(r+c+h)+(m+a)(rc+rh+ch)+rch
    */
}

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

a.sort()
minus, plus = [], []

for x in a:
    if x < 0:
        minus.append(x)
    else:
        plus.append(x)

tmp = sum([abs(x) for x in a])

if len(minus) % 2 == 0:
    print(tmp)
else:
    if plus == [] or abs(minus[-1]) < plus[0]:
        print(tmp + minus[-1] * 2)
    else:
        print(tmp - plus[0] * 2)

Measured memory_bytes: 20044
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var h, w, k, ans int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &h, &w, &k)
	m := make([]string, h)
	for i := range m {
		scanner.Scan()
		m[i] = scanner.Text()
	}

	for b := 0; b < (1 << (h + w)); b++ {
		kb := 0
		for hb := 0; hb < h; hb++ {
			if (b>>hb)&1 == 1 {
				continue
			}
			for wb := 0; wb < w; wb++ {
				if (b>>(h+wb))&1 != 1 && string(m[hb][wb]) == "#" {
					kb++
				}
			}
		}
		if kb == k {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1844
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n;
	std::cin >> n;
	int l = 1;
	for(;l<=n;l*=2) {
		if(n==l) {
			print("No");
			return 0;
		}
	}
	l/=2;

	print("Yes");
	for(int i=1;i<3;i++) {
		std::cout << i << ' ' << i+1 << ENDL;
		std::cout << n+i << ' ' << n+i+1 << ENDL;
	}
	std::cout << 1 << ' ' << n+3 << ENDL;
	for(int i=1;4+i<=n;i+=2) {
		std::cout << 3+i << ' ' << 1 << ENDL;
		std::cout << 4+i << ' ' << 3+i << ENDL;
		std::cout << 3+n+i << ' ' << 4+n+i << ENDL;
		std::cout << 1 << ' ' << 4+n+i << ENDL;
	}
	if(n%2==0) {
		std::cout << n << ' ' << l << ENDL;
		std::cout << 2*n << ' ' << n+(l^1^n) << ENDL;
	}
	return 0;
}


Measured memory_bytes: 2304
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		ArrayList<int[]> list = new ArrayList<int[]>();
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			int[] add = {i, A[i]};
			list.add(add);
		}
		Collections.sort(list, (o1, o2)->Integer.compare(o2[1], o1[1]));

		long[][] dp = new long[N+1][N+1];
		for (int i=0;i<N;i++) {
			for (int j=0;j<N;j++) {
				if (i+j>=N) continue;
				int[] tmp = list.get(i+j);
				if (i+1<=N) dp[i+1][j] = Math.max(dp[i+1][j], dp[i][j]+(long)tmp[1]*Math.abs(tmp[0]-i));
				if (j+1<=N) dp[i][j+1] = Math.max(dp[i][j+1], dp[i][j]+(long)tmp[1]*Math.abs((N-1-j)-tmp[0]));
			}
		}
		long ans = 0L;
		for (int i=0;i<N+1;i++) {
			ans = Math.max(ans, dp[i][N-i]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 84356