akhauriyash/Code-Regression huggingface dataset:
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		double s = 100000;
		double sa = 0;
		for(int i = 1;i <= n;i++){
			s = s + s*0.05;
			s = s / 1000;
			BigDecimal bi = new BigDecimal(String.valueOf(s));
			sa = bi.setScale(0,BigDecimal.ROUND_UP).doubleValue();
			sa = sa*1000;
			s = sa;
		}
		System.out.println((int)sa);
		System.exit(0);
	}
}

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  vector <int> A(N);
  int a;
  multiset<int> s;
  int cnt = 1;
  int temp = INF;
  cin >> a;
  s.insert(a);
  for(int i = 1; i < N; i++) {
    cin >> a;
    // cout << *(s.begin()) << endl;
    if (a <= *(s.begin())) {
      s.insert(a);
      cnt++;
    }
    else {
      // cout << *(--s.upper_bound(a)) << endl;
      s.erase(--s.lower_bound(a));
      // for(auto ite = s.begin(); ite != s.end(); ite++) {
      //   cout << *ite << ' ';
      // }
      // cout << endl;
      s.insert(a);
    }
    // for(auto ite = s.begin(); ite != s.end(); ite++) {
    //   cout << *ite << ' ';
    // }
    // cout << endl;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 5376
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1001001001;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

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

    ll preSum = 0;
    rep(i, n + 1) {
        preSum += a.at(i);
    }

    rep(i, n) {
        if (a.at(i) >= b.at(i)) {
            a.at(i) -= b.at(i);
        } else {
            b.at(i) -= a.at(i);
            a.at(i) = 0;
            if (a.at(i + 1) >= b.at(i)) {
                a.at(i + 1) -= b.at(i);
            } else {
                a.at(i + 1) = 0;
            }
        }
    }

    ll afterSum = 0;
    rep(i, n + 1) {
        afterSum += a.at(i);
    }

    ll ans = preSum - afterSum;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4840
n,m = map(int,input().split())
a=[]
s=[]
c=[]
ans=0
for i in range(n):
  a.append(0)
for j in range(m):
  s,c= map(int,input().split())
  if n>1 and s==1 and c==0:
    ans=-1
  if a[s-1]==0 or a[s-1]==c:
    #print(str(j)+"e")
    a[s-1]=c
  else:
    ans=-1
if n>1 and a[0]==0:
  a[0]=1
if ans!=-1:
  ans=0
  for k in range(n):
    ans+=a[k]*(10**(n-1-k))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int n,k,d=1;
int main()
{
   scanf("%d %d",&n,&k);
   for(int i=1;i<=n;i++)
   
   	d=min(d*2,d+k);
   	
   	printf("%d",d);
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

ll ext_gcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll q = a / b;
  ll g = ext_gcd(b, a - q * b, x, y);
  ll z = x - q * y;
  x = y;
  y = z;
  return g;
}

// 逆元
ll mod_inv(ll a, ll m) {
  ll x, y;
  ext_gcd(a, m, x, y);
  x %= m;
  if (x < 0)
    x += m;
  return x;
}

// x^n(mod M)
ll mod_pow(ll x, ll n, ll m) {
  ll ans = 1;
  while (n != 0) {
    if (n & 1)
      ans = ans * x % m;
    x = x * x % m;
    n = n >> 1;
  }
  return ans;
}

ll comb_specific(ll n, ll a) {
  ll factional = 1;
  ll inv = 1;

  ll tmp = n;
  rep(i, a) {
    factional = (factional * tmp) % mod;
    inv = (inv * (i + 1)) % mod;
    tmp--;
  }

  inv = mod_inv(inv, mod);

  return (factional * inv) % mod;
}

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

  ll n, a, b;
  cin >> n >> a >> b;

  ll all_comb = mod_pow(2, n, mod) - 1;
  ll na = comb_specific(n, a);
  ll nb = comb_specific(n, b);

  ll ans = (all_comb - na - nb + mod + mod) % mod;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def format_output(val)
  if val.length > 1 && val[0].nil? # 左から一桁目がnilなら1をいれる
    val[0] = 1
  end
  val.map! { |e| # nilの桁に0をいれる
    if e.nil?
      0
    else
      e
    end
  }
  val.inject("") { |str, e| str + e.to_s }
end

n, m = gets.chomp.split(" ").map(&:to_i)

sc = Array.new(m)
val = Array.new(n + 1)

(1..m).each do |i|
  sc[i - 1] = gets.chomp.split(" ").map(&:to_i)
end

success = true
sc.each do |s, c|
  if val[s].nil? || val[s] == c
    val[s] = c
  else
    success = false
    break
  end
end

val = val[1..-1] #index一個ずらし
if val[0] == 0 && n != 1
  success = false
end

if success
  puts(format_output(val))
else
  puts(-1)
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

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

  if(a==b+c || b == a+c || c == a+b) print("Yes");
  else print("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h ,w ,k;
int xs,ys,xt,yt;
const int inf = 1e9;
int dirx[] = {0,-1,1,0};
int diry[] = {1,0,0,-1};
int main(){
	cin >> h >> w >> k;
	cin>>xs>>ys>>xt>>yt;
	xs--,ys--,xt--,yt--;
	vector<string> vt(h);
	for(int i=0;i<h;i++) cin>>vt[i];
	vector<vector<int>> d(h , vector<int>(w,inf));
	
	
	queue<pair<int,int>> q;
	q.push({xs,ys});
	d[xs][ys] = 0;
	
	
	while(q.size()){
		auto tmp = q.front();
		q.pop();
		int tmpx = tmp.first;
		int tmpy = tmp.second;
		
		for(int i=0;i<4;i++){
//			int tox = tmpx + dirx[i];
//			int toy = tmpy + diry[i];
			int ttmpx = tmpx;
			int ttmpy = tmpy;
			int j;
			for(j=0;j<k;j++){
				ttmpx += dirx[i];
				ttmpy += diry[i];
				if(ttmpx>=0 and ttmpy>=0 and ttmpx<h and ttmpy<w and vt[ttmpx][ttmpy]!='@' and d[ttmpx][ttmpy] > d[tmpx][tmpy]){
					if(d[ttmpx][ttmpy] > d[tmpx][tmpy] + 1){
						d[ttmpx][ttmpy] = d[tmpx][tmpy] + 1;
						q.push({ttmpx , ttmpy});
					}
				}else break;
			}
			
		}
	}
	
	cout<<(d[xt][yt]==1e9 ?  -1 : d[xt][yt])<<endl;
	return 0;
	
}

Measured memory_bytes: 12092
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

int a[N],dp[N];
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    }
    printf("%d\n",dp[n]);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}




