akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#define clr(x,y) memset(x,y,sizeof(x))
using namespace std;

int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
char g[60][60];
int x[1005],y[1005];
int a[60][60],b[60][60],c[60][60];
bool vis[60][60];
int n,m,k,i,j,T,ex,ey;
vector<int> vc[60][60];

bool dfs(int x,int y,int t){
    if(vis[x][y]) return false;
    vis[x][y]=true;
    if(x==ex&&y==ey){
        T=t;
        return true;
    }
    for(int i=0;i<4;i++){
        int xx=x+dx[i],yy=y+dy[i];
        if(xx<0||xx>=n||yy<0||yy>=m||g[xx][yy]=='#') continue;
        if(dfs(xx,yy,t+1)){
            vc[x][y].push_back(t);
            return true;
        }
    }
    return false;
}
int main(){
//    freopen("in.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<n;i++) scanf("%s",g[i]);
    for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&b[i][j]);
    for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&a[i][j]);
    for(i=0;i<n;i++) for(j=0;j<m;j++) scanf("%d",&c[i][j]);

    T=0;
    for(i=1;i<=k;i++){
        clr(vis,0);
        scanf("%d%d",&x[i],&y[i]);
        ex=x[i],ey=y[i];
        if(i==1) continue;
        dfs(x[i-1],y[i-1],T);
    }
    vc[x[k]][y[k]].push_back(T);
    int ans=0;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(vc[i][j].size()==0) continue;
            ans+=a[i][j]+c[i][j];
            for(k=0;k<vc[i][j].size()-1;k++){
                int t1=(vc[i][j][k+1]-vc[i][j][k])*b[i][j];
                int t2=a[i][j]+c[i][j];
                ans+=min(t1,t2);
            }
        }
    }
//    for(i=0;i<n;i++){
//        for(j=0;j<m;j++){
//            printf("%d ",vc[i][j].size());
//        }
//        puts("");
//    }
    printf("%d\n",ans);
    return 0;
}

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

bool check(int x){
  
  long long p=0, value=0;
  
  while(p<s.size()){
    
    int num=0, flag=0;
    
    if(s[p]=='-') flag=1;
    if(s[p]!='x') p++;

    while('0'<=s[p]&&s[p]<='9') num=num*10+s[p++]-'0';
    
    if(num==0) num=1;
    
    if(flag) num*=-1;
    
    if(s[p+1]=='^') value+=num*pow(x,s[p+2]-'0'), p+=3;
    else value+=num*x, p++;
    
  }
  
  return value==0;
}

int main(){
  
  cin>>s;
  
  s+="x^0";
  
  for(int i=2000;i>=-2000;i--)
    if(check(i)){
      cout<<"(x";
      if(i<0) cout<<"+"<<i*(-1);
      else cout<<"-"<<i;
      cout<<")";
    }
  
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 3532
s = gets.strip.to_i

h = {}
h[s] = 1

2.upto(1000000) do |i|
  s = s.even? ? s / 2 : (s * 3) + 1
  unless h[s].nil? 
    puts i
    break
  else
    h[s] = i
  end
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
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; }

const int mod = 1000000007;
//const int mod = 998244353;
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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[2010];
int main()
{
    ll s;
    cin >> s;
    dp[0] = 1;
    dp[1] = 0;dp[2] = 0;
    rep2(i, 3, s+1)
    {
       dp[i] = dp[i-3] + dp[i-1];
    }
    cout << dp[s] << endl;
    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = nm[0];
            int m = nm[1];
            bool[] red = new bool[n];
            int[] box = new int[n];
            for (int i = 0; i < n; i++)
            {
                box[i] = 1;
            }
            red[0] = true;
            for (int i = 0; i < m; i++)
            {
                int[] xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int x = xy[0] - 1;
                int y = xy[1] - 1;
                if(red[x])
                {
                    red[y] = true;
                }
                box[x]--;
                box[y]++;
                if(box[x]<1)
                {
                    red[x] = false;
                }
            }
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (red[i]) ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 7448
def saiki(bang, abbali, tf):

    ans = 0
    if all(tf) == True:
        return 1
    stack = []
    for i in range(len(abbali)):
        if abbali[i][0] == bang and tf[abbali[i][1]-1] == False:
            stack.append(abbali[i][1])

    for i in range(len(stack)):
        tf[stack[i]-1] = True
        ans += saiki(stack[i], abbali, tf)
    return ans

def bridge(n , m , abl):

    ans = 0
    for i in range(m):
        abbali = []
        count = 0
        tf = [False]*n
        for q in range(m):
            if i != q:
                abbali.append(list((abl[q])))
                abbali.append(list(reversed(abl[q])))
        count = saiki(1, abbali, tf)
        ans += count if count < 1 else 1

    return m - ans

def main():
    n , m = map(int , input().split())
    abl = [list(map(int , input().split())) for i in range(m)]
    print(bridge(n , m , abl))

if __name__ == '__main__':
    main()


Measured memory_bytes: 44508
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	double x,y,z,maximum,tmp;

	while(true){
		scanf("%lf %lf %lf",&x,&y,&z);
		if(x == 0 && y == 0 && z == 0)break;

		maximum = 0;

		for(double i = 1; i <= z-1; i+=1){
			for(double k = i; k <= z-1; k++){
				if(i+k > z)break;

				if(floor(i*(100+x)/100)+floor(k*(100+x)/100) == z){
					tmp = floor(i*(100+y)/100) + floor(k*(100+y)/100);
					maximum = max(maximum,tmp);
				}
			}
		}

		printf("%.0f\n",maximum);

	}

	return 0;
}

