akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ff first
#define ss second
///////////////////////////////////////////////////////////
const ll mod = 1e9 + 7 ;
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
//////////////////////////////////////////////////////////

void solve( ){
    int n ;
    cin >> n ;
  string s , t ;
    cin >> s >> t ;
    for( int i = 0 ; i < n ; i++){
        cout << s[i] << t[i] ;
    }
}
int main(){
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test_case=1 ;
    //cin >> test_case ;
    //precal();
    for( int i = 1 ; i <= test_case ; i++){
        solve( );
    }
}
// 0 0 1 2
// 0 1 1 2


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    cin >> x >> y;
    if(x>0 && y>0 && x>y){
        cout << 2+x-y;
    }else if(x>0 && y>0 && x<y){
        cout << y-x;
    }else if(x>0 && y<=0){
        if(-x>=y){
            cout << 1-(x+y);
        }else{
            cout << 1+x+y;
        }
    }else if(x<=0 && y>0){
        if(-x>y){
            cout << min(y-x,1-x-y);
        }else{
            cout << min (1+x+y,y-x);
        }
    }else if(x<=0 && y <=0 && x>y){
        cout << min(2+x-y,1-x-y);
    }else{
        cout << y-x;
    }
    cout << endl;
    return 0;
}


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

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> data(m);
	ff(i, 0, m) {
		int a, b;
		cin >> a >> b;
		data[i].first = min(a, b);
		data[i].second = max(a, b);
	}
	st(data);
	set<int> ow;
	ff(i, 0, m) {
		if (data[i].first == 1) {
			ow.insert(data[i].second);
		}
		if (ow.count(data[i].first)) {
			if (data[i].second == n) {
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
const ll MOD = 998244353;
int kaijou(ll k, ll l){
    ll re = 1;
    for(int i = 0; i < l; i++){
        re *= k;
        re %= MOD;
    }
    return re;
}
int main(){
    ll n; cin >> n;
    vector<ll> vec(n, 0);
    bool flag = false;
    for(int i = 0; i < n; i++){
        ll a; cin >> a; vec[a]++;
        if(i == 0 and a != 0) flag = true;
        else if(i != 0 and a == 0) flag = true;
    }
    if(flag){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for(int i = 1; i < n; i++){
        ans *= kaijou(vec[i - 1], vec[i]);
        ans %= MOD;
        //cout << vec[i - 1] << " " << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let s = iter.next().unwrap();
	let t = iter.next().unwrap();
	let u = format!("{}{}", t, s);
	println!("{}", u);
}

Measured memory_bytes: 4352
read a b

if [ $a -lt 0 ] || [ $a -gt 10 ]; then
  echo "No"
  exit
fi

if [ $b -lt 0 ] || [ $b -gt 10 ]; then
  echo "No"
  exit
fi

counter=1
while [ $counter -le $b ]
do
  aa=`echo $aa$a`
  ((counter++))
done

counter=1
while [ $counter -le $a ]
do
  bb=`echo $bb$b`
  ((counter++))
done

if [ $aa = $bb ]; then
  echo $aa
  exit
fi

if [ $a -gt $b ]; then
  echo $bb
  exit
else
 echo $aa
 exit
fi

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='?'){
            break;
        }
        if(op=='+'){c=a+b;}else if(op=='-'){c=a-b;}else if(op=='*'){c=a*b;}else if(op=='/'){c=a/b;}
        cout<<c<<endl;
    }
    return 0;
}  
    



Measured memory_bytes: 3108
import math

n, k = map(int, input().split())
if n > k:
	if n+1 >= 2*k:
		for i in range(k):
			j = i+1
			c_blue = (math.factorial(n-k+1))//((math.factorial(j))*(math.factorial(n-k+1-j)))
			c_div = (math.factorial(k-1))//((math.factorial(j-1))*(math.factorial(k-1-j+1)))
			comb = c_blue * c_div
			print(comb % 1000000007)
			
	else :
		for i in range(n-k+1):
			j = i+1
			c_blue = (math.factorial(n-k+1))//((math.factorial(j))*(math.factorial(n-k+1-j)))
			c_div = (math.factorial(k-1))//((math.factorial(j-1))*(math.factorial(k-1-j+1)))
			comb = c_blue * c_div
			print(comb % 1000000007)
		for _ in range(2*k -n -1):
			print(0)
else:
	print(1)
	for i in range(n-1):
		print(0)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


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

    int low = 0;
    int high = N;
    rep(i,M){
        int a, b;
        cin >> a >> b;

        if(low<a)low = a;
        if(b<high)high = b;
    }

    if(high-low<0)cout << 0 << endl;
    else cout << high-low+1<< endl;
}



Measured memory_bytes: 3596
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a=scanner.nextInt();
    int b=scanner.nextInt();
    int t=scanner.nextInt();

    int ans=0;
    for(int i=a;i<t+0.5;i+=a){
      ans+=b;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
float v[99];i,j,k;c(float*x){i=x[1]<1[&x][1]?-1:1;}main(f){for(;~scanf("%f",v+i++););for(;j<48;j+=16)for(qsort(v+j,8,8,c),i=0;i<4;v[j-~i]=9e9,i+=2)printf(f="%.f %.2f\n",v[j+i],v[j-~i]);for(qsort(v,24,8,c);i=k<4;k+=2)printf(f,v[k],v[k+1]);}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int Y, X;
  cin >> Y >> X;
  vector<vector<char>> grid(Y, vector<char>(X));
  vector<vector<int>> Xlight(Y, vector<int>(X));
  vector<vector<int>> Ylight(Y, vector<int>(X));
  bool flag = false;
  stack<int> s;
  int count = 0;
  for (int i = 0; i < Y; i++) {
    for (int j = 0; j < X; j++) {
      cin >> grid.at(i).at(j);
      if (grid.at(i).at(j) == '.') {
        if (flag) {
          count++;
          s.push(j);
        } else {
          count = 1;
          s.push(j);
          flag = true;
        }

      } else {
        if (flag) {
          while (s.size() > 0) {
            int a = s.top();
            Xlight.at(i).at(a) = count;
            s.pop();
          }
          flag = false;
        }
      }
    }
    if (flag) {
      while (s.size() > 0) {
        int a = s.top();
        Xlight.at(i).at(a) = count;
        s.pop();
      }
      flag = false;
    }
    while (s.size() > 0) {
      s.pop();
    }
    count = 0;
    flag = false;
  }
  cout << endl;
  for (int j = 0; j < X; j++) {
    for (int i = 0; i < Y; i++) {
      if (grid.at(i).at(j) == '.') {
        if (flag) {
          count++;
          s.push(i);
        } else {
          count = 1;
          s.push(i);
          flag = true;
        }

      } else {
        if (flag) {
          while (s.size() > 0) {
            int a = s.top();
            Ylight.at(a).at(j) = count;
            s.pop();
          }
          flag = false;
        }
      }
    }
    if (flag) {
      while (s.size() > 0) {
        int a = s.top();
        Ylight.at(a).at(j) = count;
        s.pop();
      }
      flag = false;
    }
    while (s.size() > 0) {
      s.pop();
    }
    count = 0;
    flag = false;
  }
  cout <<endl;
  int max = 0;
  for (int i = 0; i < Y; i++) {
    for (int j = 0; j < X; j++) {
      if (Xlight.at(i).at(j) + Ylight.at(i).at(j) > max) {
        max = Xlight.at(i).at(j) + Ylight.at(i).at(j);
      }
    }
  }
  cout << max - 1 << endl;
}


Measured memory_bytes: 35712
import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in)
  def main(args: Array[String]) {
    val x = (1 to 28).map(_ => sc.nextInt).toSet
    val y = (1 to 30).toSet
    (y -- x).toSeq.sorted.foreach(println)
  }
}