Measured memory_bytes: 1024
x, y = map(int, input().split())

ans = 10**9 + 7

for i in range(2):
    for j in range(2):
        X = x * (-1) ** i
        Y = y * (-1) ** j
        if Y - X >= 0:
            ans = min(ans, Y - X + i + j)

print(ans)

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

int main()
{
	int n,m,j,k,i,T;
	while (cin>>k)
	{
		int x=0,y=0;
		for (i=1;i<=k;i++)
		if (i%2==0)
		x++;
		else
		y++;
		cout<<x*y<<endl;
	}
	return 0;
} 

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

struct Node{
  Node (int z) : //constracter
    key(z),
    parent(nullptr),
    right(nullptr),
    left(nullptr)
  {}
  int key;
  Node *parent;
  Node *right, *left;
  //right == nullptr && left == nullptr
};

Node *root;

void insert(Node *z){
  Node *y=nullptr;
  Node *x=root;

  while(x!=nullptr){
    y = x;
    x = (z->key < x->key) ? x->left : x->right;
  }
  if(y == nullptr) root = z;
  else (z->key < y->key ? y->left : y->right) = z;
}

bool find(Node *f, int x){
  if(f == nullptr) return false;
  if(x == f->key) return true;
  else if(x < f->key) return find(f->left, x);
  else return find(f->right, x);
}

void inorder(Node *node){
  if(node->left != nullptr) inorder(node->left);
  std::cout << " " << node->key;
  if(node->right != nullptr) inorder(node->right);
}

void preorder(Node *node){
  std::cout << " " << node->key;
  if(node->left != nullptr) preorder(node->left);
  if(node->right != nullptr) preorder(node->right);
}