Measured memory_bytes: 2732
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=998244353;
const int maxn=3e5+100;
const int N=1e6+100;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}


int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    string s;cin>>s;
    int mx=0,cnt=0;
    for(int i=0;i<sz(s);++i)
    {
        if(s[i]!='R')
        {
            mx=max(mx,cnt);
            cnt=0;
        }
        else cnt++;
    }
    mx=max(mx,cnt);
    cout<<mx<<endl;
    return 0;
}


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

int main(){
	ll n;
  	cin>>n;
  	ll x = n/500;
  	n -= x*500;
  	ll y = n/5;
  	ll ans = 0;
  	ans += x*500*2;
  	ans += y*5;
  	cout<<ans;
  	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int power = 1;
  for (int i = 0; i < 9; i++) {
    sum += (N % (power * 10) - N % power) / power;
    power *= 10;
  }
  if (N % sum == 0) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

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

  vector<LL> d(n);
  rep(i, n) cin >> d[i];

  int m;
  cin >> m;

  vector<LL> t(m);
  rep(i, m) cin >> t[i];

  map<LL, int> diff;
  map<LL, int>::iterator itr;

  rep(i, n) {
    itr = diff.find(d[i]);
    if (itr != diff.end()) {
      itr->second ++;
    } else {
      diff.insert(pair<LL, int>(d[i], 1));
    }
  }

  rep(i, m) {
    itr = diff.find(t[i]);
    if (itr != diff.end() && itr->second > 0) {
      itr->second --;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}

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

using namespace std;

int main()
{

    int i,k=0,n,x,l[101];

    cin>>n>>x;
    l[0]=0;
    for(i=0;i<n;i++)
        cin>>l[i];
    int d=0;//[x+1];
   // j=0;
/*for(i=1;i<=n;i++)
    {
        d[i]=j;
        j++;
        if(j>x)
            break;
    }*/
    //d[1]=0;
    //int a[x+1];
   // a[1]=0;
    for(i=0;i<n;i++)
    {
       d=d+l[k];// d[i]=d[i-1]+l[i-1];
       // a[i]=d[i];

        if(d>x)
            break;
        k++;
    }
    cout<<k+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <functional>

int T, N, K, i, xmin, xmax, lastx, latestx, dif[100010];

int getsum(){
	int sum=0;
	if(K>=N) K=N;
	std::sort(dif,dif+N-1,std::greater<int>());
	for(int t=0;t<K-1;++t) sum+=dif[t];
	return sum;
}

int main() {
	std::cin >> T; // データセットの数を読み込む
	for (;T>0;--T) {
		for(int t : dif) dif[i]=0;
		std::cin >> N;
		std::cin >> K;
		std::cin >> xmin;
		if(N>2){
			lastx=xmin;
			for(i=0;i<N-2;++i){
				std::cin >> latestx;
				dif[i]=latestx-lastx;
				lastx=latestx;
			}
			std::cin >> xmax;
			dif[i]=xmax-latestx;
			std::cout << xmax-xmin-getsum() << std::endl;
		}else if(N==2){
			std::cin >> xmax;
			dif[0]=xmax-xmin;
			std::cout << xmax-xmin-getsum() << std::endl;
		}else if(N==1){
			std::cout << "0" << std::endl;
		}
	}
}

Measured memory_bytes: 1568
using System;

namespace AtCoderABC123B
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] dishTime = new double[5];
            for(int i = 0; i < 5; i++) { 
                string[] line = Console.ReadLine().Split(' ');
                dishTime[i] = double.Parse(line[0]);
            }
            double sum = 0;
            double max = 0;
            foreach(double i in dishTime) {
                sum += Math.Ceiling(i/10) * 10;
                if(((Math.Ceiling(i/10) * 10)-i)>max)
                {
                    max = Math.Ceiling(i/10) * 10 - i;
                }
            }
            Console.Write((int)sum - max);
        }
    }
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (S.at(K - 1) == 'A') S.at(K - 1) = 'a';
  if (S.at(K - 1) == 'B') S.at(K - 1) = 'b';
  if (S.at(K - 1) == 'C') S.at(K - 1) = 'c';
  cout << S << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int d;
	while(~scanf("%d\n", &d)){
		long long total = 0;
		for(int i = d; i < 600; i += d)
			total += (long long)i * i * d;
		printf("%lld\n", total);
	}
	return 0;
}


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

