akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define MAPFOR(it,m) for( auto it = (m).begin(); it != (m).end() ; ++it )
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    REP(i, 5) {
        int x;
        cin >> x;
        if(x==0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/

/*実行開始からの経過時間を表すよ。
while (clock() < 1900000) { ; }
*/

/*まだ使えないテクニックのメモだよ。
for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ
*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/


int ans_h[2005][2005];
int ans_w[2005][2005];

int main() {
	int h, w; cin >> h >> w;

	char s[2005][2005];
	memset(s, '!', sizeof(s));

	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> s[i][j];
		}
	}

	int check = 0;

	for (int i = 1; i <= h; ++i) {
		check = 0;
		int tmp = 0;
		for (int j = 1; j <= w; ++j) {
			if (s[i][j] == '.') { tmp++; }
			else {
				for (int f=j-1;; f--) {
					if (s[i][f] != '.') { break; }
					ans_h[i][f] = tmp;
				}
				check = j;
				tmp = 0;
			}
		}

		if (s[i][w] == '.') {
			for (int f = w;; f--) {
				if (s[i][f] != '.') { break; }
				ans_h[i][f] = tmp;
			}
		}
	}

	for (int i = 1; i <= w; ++i) {
		check = 0;
		int tmp = 0;
		for (int j = 1; j <= h; ++j) {
			if (s[j][i] == '.') { tmp++; }
			else {
				for (int f = j-1;; f--) {
					if (s[f][i] != '.') { break; }
					ans_w[f][i] = tmp;
				}
				check = j;
				tmp = 0;
			}
		}

		if (s[h][i] == '.') {
			for (int f = h;; f--) {
				if (s[f][i] != '.') { break; }
				ans_w[f][i] = tmp;
			}
		}
	}





	int ans = 1;

	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			if (s[i][j] == '.') {
				ans = max(ans, ans_h[i][j] + ans_w[i][j] - 1);
			}
		}
	}
	/*
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cout << ans_w[i][j]<<" ";
		}
		cout << endl;
	}

	cout << endl;

	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cout << ans_h[i][j]<<" ";
		}
		cout << endl;
	}
	*/

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 35584
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
vll sq(10,1);
vll a(50),b(50),c(50),d(50);
ll solve(ll n, ll m, ll id, ll q){
    ll ret = 0;
    if(id==n){
        
        REP(i,q){
            if(sq[b[i]]-sq[a[i]]==c[i]){
                ret+=d[i];
            }
        }
        return ret;
    }
    if(id==0){
        ret = solve(n,m,1,q);
    }else{
        for(ll i=sq[id-1];i<=m;i++){
            sq[id]=i;
            ret=max(ret,solve(n,m,id+1,q));
        }
    }
    return ret;

}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,q;
    cin >> n >> m >> q;
    ll ans = 0;
    REP(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    ans = solve(n,m,0,q);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
using namespace std;
int a[100003];
int main(){
  int n,sghhy,bdhjh=0;
  cin>>n;
  for (int i=0;i<n;i++)
  cin>>a[i];
  for (int j=0;j<n-1;j++)
  if ((a[j] == j+1) and (a[j+1] == j+2))
  {
  sghhy=a[j];
  a[j] = a[j+1];
  a[j+1] = sghhy;
  bdhjh++;
  }
  for (int hc=0;hc<n;hc++)
  {
  if (a[hc] == hc + 1)
  {
  sghhy = a[hc];
  if (hc == n - 1)
  {
  a[hc] = a[hc-1];
  a[hc-1] = sghhy;
  }
  else
  {
  a[hc] = a[hc] + 1;
  a[hc+1] =sghhy;
  }
  bdhjh++;
  }
  }
  cout<<bdhjh;
  system ("pause");
  return 0;
  }

Measured memory_bytes: 888
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	map<char,int>ma;
	rep(i,n){
		char a;cin>>a;
		ma[a]++;
	}
	if(ma.size()==3)cout<<"Three"<<endl;
	else cout<<"Four"<<endl;
}












Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<limits>
using namespace std;
int a[100000],arr[100000],n,k;
int topdown(int x);
int main()
{
  int ans;
  cin>>n>>k;
  for(int i=0;i<n;i++)
  {
   cin>>arr[i];
  }
  for(int i=0;i<n;i++)
  {
   a[i]=-1;
  }
  ans=topdown(0);
  cout<<ans;
  return 0;
  
}  
int topdown(int x)
{
 if(a[x]!=-1){return a[x];}
 for(int j=1;j<=k;j++)
 {
  if(x==n-j-1){a[x]=abs(arr[n-1]-arr[x]);return a[x];}
 }  
 
 int q=std::numeric_limits<int>::max();
 for(int i=1;i<=k;i++) 
 {
   q=min(q,topdown(x+i)+abs(arr[x+i]-arr[x]));
 }
 a[x]=q;
 return q;
}  
 

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


using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
#define rep(i,n) for(int i = 0;i<n;i++)


int main(){

    int N;cin >> N;
    long long r = 0;
    vector<int> ar(N);

    rep(i,N)cin >> ar[i];

    sort(ar.rbegin(), ar.rend());
    queue<int> q;
    q.push(ar[0]);

    for(int i = 1;i < N;i++){
        r+=q.front();
        q.pop();
        q.push(ar[i]);q.push(ar[i]);
    }
    cout << r << endl;

    

}



Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 1000005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 A,B,C,D;
bool check(int64 a,int64 b) {
    return B - A >= a && B - A <= b;
}
void Solve() {
    read(N);read(A);read(B);read(C);read(D);
    for(int i = 0 ; i <= N - 1 ; ++i) {
	int64 u = (N - 1 - i) * D - C * i,d = (N - 1 - i) * C - C * i;
	if(check(d,u)) {puts("YES");return;}
	u = C * i - (N - 1 - i) * C,d = C * i - (N - 1 - i) * D;
	if(check(d,u)) {puts("YES");return;}
    }
    puts("NO");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
n = int(input())
ai = [int(i) for i in input().split()]
bi = [int(i) for i in input().split()]
ci = [int(i) for i in input().split()]

result = sum(bi)
prei = -1
for i in ai:
    if (prei+1) == i:
        result += ci[prei-1]
    prei = i

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    long long int N,M,m=0;
    cin >> N >> M;
    if(2<N && 2<M){
        cout << (N-2)*(M-2) << endl;
    }else if(N == 2 || M == 2){
        cout << "0" << endl;
    }else if(N == 1 && M == 1){
        cout << "1" << endl;
    }else{
        cout << max(m,max(N-2,M-2)*min(N,M)) << endl;
    }
}

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

typedef long long ll;

const int mod = 998244353;

int main() {
    ll S;
    cin >> S;
    ll x1, x2, x3, y1, y2, y3;
    x1 = 0;
    y1 = 0;
    x2 = 1000000000;
    y2 = 1;
    x3 = (x2-S%x2)%x2;
    y3 = (S+x3)/x2;

    printf("%ld %ld %ld %ld %ld %ld\n", x1, y1, x2, y2, x3, y3);
}


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

int solve(int a, int b){
    int r;
    r = a % b;

    if(r == 0){
        return b;
    }else{
        return solve(b, r);
    }
}

int main(){
    int a, b;
    int gcd, lcm;

    while(cin >> a >> b){
        gcd = solve(a, b);
        lcm = a / gcd * b;

        cout << gcd << " " << lcm << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  
  rep(i,0,n){
    cin >> a[i];
    b[i] = a[i];
  }
  
  sort(ALL(b));
  int l,h;
  l = b[n/2];
  h = b[n/2 - 1];
  
  if(l==h) {
    rep(i,0,n) cout << l << endl;
    return 0;
  }
  
  rep(i,0,n){
    if(a[i] < l) cout << l << endl;
    if(a[i] > h) cout << h << endl;
  }
  return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;


ll power(ll a,ll b,ll mod){
	ll res = 1;
	while(b){
		if(b&1) res = ((res%mod)*(a%mod))%mod;
		b >>= 1;
		a = ((a%mod)*(a%mod))%mod;
	}
	return res;
	
}
int get(int n){
	if(!n)return 0;
	int unos = __builtin_popcount(n);
	return 1+get(n%unos);
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N; cin >> N;
	string str; cin >> str;
	int unos = 0;
	int pot = N-1;
	forn(i,0,N)unos += (str[i] == '1');
	
	ll res1 = 0; // unos+1
	ll res2 = 0; // unos-1
	
	forn(i,0,N){
		if(str[i] == '1'){
			res1 += power(2,pot,unos+1);
			res1 %= (unos+1);
			
			if(unos-1 > 0){
				res2 += power(2,pot,unos-1);
				res2 %= (unos-1);
			}
		}
		pot--;
	}
	pot = N-1;
	vi res;
	forn(i,0,N){
		ll tmpres1 = res1;
		ll tmpres2 = res2;
		if(str[i] == '0'){
			tmpres1 += power(2,pot,unos+1);
			tmpres1 %= (unos+1);
			//cout << i << ' ' << tmpres1 << '\n';
			res.pb(1+get(tmpres1));
		}else{
			if(unos-1 > 0){
				tmpres2 -= power(2,pot,unos-1);
				if(tmpres2 < 0)tmpres2 += (unos-1);
				res.pb(1+get(tmpres2));
			}else{
				res.pb(0);
			}
			//cout << i << ' ' << tmpres2 << '\n';
		}
		pot--;
	}
	forn(i,0,N)cout << res[i] << '\n';
	
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}
const int N=1<<8;
int ans[N][N];

int main()
{
	int h,w,n,x=0,y=0,del=1;
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<n;i++)
	{
		for(int k=read();k--;)
		{
			ans[x][y]=i;
			y+=del;
			if(y==w)
			{
				x++;
				y--;
				del=-1;
			}
			if(y<0)
			{
				x++;
				y++;
				del=1;
			}
			//printf("x=%d y=%d\n",x,y);
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			printf("%d ",ans[i][j]+1);
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for(int i=0;i<n;i++) {
			array[i] = sc.nextInt();
		}
		sc.close();

		int ans =0;
		for(int i=0;i<n;i=i+2) {
			if(array[i]%2==1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	set<int> s;
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a; s.insert(a);
	}
	if (s.size() == n) cout << "YES\n"; else cout << "NO\n";
	return 0;
}


Measured memory_bytes: 9600
def AttackSurvival():
	N, K, Q = map(int,input().split())
	A = [int(input()) for i in range(Q)]
	point = [0] * N
	for answer in A:
		point[answer - 1] += 1
	# print(point)
	for p in point:
		if K - (Q - p) > 0:
			print('Yes')
		else:
			print('No')

	# print(N, K, Q)
	# print(result)

AttackSurvival()

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

int main() {
  int N; cin >> N;
  vector<int> W(N);
  int allsum = 0;
  int sum_i = 0;
  for (int i = 0; i < N; i++) {
    cin >> W.at(i);
    allsum += W.at(i);
  }
  int minsum = allsum;
  for (int i = 0; i < N; i++) {
    sum_i += W.at(i);
    minsum = min(minsum, abs(allsum - 2 * sum_i));
  }
  cout << minsum << endl;
}

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

for i in range(1, 100000):
    if (i*0.08)//1 == a and (i*0.1)//1 == b:
        print(i)
        exit()

print(-1)



"""
while True:
    if (c*0.080)//1 == a:
        print(int(c))
        exit()
    elif (c*0.080)//1 >= a or (c*0.1)//1 != b:
        print(-1)
        exit()
    else:
        c += 1.0
"""

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<utility>
#include<vector>
#include<map>
  
using namespace std;
  
typedef pair<double,double> PBB;
typedef vector<PBB > VPBB;
typedef multimap<double,int> MDI;
typedef MDI::iterator MDII;
  
#define PUSH push_back
#define MDIVT MDI::value_type
#define PI 3.14159265359
#define INF 10000000000
#define NMAX 100
  
  
int main(){
  
    int n;
    int max,min;
    int cnt;
    double x,y;
	double ax,ay,bx,by,cx,cy;
    double ans;
    char gav;
    VPBB pin;
    MDI point;
    MDII ia,ib;

	n=0;
    while(cin>>x>>gav>>y){
		n++;
        pin.PUSH(PBB(x,y));
    }

    max=0;
    for(int i=1;i<n;i++){
        if(pin[max].second<pin[i].second) max=i;
        else if(pin[max].second==pin[i].second&&pin[max].first<pin[i].first) max=i;
    }

    for(int i=0;i<n;i++){
        if(i!=max){
            if(pin[i].second!=pin[max].second) point.insert(MDIVT(atan2(pin[i].second-pin[max].second,pin[i].first-pin[max].first),i));
            else point.insert(MDIVT(-1.0*PI,i));
        }
    }

	ia=point.begin(),ib=point.begin();
	ib++;
	ans=0;
	while(ib!=point.end()){
		ax=pin[max].first,ay=pin[max].second;
		bx=pin[(*ia).second].first,by=pin[(*ia).second].second;
		cx=pin[(*ib).second].first,cy=pin[(*ib).second].second;
		ans+=abs(((ax-cx)*(by-cy)-(ay-cy)*(bx-cx)))/2;
		///cout<<ax<<","<<ay<<","<<bx<<","<<by<<","<<cx<<","<<cy<<endl;
		///printf("%.6f\n",ans);
		ia++,ib++;
	}

	printf("%.6f\n",ans);

}

Measured memory_bytes: 1300
import sys
input = sys.stdin.readline
 
n,q = map(int,input().split())
imos = []
for i in range(n):
    s,t,x = map(int,input().split())
    imos.append((s-x,x))
    imos.append((t-x,-x))
ans = set()
j = 0
for i in range(q):
    d = int(input())
    imos.append((d,1e100))
imos.sort()
m = 1e100
flag = False
for t,stop in imos:
    if stop == 1e100:
        if ans:
            if not flag:
                m = min(ans)
                flag = True
            print(m)
        else:
            print(-1)
    elif stop > 0:
        ans.add(stop)
        if stop < m:
            m = stop
            flag = True
    else:
        ans.remove(-stop)
        if m == -stop:flag = False

Measured memory_bytes: 156416
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  vector<vector<ll>> dp(N+1,vector<ll>(3));
  vector<ll> a(N);
  vector<ll> b(N);
  vector<ll> c(N);
  for(int i = 0;i < N;i++)cin >> a[i] >> b[i] >> c[i];

  for(int i = 0;i < 3;i++)dp[0][i] = 0;

  for(int i = 1;i <= N;i++){
    dp[i][0] = max(dp[i-1][1] + b[i-1],dp[i-1][2] + c[i-1]);
    dp[i][1] = max(dp[i-1][0] + a[i-1],dp[i-1][2] + c[i-1]);
    dp[i][2] = max(dp[i-1][0] + a[i-1],dp[i-1][1] + b[i-1]);
  }

  cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;
}


Measured memory_bytes: 8064
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A_l = LI()
ans = A_l[0]
for i in range(1, N):
    ans = math.gcd(ans, A_l[i])
print(ans)

Measured memory_bytes: 93636
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	string S;
	cin >> S;
	bool ans = false;
	for (int i = 0; i < 3; i++) {
		if (S[i] == S[i + 1])
			ans = true;
	}
		if (ans)
			cout << "Bad" << endl;
		else
			cout << "Good" << endl;
		cin >> S;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,order;
  order=1;
  cin>>N;
  int a[N];
  int b[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
   }
  for(int i=0;i<N;i++){
     order=a[i];
     b[order-1]=i+1;
  
  }
  for(int i=0;i<N;i++){
  cout<<b[i]<<" ";
  }
  return 0;
}

Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
a, b = map(int, input().split())

num = 0
for i in range(0,2):
    if a < b:
        num = num + b
        b = b - 1
    elif a > b:
        num = num + a
        a = a - 1
    else:
        num = num + a
        a = a - 1

print(num)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int main() {
	char cor [] = "CODEFESTIVAL2016";
	char s[100];
	scanf("%s", s);
	int c = 0;
	REP(i, strlen(cor)) {
		if (cor[i] != s[i])
			c++;
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 384
o,x,b;
main(i,a){
  for(;~scanf("%*d%s"+!i*3,&a);i=o==3?o=b=x=!printf("%d\n",x):0)
      for(a%=6,a-5?b=b*2+1,x+=b/8,b&=7:o++;!a&b;b/=2)x++;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<algorithm>
using namespace std;
char p[101000];
int S[101000], P[101000], n;
int main(){
    scanf("%d",&n);
    scanf("%s",p);
    int i, j;
    for(i=0;p[i];i++){
        if(p[i]=='o') P[i+1] = 0;
        else P[i+1] = 1;
    }
    P[n+1] = P[1];
    for(i=0;i<8;i++){
        S[0]=i&1;
        S[1]=(i>>1)&1;
        S[2]=(i>>2)&1;
        for(j=2;j<=n+1;j++){
            S[j+1] = S[j-2]^ P[j];
        }
        if(S[0]^S[n]^S[1]^S[n+1] || S[1]^S[n+1]^S[2]^S[n+2])continue;
        for(j=1;j<=n;j++){
            printf("%c",(S[j]^S[j-1])?'W':'S');
        }
        return 0;
    }
    printf("-1\n");
}

Measured memory_bytes: 1152
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<iostream>
#include<sstream>

using namespace std;

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

vector<int> load[111];

int visit[111];
int visitone[111];

int saiki(int a){
	visitone[a]=1;
	
	int ret=0;
	visit[a]=1;
	
	rep(i,load[a].size()){
		if(visit[load[a][i]]==0){
			ret = max(ret,saiki(load[a][i]));
		}
	}
	
	visit[a]=0;
	return 1+ret;
}

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		
		rep(i,111){
			load[i].clear();
			visitone[i]=1;
			visit[i]=0;
		}
		
		rep(i,n){
			int a,b;
			cin>>a>>b;
			load[a].push_back(b);
			load[b].push_back(a);
			visitone[a]=visitone[b]=0;
		}
		
		int ans=0;
		
		rep(i,1000){
			reps(j,100){
				if(load[j].size()==i){
					ans = max(ans,saiki(j));
				}
			}
			
			int flg=1;
			reps(j,100){
				if(visitone[j]==0)flg=0;
			}
			if(flg==1)break;
		}
		
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
/*    nya-n   */
#include<stdio.h>
char nyan[30000] = {};
int nyaa = 0;
int main(){
nyan[nyaa]=getchar();nyaa++;nyan[nyaa]=getchar();nyaa--;while(nyan[nyaa]){nyaa++;nyan[nyaa]++;nyaa--;nyan[nyaa]--;}nyan[nyaa]=getchar();
nyaa++;while(nyan[nyaa]){nyaa--;nyan[nyaa]++;nyaa++;nyan[nyaa]--;}nyaa++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;
nyan[nyaa]++;nyan[nyaa]++;while(nyan[nyaa]){nyaa--;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;while(nyan[nyaa]){nyaa--;
nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyaa++;nyan[nyaa]--;}nyaa++;
nyan[nyaa]--;}nyaa++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;while(nyan[nyaa]){nyaa--;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;
nyan[nyaa]++;while(nyan[nyaa]){nyaa--;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyaa++;nyan[nyaa]--;}nyaa++;nyan[nyaa]--;}nyaa--;nyaa--;
nyaa--;while(nyan[nyaa]){nyan[nyaa]--;while(nyan[nyaa]){nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;
nyan[nyaa]--;while(nyan[nyaa]){nyan[nyaa]--;nyan[nyaa]--;while(nyan[nyaa]){nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;
while(nyan[nyaa]){nyan[nyaa]--;nyan[nyaa]--;nyan[nyaa]--;while(nyan[nyaa]){nyaa++;while(nyan[nyaa]){nyan[nyaa]++;nyan[nyaa]++;
nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;putchar(nyan[nyaa]);while(nyan[nyaa]){nyan[nyaa]--;}}}nyaa++;while(nyan[nyaa]){
nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;putchar(nyan[nyaa]);while(nyan[nyaa]){nyan[nyaa]--;}}}nyaa++;while(nyan[nyaa]){nyan[nyaa]++;
nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;putchar(nyan[nyaa]);while(nyan[nyaa]){nyan[nyaa]--;}}}nyaa++;while(nyan[nyaa]){
nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;putchar(nyan[nyaa]);while(nyan[nyaa]){nyan[nyaa]--;
}}}nyaa++;while(nyan[nyaa]){nyan[nyaa]++;putchar(nyan[nyaa]);while(nyan[nyaa]){nyan[nyaa]--;}}}nyaa++;while(nyan[nyaa]){nyan[nyaa]++;
nyan[nyaa]++;putchar(nyan[nyaa]);while(nyan[nyaa]){nyan[nyaa]--;}}}nyaa++;while(nyan[nyaa]){nyan[nyaa]++;nyan[nyaa]++;nyan[nyaa]++;
nyan[nyaa]++;putchar(nyan[nyaa]);while(nyan[nyaa]){nyan[nyaa]--;}}return 0;}


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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> v(N), w(N);
  for (int i = 0; i < N; i++) cin >> v.at(i) >> w.at(i);
  vector<vector<int> > dp(N+1, vector<int>(W+1));
  for(int i = N-1; i >= 0; i--) {
    for (int j = 0; j <= W; j++) {
      if (j < w.at(i)) {
        dp.at(i).at(j) = dp.at(i+1).at(j);
      }
      else {
        dp.at(i).at(j) = max(dp.at(i+1).at(j), dp.at(i+1).at(j-w.at(i))+v.at(i));
      }
    }
  }
  int ans = dp.at(0).at(W);
  cout << ans << endl;
}


Measured memory_bytes: 6788
#include<iostream>
using namespace std;
int main ()
{
	int a,b,c,d,e,f,g;
    while(1){
	cin>>a;
    if(a==0)
        break;
	b=(1000-a)/500;
	c=(1000-(a+500*b))/100;
	d=(1000-(a+500*b+100*c))/50;
	e=(1000-(a+500*b+100*c+50*d))/10;
	f=(1000-(a+500*b+100*c+50*d+10*e))/5;
	g=(1000-(a+500*b+100*c+50*d+10*e+5*f))/1;
        cout<<b+c+d+e+f+g<<endl;}
	return 0;
}

Measured memory_bytes: 1160
function Main(arg) {
 
    var N = arg.split("\n")[0]-0;
    var S = arg.split("\n")[1];

    if (S.length % 2 !== 0) {
        console.log("No");
        return;
    }

    var T1 = S.slice(0, S.length / 2);
    var T2 = S.slice((S.length / 2));
    
    var ans = (T1 == T2) ? "Yes" : "No";

    console.log(ans);

    return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int begin = 0;
  int end = 2*N-2;
  int query;
  bool flag = true;
  
  string S;
  cout << 0 << endl;
  fflush(stdout);
  cin >> S;
  if(S == "Vacant"){
    flag = false;
  }
  
  while(flag){
    string T;
    query = (begin + end)/2;
    if(query %2 != 0){
      query++;
    }
    cout << query << endl;
    cin >> T;
    fflush(stdout);
    if(T == "Vacant"){
      flag = false;
      break;
    }
    else if(S == T){
      begin = query;
    }
    else if(S != T){
      end = query;
    }
    if(end - begin == 2){
      cout << begin + 1 << endl;
      fflush(stdout);
      flag = false;
    }
  }
}  

Measured memory_bytes: 852
import java.util.Scanner;

public class Main {

public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		int n = 0;
		int s = 0;
		int e = 0;
		int w = 0;

		for (int i = 0; i < S.length(); i++) {
			if(S.charAt(i) == 'N'){
				n = 1;
			}else if (S.charAt(i) == 'S'){
				s = 1;
			}else if (S.charAt(i) == 'E'){
				e = 1;
			}else if (S.charAt(i) == 'W'){
				w = 1;
			}
		}

		if (n ==1 && s == 1 && e == 1 && w == 1)
			System.out.println("Yes");
		else if (n ==1 && s == 1 && e == 0 && w == 0)
			System.out.println("Yes");
		else if  (n ==0 && s == 0 && e == 1 && w == 1)
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}

}


Measured memory_bytes: 9812
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public  static void main(String[] args){
    String c;
    String[] alps = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
             "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
             "w", "x", "y", "z"};
    String[] alpb = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
             "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
             "W", "X", "Y", "Z"};
    int[] cnt = new int[26];
    while(kbd.hasNext()){
        String s = kbd.nextLine();
        int i;
        for(i=0; i<s.length(); i++){
        c = s.substring(i, i+1);
        int j=0;
        while(j<26 && !alps[j].equals(c)) j++;
        if(j<26) cnt[j]++; 
        j=0;
        while(j<26 && !c.equals(alpb[j])) j++;
        if(j<26) cnt[j]++;
        }
    }
    for(int i=0; i<cnt.length; i++){
        System.out.println(alps[i]+" : "+cnt[i]);
    }
    }
}

Measured memory_bytes: 20124
N,M = [int(i) for i in input().split()]
submissions = {str(i):[] for i in range(1,N+1)}
AC,WA = 0,0
for i in range(M):
    P,S = [j for j in input().split()]
    submissions[P].append(S)
for i in submissions:
    if 'AC' not in submissions[i]:
        continue
    for j in submissions[i]:
        if j == 'AC':
            AC+=1
            break
        WA +=1
print(AC,WA)

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<double> v(n);
	rep(i, n) cin >> v[i];
	sort(v.begin(), v.end());

	rep(i, n - 1) {
		v[i + 1] = (v[i] + v[i + 1]) / 2;
	}
	cout << v[n - 1] << endl;
	return 0;
}


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

void dia(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4){
    double d1,d2,d3,d4;
    d1=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1);
    d2=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2);
    d3=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3);
    d4=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4);
    //printf("%lf %lf %lf %lf\n",d1,d2,d3,d4);
    if(d3*d4<0&&d1*d2<0)
        printf("YES\n");
    else
        printf("NO\n");
}