int  main(){
  int n;
  std::cin >> n;

  int v, f;
  std::string s;
  for(int i=0; i<n; i++){
    std::cin >> s;
    if(s == "insert"){
      std::cin >> v;
      insert(new Node(v));
    }
    else if(s == "find"){
      std::cin >> f;
      if(find(root, f)) std::cout << "yes" << std::endl;
      else  std::cout << "no" << std::endl;
    }
    else{
      inorder(root);
      std::cout << std::endl;
      preorder(root);
      std::cout << std::endl;
    }
  }
  return 0;
}



Measured memory_bytes: 21924
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <bitset>
#include <utility>
#include <queue>
#include <deque>

using namespace std;

int main(){

    long long a,b,c;
    cin >> a >> b >> c;
        
    if( 4*a*b < (c-a-b)*(c-a-b) and (c - a - b) > 0 ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]

import itertools
from math import hypot
z = a = 0
for ptn in itertools.permutations(XY):
    a += 1
    for (x1,y1),(x2,y2) in zip(ptn,ptn[1:]):
        z += hypot(x1-x2, y1-y2)
print(z/a)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N, C;
    cin>>N>>C;
    vector<vector<int>> D(C, vector<int>(C));
    for (int y=0; y<C; y++)
        for (int x=0; x<C; x++)
            cin>>D[y][x];
    vector<vector<int>> c(N, vector<int>(N));
    for (int y=0; y<N; y++)
        for (int x=0; x<N; x++)
            cin>>c[y][x],
            c[y][x]--;

    vector<vector<int>> T(3, vector<int>(C));
    for (int y=0; y<N; y++)
        for (int x=0; x<N; x++)
            T[(y+x)%3][c[y][x]]++;
    int ans = N*N*1000;
    for (int c0=0; c0<C; c0++)
    for (int c1=0; c1<C; c1++)
    for (int c2=0; c2<C; c2++)
    if (c0!=c1 && c1!=c2 && c2!=c0)
    {
        int a = 0;
        for (int i=0; i<C; i++)
            a += T[0][i]*D[i][c0] + T[1][i]*D[i][c1] + T[2][i]*D[i][c2];
        ans = min(ans, a);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1280
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  else return gcd(y, x % y);
}
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
int main(){
  int N;
  while(cin >> N && N){
    ll d[10], v[10];
    REP(i, N) cin >> d[i] >> v[i];
    REP(i, N){
      ll g = gcd(d[i], v[i]);
      d[i] /= g;
      v[i] /= g;
    }
    ll D = d[0], V = v[0];
    REP(i, N){
      D = lcm(D, d[i]);
      V = gcd(V, v[i]);
    }
    REP(i, N){
      cout<< D / d[i] * v[i] / V << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1168
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 150;

long MOD = 1000000007;
int N;
long long dp[MAX_N][4][4][4] = {};

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                dp[3][i][j][k] = 1;
            }
        }
    }

    dp[3][0][2][1] = 0;
    dp[3][0][1][2] = 0;
    dp[3][2][0][1] = 0;

    for (int n = 3; n < N; n++) {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    for (int l = 0; l < 4; l++) {
                        if ((i == 0 && k == 2 && l == 1) ||
                            (i == 0 && j == 2 && l == 1)
                        ) {
                            continue;
                        }
                        dp[n+1][j][k][l] += dp[n][i][j][k];
                    }
                }
            }
        }
        dp[n+1][0][2][1] = 0;
        dp[n+1][0][1][2] = 0;
        dp[n+1][2][0][1] = 0;

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    dp[n+1][i][j][k] = dp[n+1][i][j][k] % MOD;
                }
            }
        }
    }

    long long ret = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                ret += dp[N][i][j][k];
            }
        }
    }

    std::cout << ret % MOD << std::endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
cnt = [0] * 10001
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            v = x*x + y*y + z*z + x*y + y*z + z*x
            if v <= n:
                cnt[v] += 1

for i in range(1, n + 1):
    print(cnt[i])


Measured memory_bytes: 9256
#include "bits/stdc++.h"
using namespace std;

