akhauriyash/Code-Regression huggingface dataset:
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, A, B = [int(_) for _ in input().split()]


a = N // (A+B)
b = N % (A+B)
if b > A:
    b = A

print(int(a * A + b))

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var a = r[0].ToInt();
            var b = r[1].ToInt();
            var ans = Lcm(a, b);
            WriteRead(ans);
        }

        public static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
        public static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int S = sc.nextInt();
        int h, m, s;

        s = S % 60;
        S = (S - s) / 60;
        m = S % 60;
        S = (S - m) / 60;
        h = S;

        System.out.println(h + ":" +m + ":" + s);
    }
}



Measured memory_bytes: 26232
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=505;
const long long INF=4557430888798830399;
int n;
long long a[N][N];
long long s1[N][N],s2[N][N];
long long f[N][N];
long long calc1(int l1,int r1,int l2,int r2)
{
	swap(l1,l2);
	swap(r1,r2);
	if(l1>r1) return 0;
	if(l2>r2) return 0;
	return s1[r1][r2]-s1[l1-1][r2]-s1[r1][l2-1]+s1[l1-1][l2-1];
}
long long calc2(int l1,int r1,int l2,int r2)
{
	if(l1>r1) return 0;
	if(l2>r2) return 0;
	return s2[r1][r2]-s2[l1-1][r2]-s2[r1][l2-1]+s2[l1-1][l2-1];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j) scanf("%lld",&a[i][j]);
	for(int i=1;i<=n+1;i++)
		for(int j=1;j<=n+1;j++)
		{
			s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1];
			if(i>j) s1[i][j]+=a[i][j];
			s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1];
			if(i<j) s2[i][j]+=a[i][j];
		}
	memset(f,63,sizeof(f));
	f[0][0]=0;
	for(int i=0;i<=n;i++)
		for(int j=i;j<=n;j++)
			if(f[i][j]<INF)
				for(int k=j+1;k<=n+1;k++)
					f[j][k]=min(f[j][k],f[i][j]+calc1(i+1,j,k+1,n+1)+calc2(j+1,k,j+1,k));
	long long res=INF;
	for(int i=0;i<=n;i++)
		res=min(res,f[i][n+1]);
	printf("%lld",res);
	return 0;
}


Measured memory_bytes: 11684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

const int MOD = 1000000007;

