akhauriyash/Code-Regression huggingface dataset:
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
cin>>head;
CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair

int main(){

  CIN(n,ma,mb);V a(n);V b(n);V c(n);REP(i,n)cin>>a[i]>>b[i]>>c[i];
  
  //dp[i][j][k] : i番目までで混合物の和がj:kになるような最小の価格
  vector<map<int,M>> dp(n+1);
  dp[0][0][0]=0;
  REP(i,n){
    FOREACH(d,dp[i]){
      FOREACH(p,d.second){
        if(dp[i+1].count(d.first)&&dp[i+1][d.first].count(p.first))
          dp[i+1][d.first][p.first]=min(dp[i+1][d.first][p.first],p.second);
        else dp[i+1][d.first][p.first]=p.second;
        if(dp[i+1].count(d.first+a[i])&&dp[i+1][d.first+a[i]].count(p.first+b[i]))
          dp[i+1][d.first+a[i]][p.first+b[i]]=min(dp[i+1][d.first+a[i]][p.first+b[i]],p.second+c[i]);
        else dp[i+1][d.first+a[i]][p.first+b[i]]=p.second+c[i];
      }
    }
  }
  int ans=INF;
  FOR(i,1,n+1)FOREACH(d,dp[i])FOREACH(p,d.second)if(d.first*mb==p.first*ma&&p.second!=0)ans=min(p.second,ans);
  COUT((ans==INF)?-1:ans);


  return 0;
}


Measured memory_bytes: 16920
#include <cstdio>
#include<iostream>
 
using namespace std;
  
int main(void){
 
	double a,before,sum;
 
    while(cin>>a){
		before=a;
		sum=before;
		for(int i=2;i<=10;i++){
			if(i%2==0) before*=2;
			else before/=3;
			sum+=before;
		}
			printf("%.8f\n",sum);
    }
 
    return 0;
}

Measured memory_bytes: 1236
#include<iostream> 
#include<string> 
#include<cstring> 
#include<vector> 
#include<map> 
#include<algorithm> 
#include<queue> 
#include<set> 
#include<cstdio> 
#include<functional> 
#include<iomanip> 
#include<cmath> 
#include<stack> 
#include<iomanip>
#include<functional>
using namespace std;
const int maxn = 2*(int)(1e5)+1000;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
typedef long long LL;
typedef unsigned long long ull;
int a[maxn];
int main() {
	//freopen("E:\\test.txt", "r", stdin);
	int n;
	while (~scanf("%d", &n)) {
		for (int i = 0; i < n; i++)
			scanf("%d", &a[i]);
		sort(a, a + n);
		int t = lower_bound(a, a + n, a[n - 1] / 2) - a;
		if (a[t] == a[n - 1] / 2) printf("%d %d\n", a[n - 1] , a[t]);
		else if (a[n - 1] & 1) {
			int l = a[n - 1] / 2, r = a[n - 1] / 2 + 1;
			int lx = a[t - 1], rx = a[t];
			if (abs(lx - l) > abs(rx - r)) printf("%d %d\n", a[n - 1], rx);
			else printf("%d %d\n", a[n - 1], lx);
		}
		else {
			int l = a[n - 1] / 2;
			int lx = a[t - 1], rx = a[t];
			if (abs(lx - l) > abs(rx - l)) printf("%d %d\n", a[n - 1], rx);
			else printf("%d %d\n", a[n - 1], lx);
		}
	}
	return 0;
}

Measured memory_bytes: 640
n,m = map(int, input().split())
lr = [0, 10**6]
for _ in range(m):
  t = sorted(list(map(int, input().split())))
  lr[0] = max(lr[0], t[0])
  lr[1] = min(lr[1], t[1])

ans = lr[1] - lr[0] + 1
if ans < 0:
  print(0)
else:
  print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < N-1; i++){
    if(v.at(i+1)<v.at(i)){
      int a = v.at(i) - v.at(i+1);
      sum += a;
    }
  }
  

  
  cout << sum + v.at(N-1) << endl;
  
}

Measured memory_bytes: 256
loop do
  n,m=gets.split.map(&:to_i)
  break if n==0
  px,py,cnt=0,0,0
  arr=Array.new()
  n.times do 
    arr<<gets.chomp.split("")
  end
  loop do
    case arr[py][px]
    when "<" then px-=1
    when ">" then px+=1
    when "^" then py-=1
    when "v" then py+=1
    else break
    end
    cnt+=1
    break if cnt>n*m
  end
  puts cnt>n*m ? "LOOP": "#{px} #{py}"
end

Measured memory_bytes: 8936
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	slice := strings.Split(s, " ")
	n := string(slice[0])
	k := string(slice[1])
	N, _ := strconv.Atoi(n)
	K, _ := strconv.Atoi(k)

	if N%K == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1)
	}
}


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