int main() {
    int r, g, b;
    cin >> r >> g >> b;

    if ((r * 100 + g * 10 + b) % 4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

using namespace std;

const int MX = 200000;

int a[MX], b[MX];

int main() {
	int n;
	ignore = scanf("%d", &n);
	for (int i = 0; i < n; i++) ignore = scanf("%d", a + i);
	for (int i = 0; i < n; i++) ignore = scanf("%d", b + i);
	
	long long sumA = accumulate(a, a + n, 0ll);
	long long sumB = accumulate(b, b + n, 0ll);
	
	set<pair<int, int>> B;
	for (int i = 0; i < n; i++) B.emplace(b[i], i);
	
	long long cnt = 0;
	while (sumB > sumA) {
		int x = B.rbegin()->second;
		B.erase(prev(B.end()));
		
		if (b[x] == a[x]) continue;
		
		int diff = b[(x == 0 ? n - 1 : x - 1)];
		diff += b[(x == n - 1 ? 0 : x + 1)];
		
		int k = max(b[x] - a[x], 0) / diff;
		if (k > 1) {
			b[x] -= k * diff;
			sumB -= k * diff;
			
			cnt += k;
		}
		else {
			b[x] -= diff;
			sumB -= diff;
			
			cnt++;
		}
		
		B.emplace(b[x], x);
	}
	
	bool ok = true;
	for (int i = 0; i < n; i++) ok = ok && a[i] == b[i];
	
	if (ok == false) cnt = -1;

	printf("%lld\n", cnt);
	
	return 0;
}


Measured memory_bytes: 11136
#include<cstdio>
#include<algorithm>
using namespace std;
int a[10005];
bool Binary_Search(int a[], int n, int key)
{
    int l=0, r=n;
    while(r>l)
    {
        int mid=(l+r)>>1;
        if(a[mid]==key) return true;
        if(a[mid]>key) r=mid;
        else l=mid+1;
    }
    return false;
}
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &a[i]);
    sort(a, a+n);
    int q, key, cnt=0;
    scanf("%d", &q);
    for(int i=0; i<q; i++)
    {
        scanf("%d", &key);
        if(Binary_Search(a, n, key)) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 2752
#include<iostream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;

int minana(int a,int b){
  if(a<b){
    return a;
  }
  else if(a>b){
    return b;
  }
  else return a;
}


int main(){
  int n;
  cin>>n;
  int r[100];
  int m[101][101];
  int j;
  int q=0;
  //int c[n];
  for(int i=1;i<=n;i++){
    cin>>r[i-1]>>r[i];
  }
  for(int i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=(1<<21);
      for(int k=i;k<j;k++){
	q=m[i][k]+m[k+1][j]+r[i-1]*r[k]*r[j];
	m[i][j]=minana(m[i][j],q);
      }
    }
  }
  
  cout<<m[1][n]<<endl;
  return 0;
}



Measured memory_bytes: 3116
//逆波兰表达式，利用输入顺序及栈的特性 
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
#define maxx 1000
int stack[maxx];
//用数组实现栈，0号元素不使用 
int top;
/*int initialize()
{
	top=0;
}
bool isEmpty()
{
	return top==0;
}
bool isFull()
{
	return top<=maxx-1;
}
int push(int x)
{
	if(isFull)
		return -1;
	else{
		//top++;
		stack[++top]=x;
	}
}
int pop()
{
	int xx;
	if(isEmpty())
		return -1;
	else
	{
		top--;
		xx=stack[top+1];
		//xx=stack[top--];
	}
	return xx;
}
int look()
{
	return stack[top];
}
*/
void push(int x)
{
	stack[++top]=x;
}
int pop()
{
	top--;
	return stack[top+1];
}
int main()
{
	char s[100];
	int top=0;
	while(scanf("%s",s)!=EOF)
	{
		if(s[0]=='+')
		{
			int a=pop();
			int b=pop();
			//cout<<a<<" "<<b<<endl;
			push(a+b);
		}
		else if(s[0]=='-')
		{
			int a=pop();
			int b=pop();
			//cout<<a<<" "<<b<<endl;
			push(b-a);
		}
		else if(s[0]=='*')
		{
			int a=pop();
			int b=pop();
			//cout<<a<<" "<<b<<endl;
			push(a*b);
		}
		else
		{
			//cout<<atoi(s)<<endl;
			push(atoi(s));//atoi标准库中的函数，用来将字符串形式的数字转换为整型数值 
		} 
	}
	int result=pop();
	cout<<result<<endl;
	return 0;
}


Measured memory_bytes: 3160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long k = in.nextLong();
            long a = in.nextLong();
            long b = in.nextLong();

            if (a < b) {
                if (2 < b - a) {
                    if (a - 1 < k) {
                        long set = (k - (a - 1)) / 2;
                        if (((k - (a - 1)) % 2 == 0)) {
                            out.print((b - a) * set + a);
                        } else {
                            out.print((b - a) * set + a + 1);
                        }
                    } else {
                        out.print(k + 1);
                    }
                } else {
                    out.print(k + 1);
                }
            } else {
                out.print(k + 1);
            }
        }

    }
}



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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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