int main(int argc, const char * argv[]) {
    double xa,ya,xb,yb,xc,yc,xd,yd;
    
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
        dia(xa,ya,xc,yc,xb,yb,xd,yd);
    }
    
    return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int table[1001];

vector<pair<int, int> > prime_factorize(int n) {
    int tmp = n;
    vector<pair<int, int> > v;
    for (int i = 2; i * i <= n; ++i) {
        ll cnt = 0;
        while (tmp % i == 0) {
            tmp /= i;
            cnt++;
        }
        if (cnt) v.eb(i, cnt);
    }
    if (tmp != 1) v.eb(tmp, 1);
    return v;
}


int main() {
    
    
    int n;
    cin >> n;
    
    rep3(i, 2, n + 1) {
        auto v = prime_factorize(i);
        for (pii vi : v) {
            table[vi.F] += vi.S;
        }
    }
    
    // rep(i, n + 1) cout << table[i] << " "; cout << '\n';
    
    ll ans = 1;
    rep(i, n + 1) {
        (ans *= table[i] + 1) %= inf;
    }
    
    cout << ans << '\n';
}


Measured memory_bytes: 256
private fun readIntList() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val (D, N) = readIntList()

    val r = (1..100).map {
        when (D) {
            0 -> 1
            1 -> 100
            2 -> 100 * 100
            else -> 1
        } * it
    }.toList()[N - 1]

    println(if (N != 100) r else r + when (D) {
        0 -> 1
        1 -> 100
        2 -> 100 * 100
        else -> 1
    })
}