using namespace std;
typedef long long LL;
int sum[1000000];

int main()
{
    LL n,m;
    while(scanf("%lld%lld",&n,&m)==2){
        LL x;
        sum[0]=0;
        for(LL i=1;i<=n;i++){
            scanf("%lld",&x);
            sum[i]=((sum[i-1]+x)%m+m)%m;
        }
        sort(sum,sum+n+1);
        LL s=1;
        long long ans=0;
        for(LL i=1;i<=n;i++){
            if(sum[i]==sum[i-1]) s++;
            else{
                ans+=s*(s-1)/2;
                s=1;
            }
        }
        ans+=s*(s-1)/2;
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
 
int main(){
        double x1;
        double y1;
        double x2; 
        double y2;
        cin >> x1 >> y1 >> x2 >> y2;
        printf("%.9lf\n",sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
 
        return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

ll solve(){
    ll n;
    cin>>n;
    ll a[n];
    ll s=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    ll s1=s/n+1;s=s/n;
    ll v1=0,v2=0;
    for(int i=0;i<n;i++)
    {
        v1+=(a[i]-s)*(a[i]-s);
        v2+=(a[i]-s1)*(a[i]-s1);
    }
    cout<<min(v1,v2)<<endl;
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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

int main(void){
    int n;
    cin>>n;
    vector<int> res = {1,2,4,8,16,32,64,128};
    rep(i,res.size()){
        if(res[i]<=n && n<res[i+1]){
            cout<<res[i]<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define dd double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl '\n'

int n;
int a[3001];
vector<vector<int>> dp(3001,vector<int>(3001,-1));

int game(int i,int j){
	if(i>j)return 0;
	if(i==j){
		return a[i];
	}

	if(dp[i][j]!=-1) return dp[i][j];

	return dp[i][j] = max(a[i]-game(i+1,j),a[j]-game(i,j-1));
}

signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n;
	for0(i,n) cin>>a[i];

	cout<<game(0,n-1)<<endl;

	return 0;
}

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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> a_tmp, a;
    for (int i = 0; i < n; i++)
    {
        int tmp; cin >> tmp;
        a_tmp.push_back(tmp);
        a.push_back(tmp);
    }
    sort(a_tmp.begin(), a_tmp.end(), greater<int>());

    int onlyOneFlag = 1;
    if (a_tmp[0] == a_tmp[1]){
        onlyOneFlag = 0;
    }

    for (int i = 0; i < n; i++)
    {
        if ((onlyOneFlag == 1) && a[i] == a_tmp[0]){
            cout << a_tmp[1] << endl;
        } else {
            cout << a_tmp[0] << endl;
        }
    }

}



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

int main(){
    int n, amari, ans;
    cin >> n;
    amari = n % 1000;
    if(amari != 0){
        ans = 1000 - amari;
    }else if(amari == 0){
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ss second
#define ff first
#define endl '\n';
int h,w,n;
bool check(vector<pair<int,int> >vertices)
{
	 bool okay=true;
	 for(auto x:vertices)
	 {
	 	   okay&=x.ff>=1;
	 	   okay&=x.ff<=h;
	 	   okay&=x.ss>=1;
	 	   okay&=x.ss<=w;
	 	   if(!okay)
	 	   	return false;
	 }
	 return okay;
}
map<pair<int,int>,int>m;
set<pair<int,int> >s;
vector<pair<int,int> >v;
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     cin>>h>>w>>n;
     vector<pair<int,int> >v;
     for(int i=0;i<n;i++)
     {
     	   int x,y;
     	   cin>>x>>y;
     	   v.push_back({x,y});
     	   m[{x,y}]++;
     }
     vector<int>go(10,0);
     for(int i=0;i<n;i++)
     {
     	     for(int x=v[i].ff-2;x<=v[i].ff;x++)
     	     {
     	     	   for(int y=v[i].ss-2;y<=v[i].ss;y++)
     	     	   {
     	     	   	      vector<pair<int,int> >vertices;
     	     	   	      int count=0;
     	     	   	      for(int a=x;a<=x+2;a++)
     	     	   	      {
     	     	   	      	   for(int b=y;b<=y+2;b++)
     	     	   	      	   	vertices.push_back({a,b}),count+=m[{a,b}];
     	     	   	      }
     	     	   	      if(!check(vertices))
     	     	   	      	continue;
     	     	   	      sort(vertices.begin(),vertices.end());
     	     	   	      if(s.find(vertices[0])==s.end())
     	     	   	      {
     	     	   	         s.insert(vertices[0]);
     	     	   	         go[count]++;
     	     	   	      }
     	     	   }
     	     }
     }
     int sum=0;
     for(int i=1;i<=9;i++)
     	sum+=go[i];
     cout<<(1LL*(h-2)*(w-2)-sum)<<endl;
     for(int i=1;i<=9;i++)
     	cout<<go[i]<<endl;
     return 0;
}


Measured memory_bytes: 221300
import sys
sys.setrecursionlimit(5 * 10**5)
input = sys.stdin.readline

N, M, X, Y = list(map(int, input().split()))

x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.append(X)
y.append(Y)

if min(y) - max(x) >= 1:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
import math
class Triangle(object):
    def __init__(self, a, b, C):
        self.a = a
        self.b = b
        self.C = math.radians(C)
    
    def getArea(self):
        return((self.a * self.getHeight()) / 2)

    def getPerimeter(self):
        return(self.a + self.b + math.sqrt(self.a ** 2 + self.b ** 2 - 2 * self.a * self.b * math.cos(self.C)))
    
    def getHeight(self):
        return(self.b * math.sin(self.C))

tri = Triangle(*[int(i) for i in input().split()])
print(tri.getArea())
print(tri.getPerimeter())
print(tri.getHeight())


Measured memory_bytes: 5720
# 2019/06/02
# CODE FESTIVAL 2016 qual C - A

# Input
s = input()

findflg = 0
for i in range(len(s)):
    if findflg == 0 and s[i] == "C":
        findflg = 1
    elif findflg == 1 and s[i] == "F":
        findflg = 2
        break

if findflg == 2:
    ans = "Yes"
else:
    ans = "No"

# Output
print(ans)


Measured memory_bytes: 2940
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int M,T,P,R;
	while(cin >> M >> T >>P >> R  && !(M==0 && T==0 && P==0 && R==0))
	{
		
		int a[50][50]={}; // Team * Problem の成否 正解なら1
		int b[50][50]={}; // 同、得点（候補）
		
		int m[2000]={0};
		int t[2000]={0};
		int p[2000]={0};
		int j[2000]={0};
		
		REP(i,R){
		cin >> m[i] >> t[i] >> p[i] >> j[i];
		t[i]--;p[i]--;}
		
		REP(i,R){
			if(j[i]==0)
			{
				a[t[i]][p[i]]=1;
				b[t[i]][p[i]]+=m[i];
			}
			else
			{
				b[t[i]][p[i]]+=20;
			}
		}
		
		int xa[50]={}; //正解数
		int xb[50]={}; //得点合計
		REP(i,T){REP(j,P){
				xa[i]+=a[i][j];
				xb[i]+=a[i][j]*b[i][j];
			}
		}
		
		int po[50]; // 得点のパターンを照準に
		REP(i,T){po[i]=xb[i];}
		sort(po,po+T);
		
//		REP(i,T){cout << xa[i] << " " << xb[i] << endl;}
//		REP(i,T){cout << po[i] << " ";}
		
		bool flag1=false; // １チームでも出力したらフラグ立てる
		for(int i=P;i>-1;i--)
		{
			for(int j=0;j<T;j++)
			{
				bool flag2 = false;  //同一正解、同一得点のチームが出力されていたらフラグ立てる
				bool flag3 = false; //同一得点を検索していたらフラグ立てる
				if(po[j-1]==po[j] && j>0){flag3=true;}
				for(int k=(T-1);k>-1;k--)
				{
					if(flag3){break;}
					if(	xa[k]==i && xb[k]==po[j] )
					{
						if(!flag1){cout << k+1; flag1=true;flag2=true;}
						else if(flag1 && !flag2){cout<<"," << k+1;flag2=true;}
						else {cout << "=" << k+1;}
					}
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int N;
  cin >> N;
  vector<int> v(N);
  rep(i, 0, N) { cin >> v[i]; }
  map<int, int> m;
  vector<int> ans, w(v);

  sort(all(w));

  int a = w[N / 2 - 1], b = w[N / 2];
  dump(a,b);

  rep(i, 0, N) {
    if (i < N / 2)
      m[w[i]]=b;
    else
      m[w[i]]=a;
  }

  rep(i, 0, N) cout << m[v[i]] << endl;

  return 0;
}


Measured memory_bytes: 12928
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 200000;
const int N = 100;

ll A[MAX],B[MAX],ta[MAX],tb[MAX];
int n;

int cnt(ll a,ll t){
	int upper=n-1,lower=0,ret=-1;
	while(upper>=lower){
		int mid=(upper+lower)/2;
		if(a+tb[mid]<t){
			ret=max(ret,mid);
			lower=mid+1;
		}
		else upper=mid-1;
	}
	return ret;
}

int main() {
	cin>>n;
	rep(i,n) cin>>A[i];
	rep(i,n) cin>>B[i];
	ll ans=0;
	rep(i,29){
		ll t=1<<i,c=0;
		rep(j,n) ta[j]=A[j]%(2*t);
		rep(j,n) tb[j]=B[j]%(2*t);
		sort(tb,tb+n);
		rep(j,n) c+=cnt(ta[j],4*t)-cnt(ta[j],3*t)+cnt(ta[j],2*t)-cnt(ta[j],t);
		ans+=t*(c%2);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <set>
#include <iterator>
#include <map>
using namespace std;

vector<int> table;


void check(int x){
    bool a = false, b = false, c = false;
    string tmp = to_string(x);
    for(int i = 0; i < tmp.size(); i++){
        if(tmp[i] == '3'){
            a = true;
        }else if(tmp[i] == '5'){
            b = true;
        }else{
            c = true;
        }
    }
    if(a == true && b == true && c == true){
        table.push_back(x);
    }
}

void dfs(int x){
    check(x);
    if(x <= 100000000){
        dfs(10 * x + 3);
        dfs(10 * x + 5);
        dfs(10 * x + 7);    
    }
}

int main(){
    int N;
    cin >> N;
    // dfs(0);
    dfs(3);
    dfs(5);
    dfs(7);
    sort(table.begin(), table.end());
    cout << upper_bound(table.begin(), table.end(), N) - table.begin() << endl;
    
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x, y;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		int ans = x + (y / 2);
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 22868
#pragma GCC optimize("O3", "unroll-loops")

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <sstream>
#include <deque>
#include <queue>
#include <random>
#include <complex>

using namespace std;

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FIXED cout << fixed << setprecision(12);
#define RANDOM srand(94385)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define graph vector<vector<int>>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define f first
#define s second
#define hashmap unordered_map
#define hashset unordered_set
#define eps 1e-9
#define mod 1000000007
#define inf 3000000000000000007ll
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define shuffle(a) \
    for (int i = 0; i < sz(a); ++i) \
        swap(a[i], a[rand() % sz(a)])

template<class T, class U> inline void checkmin(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void checkmax(T &x, U y) { if (y > x) x = y; }
template<class T, class U> inline bool ifmax(T &x, U y) { if (y > x) return x = y, true; return false; }
template<class T, class U> inline bool ifmin(T &x, U y) { if (y < x) return x = y, true; return false; }
template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline void rsort(T &a) { sort(rall(a)); }
template<class T> inline void reverse(T &a) { reverse(all(a)); }
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.f >> p.s; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

signed main() {
    FAST; FIXED; RANDOM;
    int n;
    cin >> n;
    cout << 180 * (n - 2);
    return 0;
}   


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int a, b, c, x, y;

	cin >> a >> b >> c >> x >> y;

	//ABの方が得
	if (a + b > 2 * c) {
		int min = (x < y) ? x : y;
		int max = (x > y) ? x : y;
		int minp = a*(x - min) + b*(y - min) + 2*c*min;
		int maxp = 2*c*max;
		cout << ((minp < maxp) ? minp : maxp) << endl;
	} 
	//それぞれ買った方が得
	else {
		cout << a*x + b*y << endl;
	}

}

Measured memory_bytes: 256
/* 163-C.cpp
 *     Created on : Apr 19, 2020 
 *     Time       : 6:19:09 PM
 *     Author     : null_ptr
 */
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<int> nums(n),cnt(n+1);
	for(int i=0;i<n-1;++i)
	{
		cin>>nums[i];
		cnt[nums[i]]++;
	}
	for(int i=1;i<=n;++i)
		cout<<cnt[i]<<'\n';
}


Measured memory_bytes: 4844
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VLL b(n);
    REP(i,0,n) b[i] = a[i];
    sort(all(b));
    reverse(all(b));
    REP(i,0,n) {
        if (a[i] == b[0]) cout << b[1] << endl;
        else cout << b[0] << endl;
    }
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 4736
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> cs(N);
  F0R(i, N) {
    cin >> cs[i];
    cs[i]--;
  }
  vector<vector<int>> G(N);
  F0R(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<i64> rs(N, N* ((i64)N + 1) / 2); // その色を通るパス数
  vector<i64> ps(N);  // その色ではじまる部分木のサイズ

  auto dfs = [&](auto dfs, int v, int p)->int {

    //cout << "Entering " << v << newl;
    i64 rsv = ps[cs[v]];
    ps[cs[v]] = 0;
    i64 sub = 0;
    int vc = 1;
    for (auto c : G[v]) {
      if (c == p) continue;
      int n = dfs(dfs, c, v);
      i64 s = n - ps[cs[v]];
      //debug(s);
      ps[cs[v]] = 0;

      // 色cs[v]を通らないパスの数
      sub += ((i64)s + 1) * s / 2;
      vc += n;
    }
    rs[cs[v]] -= sub;

    ps[cs[v]] = rsv + vc;
    //debug(ps[cs[v]]);
    //cout << "Leaving " << v << newl;
    return vc;
  };
  
  i64 a = dfs(dfs, 0, -1);
  //debug(a);
  F0R(i, N) {
    if (i == cs[0]) continue;
    i64 s = a - ps[i];
    rs[i] -= (s + 1) * s / 2;
  }

  F0R(i, N) {
    cout << rs[i] << newl;
  }
}
#endif


Measured memory_bytes: 43028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
    ll x,y;
};
node a[60];
node b[60];
ll c[60];
int d[60];
int main()
{
    int n,m;
    memset(c,1e9+10,sizeof(c));
    memset(d,1e9+10,sizeof(d));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld %lld",&a[i].x,&a[i].y);
    for(int i=1;i<=m;i++){
        scanf("%lld %lld",&b[i].x,&b[i].y);
        for(int j=1;j<=n;j++)
        {
            if( (abs(b[i].x-a[j].x) + abs(b[i].y - a[j].y)) < c[j]){
                c[j] = abs(b[i].x-a[j].x) + abs(b[i].y - a[j].y);
                d[j] = i;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<d[i]<<endl;
    }
    return 0;
}


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

#define BR "\n"

ll MOD = 1e9+7;

ll calc(ll x, ll y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  ll temp = calc(x, y / 2);
  temp = (temp * temp) % MOD;
  if (y % 2) return (x * temp) % MOD;
  else return temp;
}

int main() {
  ll M, N;
  cin >> M >> N;
  ll ans = calc(M, N);
  
  cout << ans << BR;
  return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
 
int main(void)
{
int n,a,i,clr[9]={0},j,cnt=0;
scanf("%d",&n);

for(i=0; i<n;i++){
scanf("%d",&a);
for(j=8;j>=0;j--){
if(a>=j*400){
clr[j]++;
break;
}
}
}

for(j=0;j<8;j++){
if(clr[j]>0)cnt++;
}
if(cnt==0 && clr[8]>0)
printf("%d ",1);
else
printf("%d ",cnt);

printf("%d\n",cnt+clr[8]);
 
 
return 0;
}

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

int main(){
    string ss;
    while( cin >> ss ){
        for(string::iterator it = ss.begin(); it != ss.end(); it++){
            if( *it == '@' ){
                for(int i = 0; i < *(it+1)-'0'; i++){
                    cout << *(it+2);
                }
                it += 2;
            }else{
                cout << *it;
            }
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M; 
        exp>>=1;
    }
    return res;
}

void solve()
{
    li d,s,t;

    cin>>d>>t>>s;

    if(t*s>=d)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
}

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

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

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

using namespace std;

// Function to solve the problem come here.

int foo(int N)
{

    int j = N;
    while (true)
    {
        if (j % N == 0 && j % 2 == 0)
            return j;

        j += N;
    }
}

int main(int argc, char **argv)
{
    // Solve the problem here
    int N;
    cin >> N;
    cout << foo(N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

// 4と9を含まない数字の組合せ
long dp[20000][2][100];
int D;
// 各桁の総和を知りたい場合は引数にsum,判定にsum==D
long rec(string &s, int k=0, bool tight=true, int sum=0){
  if(k == s.size()){
    //条件によって返す値が決まる
    return (sum == 0);
  }

  int m = s.at(k) - '0'; //k桁目の数字

  if(dp[k][tight][sum] != -1) return dp[k][tight][sum];

  int x = (tight ? m : 9);
  long res = 0;
  for(int i=0; i<=x; i++){
    //if(i == 4 || i == 9) continue;
    res += rec(s, k+1, i==x && tight, (sum+i)%D);
    res %= MOD;
  }

  return dp[k][tight][sum] = res;
}

void dpInit(long value=-1, int a = 1, int b = 1, int c = 1){
  for(int i=0; i<a; i++){
    for(int j=0; j<b; j++){
      for(int k=0; k<c; k++){
        dp[i][j][k] = value; 
      }
    }
  }
}

int main(){
  string s;
  cin >> s >> D;
  dpInit(-1,20000,2,100);
  cout << (rec(s,0,true,0) + MOD - 1) % MOD << endl;
}

Measured memory_bytes: 35720
h,w=map(int,input().split())
n=int(input())
A=list(map(int,input().split()))
MAP=[[0 for i in range(w)] for j in range(h)]
s,num=0,1
for i in range(h):
    if i%2==0:add=[k for k in range(w)]
    else:add=[k for k in reversed(range(w))]
    for j in add:
        MAP[i][j]=num
        A[s] -=1
        if A[s]==0:
            s +=1
            num +=1

for i in range(h):print(*MAP[i])

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

int main() {
  int N,M;
  cin >> N >> M;
  //vector<vector<int>> loadList(M, vector<int>(2));

  dsu d(N);
  for (int i = 0; i < M; i++) {
	int a, b;
    cin >> a >> b;
    --a; --b;
    d.merge(a,b);
	//loadList.at(i).at(0) = a;
    //loadList.at(i).at(1) = b;
  }


  //for (int i = 0; i < M; i++) {
    //d.merge(loadList.at(i).at(0), loadList.at(i).at(1));
  //}
  
  int size = (int)d.groups().size();
  if (size == 1) {
    cout << 0;
  } else if (size == 0) {
    printf("%u",N-1);
  } else {
    printf("%u",size-1);
  }
}

Measured memory_bytes: 8984
#include <bits/stdc++.h>
    #define HAR BAR LAGTA HAI APUN HI J BHAGWAAN HAI!!
    #define UTSAV  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #define ll long long int
    #define MAX 1e9
    #define MIN -1e9
    #define mod 1000000007
    #define pb push_back
    #define all(x) (x).begin(), (x).end()
    #define debug(x) cerr<<#x<<'='<<(x)<<endl;
    #define output(x) cout << ( x ? "YES" : "NO" ) << '\n' ;
    #define mxn 100005
    using namespace std;
    int main()
    {
        UTSAV
        int n;
        cin>>n;
        if(n) cout<<0<<endl;
        else cout<<1<<endl;
        return 0;
    }
       

Measured memory_bytes: 3664
from fractions import gcd
A, B = map(int, input().split())

saidai_kouyaku = gcd(A,B)

#%%
kouyaku = [0 for _ in range(int(saidai_kouyaku**0.5)+2)]
kouyaku[1] = 1


for i in range(2,len(kouyaku)):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1

if saidai_kouyaku > 1:
    print(answer+1)
else:
    print(answer)

Measured memory_bytes: 13024
/*
author: Apoorv Singh
*/

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

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

ll fpow(ll a, ll n)
{
    ll ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << max(0,(a+b)-n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int n;
    cin>>n;
    /*
    vector<pair<int, int>> p(n);
    int index;
    rep(i, n){
        cin >> index;
        p[i] = make_pair(i+1, index);
    }
    */
   map<int, int> m;
   int index;
   rep(i, n){
       cin >> index;
       m[index] = i+1;
   }
   REP(i, 1, n+1) cout << m[i] << ' ';
   cout << endl;
    
    return 0;
}


Measured memory_bytes: 5504
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int n,m;
    cin >> n >> m;
    int ans = 0;
    if (m==1){
    pri(0); 
    return 0;
    }

    int i=0;
   while((n-1)*i+1<m) i++;
    
   pri(i);
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        StringBuilder ans = new StringBuilder(s.next());
        String str = ans.toString();
        String check = str;
        for (int i = 0 ; i == 0 || !str.equals(check); i++) {
            check = str;
            str = str.replaceAll("\\(\\)", "");
        }
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == ')') {
                ans.insert(0, "(");
            } else {
                ans.insert(ans.length(), ")");
            }
        }
        System.out.println(ans);
    }
}


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

int main(){
int a,b;
  cin >>a>>b;
  if(b==1) cout <<0<<endl;
  else if(b<=a) cout <<1<<endl;
  else{
    for(int i =0;true;i++){
    if(b<=(a-1)*i+a){
    cout << i+1<<endl;
      break;
    }
    }
  } 
}

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

int main(){
    int x,y,work;
    cin >> x >> y;
    while(!(x == 0 && y == 0)){
        if(x > y){
            work = x;
            x = y;
            y = work;
        }
        cout << x << " " << y << endl;
        cin >> x >> y;
    }
    return 0;
}

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

int dp[101][4][4][4];

int main() {
	int n; cin >> n;
	dp[0][3][3][3] = 1;
	int mod = 1'000'000007;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) {
					if (dp[i][j][k][l] == 0) {
						continue;
					}
					for (int a = 0; a < 4; a++) {
						if (a == 2) {
							if (j == 1 && k == 0) {
								continue;
							}
							else if (j == 0 && k == 1) {
								continue;
							}
							if (j == 1 && l == 0) {
								continue;
							}
							if (k == 1 && l == 0) {
								continue;
							}
						}
						else if (a == 1) {
							if (j == 2 && k == 0) {
								continue;
							}
						}
						dp[i + 1][a][j][k] += dp[i][j][k][l];
						dp[i + 1][a][j][k] %= mod;
					}
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				ans += dp[n][i][j][k];
				ans %= mod;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
int mod1=998244353,mod2=(int)1e9+7;
int power(int n,int k,int mod){int ans=1; n=n%mod;while(k>0){if(k&1)ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return (ans+mod)%mod;}//negative nos & 0^0
struct triplet{int a,b,c;};bool operator < (const triplet &t1,const triplet &t2){if(t1.a<t2.a)return true;if(t1.a==t2.a && t1.b <t2.b)return true;if(t1.a==t2.a && t1.b ==t2.b && t1.c<t2.c)return true;return false;}

int32_t main()
{

	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	 int t=1; 
	 // cin>>t;
    while(t--)
    {
    	int n;
    	cin>>n;
    	int a[n];
    	int sumsq=0,sum=0;
    	for(int i=0;i<n;i++)
    	{
    		cin>>a[i];
    		sumsq=(sumsq+a[i]*a[i])%mod2;
    		sum=(sum+a[i])%mod2;
    	}	
    	int x=((sum*sum)%mod2-sumsq%mod2+mod2)%mod2;
    	int inv2=power(2,mod2-2,mod2);
    	cout<<(x*inv2)%mod2;

    }
}


Measured memory_bytes: 5172
#include <iostream>
#include <string>
#include <ctype.h>

using namespace std;

int main() {
	//------------入力------------
	//string型文字列a,b,cを定義
	string a, b, c;
	//a,b,cを入力
	cin >> a >> b >> c;

	//------------出力------------
	//int型文字d,e,fを定義
	int d, e, f;
	//入力された文字列a,b,cの先頭を各々大文字に変換
	d = toupper(a[0]);
	e = toupper(b[0]);
	f = toupper(c[0]);
	//変換後の文字をつなげて出力
	printf("%c", d);
	printf("%c", e);
	printf("%c", f);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main() {
	cin >> n;
	if (n <= 999)cout << "ABC" << endl;
	else cout << "ABD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template <typename T>
class BIT {
    int sz;
public:
    std::vector<T> node;
    BIT(int sz): sz(sz+1), node(std::vector<T>(sz+1, 0)) {}
    void add(int idx, T val) {
        ++idx;
        assert(0 < idx && idx < sz);
        while(idx < sz) {
            node[idx] += val;
            idx += idx & -idx;
        }
    }
    T sum(int idx) {
        ++idx;
        assert(0 < idx && idx < sz);
        T res = 0;
        while(idx > 0) {
            res += node[idx];
            idx -= idx & -idx;
        }
        return res;
    }
};
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, q; cin >> n >> q;
  vi c(n);
  for(int i=0;i<(n);++i) {
    cin >> c[i];
  }
  vector<pair<P, int>> v(q);
  for(int i=0;i<(q);++i) {
    cin >> v[i].first.second >> v[i].first.first;
    v[i].second = i;
  }
  sort((v).begin(),(v).end());
  for(int i=0;i<(q);++i) swap(v[i].first.first, v[i].first.second);
  vi last(n+1, -1);
  BIT<ll> bit(n+1);
  int nowr = 0;
  vi ans(q);
  for(int i=0;i<(q);++i) {
    int nxtr = v[i].first.second;
    while(nowr < nxtr) {
      if(last[c[nowr]] != -1) {
        bit.add(last[c[nowr]], -1);
      }
      bit.add(nowr, 1);
      last[c[nowr]] = nowr;
      nowr++;
    }
    ans[v[i].second] = bit.sum(v[i].first.second-1) - (v[i].first.first == 1 ? 0 : bit.sum(v[i].first.first-2));
  }
  for(int i=0;i<(q);++i) {
    cout << ans[i] << "\n";
  }
}


Measured memory_bytes: 19320
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>

using ll = long long;
const ll INF = (ll)1e18;

ll H, W;

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::cin >> H >> W;
  std::vector< std::string > vs(H, std::string(W, '.'));
  std::vector< std::vector<ll> > dist(H, std::vector<ll>(W, INF));

  ll sharp_cnt = 0;
  for (ll y = 0; y < H; y++) {
    for (ll x = 0; x < W; x++) {
      std::cin >> vs[y][x];
      if (vs[y][x] == '#') {
	sharp_cnt++;
      }
    }
  }

  // y, x
  std::queue< std::pair< ll, ll > > que;

  dist[0][0] = 1;
  que.push(std::make_pair(0, 0));

  while (!que.empty()) {
    std::pair< ll, ll > p = que.front();
    que.pop();
    ll y = p.first;
    ll x = p.second;
    if (x+1 < W && y < H && vs[y][x+1] == '#') {
      if (dist[y][x+1] > dist[y][x] + 1) {
	dist[y][x+1] = dist[y][x] + 1;
	que.push(std::make_pair(y, x+1));
      }
    }
    if (x < W && y+1 < H && vs[y+1][x] == '#') {
      if (dist[y+1][x] > dist[y][x] + 1) {
	dist[y+1][x] = dist[y][x] + 1;
	que.push(std::make_pair(y+1, x));
      }
    }
  }


  if (dist[H-1][W-1] == sharp_cnt) {
    std::cout << "Possible" << std::endl;
  } else {
    std::cout << "Impossible" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;
int h, w;
string a[8];
bool used[8][8] = {};

bool dfs(int cx, int cy, int gx, int gy)
{
  used[cy][cx] = true;
  if (cx == gx && cy == gy)
    return true;
  bool ans = false;
  if (cx < w - 1 && a[cy][cx + 1] == '#')
  {
    ans = dfs(cx + 1, cy, gx, gy);
  }
  if (ans)
    return ans;
  if (cy < h - 1 && a[cy + 1][cx] == '#')
  {
    ans = dfs(cx, cy + 1, gx, gy);
  }
  if (ans)
    return ans;
  used[cy][cx] = false;
  return false;
}

int main()
{
  cin >> h >> w;
  REP(i, h)
  {
    cin >> a[i];
  }

  dfs(0, 0, w - 1, h - 1);
  REP(i, h)
  {
    REP(j, w)
    {
      if (a[i][j] == '#' && !used[i][j])
      {
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  cout << "Possible" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d;cin>>a>>b>>c>>d;
  while(1)
  {
    c=c-b;
    if(c<=0){cout<<"Yes\n";return 0;}
    a=a-d;
    if(a<=0){cout<<"No\n";return 0;}
  }
}

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

int a[200005];
struct node{
deque<int>v;
};

int res[200005];
int r=0;
deque<int>an,bn;
void solve(int n){
	
	if(n&1){
		for(int i=n;i>=1;i-=2){
			res[++r]=i;
		}
		for(int i=2;i<=n-1;i+=2){
			res[++r]=i;
		}
	}
	else{
		for(int i=n;i>=2;i-=2){
			res[++r]=i;
		}
		for(int i=1;i<=n-1;i+=2){
			res[++r]=i;
		}
	}
		for(int i=1;i<=r;i++){
		cout<<a[res[i]]<<" ";
	}
}
int main(){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
	scanf("%d",&a[i]);
	}
	if(n==1){
		printf("%d ",a[1]);
	
		return 0;
	}
	//solve(n);

		an.push_back(1);
		bn.push_front(1);
		
	for(int i=2;i<=n;i++){
if(i&1){
     an.push_back(i);
	 bn.push_front(i);
}
else{
	  bn.push_back(i);
	  an.push_front(i);
	
}
if(i==n){
	if(n&1){
		int t=bn.size()-1;
		for(int x=0;x<=t;x++){
			printf("%d ",a[bn[x]]);
			
		}
	}
	else{
			int t=an.size()-1;
		for(int x=0;x<=t;x++){
			printf("%d ",a[an[x]]);
			
		}
	}
}
		}
	
	

	
	return 0;
}

Measured memory_bytes: 4608
#include <cstdio>
int A, B;
char s[20];
int main(){
  	scanf("%d%d", &A, &B);
 	scanf("%s", &s);
  	for(int i=0;i<A;i++)if(!('0'<=s[i] && s[i]<='9')){
      	puts("No"); return 0;
    }
  	if(s[A]!='-'){
    	puts("No"); return 0;
    }
  	for(int i=A+1;i<=A+B;i++)if(!('0'<=s[i] && s[i]<='9')){
      	puts("No"); return 0;
    }
  	puts("Yes");
}



Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
int c[503],s[503],f[503];
int ans[503];
int main(){
    cin>>n;
    for(int i=1;i<n;i++)cin>>c[i]>>s[i]>>f[i];
    for(int i=1;i<n;i++){
        int cur=s[i]+c[i];
        for(int j=i+1;j<n;j++){
            if(cur<=s[j])cur=s[j]+c[j];
            else{
                int k=(cur-s[j]);
                if(k%f[j]==0)cur+=c[j];
                else{
                    cur=s[j]+((k/f[j])+1)*f[j]+c[j];
                }
            }
        }
        ans[i]=cur;
    }
    for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  char t[n/2];
  bool flag=true;
  if(n%2==1)flag=false;
  else{
    for(int i=0; i<n/2; i++){
      t[i]=s[i];
    }
    for(int i=n/2; i<n; i++){
      if(t[i-n/2]!=s[i])flag=false;
    }
  }
  if(flag)cout << "Yes";
  else cout << "No";
  cout << endl; 
}

Measured memory_bytes: 256