const ll SIZE = 1e5+10;

string s;
string you[7];

int main(){
    cin >> s;
    you[0] = "SUN";
    you[1] = "MON";
    you[2] = "TUE";
    you[3] = "WED";
    you[4] = "THU";
    you[5] = "FRI";
    you[6] = "SAT";
    ll ans = 7;
    for(int i = 0 ; i < 7; i++){
        if(you[i] == s){
            cout << ans << endl;
            return 0;
        }
        --ans;
    }
    cout << ans << endl;    
}

Measured memory_bytes: 256
#include<stdio.h>
#include <ctype.h>

int main(void)
{
    int n,k,i;
    

    scanf("%d %d",&n,&k);
    char s[n-1];
    scanf("%s",s);

    if(s[k-1] == 'A'){
        s[k-1] = 'a';
    }else if(s[k-1] == 'B'){
        s[k-1] = 'b';
    }else if(s[k-1] == 'C'){
        s[k-1] = 'c';
    }

    printf("%s",s);

    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

typedef complex<double>Point;
typedef double D;
Point in(){
    int x,y;
    cin>>x>>y;
    return Point(x,y);
}
D cross(Point a,Point b){
    return a.real()*b.imag()-a.imag()*b.real();
}

signed main(){
    Point a=in();
    Point b=in();
    Point c=in();

    D S=abs(cross(c-a,b-a))/2.0;
    D r=S/(abs(a-b)+abs(b-c)+abs(c-a))*2;

    D l=max({abs(a-b),abs(b-c),abs(c-a)});
    printf("%.20f\n",l*r/(2*r+l));
    return 0;
}


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

int main() { 
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n){
    ll a;
    cin >> a;
    while(a%2==0){
      ans++;
      a /= 2;
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 3608
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	vector<int> parents(n);
	int answer = 0;
	for(int i = 0; i < n; ++i)
	{
		cin >> parents[i];
		--parents[i];
		if(parents[i] < i) answer += (parents[parents[i]] == i);
	}
	cout << answer << '\n';
}

Measured memory_bytes: 3668
#include<iostream>
using namespace std;
int main()
{
    string a;
    int s=0;
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        if(s==0&&a[i]=='C')s++;
        if(s==1&&a[i]=='F')s++;
        if(s==2){cout<<"Yes\n";return 0;}
    }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, d, e = list(map(int, readline().split()))

    x = a * 60 + b
    y = c * 60 + d
    z = y - x

    print(z-e)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61700
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var p = 0;
            var map = new int[n, n];
            var map2 = new int[n * n];
            var a = new int[n, n];
            var rmin = new int[n];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var rmint = int.MaxValue;
                for (int j = 0; j < n; j++)
                {
                    var t = int.Parse(line[j]);
                    a[i, j] = t;
                    if (t < rmint) rmint = t;
                    map[i, j] = p;
                    map2[p++] = t;
                }
                rmin[i] = rmint;
            }
            var r = new HashSet<int>();
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    if (a[i, j] == rmin[i]) r.Add(map[i, j]);

            var c = getc(a, map, n);
            var ans = getAns(r, c, a, map2);
            Console.WriteLine(ans);
        }
    }
    static int getAns(HashSet<int> r, List<int> c, int[,] a, int[] map2)
    {
        var ans = new List<int>();
        foreach (var x in c)
            if (!r.Add(x)) ans.Add(map2[x]);
        if (ans.Count() == 0) return 0;
        else return ans[0];
    }
    static List<int> getc(int[,] a, int[,] map, int n)
    {
        var cmax = new int[n];
        for (int i = 0; i < n; i++)
        {
            var cmaxt = -1;
            for (int j = 0; j < n; j++)
                if (a[j, i] > cmaxt) cmaxt = a[j, i];
            cmax[i] = cmaxt;
        }
        var ans = new List<int>();
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (a[j, i] == cmax[i]) ans.Add(map[j, i]);
        return ans;
    }
}