Measured memory_bytes: 44996
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,cnt=0,ans=0;
  string S;
  cin>>N>>S;
  REP(i,N){
    if(S[i]=='R') cnt++;
  }
  REP(i,cnt){
    if(S[i]=='W') ans++;
  }
  co(ans);
  return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j,l;
	int a,b,n;
	int s[55],s1[55];
	int num=0;
	scanf("%d",&n);
	for(i=0;i<55;i++){
		s[i]=i;
	}
	for(i=1;i<=n;i++){
		scanf("%d",&s1[i]);
		
	}
	for(i=1;i<=n;i++){
		if(s[i]!=s1[i])num++;
		
	}
	if(num>2)printf("NO");
	else printf("YES");
	
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int counter=0;
		int N= sc.nextInt();
		int f = 0;
		int count = 0;
		for(int i = 1; i <= N; i++){
			f = i%2;
			if(f == 1){
				counter+=1;
			}
		}
		System.out.println((double)counter/N);
	}
}

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

int main() {
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    rep(i, n) cin >> a.at(i);
    rep(i, m) cin >> b.at(i);

    int ai = 0;
    rep(i,n) {
        if(a.at(i) <= k) {
           ai++;
           k -= a.at(i); 
        }
        else break;
    }

    int bi = 0;
    rep(i, m) {
        if(b.at(i) <= k) {
            bi++;
            k -= b.at(i);
        }
        else break;
    }

    int ans = ai + bi;
    int ansi = ans;
    for(int i = ai-1; 0 <= i; i--) {
        k += a.at(i);
        ansi--;
        while(bi < m) {
            if(b.at(bi) <= k) {
                ansi++;
                k -= b.at(bi);
                bi++;
            }
            else break;
        }
        ans = max(ansi, ans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,mod=998244353;
int n,k,m,a[N],sum[N];
int dp[N][N][N];
//dp[i][j][h] 第i个坑，用了j个1，移动了k次的方案数
char s[N];
int main()
{
    scanf("%s%d",s+1,&k);
    for(int i=1;s[i];i++) m+=s[i]=='1';
    int t=0;
    for(int i=1;s[i];i++)
        if(s[i]=='0') a[++n]=t,t=0;
    else t++;
    a[++n]=t;
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    k=min(k,m);
    dp[0][0][0]=1;
    for(int i=0;i<n;i++)
        for(int j=sum[i];j<=sum[n];j++)
            for(int h=0;h<=k;h++)
        {
            if(!dp[i][j][h]) continue;
            for(int f=max(j,sum[i+1]);f<=sum[n];f++)
                if(f>=sum[i+1]&&h+f-j-a[i+1]<=k)
            {
                if(i+1==n&&f-j>a[i+1]) break;
                int cost=f-j<=a[i+1]?0:f-j-a[i+1];
                dp[i+1][f][h+cost]=(dp[i+1][f][h+cost]+dp[i][j][h])%mod;
            }
        }
    ll ans=0;
    for(int i=0;i<=k;i++) ans=(ans+dp[n][m][i])%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 17868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n;
	while (cin >> n, n)
	{
		vector<char> v(n);
		cin >> v;
		map<char, int> mp;
		REP(i, n)
		{
			mp[v[i]]++;
			char t;
			int fi = 0, se = 0;
			for (auto j : mp)
			{
				if (j.second >= fi)
				{
					t = j.first;
					se = fi;
					fi = j.second;
				}
				else if (j.second >= se)
				{
					se = j.second;
				}
			}
			if (se + n - i - 1 < fi)
			{
				cout << t << " " << i + 1 << endl;
				goto next;
			}
		}
		cout << "TIE" << endl;
	next:;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=(1<<22);
int dp[1000000];
int d[20];
int main()
{
	int n, m; cin >> n >> m;
	fill(dp, dp + n + 1 , INF);
	for (int i = 0; i < m; ++i) {
		cin >> d[i];
	}
	dp[0] = 0;
	for (int i = 0; i < m; ++i) {
		for (int j = d[i]; j <= n; ++j) {
			dp[j] = min(dp[j], dp[j - d[i]] + 1);
		}
	}
	cout << dp[n] << endl;
}

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

int cnt[50001];

int main() {
    int n, m;
    cin >> n >> m;
    memset(cnt, 1000000, sizeof(cnt));
    cnt[0] = 0;
    vector<int> cs(m);
    for (int i = 0; i < m; i++) {
        cin >> cs[i];
    }
    for (int i = 0; i < 100; i++) {
        for (int i = 0; i < m; i++) {
            int c = cs[i];
            for (int j = 1; j * c <= 50000; j++) {
                cnt[c * j] = min(cnt[c * j], j);
            }
            for (int j = 50000; j >= 0; j--) {
                if (j - c >= 0) {
                    cnt[j] = min(cnt[j], cnt[j - c] + 1);
                }
            }
        }
    }
    cout << cnt[n] << endl;
}


Measured memory_bytes: 3292
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
    int k;
    int a,b;
    cin >> k;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3104
a,b,h,m = map(int,input().split())
import math

dig_h = math.radians(360*h/12 + 30*m/60)
dig_m = math.radians(360*m/60)

x = b * math.sin(dig_h) - a * math.sin(dig_m)
y = b * math.cos(dig_h) - a * math.cos(dig_m)

print(math.sqrt(x**2 + y**2))




Measured memory_bytes: 62544
#include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

using Graph = vector<vector<int>>;
vector<bool> seen;

int dfs(const Graph &G, int v)
{
    bool allComp = true;
    for(auto visit:seen)
    {
        if(!visit) allComp = false;
    }
    if(allComp) return 1;

    int ret = 0;
    seen[v] = true;
    for(auto next_v:G[v])
    {
        if(seen[next_v]) continue;
        seen[next_v] = true;
        ret += dfs(G,next_v);
        seen[next_v] = false;
    }
    return ret;
}

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

    Graph graph(N);
    for(int i=0;i<M;i++)
    {
        int A,B;
        cin >> A >> B;
        graph[A-1].push_back(B-1);
        graph[B-1].push_back(A-1);
    }
    seen.assign(N,false);

    cout << dfs(graph,0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N,M;cin>>N>>M;
    vector<int>a(N);
    int sum=0;
    rep(i,N){
        cin>>a.at(i);
        sum+=a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int lim;
    if(sum%(4*M)==0){
        lim=sum/(4*M);
    }else{
        lim=sum/(4*M)+1;
    }
    int sum2=0;
    rep(i,N){
        if(a.at(i)>=lim){
            sum2++;
        }
        if(sum2>=M){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }



void func(long long A, long long B, long long C, long long K){

    lli ans = 0;
    ans += min(A,K);
    K -= ans;
    K -= min(K,B);

    ans -= min(C,K);

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    func(A, B, C, K);
    return 0;
}


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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int left = 0, right = 0;
	for(int i=0;i<n;i++) {
		if(left > 0 and s[i] == ')') left--;
		else if(s[i] == '(') left++;
		else right++;
	}
	string ans = s;
	for(int i=0;i<right;i++) ans = '(' + ans;
	for(int i=0;i<left;i++) ans = ans + ')';
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

struct S {
  decltype(begin(string())) b,e;
};

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;

  vector<S> bests;

  for(int i=0; i<s.size(); ++i) {
    for(int j=i+1; j<s.size()+1 && j<i+6; ++j) {
      auto b = s.begin()+i;
      auto e = s.begin()+j;
      if(bests.empty()) {
        bests.push_back({b, e});
      }
      int sk=bests.size();
      for(int k=min(size_t(4),bests.size()-1); k>=0; --k) {
        if(lexicographical_compare(b, e, bests[k].b, bests[k].e)) {
          sk = k;
        } else if(equal(b, e, bests[k].b, bests[k].e)) {
          goto lend;
        } else {
          break;
        }
      }
      if(sk>=0) bests.insert(begin(bests)+sk, {b, e});
      if(bests.size()>5) bests.erase(begin(bests)+5, end(bests));

      lend: 0;

    }
  }
  /*
  for(auto best:bests) {
    cout << string(best.b, best.e) << endl;
  }
  */
  cout << string(bests[k-1].b, bests[k-1].e) << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    rep(i,n){
        auto num_A = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        auto num_C = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
        ans += num_A * (n - num_C);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 100000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, m, a, b, ans;
int  nxt[100001];
bool con[100001];
vector<int> adj[100001];

void search() {
    queue<int> toVisit;
    toVisit.push(1);
    while (toVisit.size() > 0) {
        int parent = toVisit.front(); toVisit.pop();
        for (auto it = adj[parent].begin(); it != adj[parent].end(); it++) {
            if (!con[*it]) {
                nxt[*it] = parent;
                con[*it] = true;
                toVisit.push(*it);
            }
        }
    }
}

int main() {
    scanf(" %d %d", &n, &m);
    rep(0,m) {
        scanf(" %d %d", &a, &b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    con[1] = true;
    rep(2, n+1) con[i] = false;
    search();

    printf("Yes\n");
    rep(2, n+1) printf("%d\n", nxt[i]);
}

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

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

int main(){
    int n, x; cin >> n >> x;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] = abs(x - a[i]);
    }
    int ans = a[0];
    for(int i = 1; i < n; i++){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
using namespace std;
int main(){
	int row, col, K;
	cin >> row >> col >> K;
	vector<vector<int>> v(row, vector<int>(col, 0));
	vector<int> rowblocks(row), colblocks(col);
	int res=0;
	for(int i=0; i<row; ++i)
		for(int j=0; j<col; ++j)
		{
			char c;
			cin >> c;
			if(c=='#') v[i][j]=1;
		}

	int rows = 1<<row, cols = 1<<col;
	for(int i=0; i<rows; ++i)
	{
		for(int j=0; j<cols; ++j)
		{
			int bb = 0;
			for(int k=0; k<row; ++k)
				for(int l=0; l<col; ++l)
				{
					if(v[k][l] && ((i>>k)&1)==0 && ((j>>l)&1)==0) ++bb;
				}
			if(bb==K) ++res;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
typedef long long ll;

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MAX_INT 100000
#define MOD 1000000007
#define forf(i,a,b) for(int i=a;i<b;i++)


// vector<int> adj[1000002];
// int vis[1000002],dep[1000002],siz[1000002];


// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;
//     siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }


void solve()
{
    ll n;cin>>n;
    ll m;cin>>m;
    // ll k;cin>>k;
    // string s="",s1="",s2="";
    ll tmp=0,cnt=0,ans=0,tmp1=0,fg=0,fg1=0;
    ll a[n]; forf(i,0,m) cin>>a[i];
    forf(i,0,m) tmp+=a[i];
    if(tmp>n) cout<<-1;
    else cout<<n-tmp;
    
    
}
    
int main()
{
    IOS;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 3696
a, b = map(int, input().split())

if a == b:
    print("0")
    exit()

if a < b:
    if b - a < a:
        print(b-a)
        exit()
    else:
        print(a)
        exit()

k = a % b
if abs(k - b) < k:
    print(abs(k - b))
else:
    print(k)

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

namespace Test
{
    class ForStudy
    {
        public static void Main(string[] args)
        {
            var list=new List<int>();
            while(true){
                string str=Console.ReadLine();
                if(str=="0"){
                    break;
                }else{
                    int sum=0;
                    foreach(char c in str){
                        sum+=int.Parse(c.ToString());
                    }
                    list.Add(sum);
                    
                }
            }
            foreach(int i in list){
                Console.WriteLine(i);
            }
        }
    }
}



Measured memory_bytes: 15980
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
    int n;
    cin >> n;
    print(n / 3);
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll X;
    cin >> X;

    ll count = 0;
    ll t = 100;
    while(t<X){
        t *= 1.01;
        ++count;
    }
    cout << count << endl;
}


Measured memory_bytes: 3692
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader (is);
		String input[] = br.readLine().split(" ");
		//[x][0] = ボールの個数  -1以上
		//[x][1] = 赤のボールがある 1 0
		//[x][2] = 赤のボールが入れられた 1 0
		int boxCount = Integer.parseInt(input[0]);
		int[][] box =new int [boxCount][3];
		for(int i=0;i<boxCount;i++) {
			for(int j=0;j<3;j++) {
				box[i][j]=0;
			}
		}
		//1番目の箱は赤のボールがある
		box[0][1] = 1;
		box[0][2] = 1;
		int order = Integer.parseInt(input[1]);
		while(br.ready()) {
			String temp[] = br.readLine().split(" ");
			int before = Integer.parseInt(temp[0])-1;
			int after = Integer.parseInt(temp[1])-1;
			if(box[before][0] >= 0) {
				//赤のボールが移されたなら
				if(box[before][1]==1) {
					box[before][1] = 0;
					box[after][1] = 1;
					box[after][2] = 1;
				}
				//赤のボールが入れられた可能性があるなら、受け先も可能性アリにする
				if(box[before][2]==1) {
					box[after][2] = 1;
				}
				//ボールがなくなる場合は赤のボールのある可能性はない
				if(box[before][0] == 0) {
					box[before][2] = 0;
				}
				box[before][0]--;
				box[after][0]++;
			}
		}
		int result = 0;
		for(int i =0 ;i<boxCount ; i++) {
			//if(box[i][0] >= 0) {
				if(box[i][2] == 1) {
					result++;
				}
			//}
		}
		System.out.println(result);
	}

}

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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    unsigned long a{0}, b{0}, c{0};
    unsigned long ans{1};
    for(auto& i : A){
        cin >> i;
        auto k{0UL};
        k += (a == i) + (b == i) + (c == i);
        (ans *= k) %= 1000000007;
        if(a == i)++a;
        else if(b == i)++b;
        else if(c == i)++c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
//using static CS_AtCoder.Utils;
//using static CS_AtCoder.Scan;
////using static CS_AtCoder.Library;


namespace CS_AtCoder {
	
	class Program {
		static void Main(string[] args) {
			new Calc().Solve();
		}
	}
	public class Calc {
        //Scan cin = new Scan();
        private List<int>[] graph;
        int[] NM;

        public void Solve() {
            NM = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            string POS = "POSSIBLE", IMP = "IMPOSSIBLE";
            graph = new List<int>[NM[0]];
            for (int i = 0; i < NM[0]; i++) {
                graph[i] = new List<int>();
            }
            for (int i = 0; i < NM[1]; i++) {
                var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                graph[ab[0]-1].Add(ab[1]-1);
                graph[ab[1]-1].Add(ab[0]-1);
            }
            if (bfs(0, 0)) { POS.WL(); } else { IMP.WL(); }
			return;
		}
        private bool bfs(int from,int step) {
            if (step > 2) return false;
            if (step == 2) {
                if (from == NM[0]-1) return true;
                else return false;
            }
            for (int i=0;i<graph[from].Count;i++) {
                var item = graph[from][i];
                if (bfs(item, step + 1)) return true;
            }
            return false;
        }
	}

	public class Scan {
		//public Scan() { }
		//public int ReadInt() => int.Parse(Console.ReadLine());
		//public int[] ReadInt(char separator) => Console.ReadLine().Split(separator).Select(int.Parse).ToArray();
		//public double ReadDouble() => double.Parse(Console.ReadLine());
		//public double[] ReadDouble(char separator) => Console.ReadLine().Split(separator).Select(double.Parse).ToArray();
		//public long ReadLong() => long.Parse(Console.ReadLine());
		//public long[] ReadLong(char separator) => Console.ReadLine().Split(separator).Select(long.Parse).ToArray();
		//public string ReadLine() => Console.ReadLine();
		//public string[] ReadLine(char separator) => Console.ReadLine().Split(separator).ToArray();
	}
	public static class Utils {
		//public static string Docking<T>(this IEnumerable<T> collection,string separator="") {
		//	return string.Join(separator, collection);
		//}
		public static void WL(this object obj) => Console.WriteLine(obj);
        public static void WL(this string obj) => Console.WriteLine(obj);
		public static void WL<T>(this IEnumerable<T> collection) {
			foreach (var item in collection) {
				item.WL();
			}
		}
		//public static void REP(int n,Action<int> act) {
		//	for (int i = 0; i < n; i++) act(i);
		//}
		//public static long Mod(long x) => x % ((long)1e9 + 7);
		//public static long ModPow(long x,long a) {long tmp = 1;	while (a!=0) {if (a%2==1) {	tmp = Mod(tmp * x);	}x = Mod(x * x);a /= 2;	}return tmp;}
		//public static long DivMod(long x, long y) => (Mod(x * ModPow(y, (long)1e9 + 5)));
		//public static int ManhattanDistance(int x1, int y1, int x2, int y2) => (Abs(x2 - x1) + Abs(y2 - y1));
	}
}


Measured memory_bytes: 37676
#include <cstdio>
#include <math.h>
using namespace std;

int main()
{
  int n, k;
  scanf("%d %d", &n, &k);
  double cnt = 0;
  double p = 0;
  for (int i = 1; i <= n; i++)
  {
    if (i >= k)
    {
      p = p + (((double)n - (double)k + 1.0) / (double)n);
      break;
    }
    else
    {
      cnt = 0;
      while (1)
      {
        cnt++;
        if (i * pow(2, cnt) >= k)
        {
          break;
        }
      }
      p = p + (pow(0.5, cnt) / n);
    }
  }

  printf("%.16f\n", p);

  return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b, c;
    cin >> a >> b >> c;

    if(a%2 or b%2 or c%2){
        ppp(0);
        return 0;
    }

    if(a == b and b == c){
        ppp(-1);
        return 0;
    }
    ll cnt = 0LL;
    while(a%2 == 0 and b%2 == 0 and c%2 == 0){
        ll tmpa = a, tmpb = b, tmpc = c;
        a = (tmpb+tmpc)/2;
        b = (tmpa+tmpc)/2;
        c = (tmpa+tmpb)/2;
        cnt++;
    }


    ppp(cnt);

    return 0;
}


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

int main()
{
	char str[100];

	cin >> str;

	int l=strlen(str);

	int st=0;
	int en=l-1;

	int ispali=1;
	int fispali=1;
	int eispali=1;

	while(st<=en)
	{
		if(str[st] == str[en])
		{
			st++;
			en--;
		}

		else
		{
			ispali=0;
			break;
		}
	}

	
	st=0;
	en=(l-2)/2;

	while(st<=en)
	{
		if(str[st] == str[en])
		{
			st++;
			en--;
		}

		else
		{
			fispali=0;
			break;
		}
	}

	st=(l+1)/2;
	en=l-1;

	while(st<=en)
	{
		if(str[st] == str[en])
		{
			st++;
			en--;
		}

		else
		{
			eispali=0;
			break;
		}
	}

	if(ispali && fispali && eispali)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	

}

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

int main()
{
	int A, B, coin = 0;
	
	cin >> A >> B;
	
	for (int i = 0; i < 2; i++) {
		if (A <= 0 || B <= 0) {
			break;
		}
		if (A > B) {
			coin += A;
			A--;
		}
		else {
			coin += B;
			B--;
		}
	}
	
	cout << coin << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<vector<ll>> cnt(9,vector<ll>(9,0));
    rep(i,1,n+1){
        string s = to_string(i);
        if (s[s.length()-1] != '0'){
            cnt[s[0]-'1'][s[s.length()-1]-'1']++;
        }
    }
    ll ans = 0;
    rep(i,9){
        rep(j,9){
            ans += cnt[i][j]*cnt[j][i];
        }
    }
    PRINT(ans);
}



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

using namespace std;

#define INF (1<<29)
#define MAX_V 100010
#define MAX_LOG_V 110
typedef long long ll;

vector<int> G[MAX_V];
int root;
int deg[MAX_V];

int parent[MAX_LOG_V][MAX_V];  
int depth[MAX_V];

void dfs(int v, int p, int d)
{
    parent[0][v] = p;
    depth[v] = d;
    for (int i = 0; i < (int)G[v].size(); i++) { 
	if(G[v][i] != p) {
	    dfs(G[v][i], v, d+1);
	}
    }
}

void init(int V)
{
    root = 0;
    dfs(root, -1, 0);
    for (int k = 0; k + 1 < MAX_LOG_V; k++) {
	for (int v = 0; v < V; v++) {
	    if (parent[k][v] < 0) {
		parent[k+1][v] = -1;
	    } else {
		parent[k+1][v] = parent[k][parent[k][v]];
	    }
	}
    }
}

int lca(int u, int v)
{
    if(depth[u] > depth[v]){
	swap(u, v);
    }
    for (int k = 0; k < MAX_LOG_V; k++) {
	if ((depth[v] - depth[u]) >> k & 1) {
	    v = parent[k][v];
	}
    }
    if (u == v) {
        return u;
    }
    for (int k = MAX_LOG_V-1; k >= 0; k--) {
	if (parent[k][u] != parent[k][v]) {
	    u = parent[k][u];
	    v = parent[k][v];
	}
    }
    return parent[0][u];
}

int main()
{
    int n, p;
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> p; --p;
        G[p].push_back(i+1);
    }
    
    queue<int> Q; Q.push(0);
    vector<ll> d(MAX_V, INF); d[0] = 0;
    vector<int> path; path.push_back(0);
    while (!Q.empty()) {
        int v = Q.front(); Q.pop();
        for (int i = 0; i < (int)G[v].size(); i++) {
            int to = G[v][i];
            if (d[v] + 1 < d[to]) {
                d[to] = d[v] + 1;
                Q.push(to);
                path.push_back(to);
            }
        }
    }
    
    init(n);
   
    ll res = 0;
    for (int i = 1; i < n; i++) {
        int l = lca(path[i-1], path[i]);
        res += d[path[i-1]] + d[path[i]] - 2*d[l];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 56364
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
var
s,s1:string;
i,j,c,x,y:longint;
begin
read(s);
for i:=1 to length(s) do
begin
if x=y then begin inc(x); if s[i]='p' then dec(c);end
else
 begin
inc(y);
if s[i]='g' then inc(c);
end;
end;
writeln(c);
end.


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		int MAX = 1000000;
		int [] primeLen = new int[MAX];
		boolean [] isPrime = new boolean[MAX];
		for (int i=2;i<MAX;i++) {
			isPrime[i] = true;
		}
		for (int i=2;i<(int)Math.sqrt(MAX)+1;i++) {
			if (isPrime[i]) {
				for (int j=i*i;j<MAX;j+=i) {
					isPrime[j] = false;
				}
			}
		}
		int cnt = 0;
		for (int i=0;i<MAX;i++) {
			if (isPrime[i]) cnt++;
			primeLen[i] = cnt;
		}
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			int n = s.nextInt();
			System.out.println(primeLen[n]);
		}
	}
}



Measured memory_bytes: 31460
#include<iostream>
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{
   long long int t,c=0;
    scanf("%lld",&t);
  long long int yen=100,amt=0;
  while(yen<t)
  {
      ++c;
    yen=yen+(long long int)(yen)/100;
  }
  printf("%lld",c);
}

Measured memory_bytes: 3820
import java.util.*;
 
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        long sum = 0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            sum += A[i];
        }
        // left -> right
        long leftSum = 0;
        int i = 0;
        while (2*leftSum < sum) {
            leftSum += A[i++];
        }
        // right -> left
        long rightSum = 0;
        i = N-1;
        while (2*rightSum < sum) {
            rightSum += A[i--];
        }
        System.out.println(Math.min(leftSum - (sum-leftSum), rightSum - (sum-rightSum)));
    }
}


Measured memory_bytes: 66084
echo H,W,A,B=`tr \  ,`\;M,C,Z=10**9+7,1,0 '
for I in range(1,H'{'):C=C*(W+H-B+~I)*pow(','-A):Z+=C;C=C*(B-1+I)*(H-I)*pow((W+H-B+~I)*'}I,M-2,M\)%M '
print(Z+C)%M'|pypy

Measured memory_bytes: 88704
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    char s[20];
    for(int i=0;i<20;++i){cin>>s[i];}
    cout<<s[0]<<s[1]<<s[2]<<endl;
    
}


Measured memory_bytes: 3636
#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;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    int n;
    cin >> n;
    cout << n * 800 - n / 15 * 200 << endl;
}


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

int main(void){
  int cost[3];
  for(int i=0; i<3; i++){
    cin >> cost[i];
  }
  sort(cost, cost+3, greater<int>());
  cout << cost[0] - cost[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
  
int main(){
    std::vector<int> a(4);
      
    while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
        int hit = 0, blow = 0;
          
        for(int i = 0; i < 4; ++i){
            int b;
            std::cin >> b;
              
            auto it = std::find(a.begin(), a.end(), b);
            if(it == a.begin() + i){
                ++hit;
            }
            else if(it != a.end()){
                ++blow;
            }
        }
        std::cout << hit << " " << blow << std::endl;
    }
     
    return 0;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int64_t
codefestival_2016_qualC_c()
{
    const int64_t mod = 1000000007;

    size_t n;
    cin >> n;
    vector<size_t> a(n), b(n);
    cin >> a >> b;

    const size_t nil = (size_t) -1;
    vector<size_t> h(n, nil);

    h[0] = a[0];
    for(size_t i = 1; i < n; ++i)
        if(a[i - 1] < a[i]) h[i] = a[i];

    DEBUG(h);

    // reverse(begin(b), end(b));

    if(h[n - 1] != nil && h[n - 1] != b[n - 1])
        return 0;

    h[n - 1] = b[n - 1];

    for(size_t i = n - 2; i < n; --i)
    {
        if(h[i] != nil && b[i] < h[i])
            return 0;

        if(b[i + 1] < b[i])
        {
            if(h[i] != nil && h[i] != b[i])
                return 0;

            h[i] = b[i];
        }
    }

    for(size_t i = 0; i < n; ++i)
        if(h[i] != nil && a[i] < h[i])
            return 0;

    DEBUG(h);

    int64_t out = 1;
    for(size_t i = 0; i < n; ++i)
        if(h[i] == nil)
            out = out * ((int64_t) min(a[i], b[i])) % mod;

    return out;
}


int main(const int argc, char * argv [])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << codefestival_2016_qualC_c();

    return EXIT_SUCCESS;
}


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

long long A, B, num;


void prime_factor(){
	long long Abak = A;
	long long Bbak = B;

	num++;
	for(long long i = 2; i*i <= min(A, B); i++){
		if(Abak % i == 0 && Bbak % i == 0){
			num++;
		}
		while(Abak % i == 0){
			Abak /= i;
		}
		while(Bbak % i == 0){
			Bbak /= i;
		}
	}
	if(Abak > 1 && Bbak > 1 && Abak == Bbak){
		num++;
	}
}



int main(){
	cin >> A >> B;
	prime_factor();
	cout << num << endl;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	ll a, b;
	cin >> a >> b;
	cout << a*b << endl;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3604