const long MOD = 1e9 + 7;
long n, m, k, ans, t, div6;

long powMod(long x, long n, long mod){
	if (n == 1) return (x % mod);
	else if (n % 2 == 0){
		long t = powMod(x, n/2, mod);
		return (t*t) % mod;
	}
	else{
		return (x*powMod(x, n-1, mod)) % mod;
	}
}

long combMod(long n, long k, long mod){
	long a = min(k, n-k);
	long b = 1;
	long c = 1;
	for (int i = 1; i <= a; ++i){
		b = (b*i) % mod;
	}
	for (int i = n-a+1; i <= n; ++i){
		c = (c*i) % mod;
	}
	b = powMod(b, mod-2, mod);
	return (b*c) % mod;
}

int main(){
	cin >> n >> m >> k;
	div6 = powMod(6L, MOD-2, MOD);
	t = powMod(m, 2, MOD);
	t = (t*(n-1)) % MOD;
	t = (t*n) % MOD;
	t = (t*(n+1)) % MOD;
	ans = t;
	t = powMod(n, 2, MOD);
	t = (t*(m-1)) % MOD;
	t = (t*m) % MOD;
	t = (t*(m+1)) % MOD;
	ans = (ans + t) % MOD;
	ans = (ans*div6) % MOD;
	ans = (ans*combMod(n*m-2, k-2, MOD)) % MOD;
	cout << ans;
}

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

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n, m;
int a[MAX];
ll c[MAX];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        read(a[i]);
        c[a[i]]++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans += (ll)c[i]*(c[i]-1)/2;
    }
    for(int i = 1; i <= n; i++){
        ll x = ans-(c[a[i]]*(c[a[i]]-1))/2;
        x += (c[a[i]]-1)*(c[a[i]]-2)/2;
        write(x), putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
using namespace std;
#define MAX 100

int main(){
  int n;
  cin >> n;
  int u, k, v, adj[MAX+1][MAX+1];

  // init
  for ( int i = 1; i <= n; i++){
    for ( int j = 1; j <= n; j++){
      adj[i][j] = 0;
    }
  }

  for ( int i = 1; i <= n; i++){
    cin >> u >> k;
    for ( int j = 0; j < k; j++ ){
      cin >> v;
      adj[u][v] = 1;
    }
  }

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

  return 0;
}


Measured memory_bytes: 3152
import itertools

H, W = map(int, input().split())
S = [[0]*W for _ in range(H)]
for h in range(H):
    s = input()
    for w in range(W):
        if s[w] == '#':
            S[h][w] = '#'

for i, j in itertools.product(range(H), range(W)):
    if S[i][j] == '#':
        if j != 0 and S[i][j-1] != '#':
            S[i][j-1] += 1
        if j != W - 1 and S[i][j+1] != '#':
            S[i][j+1] += 1
        if i != 0 and S[i-1][j] != '#':
            S[i-1][j] += 1
        if i != H-1 and S[i+1][j] != '#':
            S[i+1][j] += 1

        if j != 0 and i != 0 and S[i-1][j-1] != '#':
            S[i-1][j-1] += 1
        if j != W - 1 and i != H - 1 and S[i+1][j+1] != '#':
            S[i+1][j+1] += 1
        if i != 0 and j != W - 1 and S[i-1][j+1] != '#':
            S[i-1][j+1] += 1
        if i != H-1 and j != 0 and S[i+1][j-1] != '#':
            S[i+1][j-1] += 1

for s in S:
    print(*s, sep='')


Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long []a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextLong();
		}
		scan.close();
		Arrays.sort(a);
		long max = a[n - 1];
		long median1 = 0;
		long median2 = 0;
		long ans2 = 0;
		if(max % 2 == 0) {
			median1 = max / 2;
			long min = (median1 - a[0]) * (median1 - a[0]);
			ans2 = a[0];
			for(int i = 1; i < n - 1; i++) {
				long k = (median1 - a[i]) * (median1 - a[i]);
				if(min > k) {
					min = k;
					ans2 = a[i];
				}
			}
		}else {
			median1 = max / 2 ;
			median2 = max / 2 + 1;
//			System.out.prlongln(median1);
//			System.out.prlongln(median2);
			long k1 = (median1 - a[0]) * (median1 - a[0]);
			long k2 = (median2 - a[0]) * (median2 - a[0]);
			long min = 0;
			if(k1 < k2) {
				min = k1;
			}else {
				min = k2;
			}
			ans2 = a[0];
			for(int i = 1; i < n - 1; i++) {
				long min1 = (median1 - a[i]) * (median1 - a[i]);
				long min2 = (median2 - a[i]) * (median2 - a[i]);
				long k;
				if(min1 > min2) {
					k = min2;
				}else {
					k = min1;
				}
//				System.out.prlongln(min1);
//				System.out.prlongln(min2);
				if(k < min) {
					min = k;
					ans2 = a[i];
				}
			}
		}
		System.out.println(max + " " + ans2);
	}
}