Measured memory_bytes: 16496
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//vector<ll> vll;
ll num[ten52];
ll num2[ten52];

int main(void)
{
    //double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    //char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>a1>>a2>>a3>>n;
    if(n<=a1) cout<<n;
    else
    {
        n-=a1;
        sum=a1;
        if(n<=a2) cout<<sum;
        else
        {
            n-=a2;
            cout<<sum-n;
        }
    }
    return 0;
}





Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j,n,m;	cin>>n>>m;
	vector<pint> v;

	for(i=2;i<=m;i++){
		if(i*i>m)	break;
		if(m%i!=0)	continue;
		int temp=0;
		while(m%i==0){
			temp++;	m/=i;
		}
		v.pb(make_pair(i,temp));
	}
	if(m!=1)	v.pb(make_pair(m,1));

	ll ans=1;

	ll a[n][31],cum[n][31];

	for(i=0;i<n;i++){
		a[i][0]=1;	cum[i][0]=1;
	}

	for(j=1;j<=30;j++){
		a[n-1][j]=1;	cum[n-1][j]=(cum[n-1][j-1]+a[n-1][j])%mod;
	}

	for(i=n-2;i>=0;i--){
		for(j=1;j<=30;j++){
			a[i][j]=cum[i+1][j];
			cum[i][j]=cum[i][j-1]+a[i][j];	cum[i][j]%=mod;
		}
	}

	for(i=0;i<v.size();i++){
		ans=(ans*a[0][v[i].second])%mod;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 48768
N = int(input())
S = input()
ans = 0
for i in range(N):
    X = dict()
    Y = dict()
    p = []
    count = 0
    for j in range(N):
        if j <= i:
            if S[j] in X:
                X[S[j]] += 1
            else:
                X[S[j]] = 0
        else:
            if S[j] in Y:
                Y[S[j]] += 1
            else:
                Y[S[j]] = 0
        if S[j] in X and S[j] in Y:
            if S[j] not in p:
                count += 1
                p.append(S[j])
    ans = max(ans,count)
print(ans)


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){
	/*input*/
	string s;	cin >> s; 
	int k;	cin >> k;
	/*calculation*/
	vector<string>dic(1);
	for(int i = 1; i <= k; i++){	//文字数
		for(int j = 0; j < s.size() - (i - 1); j++){
			string tmp;
			for(int k = 0; k < i; k++){
				tmp += s[j + k];
			}
			bool flag = true;
			for(int k = 0; k < dic.size() && flag; k++){	//かぶり判定
				if(dic[k] == tmp){
					flag = false;
					break;
				}else{
					flag = true;
				}
			}
			if(flag){
				dic.push_back(tmp);
			}
		}
	}
	sort(dic.begin(), dic.end());
	/*output*/
	cout << dic[k] << endl;
}


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