ll nck(ll n, ll k){
    // 0~k-1までの和～n-k+1~nまでにいくつ数があるか？
    ll begin = (0+k-1)*k/2;
    ll end = (n-k+1 + n)*k/2;
    return end-begin+1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    // (n+1Ck ~ n+1Cn+1 まで)
    ll ans = 0;
    for(int i = k; i<=n+1; i++){
        ans += (nck(n, i)%MOD);
    }
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pi 3.141592653589793238

int main( )
{
     float r,ans;
     cin>>r;
     ans = 2*pi*r;
     printf("%.20f\n",ans);
     //cout<<fixed<<setprecision(20)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3776
n,m,x=map(int, input().split())
C, A = [], []
for i in range(n):
	c, *a = map(int, input().split())
	C.append(c)
	A.append(a)
# print(A)
# print(C)
cost=0
#preserve each sums of algorithms
# print(X)
flg=False
ans=sum(C)
for i in range(1,2**n):
	# X=[[0] for _ in range(m)]
	X=[0]*m
	cost=0
	flg=True
	#j is the chosen textbook
	for j in range(n):
		if (i>>j)&1 == 1:
			cost += C[j]
			for k in range(m):
				X[k] += A[j][k]
	for idx in X:
		if idx < x:
			flg = False
			break
	# print(X)
	# print("C[]: ", C)
	# print("cost: ", cost)
	# print("ans: ", ans)
	if flg:
		ans = min(ans,cost)

if flg:
	print(ans)
else:
	print('-1')

Measured memory_bytes: 9224
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	int n;
	cin >> n;
	
	int count=0;
	for(int i=1;i<=n; i++){
		if(to_string(i).size() % 2 != 0) count++;
	}
	
	cout << count << endl;
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<int, int>::iterator;




int main() {
	int N, X;
	cin >> N >> X;

	int cnt = 1;
	int cod = 0;
	vector<int> vL(N,0);
	for (int i = 0; i != N; ++i) {
		int L;
		cin >> L;
		vL[i] = L;
	}

	for (int i = 0; i != N; ++i) {
		if (cod + vL[i] <= X) {
			cod += vL[i];
			cnt++;
		}
		else {
			break;
		}
	}

	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
using namespace std;
using ll = long long;

int main() {

	double t,x,ans=0;
	cin >> t >> x;
	ans = t / x;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;



    cout << ((A*B)%2==0?"Even":"Odd")<< endl;


    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <cstdlib>
#include <iterator>
using namespace std;

//#define TEST
int main()
{
#ifdef TEST
	freopen("data.in", "r", stdin);
	freopen("data.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	string str;
	while(cin >> str) {
		for (int i = 0; i < str.length(); i += 2) {
			cout<< str[i];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 592
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    map<ll,ll> mp[2];
    mp[0][0]=mp[1][0]=0;
    rep(i,n){
        ll v;cin>>v;
        ++mp[i%2][v];
    }

    vp a[2];
    rep(i,2)for(auto &p:mp[i]){
        a[i].emplace_back(p.second,p.first);
    }
    sort(a[0].rbegin(),a[0].rend());
    sort(a[1].rbegin(),a[1].rend());

    ll ans=INF;
    rep(i,2)rep(j,2){
        if(a[0][i].second == a[1][j].second)continue;
        chmin(ans,n-a[0][i].first-a[1][j].first);
    }
    cout<<ans<<endl;
}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int n, m;
int D[N + N], T[N + N];

int Solve(){
    for(int i = 1, j = 1; i <= m; i++){
        int paichi = 0;
        for(  ; j <= n; j++){
            if(D[j] == T[i]){
                j++;
                paichi = 1;
                break;
            }
        }
        if(paichi == 0) return 0;
    }
    return 1;
}

int main(){
    fastScan(n);
    for(int i = 1; i <= n; i++){
        fastScan(D[i]);
    }
    sort(D + 1, D + n + 1);
    fastScan(m);
    for(int i = 1; i <= m; i++){
        fastScan(T[i]);
    }
    sort(T + 1, T + m + 1);
    puts(Solve() ? "YES" : "NO");
}


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

signed main(){

    int a, b; cin >> a >> b;
    if(a * b <= 0) cout << "Zero" << endl;
    else if(a > 0 && b > 0) cout << "Positive" << endl;
    else{
        int num = b - a;
        if(num % 2 == 1) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }

    return 0;
}

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

ll x, y, i;
int main() {
	cin >> x >> y;
	if(x%y==0) return puts("-1")*0;
	for(i=2; ; i++) {
		if(x*i<0) return puts("-1")*0;
		if(x*i%y) break;
	}
	cout << x*i;
	return 0;
}

Measured memory_bytes: 256
N = int(raw_input())
TA = [map(int, raw_input().split()) for _ in range(N)]
nt, na = 1, 1
for t, a in TA:
    xt = nt / t
    if nt % t != 0:
        xt += 1
    xa = na / a
    if na % a != 0:
        xa += 1
    x = max(xt, xa)
    nt, na = t*x, a*x
print nt + na


Measured memory_bytes: 2692
#include<iostream>

using namespace std;

int main(){

    long n,a;

    cin >> n;

    long sum = 0;
    long max,min;

    for(int i = 0; i < n; i++){
        cin >> a;
        sum += a;
        if (i == 0){
            max = a;
            min = a;
        } else {
            if (a > max){
                max = a;
            } else if (a < min){
                min = a;
            }
        }

    }

    cout << min << " " << max << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {


public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    //int r = 0;
    sc.close();

    if(n % 1000 == 0){
        System.out.println(0);
    }else{
        System.out.println(1000 - n%1000);
    }

}

}


Measured memory_bytes: 35548
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;

int dat[100005];
int minn[100005];

int main(){
	int in;
	int t,k,min_k;
	cin>>in>>k;
	rep(i,in,1){
		cin>>dat[i];
	}
	for(int i=in-1;i>=1;i--){
		t=INF;
		min_k=min(k,in-i);
		for(int j=1;j<=min_k;j++){
			t=min(t,abs(dat[i]-dat[i+j])+minn[i+j]);
		}
		minn[i]=t;
	}
	cout<<minn[1]<<endl;	
	return 0;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	
	map<int,int> mp;
	rep(i,10){
		mp[i] = -1;
	}
	
	rep(i,M){
		int s,c;
		cin >> s >> c;
		if(mp[s] != -1 && mp[s] != c){
			cout << -1 << endl;
			return 0;
		}
		mp[s] = c;
		
	}
	
	if( N!=1){
		if(mp[1] != -1 && mp[1] == 0){
			cout << -1 << endl;
			return 0;
		}
	}
	
	if(N== 1){
		if(mp[1] != -1){
			cout << mp[1] << endl;
			return 0;
		}else{
			cout << 0 << endl;
			return 0;
		}
	}
	
	
	vector<int> ans(N+1);
	
	REP(i,N){
		if(i==1){
			if(mp[i] == -1){
				ans[i] = 1;
			}else{
				ans[i] = mp[i];
			}
		}else{
			if(mp[i] == -1){
				ans[i] = 0;
			}else{
				ans[i] = mp[i];
			}
		}
	}
	
	REP(i,N){
		cout << ans[i];
	}
	
	puts("");
	
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int n,m,l;
	scanf("%d %d %d",&n,&m,&l);
	int A[n][m],B[m][l];
	long long int C[n][l];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			C[i][j] = 0;
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < l; j++){
			scanf("%d",&B[i][j]);
		}
	}

	for(int i = 0; i < n; i++){
		for(int k = 0; k < l; k++){
			for(int j = 0; j < m; j++){
				C[i][k] += A[i][j]*B[j][k];
			}
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < l-1; j++){
			printf("%lld ",C[i][j]);
		}
		printf("%lld\n",C[i][l-1]);
	}
}


Measured memory_bytes: 2736
s=list(input())
n=len(s)
if s[0]!='A':print('WA')
else:
  c=0
  for i in range(2,n-1):
    if s[i]=='C':c+=1
  if c!=1:print('WA')
  else:
    s.remove('A')
    s.remove('C')
    t=''.join(s)
    u=t.lower()
    if t==u:print('AC')
    else:print('WA')

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner (System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] c = new int[N];
		int[] t = new int[N];
		int p = 1001;
		for (int i = 0; i < N; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			if ((t[i] <= T) && (c[i] < p)) {
				p = c[i];
			}
		}
		if (p == 1001) {
			System.out.println("TLE");
		} else {
			System.out.println(p);
		}
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll n;
string s;
map<pair<string,string>,ll>cnt;
ll ans=0;
void mae(string ss,string sss,ll depth){
  if(depth==n){
    reverse(ALL(ss));
    reverse(ALL(sss));
    cnt[mp(ss,sss)]++;
    return;
  }
  mae(ss+s[depth],sss,depth+1);
  mae(ss,sss+s[depth],depth+1);
}
void ushiro(string ss,string sss,ll depth){
  if(depth==2*n){
    ans+=cnt[mp(ss,sss)];
    return;
  }
  ushiro(ss+s[depth],sss,depth+1);
  ushiro(ss,sss+s[depth],depth+1);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  cin>>s;
  mae("","",0);
  ushiro("","",n);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 84992
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <complex>
#include <iomanip>
#include <bitset>
#include <random>
#include <vector>
#include<string>

using namespace std;

int main() {
	long n, a, min = 11111111111111111, ans;
	cin >> n;
	for (int i = 0; i < 5; i++) {
		cin >> a;
		if (a < min)
			min = a;
	}
	ans = (n - 1) / min + 5;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  //corners =4 -> Doesn't change                                                
  //middle  =9                                                                  
  //edges   =6 -> Doesn't change                                                
  //if only one row or one column                                               
  // -- left/right/top/bottom = 2 -> Doesn't change                             
  // -- middle = 3                                                              
  //if N=M=1, only 1 change                                                     
  ll N, M;
  ll res=0;
  cin >> N >> M;

  if(N==1 && M==1) res=1;
  else if(N==1 || M==1) res = max(N,M)-2;
  else{
    res = (N-2)*(M-2);
  }

  cout << res << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  ll A = nextInt();
  ll B = nextInt();
  ll C = nextInt();
  ll D = nextInt();

  bool ans = false;

  for (ll i = 0; i < N - 1; i++) {
    ll x = A + (i * C) - (N - 1 - i) * D;
    // if (N <= 10) cout << x << " " << (N-1)*(D-C) << endl;
    if (x <= B && B <= x + (N-1)*(D-C)) ans = true;
  }
  cout << (ans ? "YES": "NO") << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
#define x real()
#define y imag()
 
string ccw(P a,P b,P c){
  P ab=b-a,ac=c-a;
  P k=ac*conj(ab);
  if(k.y>0)return "COUNTER_CLOCKWISE";
  if(k.y<0)return "CLOCKWISE";
  if(k.x<0)return "ONLINE_BACK";
  if(abs(ab)<abs(ac))return "ONLINE_FRONT";
  return "ON_SEGMENT";
}
 
int main(){
  double x0,y0,x1,y1,x2,y2;
  cin>>x0>>y0>>x1>>y1;
  P a(x0,y0);
  P b(x1,y1);
  int n;
  cin>>n;
  while(n--){
    cin>>x2>>y2;
    P c(x2,y2);
    cout<< ccw(a,b,c) <<endl;
  }
  return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <random>
#include <chrono>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
template <class T> void chmax(T& a, const T b) { a = max<T>(a, b); }
template <class T> void chmin(T& a, const T b) { a = min<T>(a, b); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int N; cin >> N;
	V<int> b(N),ans(N);
	for (int i = 0; i < N; ++i) cin >> b[i];
	
	for (int i = 0; i < N; ++i){
		bool flg = 1;
		for(int j = b.size()-1; 0 <= j; --j){
			if(b[j] == j + 1){
				ans[i] = b[j];
				b[j] = 0;
				flg = 0;
				break;
			}
		}
		if(flg){
			cout << -1 << endl;
			return 0;
		}
		V<int> tmp;
		for (int j = 0; j < b.size(); ++j) if (b[j] != 0) tmp.push_back(b[j]);
		b = tmp;
	}
	for (int i = N - 1; 0 <= i; --i) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    static Scanner in = new Scanner(System.in);
 
    void solve() {
		int r = in.nextInt(), g = in.nextInt();
		System.out.println(r +(g-r)*2);
	}
	
    public static void main(String[] args) {
		new Main().solve();
    }
}

Measured memory_bytes: 23764
def calc_cost(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])

h, w, d = map(int, input().split())
grid = [None]*(h*w)
for i in range(h):
    for j, c in enumerate(list(map(int, input().split()))):
        grid[c-1] = (i,j)
cost = {}
for i in range(h*w):
    now = h*w -1 - i
    up = now + d
    if up not in cost:
        cost[now] = 0
    else:
        cost[now] = cost[up] + calc_cost(grid[now], grid[up])

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(cost[l-1] - cost[r-1])

Measured memory_bytes: 24756
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
void input() { cin >> S >> T; }
void solve() {
    rep(i, S.length()) {
        if(S[i] != T[i])
            ans++;
    }
    cout << ans << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 3740
import math
def main():

    A, B, H, M = map(int, input().split())

    ang1 = H * 30 + (30/60) * M
    ang1 = (ang1/180) * math.pi
    x1 = A * math.cos(ang1)
    y1 = A * math.sin(ang1)


    ang2 = M * 6
    ang2 = (ang2/180) * math.pi
    x2 = B * math.cos(ang2)
    y2 = B * math.sin(ang2)

    return math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9524
object Main {

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

    val S = sc.nextLine()
    val T = sc.nextLine()

    val dp = Array.fill(S.length+1, T.length+1)(0)
    val dpi = Array.fill(S.length+1, T.length+1)(-1)
    val dpj = Array.fill(S.length+1, T.length+1)(-1)

    var i = 0
    while (i < S.length) {
      var j = 0
      while (j < T.length) {
        if (S(i) == T(j)) {
          if ((dp(i)(j) + 1) > dp(i + 1)(j + 1)) {
            dp(i + 1)(j + 1) = dp(i)(j) + 1
            dpi(i + 1)(j + 1) = i
            dpj(i + 1)(j + 1) = j
          }
        }
        if (dp(i + 1)(j) > dp(i + 1)(j + 1)) {
          dp(i + 1)(j + 1) = dp(i + 1)(j)
          dpi(i + 1)(j + 1) = dpi(i + 1)(j)
          dpj(i + 1)(j + 1) = dpj(i + 1)(j)
        }
        if (dp(i)(j + 1) > dp(i + 1)(j + 1)) {
          dp(i + 1)(j + 1) = dp(i)(j + 1)
          dpi(i + 1)(j + 1) = dpi(i)(j + 1)
          dpj(i + 1)(j + 1) = dpj(i)(j + 1)
        }
        j += 1
      }
      i += 1
    }

    i = dpi(S.length)(T.length)
    var j = dpj(S.length)(T.length)
    var bldr = new StringBuilder
    while (i >= 0 || j >= 0) {
      if (S(i) == T(j))
        bldr.append(S(i))
      val _i = dpi(i)(j)
      val _j = dpj(i)(j)
      i = _i
      j = _j
    }
    println(bldr.result().reverse)
  }

}

Measured memory_bytes: 148052
s = input()

ans = ''

check = 0

for i in range(len(s)):
	if s[i] == '0':
		ans = ans + '0'
	elif s[i] == '1':
		ans = ans + '1'
	else:
		if ans == '':
			pass
		else:
			#print(ans)
			ans = ans[0:len(ans)-1]
			#print(ans)

print(ans)


Measured memory_bytes: 3064
n, m = gets.chomp.split(" ")
n = n.to_i # s
m = m.to_i # c

# Scc
num_c = n * 2 + m
#p num_c
ans =  num_c / 4
if ans * 2 > m
  puts m / 2
else
  puts num_c / 4 
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector <vector <int>> a(h, vector <int> (w));
    rep (i, h) rep (j, w) cin >> a[i][j];

    vector <int> yoko(h, 0), tate(w, 0);
    rep (i, h) rep (j, w) yoko[i] += a[i][j];
    rep (i, w) rep (j, h) tate[i] += a[j][i];

    int mini = 1e9;
    rep (i, h) rep (j, w) {
        int sum = 0;
        rep (ii, h) rep (jj, w) sum += min(abs(i - ii), abs(j - jj)) * a[ii][jj];
        mini = min(mini, sum);
    }
    cout << mini << endl;

    return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>

int main()
{
  int A, B, result = 0, count = 2;
  scanf("%d %d",&A,&B);
  while ( count > 0 ) {
    count--;
    if ( A > B ) {
      result += A;
      A--;
    } else {
      result += B;
      B--;
    }
  }
  printf("%d",result);
}

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

int main(){
    int N;
    int min = 999999;
    cin >> N;
    int a;
    int count_a;
    rep(i, N){
        a = 0;
        cin >> a;
        count_a = 0;
        do
        {
            if (a % 2 == 0)
            {
                count_a += 1;
                a /= 2;
            }
            else
            {
                break;
            }
        } while (a > 0);
        if (min > count_a){
            min = count_a;
        }
    }

    cout << min << endl;

}

Measured memory_bytes: 3580
/*
 *  * main.cpp
 *   *
 *    */

#include<bits/stdc++.h>
using namespace std;

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int A[1000];
int main() {

    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; ++i) scanf("%d", A + i);

    int res = 0x7fffffff;

    for (int i = 1; i <= 100; ++i) {
        int cur = 0;
        for (int j = 0; j < n; ++j) cur += (A[j] - i) * (A[j] - i);
        res = min(cur, res);

    }

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




    return 0;
}


Measured memory_bytes: 256
"""
def factorial(x):
    if x == 0:
        return 1
    return x * fact(x - 1)
"""
from math import *
n, m = map(int, input().split())

dif = abs(n - m)
if dif >= 2:
    ans = 0
elif dif == 1:
    ans = factorial(n) * factorial(m) % (10**9 + 7)
else:
    ans = factorial(n) * factorial(m) * 2 % (10**9 + 7)

print(ans)

Measured memory_bytes: 5172
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

#define int long long
const int M = 1000000007;

int r;
vector<int> g[100005];
map<int,int> m;

int dfs(int cur){

	int res = 0;
	for(auto to : g[cur]){
		res += dfs(to);
		res %= M;
	}
	res = res * r + 1;
	res %= M;
	m[res]++;
	return res;
}


signed main(){
	int n;
	cin >> n;
	rep(i,n - 1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b);
	}

	r = 8731873;
	dfs(0);

	int ans = 0;
	for(auto i : m){
		//show(i.second)
		ans += (i.second * (i.second - 1)) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 21052
#include <stdio.h>

typedef long long var;

const int N = 2100006;
const int MOD = 1e9 + 7;

struct Node {
  int x, y;
};

struct Rect {
  Node ld, ru;
};

var inv[N + 1], fac[N + 1], invfac[N + 1];
Rect begin, mid, end;

var c(int n, int m);
var f(int n, int m);
var operator & (Node a, Node b);
var operator & (Node t, Rect c);

int main() {
  inv[0] = fac[0] = invfac[0] = inv[1] = 1;
  for (int i = 2; i <= N; ++i) 
    inv[i] = ((MOD - MOD / i) * inv[MOD % i]) % MOD;
  for (int i = 1; i <= N; ++i) {
    fac[i] = (fac[i - 1] * i) % MOD;
    invfac[i] = (invfac[i - 1] * inv[i]) % MOD;
  }
  scanf("%d%d%d%d%d%d", &begin.ld.x, &begin.ru.x, &mid.ld.x, &mid.ru.x, &end.ld.x, &end.ru.x);
  scanf("%d%d%d%d%d%d", &begin.ld.y, &begin.ru.y, &mid.ld.y, &mid.ru.y, &end.ld.y, &end.ru.y);
  var res = 0;
  for (int i = mid.ld.x; i <= mid.ru.x; ++i) {
    var way = (((Node) {i, mid.ld.y - 1} & begin) * ((Node) {i, mid.ld.y} & end)) % MOD;
    (res -= (way * (i + mid.ld.y)) % MOD) %= MOD;
  }
  for (int i = mid.ld.y; i <= mid.ru.y; ++i) {
    var way = (((Node) {mid.ld.x - 1, i} & begin) * ((Node) {mid.ld.x, i} & end)) % MOD;
    (res -= (way * (mid.ld.x + i)) % MOD) %= MOD;
  }
  for (int i = mid.ld.x; i <= mid.ru.x; ++i) {
    var way = (((Node) {i, mid.ru.y} & begin) * ((Node) {i, mid.ru.y + 1} & end)) % MOD;
    (res += (way * (i + mid.ru.y + 1)) % MOD) %= MOD;
  }
  for (int i = mid.ld.y; i <= mid.ru.y; ++i) {
    var way = (((Node) {mid.ru.x, i} & begin) * ((Node) {mid.ru.x + 1, i} & end)) % MOD;
    (res += (way * (mid.ru.x + i + 1)) % MOD) %= MOD;
  }
  printf("%lld\n", (res + MOD) % MOD);
  return 0;
}

var c(int n, int m) { return (((fac[n] * invfac[m]) % MOD) * invfac[n - m]) % MOD; }

var f(int n, int m) { return c(n + m, n); }

var operator & (Node t, Rect r) {
  if (t.x >= r.ru.x) t.x = r.ld.x - (t.x - r.ru.x);
  if (t.y >= r.ru.y) t.y = r.ld.y - (t.y - r.ru.y);
  r.ld.x -= t.x, r.ru.x -= t.x, r.ld.y -= t.y, r.ru.y -= t.y;
  return (((f(r.ru.x + 1, r.ru.y + 1) + f(r.ld.x, r.ld.y)) % MOD) 
      - ((f(r.ru.x + 1, r.ld.y) + f(r.ld.x, r.ru.y + 1)) % MOD)) % MOD;
}


Measured memory_bytes: 49408
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  vector<int> color(9);
  for (int i = 0; i < N; i++)
  {
    if (a[i] < 3200)
      color[a[i] / 400]++;
    else
      color[8]++;
  }
  int min_color = 0;
  int max_color = 0;
  for (int i = 0; i < 8; i++)
  {
    if (0 < color[i])
    {
      min_color++;
      max_color++;
    }
  }
  max_color += color[8];
  if (min_color == 0)
    min_color = 1;
  cout << min_color << " " << max_color << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll k, a, b; cin >> k >> a >> b;

    if (b - a <= 2) {
        cout << k + 1 << endl;
        return 0;
    }

    ll d = a - 1;
    k -= d;
    ll k2 = k / 2;
    ll ans = k2 * (b - a) + a + (k % 2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll X; cin >> X;
    pt(X >= 30 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;ll ans = 0;
		for(ll i=1;i<=n;i++)
		{
			ll a;cin>>a;
			if(i%2==1&&a%2==1)ans++;
		}
		cout<<ans<<endl;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

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

int main() {
	int n;
	while(cin >> n && n){
		if(n % 1111 == 0){
			cout << "NA" << endl;
			continue;
		}
		
		int ans = 0, num = n;
		while(num != 6174){
			int l = 0, s = 0, b[4];
			for(int i = 0; i < 4; ++i){
				b[i] = num % 10;
				num /= 10;
			}
			sort(b, b + 4);
			for(int i = 3; i >= 0; --i){
				l += b[i] * pow(10, i);
				s += b[3 - i] * pow(10, i);
			}
			num = l - s;
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){
        int n;
        int a[10000]={0};
        cin>>n;
        if(n==0)break;
        long long int sum=0;
        long long int ans=-1000000;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            sum=0;
            for(int j=i;j<n;j++){
                sum+=a[j];
                ans=max(ans,sum);
            }
        }
        cout<<ans<<endl;

    }


	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll absMin = LONG_MAX;
    ll absSum = 0;
    ll countMinus = 0;
    REP(i, N)
    {
        cin >> A[i];
        if (A[i] < 0)
        {
            countMinus++;
        }
        absSum += abs(A[i]);
        absMin = min(absMin, abs(A[i]));
    }

    ll ans = 0;
    if (absMin == 0)
    {
        ans = absSum;
    }
    else
    {
        if (countMinus % 2 == 1)
        {
            ans = absSum - 2 * absMin;
        }
        else
        {
            ans = absSum;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include<stdio.h>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main(){
    while(1){
        int n;
        cin>>n;
        if(n==0){
            break;
        }
        for(int i=0; i<n; i++){
            int m,e,j;
            cin>>m>>e>>j;
            if (m==100 || e==100 || j==100 || (m+e)/2>=90 || (m+e+j)/3>=80) {
                cout<<"A"<<endl;
            }else if((m+e+j)/3>=70){
                cout<<"B"<<endl;
            }else if( (m+e+j)/3>=50 &&m>=80){
                cout<<"B"<<endl;
            }else if( (m+e+j)/3>=50 &&e>=80){
                cout<<"B"<<endl;
            }else{
                cout<<"C"<<endl;
            }
        }
    }
}



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

int stair[31];
int n;

void solve(){
	for(int i=2; i<=30; i++)
		stair[i] = 0;
	stair[1] = 1;
	stair[2] = 1;
	stair[3] = 1;
	for(int i=1; i<=27; i++){
		stair[i+1] += stair[i];
		stair[i+2] += stair[i];
		stair[i+3] += stair[i];
	}
	stair[29] += stair[28];
	stair[30] += stair[28];
	stair[30] += stair[29];
}

int main(){
	solve();
	int ans;
	while(true){
		cin >> n;
		if(!n)
			return 0;
		ans = stair[n]/10;
		if(stair[n]%10)
			ans++;
		if(ans%365)
			ans += 365;
		ans /= 365;
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
	int a=0,b,c;
	int i,j,k;
	while(a<1 || b<1 || c<1 || 10000<a || 10000<b || 10000<c){
	scanf("%d%d%d",&a,&b,&c);
	}
	if(a<b) {
		if(b<c) printf("%d %d %d\n",a,b,c);
		else{
			if(a<c) printf("%d %d %d\n",a,c,b);
			else printf("%d %d %d\n",c,a,b);
		}
	}
	else{
		if(c<b) printf("%d %d %d\n",c,b,a);
		else{
			if(a<c) printf("%d %d %d\n",b,a,c);
			else printf("%d %d %d\n",b,c,a);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;int h,i;int main(){vector<int>l;for(i=0;i++<10;l.push_back(h))cin>>h;sort(l.begin(),l.end(),greater<int>());for(i=0;i++<3;)cout<<l.begin()[i-1]<<'\n';}

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

const int N = 1005, M = 200233;
int n, m;
bool ok1[M], ok2[M], visit[N];
vector<pair<int, int>> G[N], rG[N];
void dfs(int x) {
  visit[x] = true;
  for (auto y : G[x]) if (!visit[y.first]) dfs(y.first);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    G[x].emplace_back(y, i);
    rG[y].emplace_back(x, i);
  }
  for (int x = 1; x <= n; x++) {
    for (int j = 1; j <= n; j++) visit[j] = false;
    dfs(x);
    for (auto y : rG[x]) ok1[y.second] = visit[y.first];
    for (int j = 1; j <= n; j++) visit[j] = false;
    visit[x] = true;
    for (auto y : G[x]) ok2[y.second] |= visit[y.first], dfs(y.first);
    reverse(G[x].begin(), G[x].end());
    for (int j = 1; j <= n; j++) visit[j] = false;
    visit[x] = true;
    for (auto y : G[x]) ok2[y.second] |= visit[y.first], dfs(y.first);
  }
  for (int i = 1; i <= m; i++) {
    puts(ok1[i] == ok2[i] ? "same" : "diff");
  }
}


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

int N;
int divis[101] = { 0 };

int CntPrime(int primenum);

int main() 
{
	int num;
	int numerator;	/*割られる数*/
	int denominator;	/*割る数*/
	int ans;
	scanf("%d", &N);
	for (numerator = 2;numerator <= N;numerator++)
	{
		num = numerator;
		for (denominator = 2; denominator <= N; denominator++)
		{
			/*やりたいのは素因数分解だが、小さい順にやっているので無駄だけど問題はないはず*/
			/*jは素数だけにしたかったが、100までの素数を羅列する不毛なことになるのは面倒*/
			/*100までなのに素数か判別するほうが面倒*/
			/*ただ、2を見た後に4を見たりしているので、重複あるしもっと簡単にできるはず……*/
			while (num%denominator ==0)
			{
				divis[denominator]++;
				num = num / denominator;
			}
		}
	}
	/*素因数分解で約数の数を数えるやつ 証明は略*/
	ans = CntPrime(75) + CntPrime(25)*(CntPrime(3) - 1) + CntPrime(15)*(CntPrime(5) - 1) + (CntPrime(5)*(CntPrime(5)-1)/2)*(CntPrime(3)-2);
	printf("%d", ans);

	return 0;
}

int CntPrime(int numofprime)
{
	int denominator;
	int kindprime=0;

	for (denominator = 2; denominator <=  N; denominator++)
	{
		if (divis[denominator]>= (numofprime-1))
		{
			kindprime++;
			/*指定された数-1以上持っている約数の種類*/
		}
	}
	return kindprime;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    char s;
    cin>>a>>b;
    if(a>=b){
    for(int i=0;i<a;i++){
        cout<<to_string(b);
    }
    }
    else {
    for(int i=0;i<b;i++){
        cout<<to_string(a);
    }
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/extc++.h>
typedef long long ll;

using namespace std;

// using namespace __gnu_pbds;
#define Init1 ios::sync_with_stdio(false)
#define Init2 cin.tie(0)
#define INF 0x3f3f3f3f
// #pragma GCC optimize(2)

const int N = 1e5 + 105;
struct node{
    int col, val; // 1 红 2 绿 3 白
    bool operator<(const node&tl) const{
        return val < tl.val;
    }
} now;
priority_queue<node>que;
int main(){
    // Init1; Init2;
    int x, y, a, b, c;
    cin>>x>>y>>a>>b>>c;
    for(int i = 1; i <= a; ++i){
        cin>>now.val; now.col = 1;
        que.push(now);
    }
    for(int i = 1; i <= b; ++i){
        cin>>now.val; now.col = 2;
        que.push(now);
    }
    for(int i = 1; i <= c; ++i){
        cin>>now.val; now.col = 3;
        que.push(now);
    }
    int r = 0, g = 0, w = 0;
    ll ans = 0;
    while(!que.empty()){
        now = que.top(); que.pop();
        if(r + g + w >= x + y) break;
        if(now.col == 1){
            if(r < x) ans += now.val, ++r;
        }
        if(now.col == 2){
            if(g < y) ans += now.val, ++g;
        }
        if(now.col == 3){
            ans += now.val; ++w;
        }
    }
    cout<<ans<<endl;
    // system("pause");
}

Measured memory_bytes: 6512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int count=0;
			while(sc.hasNext()) {
				int n=sc.nextInt();
				if(n==0) break;
				int a=sc.nextInt();
				int b=sc.nextInt();
				int c=sc.nextInt();
				int d=sc.nextInt();
				int min=200000;
				int mina=0, minb=0, minc=0, mind=0;
				
				for(int ten=0; ten<=a; ten++) {
					for(int fif=0; fif<=b; fif++) {
						for(int hun=0; hun<=c; hun++) {
							for(int fiv=0; fiv<=d; fiv++) {
								int coin=ten*10+fif*50+hun*100+fiv*500;
								if(coin>=n) {
									int t=coin-n;
									int sum=a-ten+b-fif+c-hun+d-fiv;
									sum+=t/500;
									t%=500;
									sum+=t/100;
									t%=100;
									sum+=t/50;
									t%=50;
									sum+=t/10;
									if(min>sum) {
										mina=ten;
										minb=fif;
										minc=hun;
										mind=fiv;
										min=sum;
									}
								}
							}
						}
					}
				}
				if(count>0) 
					System.out.println();
				if(mina>0)
				System.out.println("10 "+mina);
				if(minb>0)
				System.out.println("50 "+minb);
				if(minc>0)
				System.out.println("100 "+minc);
				if(mind>0)
				System.out.println("500 "+mind);
				count++;
			}


		}
	}
}


Measured memory_bytes: 42736
package main

import "fmt"

func main() {
	var a, b, c int
	ans := 0
	fmt.Scan(&a, &b, &c)
	for i := a; i <= b; i++ {
		if c%i == 0 {
			ans++
		}
	}
	fmt.Println(ans)
	return
}



Measured memory_bytes: 1156