Measured memory_bytes: 36396
n = int(input())
m = ["3","5","7"]
m1 = m.copy()
for i in range(2,10):
    mi = []
    for x in m1:
        mi.append(x+"3")
        mi.append(x+"5")
        mi.append(x+"7")
    m += mi
    m1 = mi
count = 0
for x in m:
    if int(x)<= n and x.count("3")*x.count("5")*x.count("7") != 0:
        count += 1
print(count)

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

int main()
{
	int n;
	string s;

	cin >> n >> s;

	string subS = s.substr(n / 2, n / 2);
	s = s.substr(0, n / 2);
	if (n % 2 == 1)
	{
		cout  << "No";
	}
	else if (subS == s)
	{
		cout << "Yes";
	}
	else 
	{
		cout << "No";
	}
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(30);

    int n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];

    bool can = 1;
    for(auto i : a) {
        if(i%2==0) {
            if(!(i%3==0 || i%5 == 0)) can = 0;
        }
    }
    cout << (can? "APPROVED": "DENIED") << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int h, n;
  cin >> h >> n;
  vi a(n);
  rep(i, n) cin >> a[i];

  int atack = 0;
  rep(i, n) atack += a[i];

  if (atack >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
char a[100010];
int i;
int main()
{
	gets(a);
	int la=strlen(a);
	if(a[0]==a[la-1])
	{
		if(la%2==1)
		printf("Second");
		else
		printf("First");
	}
	else
	{
		if(la%2==1)
		printf("First");
		else
		printf("Second");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  int n = in();
  vi p(n);
  REP(i, n) p[i] = in();

  vi a(n), b(n);
  REP(i, n){
    a[i] = i * n + 1;
    b[n - i - 1] = a[i];
  }

  REP(i, n){
    a[p[i] - 1] += i;
  }
  
  REP(i, n){
    cout << a[i] << " ";
  } cout << endl;
  REP(i, n){
    cout << b[i] << " ";
  } cout << endl;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main(){
    int n;
    cin >> n;
    int n1 = n/100;
    int n2 = n%100;
    string ans;
    bool m1 = (n1 >= 1 && n1 <= 12);
    bool m2 = (n2 >= 1 && n2 <= 12);
    if(m1 && m2) ans = "AMBIGUOUS";
    else if(m1) ans = "MMYY";
    else if(m2) ans = "YYMM";
    else ans = "NA";
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
r = n%2

d = [0]*n
for a in A:
    if a%2 == r:
        print(0)
        break
    d[a] += 1
    if (d[a] > 2) or (a == 0 and d[0] > 1):
        print(0)
        break
else:
    print(2**(n//2) % (10**9+7))

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	ll n;
	cin >> n;
	vector<ll> a(10000, 0);
	for(ll i = 1; i <= 10000; ++i){
		a[i-1] = i * (i + 1) / 2;
	}
	int ii = 0;
	for(int i = 0; i < 10000; ++i){
		if(n <= a[i]){
			ii = i+1;
            break;
		}
	}
	for(int i = ii; 0 < i; --i){
		if(0 <= n - i){
			cout << i << endl;
			n -= i;
			if(n == 0) return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-9;
const long long INF = OO;
const int MAXN = 5003, MAXM = 102, Mod = 998244353, MAXLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout
			<< fixed;

	int n;
	cin >> n;
	vector<int> arr(n);
	vector<int> Idx(n);
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
		--arr[i];
		Idx[arr[i]] = i;
	}

	set<int> st;
	vector<pair<int, int>> after(n), before(n);
	for (int i = n - 1; ~i; --i) {
		after[i] = { -1, -1 };
		auto it = st.lower_bound(Idx[i]);
		if (it != st.end()) {
			after[i].second = (*it) - 1;
			++it;
			if (it != st.end()) {
				after[i].first = *it - 1;
			} else {
				after[i].first = n - 1;
			}
		} else {
			after[i].second = n - 1;
		}

		before[i] = { -1, -1 };
		it = st.lower_bound(Idx[i]);
		if (it != st.begin()) {
			--it;
			before[i].second = *it + 1;
			if (it != st.begin()) {
				--it;
				before[i].first = *it + 1;
			} else {
				before[i].first = 0;
			}
		} else {
			before[i].second = 0;
		}
		st.insert(Idx[i]);
	}

	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		if (after[i].first != -1) {
			ans += 1LL * (Idx[i] - before[i].second + 1)
					* (after[i].first - after[i].second) * (i + 1);
		}
		if (before[i].first != -1) {
			ans += 1LL * (before[i].second - before[i].first)
					* (after[i].second - Idx[i] + 1) * (i + 1);
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define vc vector<int>
#define um unordered_map<int,int>
#define ll long long 
#define rep(i,a,b) for(__typeof(a) i=a; i<b; i++)
#define si(a) a.size()
#define all(a) a.begin(),a.end()
#define ss(a) a.second
#define ff(a) a.first
#define M 1000000
#define pb push_back
#define repit(i,a) for(auto i=a.begin(); i!=a.end(); i++)
#define take(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
#define out(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<' '
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define reprev(i,b,a) for(__typeof(b) i=b; i>=a; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define doublearray vector<vector<int>>
#define mod 998244353 
using namespace std;
ll max(ll a, ll b){ return a>b?a:b; }
ll min(ll a, ll b){ return a<b?a:b; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
int binaryS(ll x, ll sb[], int m){
    int l = 0, r=m;
    int mid = (l+r)/2;
    while(l<r){
        mid = (l+r)/2;
        if(sb[mid]<x) l= mid+1;
        else if(sb[mid]>x) r = mid-1;
        else return mid;
    }
    return l;
}
int main(){
    fastio;
    int n,x,t; cin>>n>>x>>t;
    cout<<((int)ceil(n/(float)x)*t)<<endl;
    return 0;
}





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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

struct UnionFind{
    vector<int> par;
    UnionFind(int n){
        REP(i,n)par.pb(i);
    }
    int root(int x){
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y)return;
        par[x] = y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

struct edge{
    int to, cost;
};

int64 dijkstra(int32 n, int32 s, int32 t, vector<vector<pii>> &adj){
    vector<int64> d(n, LLINF);
    d[s] = 0;
    priority_queue<pii, vector<pii>, greater<pii>> que;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p = que.top();que.pop();
        int v = p.second;
        if(d[v] < p.first)continue;
        for(int i = 0; i < (signed)adj[v].size(); i++){
            int32 to, cost;
            tie(to, cost) = adj[v][i];
            if(d[to] > d[v] + cost){
                d[to] = d[v] + cost;
                que.push(pii(d[to], to));
            }
        }
    }
    return d[t];
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    priority_queue<tuple<int32,int32,int32>> dist;
    REP(i,n)REP(j,n){
        int32 a;
        cin >> a;
        if(i < j){
            dist.emplace(-a, i, j);
        }
    }
    UnionFind uf(n);
    vector<vector<int64>> path(n, vector<int64>(n, LLINF));
    REP(i,n)path[i][i] = 0;
    vector<vector<pii>> adj(n);
    int64 ans = 0;
    priority_queue<tuple<int32,int32,int32>> dist2;
    while(!dist.empty()){
        int32 d, a, b;
        tie(d, a, b) = dist.top();
        d *= -1;
        dist.pop();
        if(!uf.same(a, b)){
            ans += d;
            path[a][b] = d;
            path[b][a] = d;
            adj[a].pb(pii(b,d));
            adj[b].pb(pii(a,d));
            uf.unite(a,b);
        }else{
            dist2.emplace(-d,a,b);
        }
    }
    while(!dist2.empty()){
        int32 d,a,b;
        tie(d,a,b) = dist2.top();
        dist2.pop();
        d *= -1;

        int32 dijk = dijkstra(n, a, b, adj);

        if(dijk > d){
            path[a][b] = path[b][a] = d;
            adj[a].emplace_back(b,d);
            adj[b].emplace_back(a,d);
            ans += d;
        }else if(dijk < d){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    // REP(i,n){
    //     REP(j,n)cout << path[i][j] << " ";
    //     cout << endl;
    // }
    return 0;
}

Measured memory_bytes: 4340