int main(){
  ll h, w;
  cin >> h >> w;
  if (min(h,w) == 1)
  {
    cout << 1 << endl;
    return 0;
  }
  ll n = h*w;
  ll ans = (n+1)/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

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

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

string S;

string change(const string& s, char c)
{
    string result(begin(s), end(s)-1);

    for(size_t i = 0; i < result.size(); ++i) {
        if(s[i] == c || s[i+1] == c) {
            result[i] = c;
        }
    }

    return result;
}

void solve()
{
    int cnt_min = 99999;

    for(char c = 'a'; c <= 'z'; ++c) {
        string s = S;
        for(size_t i = 0; i < S.size(); ++i) {
            if(all_of(begin(s), end(s), [c](char e) { return e == c; })) {
                int cnt = i;
                if(cnt < cnt_min) {
                    cnt_min = cnt;
                    break;
                }
            }
            s = change(s, c);
        }
    }

    cout << cnt_min << "\n";
}

int main()
{
    cin >> S;

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, m;
vector<int>v[1005];
int dp[1 << 13];
int cost[1005];
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> cost[i];
		int k; cin >> k;
		rep(j, k) {
			int p; cin >> p; p--;
			v[i].push_back(p);
		}
	}
	rep(i, 1 << n)dp[i] = inf;
	dp[0] = 0;
	rep(i, 1 << n) {
		rep(j, m) {
			int ne = i;
			rep(k, v[j].size()) {
				ne |= 1 << v[j][k];
			}
			chmin(dp[ne], dp[i] + cost[j]);
		}
	}
	if (dp[(1 << n) - 1] != inf)cout << dp[(1 << n) - 1] << endl;
	else cout << -1 << endl;

}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

char s[1000001];