Measured memory_bytes: 50852
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ss(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define per(i, l, r) for (int i = r; l <= i; --i)

using ll = long long;
using namespace std;

string s;
int cnt[26];
 
int main() {
	cin >> s;
	for (auto x : s)
		cnt[x - 'a']++;
	ll res = 0;
	rep(i, 0, 25)
		rep(j, i + 1, 25)
			res += 1LL * cnt[i] * cnt[j];
	cout << res + 1 << endl;
	return 0;
}


Measured memory_bytes: 3744
#include<stdio.h>
int main(void){
	int num,w[31],n,i,a,b;
	scanf("%d",&num);
	for(i=1;i<=num;i++){w[i]=i;}
	scanf("%d",&n);
	while(n--){
		scanf("%d,%d",&a,&b);
		i=w[a];w[a]=w[b];w[b]=i;
	}
	for(i=1;i<=num;i++)printf("%d\n",w[i]);
	return 0;
}

Measured memory_bytes: 596
package main

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

func main() {
	N := sc.nextInt()
	S := sc.next()
	if N%2 != 0 {
		no()
		return
	}
	if S[0:len(S)/2] == S[len(S)/2:len(S)] {
		yes()
	} else {
		no()
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <assert.h>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <double,P> PP;
  
static const double EPS = 1e-8;

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

class SternBrocotTree {
public:
  SternBrocotTree(int B,int p)
    : max_depth(0),
      ans_left_numerator(0),
      ans_right_numerator(0),
      ans_left_denominator(0),
      ans_right_denominator(0){
    this->B = B;
    this->p = p;
  }

  void dfs(int left_numerator,int left_denominator,
           int right_numerator,int right_denominator,int depth){
    int next_numerator = left_numerator + right_numerator;
    int next_denominator = left_denominator + right_denominator;

    if(contains(left_numerator,left_denominator,next_numerator,next_denominator)){
      dfs(left_numerator,left_denominator,next_numerator,next_denominator,depth+1);
    }

    if(max_depth < depth){
      max_depth = depth;
      ans_right_numerator = right_numerator;
      ans_right_denominator = right_denominator;
      ans_left_numerator = left_numerator;
      ans_left_denominator = left_denominator;
    }

    if(contains(next_numerator,next_denominator,right_numerator,right_denominator)){
      dfs(next_numerator,next_denominator,right_numerator,right_denominator,depth+1);
    }
  }
  void disp(){
    printf("%d/%d %d/%d\n",
           ans_right_numerator,ans_right_denominator,
           ans_left_numerator,ans_left_denominator);
  }
private:
  int B;
  int p;
  int max_depth;
  int ans_left_numerator;
  int ans_left_denominator;
  int ans_right_numerator;
  int ans_right_denominator;
  
  bool contains(int left_numerator,int left_denominator,
                int right_numerator,int right_denominator){
    if(left_numerator > B || left_denominator > B
       || right_numerator > B || right_denominator > B) return false;
    if(left_numerator * left_numerator < left_denominator * left_denominator * p
       && p * right_denominator * right_denominator < right_numerator * right_numerator){
      return true;
    }
    return false;
  }
};

int main(){
  int p;
  int n;

  while(~scanf("%d %d",&p,&n)){
    if(p == 0 && n == 0) break;
    SternBrocotTree sbt(n,p);
    sbt.dfs(0,1,1,0,0);
    sbt.disp();
  }
}

Measured memory_bytes: 1192
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var i = 0;
 while(true){
   if(lines[i] == 0){
     break;
   }
   var n = lines[i];
   console.log("Case " + Number(i+1) + ": " + n);
   i++;
 }
});


Measured memory_bytes: 23640
package main

import (
	"fmt"
)

func main() {
	var n, x int
	fmt.Scanf("%d %d", &n, &x)

	l := make([]int, n)
	d := make([]int, n+1)

	for i := range l {
		fmt.Scan(&l[i])
	}
	for i := 1; i < n+1; i++ {
		d[i] = d[i-1] + l[i-1]
	}
	ans := 0

	for _, v := range d {
		if v <= x {
			ans++
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 512
import math
from collections import Counter
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
a = li()

cnt = Counter(a)
ans = 0
for i,j in cnt.items():
    if i > j:
        ans += j
    else:
        ans += j - i
print(ans)

Measured memory_bytes: 22480
x,n=map(int,input().split())
ar=[int(i) for i in input().split()]
arr=[i for i in range(0,1000) if i not in ar]
arr.sort()
mini=10000000
for i in arr:
    if abs(i-x)<mini:
        mini=abs(i-x)
        ans=i 
print(ans)

Measured memory_bytes: 9120
#include<stdio.h>
#include<stdlib.h>

int main(){
 int n,i;
 scanf("%d",&n);
 int* p;
 p=malloc((n+1)*sizeof(int));
 for(i=0;i<n;i++){
  scanf("%d",&p[i]);}
 for(i=1;i<n;i++){
  printf("%d ",p[n-i]);}
 printf("%d\n",p[0]);
 free(p);
 return 0;}

Measured memory_bytes: 596
-module('Main').
-export([main/1]).

solve() ->
    [S] = input("~s"),
    Ans = case lists:any(fun (C) -> C =:= $7 end, S) of
        true -> "Yes";
        false -> "No"
    end,
    io:format("~s~n", [Ans]),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.


Measured memory_bytes: 21840
n = int(input())
pp = []
pm = []
mp = []
mm = []

for i in range(n):
    x, y = list(map(int, input().split()))
    pp.append(x + y)
    pm.append(x - y)
    mp.append(-x + y)
    mm.append(-x - y)

max_pp = max(pp)
min_pp = min(pp)
max_pm = max(pm)
min_pm = min(pm)
max_mp = max(mp)
min_mp = min(mp)
max_mm = max(pm)
min_mm = min(pm)

max_val = max(max_pp - min_pp, max_pm - min_pm, max_mp - min_mp, max_mm - min_mm)
print(max_val)



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int G=0;
    for (;N--;){
        int A,K; cin >> A >> K;
        while(K<=A&&A%K!=0){
            int sub=A/K+1;
            A-=(A%K+sub-1)/sub*sub;
        }
        G^=A/K;
    }
    cout << (G?"Takahashi":"Aoki") << '\n';
}

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

using namespace std;

int main(){
	long long A, B, Q;
	cin >> Q;
	while(Q--){
		cin >> A >> B;
		long long C = A * B;
		long long lo = 1, hi = 2e9, ans = 0;
		while(lo <= hi){
			long long mid = (lo + hi) / 2LL;
			long long D = 0;
			long long M = mid / 2LL;

			for(long long i = M - 5; i <= M + 5; ++i){
				if(i < 1 || i > mid) continue;
				long long a = i;
				if(A <= a) ++a;
				long long b = mid - i + 1LL;
				if(B >= b) --b;
				D = max(D, a * b);
			}
			if(D < C) ans = mid, lo = mid + 1;
			else hi = mid - 1;
		}
		if(ans >= min(A, B)) --ans;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <regex>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define pq priority_queue<int,vector<int>,greater<int>>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define INF 9999999999
#define F first
#define S second
//#define int long long

using namespace std;

typedef pair<int, int> pi;
typedef pair<int, pi> pp;

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int main() {
	int i, a, b;
	cin >> i;
	if(i == 1)
		cout << "Hello World" << endl;
	else {
		cin >> a >> b; cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))


class Vec{
public:
  double x, y;
  Vec(double x = 0, double y = 0):x(x),y(y){}

  void read(){
    cin >> x >> y;
  }

  void print(){
    printf("%.10lf %.10lf\n", x, y);
  }
  
  Vec operator+(const Vec &other)
  {
    Vec result = *this;
    result.x += other.x;
    result.y += other.y;
    return result;
  }

  Vec operator-(const Vec &other)
  {
    Vec result = *this;
    result.x -= other.x;
    result.y -= other.y;
    return result;
  }

  Vec operator*(const double &k)
  {
    Vec result = *this;
    result.x *= k;
    result.y *= k;
    return result;
  }

  Vec operator/(const double &k)
  {
    Vec result = *this;
    result.x /= k;
    result.y /= k;
    return result;
  } 
  
  double cross(const Vec &other)
  {
    return x*other.y - y*other.x;
  }

  double dot(const Vec &other){
    return x*other.x + y*other.y;
  }
  
  bool operator==(const Vec &other) const
  {
    return abs(x - other.x) < EPS && abs(y - other.y) < EPS;
  }

  double norm()
  {
    return sqrt(x*x+y*y);
  }

  double norm2()
  {
    return x*x+y*y;
  }

  Vec standard(){
    Vec result = *this;
    return result/result.norm();
  }
};

//ccw:1, cw:-1, other:0
Int CCW(Vec a, Vec b, Vec c){
  b = b - a;
  c = c - a;
  if(b.cross(c) > EPS)return -1;
  if(b.cross(c) < -EPS)return 1;
  return 0;
}

double dist(Vec a, Vec b){
  return (a-b).norm();
}
			

class Line{
public:
  Vec a, b;
  Vec vect;
  Line(Vec a = Vec(), Vec b = Vec()):a(a),b(b),vect(b-a){}

  //projection
  Vec proj(Vec p){
    p = p - a;
    return a + vect * vect.dot(p) / vect.norm2();
  }

  //reflection
  Vec reflect(Vec p){
    return proj(p) * 2 - p;
  }

  bool onSegment(Vec p){
    return abs((p-a).cross(b-a)) < EPS && (p-a).dot(p-b) < EPS;
  }

  //other -> LineSegment(not inclusive), this -> Line
  bool _intersect(Line &other){
    return CCW(a, b, other.a) * CCW(a, b, other.b) < 0;
  }

  //other, this: both are LineSegment(inclusive)
  bool intersect(Line &other){
    return onSegment(other.a) || onSegment(other.b) || other.onSegment(a) || other.onSegment(b) || _intersect(other) && other._intersect(*this);
  }

  //low accuracy
  Vec crossPoint(Line &other){
    double ratio = (a - other.a).cross(vect) / other.vect.cross(vect);
    return other.a + other.vect * ratio;
  }

  double dist(Vec p){
    Vec pp = proj(p);
    if(onSegment(pp))return ::dist(p, pp);
    else return min(::dist(p, a), ::dist(p, b));
  }
  
  double dist(Line &other){
    if(intersect(other))return 0;
    return min(min(dist(other.a), dist(other.b)), min(other.dist(a), other.dist(b)));
  }
};


int main(){
  Int q;
  cin >> q;
  while(q--){
    Vec p0, p1, p2, p3;
    p0.read();
    p1.read();
    p2.read();
    p3.read();
    Line l1(p0, p1), l2(p2, p3);
    printf("%.10lf\n", l1.dist(l2));
  }
  return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

bool solve(const string& s, int n, int a, int b) {
  vector<bool> ok(n, false);
  ok[a] = true;
  FOR(i,a,b) {
    if (ok[i]) {
      if(s[i+1] == '.') ok[i+1] = true;
      if(s[i+2] == '.') ok[i+2] = true;
    }
  }
  return ok[b];
}

int main()
{
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  --a;--b;--c;--d;
  string s;
  cin>>s;
  bool ok;
  if (c > d) {
    ok = false;
    FOR(i,b,d+1) {
      if (s.substr(i-1, 3) == "...") {
        ok = true;
      }
    }
    ok = ok && solve(s,n,a,c) && solve(s,n,b,d);
  } else {
    ok = solve(s,n,a,c) && solve(s,n,b,d);
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
    int a, b, c;
    cin>>a;
    cin>>b;

    if ( a == 1 & b == 3 ) {
        cout << 2 << endl;
    }
    else if ( a == 1 & b == 2 ) {
        cout << 3 << endl;
    }
    else if ( a == 2 & b == 1 ) {
        cout << 3 << endl;
    }
    else if ( a == 2 & b == 3 ) {
        cout << 1 << endl;
    }
    else if ( a == 3 & b == 1) {
        cout << 2 << endl;
    }
    else if ( a == 3 & b == 2 ) {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


a, b, c = [int(x) for x in input().split()]
re = set()
for i in range(1, int(b / gcd(a, b)) + 1):
    re.add(a * i % b)
print("YES") if c in re else print("NO")


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int a,b;
    while(scanf("%d %d",&a,&b) != EOF){
        int sum,cnt=1;
        sum=a+b;
        while(sum>=10){
            sum=sum/10;
            cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}



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


int main(){
	string a,b;
	cin>>a>>b;

	for (int i = 0; i < b.size(); i++){
		cout<<a[i]<<b[i];
	}
	if(a.size()!=b.size()){
		cout<<a[a.size()-1];
	}

	cout<<endl;
	

} 

Measured memory_bytes: 256
/*
	Author: zhaodeyin
	Time: 2018.3.25
*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int a[105];
int main(){
	int n,k,x;
	cin>>n>>k>>x;
	int ans = 0;
	for(int i = 1; i <= n; i++) cin>>a[i];
	for(int i = 1; i <= n; i++){
		int sum = 0;
		int t = a[i];
		int w = 1;
		if(a[i] < k) 
			while(t <= k){
			sum++;
			t = a[i]*w+1;
			w++;
		}
		else sum = 1;
		ans += sum;
	}
	cout<<ans+x<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
		int c = sc.nextInt();
        int ans = 0;
        int i;
        for(i = a;i <= b;i++){
          if(i % c == 0){
           ans += 1;
          }
        }
      	System.out.println(ans);
 
    }
}

Measured memory_bytes: 35568
li = lambda: list(map(int,input().split()))

d,g = li()
g //= 100
num,comp = [], []
for _ in range(d):
    a,b = li()
    num.append(a)
    comp.append(b//100)

from itertools import product
mul = product((0, 1), repeat=d)

ans = float('inf')
for m in mul:
    pt = sum(m[i]*comp[i] for i in range(d)) + sum(m[i]*(i+1)*num[i] for i in range(d))
    n = sum(m[i]*num[i] for i in range(d))
    if pt < g:
        if not all(m):
            i = [i for i,j in enumerate(m) if j==0][-1]
        else:
            continue
        if pt + (i+1)*(num[i]-1) < g:
            continue
        n += -((pt-g)//(i+1))
    ans = min(ans,n)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int s[100004];

int main(){
    int N; cin>>N;
    ll sum = 0;
    for(int i=0;i<N;i++) cin>>s[i], sum+= s[i];
    
    int sub = 0;
    
    for(int i=1;i<N;i+=2)sub += s[i];
    sub *= 2;
    int x = sum - sub;
    cout<<x<<" ";
    vector<int> v(N);v[0]=x;
    for(int i=0;i<N-1;i++){
        v[i+1] = 2*s[i]-v[i];
        cout<<v[i+1]<<" ";
    }
    cout<<endl;
}

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

int count_divisor(int n){
  int n_half = n/2;
  int c[n_half] = {0};
  int d_max;
  for(int i=2;i<n_half;i++){
    if(n%i==0){
      n /= i;
      c[i]++;
      if(n>1){
        i--;
        continue;
      } else{
        d_max = i;
        break;
      }
    }
  }
  int r = 1;
  for(int i=2;i<d_max+1;i++){
    r *= (c[i]+1);
  }
  return r;
}

int main(){
  int N; cin >> N;
  int count = 0;
  for(int i=105;i<N+1;i+=2){
    if(count_divisor(i)==8){
      count++;
    }
  }
  cout << count << endl;
}

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

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

if N%2 == 0:
    ans = sum(A[1:(N-2)//2+1])*2
else:
    ans = sum(A[1:(N-2)//2+1])*2 + A[(N-2)//2+1]
ans += A[0]
print(ans)

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

using namespace std;
typedef long long ll;

const int inf = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int pos = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    cout << (n - 1 + k - 2) / (k - 1);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long

int main(int argc, char const *argv[]){
	int h,w;
	int j = 0;
	char c[107][107] = {'\0'};
	scanf("%d%d",&h,&w);
	for (int i = 0; i < h; ++i)	scanf(" %s",c[i]);
	for (int i = 0; i < 2 * h; ++i)
	{
		if(i % 2 == 0 && i > 0)	++j;
		printf("%s\n",&c[j]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	char a[100];
	int n,ans=10000;
	int i,j,k;
	scanf("%s",a+1);
	n=strlen(a+1);
	for(i=1;i<=n;i++)
	{
		j=i+1,k=j+1;
		if(k<=n)
			{
				ans=min(ans,abs((a[i]-'0')*100+(a[j]-'0')*10+(a[k]-'0')-753));
			}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){int b=1;Map<Integer,Integer>m=new TreeMap<Integer,Integer>();for(Scanner s=new Scanner(System.in);s.hasNext();){String x=s.nextLine();if(x.isEmpty()){b=0;x=s.nextLine();}int y=new Integer(x.split(",")[0]);if(b>0)m.put(y,m.containsKey(y)?m.get(y)-1:-1);else if(m.containsKey(y))m.put(y,Math.abs(m.get(y))+1);}for(int y:m.keySet())if(m.get(y)>0)System.out.println(y+" "+m.get(y));}}

Measured memory_bytes: 12000
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(b+c<a){
        printf("0\n");
    }
    else{
        printf("%d\n",c-abs(a-b));
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,ji,a[N],mi=1e9;
long long ans=0;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mi=min(mi,abs(a[i]));
		if(a[i]<0)ji++;
	}
	if(ji%2==0)
		for(int i=0;i<n;i++)
			ans+=abs(a[i]);
	else{
		bool f=true;
		for(int i=0;i<n;i++)
		{
			if(abs(a[i])==mi&&f)
			{
				f=false;
				ans-=abs(a[i]);
			}
			else
				ans+=abs(a[i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int a[4],c[4];
  while(cin>>a[0]){
    int e=0,b=0;
    for(int i=1;i<4;i++)
      cin>>a[i];
    for(int i=0;i<4;i++){
      cin >> c[i];
      for(int j=0;j<4;j++)
	if(c[i]==a[j]){
	  if(i==j)e++;
	  else b++;
	}
    }
    cout<<e<<' '<<b<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

// 約数列挙、O(sqrt(N))
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
  ll N; cin >> N;
  auto divs = divisor(N);

  ll ans = 0;
  for (ll q : divs){
    ll e = N/q;
    if (q<=e-2) ans += e-1;
  }
  cout << ans << endl;

 

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3620
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define len(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}


void solve(){
  int x;
  cin >> x;
  cout << 1 - x << endl;
}

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


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all;

int main() {
  int N;
  string S;
  cin >> N >> S;
  replace_all(S, "ABC", "");
  cout << (N - S.size()) / 3 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        rep(i, N) par[i] = i;
    }
    int root(int x) {
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        par[rx] = ry;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> p(n);
    rep(i, n) {cin >> p[i]; --p[i];}
    UnionFind tree(n);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        tree.unite(a, b);
    }
    int ans = 0;
    rep(i, n) if (tree.same(i, p[i])) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

long long N;
long long A[304][304], d[304][304];
long long s;

int main()
{
    cin >> N;
    for(long long i = 0; i < N; i++){
        for(long long j = 0; j < N; j++){
            cin >> A[i][j];
            d[i][j] = A[i][j];
        }
    }

    for(long long k = 0; k < N; k++){
        for(long long i = 0; i < N; i++){
            for(long long j = 0; j < N; j++){
                if(A[i][j] > A[i][k] + A[k][j]){
                    cout << -1 << endl;
                    return 0;
                }

                if(A[i][j] == A[i][k] + A[k][j]){
                    if(i!=k && j != k) d[i][j] = 0;
                }
            }
        }
    }

    for(long long i = 0; i < N; i++){
        for(long long j = i; j < N; j++){
            s += d[i][j];
        }
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 1664