int main() {
  int n;
  S(n);
  getchar_unlocked();
  rep(i,0,n) {
    s[i] = getchar_unlocked();
  }
  int q;
  S(q);
  while(q--) {
    int k;
    S(k);
    LL sm = 0, ans = 0, d = 0, m = 0, dd = 0;
    rep(i,0,n) {
      if(i - k >= 0) {
        if(s[i - k] == 'D') {
          dd++;
        } else if(s[i - k] == 'M') {
          m--;
          sm -= dd;
        }
      }

      if(s[i] == 'D') {
        d++;
      } else if(s[i] == 'M') {
        m++;
        sm += d;
      } else if(s[i] == 'C') {
        ans += sm - m * dd;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
const ll mod = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<string> a(n);
  for (string &i : a) cin >> i;
  vector<vector<int>> f(n, vector<int>(26, 0));
  for (int i = 0; i < n; i++) {
    for (char c : a[i]) {
      f[i][c - 'a'] += 1;
    }
  }
  for (int i = 0; i < 26; i++) {
    int maxi = 100;
    for (int j = 0; j < n; j++) {
      maxi = min(maxi, f[j][i]);
    }
    for (int j = 0; j < maxi; j++) {
      cout << char(i + 'a');
    }
  }
  cout << endl;
  return 0;
}


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

int main()
{
    long long a, b, c, d, ans = 0;
    cin >> a >> b >> c >> d;
    ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * d);
    ans = max(ans, b * c);

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <cstdio>
using namespace std;
typedef long long ll;
const int N=100010,M=200010;
int n,m;
int h[N],tot;
struct Edge{
	int v,next;
}e[M*2];
bool vis[N];
int col[N];
bool flag;
// sum
ll single,nobi,bi;
void addEdge(int u,int v){
	e[++tot]=(Edge){v,h[u]}; h[u]=tot;
	e[++tot]=(Edge){u,h[v]}; h[v]=tot;
}
void readData(){
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		addEdge(u,v);
	}
}
void paint(int u){
	vis[u]=true;
	if(!h[u])
		throw 0;
	for(int i=h[u],v;i;i=e[i].next){
		v=e[i].v;
		if(!vis[v]){
			col[v]=(col[u]^1);
			paint(v);
		}
		else if((col[u]^col[v])!=1)
			flag=false;
	}
}
void calcNum(){
	for(int u=1;u<=n;u++)
		if(!vis[u]){
			try{
				flag=true;
				paint(u);
			}
			catch(int e){
				single++;
				continue;
			}
			if(flag)
				bi++;
			else
				nobi++;
		}
}
int main(){
	readData();
	calcNum();
	printf("%lld\n",(single*single+2*single*(n-single))+nobi*nobi+2*nobi*bi+2*bi*bi);
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
typedef long long ll;
int main(){
    int N;
    cin>>N;
    vector<int>A(N);
    vector<int>B(N);
    int max_a=0,b;
    rep(i,N){
        cin>>A[i]>>B[i];
        if(max_a<A[i]){
            max_a=A[i];
            b=B[i];
        }
    }
    cout<<max_a+b<<endl;


    return 0;
}

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

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

  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if ( S == "Y" ){
      cout << "Four" << endl;
      break;
    }
    else if ( i == N-1){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 3596
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion



//ABC 126 B - YYMM or MMYY
int main(void) {

	int i,n,c,v[51],ans=0;

	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &c);
		ans += (v[i] - c < 0) ? 0 : v[i] - c;
	}
	
	printf("%d\n", ans);
	return 0;
}




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

int main() {
    int N;
    cin >> N;
    vector<ll>A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    int flag = 1;
    for (int i = 0; i < N; ++i) {
        if (A[i] > 0) flag = 0;
    }
    if (flag) {
        int k = 0;
        for (int i = 1; i < N; ++i) {
            if (A[k] < A[i]) k = i;
        }
        cout << A[k] << "\n";
        cout << N - 1 << "\n";
        for (int i = N; i > k + 1; --i) {
            cout << i << "\n";
        }
        for (int i = 0; i < k; ++i) {
            cout << 1 << "\n";
        }
        return 0;
    }

    ll odd = 0, even = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] < 0) continue;
        if (i % 2) odd += A[i];
        else even += A[i];
    }
    vector<int>ans;
    if (even < odd) {
        ans.push_back(1);
        A.erase(A.begin()); N--;
        even = odd;
    }
    cout << even << "\n";
    int last = N - 1;
    for (; last >= 0; --last) {
        if (last % 2) continue;
        if (A[last] > 0) break;
    }
    for (int i = N; i > last + 1; --i) {
        ans.push_back(i);
        A.pop_back();
    }
    while (A.size() > 1) {
        if (A[0] <= 0) {
            ans.push_back(1);
            ans.push_back(1);
        } else if (A[2] <= 0) {
            ans.push_back(3);
            A[2] = A[0];
        } else {
            ans.push_back(2);
            A[2] = A[0];
        }
        A.erase(A.begin());
        A.erase(A.begin());
    }

    cout << ans.size() << "\n";
    for (auto x: ans) {
        cout << x << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

/*各位の和　
int sum = 0;
for(int i = 0; i <= 5; i++){
   sum += n%10;
   n /= 10;  
}
*/

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  double n,t,a,b=0;
  cin>>n>>t>>a;
  b=10000000;
  vector<double> h(n);
  rep(i,n){
    cin>>h[i];
    h[i]=abs(a-(t-h[i]*0.006));
    if(h[i]<b)
    {
      b=h[i];
      q=i+1;
    }
    }
  print(q)
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> h(n);
  vector<bool> v(n, true);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  
  vector<ll> dh(n);
  for(int i=1; i<n; i++){
  	dh[i] = h[i+1] - h[i]; 
  }
  
  ll lim = h[0] - 1;
  for(int i=0; i<n-1; i++){
  	if(dh[i] < -1){
      cout << "No" << endl;
      return 0; 
    }
    if(dh[i] == -1){
      if(lim - h[i] > 0){
        cout << "No" << endl;
      	return 0;
      }else{
      	lim = h[i];
      }
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int n,r,c,t,min=1001,i;
	scanf("%d %d", &n, &r);
	for(i=0; i<n; i++)
	{
		scanf("%d %d", &c, &t);
		if(t<=r&&min>c)
		min=c;
	}
	if(min<1001)
	printf("%d\n", min);
	else
	printf("TLE\n");
	
	return 0;
}

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

int main() {
	ll n,a,b;
	cin >> n >> a >> b;
	ll ans;
	if(a==b) ans = 1;
	else if(a>b) ans = 0;
	else{
		if(n==1) ans=0;
		else{
			ans = b*(n-2)-a*(n-2)+1;
		}
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
const int MAX_N = 1000;
const ll MOD = 1000000007;

int main() {
  int N;
  std::cin >> N;

  int cnt[MAX_N + 1] = {};
  for(int i = 2; i <= N; ++i) {
    int tmp = i;
    for(int j = 2; j <= tmp; ++j) {
      while(tmp % j == 0) {
        tmp /= j;
        ++cnt[j];
      }
    }
  }

  ll ans = 1;
  for(int i = 1; i <= N; ++i) {
    ans *= cnt[i] + 1; ans %= MOD;
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256