akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;

vector<int> id[10000];
vector<string> c[10000];
int p[10000];
string name[10000];
int n,m;
string a,b;

int search(string s){
  int cur = 0;
  string tmp = "";
  for(int i=1;i<s.size();i++){
    if(s[i]=='/'){
      if(tmp=="."){
	if(id[cur].empty())return -1;
	tmp = ""; continue;
      }
      if(tmp==".."){
	if(cur == 0)return -1;
	if(id[cur].empty())return -1;
	cur = p[cur]; tmp = ""; continue;
      }

      bool f = false;
      for(int j=0;j<c[cur].size();j++){
	if(c[cur][j] == tmp){
	  cur = id[cur][j];
	  f = true;
	  break;
	}
      }
      if(!f)return -1;
      tmp = "";
    }else{
      tmp += s[i];
    }
  }
  
  if(tmp.size()){
    if(tmp=="."){
      if(id[cur].empty())return -1;
    }else if(tmp==".."){
      if(cur==0)return -1;
      if(id[cur].empty())return -1;
      cur = p[cur];
    }else{
      bool f = false;
      for(int i=0;i<c[cur].size();i++){
	if(c[cur][i] == tmp){
	  cur = id[cur][i];
	  f = true;
	  break;
	}
      }
      if(!f)return -1;
    }

    if(id[cur].empty())return cur;

    for(int i=0;i<c[cur].size();i++){
      if(c[cur][i] == "index.html"){
	if(id[id[cur][i]].empty())return id[cur][i];
	return -1;
      }
    }
    return -1;
  }else{
    if(id[cur].empty())return -1;

    for(int i=0;i<c[cur].size();i++){
      if(c[cur][i] == "index.html"){
	if(id[id[cur][i]].empty())return id[cur][i];
	return -1;
      }
    }
    return -1;
  }
}
int main(){

  while(cin >> n >> m ,n){
    for(int i=0;i<10000;i++){
      id[i].clear(); c[i].clear();
    }

    int num = 1;
    for(int i=0;i<n;i++){
      cin >> a;
      string tmp;
      int cur = 0;
      for(int i=1;i<a.size();i++){
	if(a[i]=='/'){
	  bool f = false;
	  for(int j=0;j<c[cur].size();j++){
	    if(c[cur][j] == tmp){
	      cur = id[cur][j];
	      f = true;
	      break;
	    }
	  }
	  if(!f){
	    id[cur].push_back(num);
	    c[cur].push_back(tmp);
	    p[num] = cur;
	    name[num] = tmp;
	    cur = num;
	    num++;
	  }
	  tmp = "";
	}else{
	  tmp += a[i];
	}
      }
      
      if(tmp.size()){
	id[cur].push_back(num);
	c[cur].push_back(tmp);
	p[num] = cur;
	name[num] = tmp;
	num++;
      }
    }

    for(int i=0;i<m;i++){
      cin >> a >> b;
      int aid = search(a), bid = search(b);
      if(aid == -1 || bid == -1){
	cout << "not found\n";
      }else cout << ((aid==bid)?"yes":"no") << endl;
    }
  }
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    ll mod = 1e9 + 7;
    ll way = (s[0] == t[0]) ? 3 : 6;
    for(int i = 1; i < n; i++) {
        if (s[i] == s[i-1]) continue;
        if (s[i] == t[i]) {
            if (s[i-1] == t[i-1])
                way *= 2;
        } else if (s[i] != t[i]) {
            if (s[i-1] == t[i-1])
                way *= 2;
            else
                way *= 3;
        }
        way %= mod;
    }
    cout << way << endl;
    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const int mod = 1e9 + 7;

ll pw(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1) res=res*a%mod;
		a=a*a%mod; b>>=1;
	}
	return res;
}

int a[MAXN];

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	ll sum = 0, ans = 0;
	for(int i=1; i<=n; ++i)
	{
		ans = (ans + sum * a[i]) %mod;
		sum = (sum + a[i]) %mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
    string s,u,t;
    int a,b;
    cin>>s>>u;
    cin>>a>>b;
    cin>>t;
    
    if(s==t)
        cout<<--a<<" "<<b<<endl;
    else
        cout<<a<<" "<<--b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
    }
    int d = 0;
    int cnt = 1;
    rep(i, n) {
        d += v[i];

        if (d > x) {
            break;
        }
        cnt++;
    }
    cout << min(n + 1, cnt) << endl;
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto c:v) cout<<" "<<c; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
void solve(){
	int h,n;
	cin>>h>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		sum+=x;
	}
	if(sum>=h)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
//	cin>>T;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int rectangular = 0;
		int dimond = 0;

		while(sc.hasNext()) {
			String[] numbers = sc.nextLine().split(",");

			int a = Integer.parseInt(numbers[0]);
			int b = Integer.parseInt(numbers[1]);
			int c = Integer.parseInt(numbers[2]);

			if(a * a + b * b == c * c) {
				rectangular++;
			}
			if(a == b) {
				dimond++;
			}
		}

		System.out.println(rectangular);
		System.out.println(dimond);

	}

}

Measured memory_bytes: 26252
#include<iostream>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
#include<cstring>
using namespace std;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
int func(int k);
int main() {

	//A
	/*int n;
	cin >> n;
	if (n >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
	*/

	//B
	/*int n;
	int i;
	int counter = 0;
	long long int x, y;
	long long int d;
	cin >> n >> d;
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		if (x * x + y * y <= d * d)counter++;
	}
	cout << counter << endl;
	return 0;
	*/

	//C
	int k;
	cin >> k;
	//for (k = 1; k < 100; k++) {
		func(k);
	//}
	return 0;
	//D
	/*int n;
	string c;
	cin >> n;
	cin >> c;
	int sum = 0;
	int i, j;
	int s = 0;
	i = 0; j = n - 1;
	while (i < j) {
		if (c[i] == 'W') {
			if (c[j] == 'R') {
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
			else {
				while (c[j] != 'R') {
					j--;
					if (j < 0 || j <= i) {
						cout << sum << endl;
						return 0;
					}
				}
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
		}
		else {
			while (c[i] != 'W') {
				i++;
				if (i >= n || i >= j) {
					cout << sum << endl;
					return 0;
				}
			}
			if (c[j] == 'R') {
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
			else {
				while (c[j] != 'R') {
					j--;
					if (j < 0 || j <= i) {
						cout << sum << endl;
						return 0;
					}
				}
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
		}
	}

	cout << sum << endl;
	return 0;
	*/

	//E
	//二分探索
	/*int n, k;
	cin >> n >> k;
	int a[200000];
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int sum = 0;
	int left = 0, right = 1000000000, mid = (int)((right + left) / 2);
	while (right - left > 1) {
		sum = 0;
		for (i = 0; i < n; i++) {
			sum = sum + (int)(a[i] / mid);
			if (a[i] % mid == 0)sum--;
		}
		if (sum <= k) {
			right = mid;
		}
		else {
			left = mid;
		}
		mid = (int)((right + left) / 2);
		

	}
	cout << right << endl;
	return 0;
	
	*/

}
int func(int k) {

	if (k % 2 == 0 || k % 5 == 0) {
		cout << -1 << endl;
		return 0;
	}
	int i = 7, j = 1;
	while (i % k != 0) {
		i = (i * 10 + 7) % k;
		j ++;
	}
	cout << j << endl;
	return j;
	/*long long int flag3 = 1;
	while (k % 3 == 0) {
		k = k / 3;
		flag3 = flag3 * 3;
	}

	if (7 % k == 0) {
		cout  << flag3 << endl;
		return 0;
	}
	if (k % 2 == 0 || k % 5 == 0) {
		cout  << -1 << endl;
		return 0;
	}
	if (k % 7 == 0)k = k / 7;



	long long int i = 0;
	long long int j = 1;
	while (1) {
		i++;
		j = j * 10;
		j = j % k;
		if (j == 1) {
			i = i * flag3;
			cout  << i << endl;
			return 0;
		}

	}*/

}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}


Measured memory_bytes: 3572
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
// a>=0, b>=0, x*a+y*b=gcd>=0, a>0,b>0=>abs(y)<=a,abs(x)<=b
LL gcdex(LL a,LL b,LL& x, LL& y){
	LL ax=1,ay=0;
	LL bx=0,by=1;
	while(b){
		LL r=a/b;
		LL t=a-r*b; a=b; b=t;
		LL tx=ax-r*bx; ax=bx; bx=tx;
		LL ty=ay-r*by; ay=by; by=ty;
	}
	x=ax;
	y=ay;
	return a;
}
LL modinv(LL a, LL mod){
	LL x,y;
	gcdex(a,mod,x,y);
	if(x<0){
		x+=mod;
	}
	return x;
}

const int N=1e5+1;
const int M=1e9+7;
template<int S>
struct Comb
{
	LL f[S+1];
	LL r[S+1];
	LL mod;
	Comb(int m)
	{
		mod=m;
		f[0]=1;
		r[0]=1;
		for(LL i=1;i<=S;i++){
			f[i]=i*f[i-1]%m;
			r[i]=modinv(i,m)*r[i-1]%m;
		}
	}
	LL c(int n,int i){
		if(i<0&&n<i)
		{
			assert(0);
			return 0;
		}
		return f[n]*r[i]%mod*r[n-i]%mod;
	}
};
Comb<N> comb(M);
LL C(int n,int i){
	return comb.c(n,i);
}
int indices[N];
int main() {
	int n;
	cin >> n;
	memset(indices,-1,sizeof(indices));
	int l;
	for(int i=0;i<=n;i++){
		int a;
		cin >> a;
		if(indices[a]==-1){
			indices[a]=i;
		}
		else{
			l=i-indices[a]+1;
		}
	}
	for(int i=1;i<=n+1;i++){
		LL r=C(n+1,i);
		if(n+1-l>=i-1){
			r+=M-C(n+1-l,i-1);
			r%=M;
		}
		cout << r << endl;
	}


	return 0;
}



Measured memory_bytes: 3200
using System;

class MainClass {
    static void Main() {
        string s = Console.ReadLine();
        int sum = 0;
        for (int i = 0; i < s.Length; i++) {
            sum += int.Parse(s[i].ToString());
        }
        if (int.Parse(s)% sum == 0)Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

int N, W;
i64 v[100100];
int w[100100];
i64 dp[105][100100];

i64 slv(int idx, int rem)
{
  if (idx >= N) { return 0; }
  i64 &ret = dp[idx][rem];
  if (~ret) { return ret; }

  ret = slv(idx+1, rem);
  if (rem - w[idx] >= 0) chmax(ret, slv(idx+1, rem-w[idx]) + v[idx]);

  return ret;
}

signed main()
{
  cin >> N >> W;
  for (int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }

  memset(dp, -1, sizeof(dp));

  cout << slv(0, W) << endl;

  return 0;
}



Measured memory_bytes: 82432
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

bool check(vector<pair<ld, ld>>&ps, ld dis) {
	map<ld, int>mp;
	for (int i = 0; i < ps.size(); ++i) {
		auto p(ps[i]);
		ld d = sqrt(p.second*p.second - dis*dis);
		ld l(p.first - d);
		ld r(p.first + d);
		mp[l]++;
		mp[r]--;
	}
	int num = 0;
	bool flag = false;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		auto m(*it);
		num += m.second;
		if (num == ps.size())flag = true;
	}
	return flag;
}

int main() {
	int N; cin >> N;
	vector<pair<ld, ld>>ps;
	ld amin = 0;
	ld amax = 1e18;
	for (int i = 0; i < N; ++i) {
		int a, b; cin >> a >> b;
		ps.emplace_back(a, b);
		amax = min(amax, ld(b));
	}

	amax -= 1e-9;
	int kk =30;
	while (kk--) {
		ld amid((amin + amax) / 2);
		if (check(ps, amid)) {
			amin = amid;
		}
		else {
			amax = amid;
		}
	}
	cout << setprecision(10) << fixed << amin << endl;
	

	return 0;
}

Measured memory_bytes: 21388
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007

#define SZ 10005
using namespace std;


int main()
{
    ll csm[3][31];
    memset(csm, 0, sizeof(csm));
    int n,c;
    cin>>n>>c;
    int d[31][31];
    int mat[501][501];
    for(int i=1; i<=c; i++)
        for(int j=1; j<=c; j++) cin>>d[i][j];
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cin>>mat[i][j];
            csm[(i+j)%3][mat[i][j]]++;
        }
    }
    ll ans = INT_MAX;
    for(int i=1; i<=c; i++)
    {
        for(int j=1; j<=c; j++)
        {
            if(i==j) continue;
            for(int k=1; k<=c; k++)
            {
                if(i==k || j==k) continue;
                ll now = 0;
                for(int col=1; col<=c; col++)
                {
                    now += csm[0][col]*d[col][i];
                    now += csm[1][col]*d[col][j];
                    now += csm[2][col]*d[col][k];
                }
                ans = min(now, ans);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;
 
//TIPE DATA BENTUKAN
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;


bool besarDulu(const int &a, const int &b)
{
    return a > b;
}

bool tupleSort(tuple<int, int, int> &a, tuple<int, int, int> &b)
{
    return get<2>(a) > get<2>(b);
}


int fact(int n)
{
    if (n <= 0) return 1;
    return n * fact(n-1);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    string s2, s3;
    int batas = s.length()/2;
    s2 = s.substr(0, batas);
    s3 = s.length() % 2 == 0 ? s.substr(batas, batas) : s.substr(batas+1, batas);
    reverse(s3.begin(), s3.end());
    if (s2 == s3)
    {
        //cout << "t1" << endl;
        string s4, s5;
        batas = s2.length()/2;
        s4 = s2.substr(0, batas);
        s5 = s2.length() % 2 == 0 ? s2.substr(batas, batas) : s2.substr(batas+1, batas);
        reverse(s5.begin(), s5.end());
        //cout << s4 << ' ' << s5 << endl;
        if (s4 == s5)
        {
            //cout << "t2" << endl;
            batas = s3.length()/2;
            s4 = s3.substr(0, batas);
            s5 = s3.length() % 2 == 0 ? s3.substr(batas, batas) : s3.substr(batas+1, batas);
            reverse(s5.begin(), s5.end());
            if (s4 == s5)
            {
                puts("Yes");
                return 0;
            }
        }
        
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,j,n) for (int i = n; j<=i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

int main(){
  ll N,M,ans=0,now=0;cin>>N>>M;
  vector<P> vec(N);
  REP(i,0,N){cin>>vec[i].first>>vec[i].second;}
  sort(vec.begin(),vec.end());
  for(int i=0;now<M;i++){
    ans+=vec[i].first*min(M-now,vec[i].second);
    now+=min(M-now,vec[i].second);
  }
  print(ans)


}


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

int main(void){
    int n;
    cin >> n;
    vector<int> num(n);
    for (int i = 0; i < n;i++){
        cin >> num.at(i);
    }
    int cnt = 0;
    for (int i = 0; i < n-1;i++){
            if(num.at(i)!=i+1)
                cnt++;
    }
    if(cnt<=2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

using namespace std;

queue < int > q;
vector < int > v[100005], r[100005], NVL[100005], t[100005];
vector < int > :: iterator it, itt, ittt;
int nvl[100005];

int main()
{
    int n, m, i, j, x, y, nvl_max = 0;

    cin >> n >> m;
    for ( i = 1 ; i <= m ; i++ )
    {
        cin >> x >> y;
        v[x].push_back ( y );
        v[y].push_back ( x );
    }

    if ( m % 2 == 1 )
    {
        cout << -1;
        return 0;
    }

    q.push ( 1 );
    nvl[1] = 1;
    NVL[1].push_back ( 1 );
    while ( q.empty() == 0 )
    {
        x = q.front();
        q.pop();

        for ( i = 0 ; i < v[x].size() ; i++ )
            if ( nvl[v[x][i]] == 0 )
            {
                q.push ( v[x][i] );
                nvl[v[x][i]] = nvl[x] + 1;
                NVL[nvl[x]+1].push_back ( v[x][i] );
            }
    }

    for ( i = 1 ; i <= n ; i++ )
        for ( it = v[i].begin() ; it != v[i].end() ; it++ )
            if ( nvl[i] < nvl[*it] || ( nvl[i] == nvl[*it] && i < *it ) ) r[i].push_back ( *it ), t[*it].push_back ( i );

    for ( i = 1 ; i <= n ; i++ ) nvl_max = max ( nvl_max, nvl[i] );

    for ( i = nvl_max ; i >= 1 ; i-- )
        for ( it = NVL[i].begin() ; it != NVL[i].end() ; it++ )
            if ( r[*it].size() % 2 == 1 )
            {
                for ( itt = t[*it].begin() ; itt != t[*it].end() ; itt++ )
                    if ( nvl[*itt] == i - 1 )
                    {
                        r[*it].push_back ( *itt );
                        for ( ittt = r[*itt].begin() ; ittt != r[*itt].end() ; ittt++ )
                            if ( *ittt == *it )
                            {
                                r[*itt].erase ( ittt );
                                break;
                            }

                        break;
                    }
            }

    cout << '\n';
    for ( i = 1 ; i <= n ; i++ )
        if ( r[i].empty() == 0 ) for ( j = 0 ; j < r[i].size() ; j++ ) cout << i << ' ' << r[i][j] << '\n';

    return 0;
}


Measured memory_bytes: 22144
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    // ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
    //vector<ll> X(N);
    //string s;
    //in >> s;
    //vector<string> s;
    //s.resize(N);
    ll R;
    in >> R;
    double ans=0;
    double PI=3.14159265358979323846;
    ans = 2.0 * (double)R * PI;
    
    out << ans << endl; 
    
    
}

Measured memory_bytes: 3796
from bisect import bisect_right
N,C,K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])
cur = 0
cnt = 0
while cur<N:
    ind = bisect_right(T,T[cur]+K)
    if ind-cur<=C:
        cnt += 1
        cur = ind
    else:
        cnt += 1
        cur += C
print(cnt)

Measured memory_bytes: 82048
#include<stdio.h>

int a[500000];
int h;

void maxHeapify(int i)
{
  int largest;
  int temp;
  
  if(i*2 <= h && a[i*2] > a[i])largest = i*2;
  else largest = i;
  if(i*2+1 <= h && a[i*2+1] > a[largest])largest = i*2+1;

  if(largest != i)
    {
      temp = a[i];
      a[i] = a[largest];
      a[largest] = temp;

      maxHeapify(largest);
    }

  return;
}

void buildMaxHeap()
{
  int i;
  
  for(i = h/2; i > 0; i--)
    {
      maxHeapify(i);
    }

  return;
}

int main()
{
  int i;
  
  for(i = 0; i < 500000; i++)
    {
      a[i] = NULL;
    }
  
  scanf("%d", &h);
  for(i = 1; i <= h; i++)
    {
      scanf("%d", &a[i]);
    }

  buildMaxHeap();
  
for(i = 1; i <= h; i++)
    {
      printf(" %d", a[i]);
    }
 printf("\n");
  return 0; 
}



Measured memory_bytes: 3740
A=int(input())
B=int(input())
C=int(input())
X=int(input())

def exist_combination(A,B,C,target):
  count = 0
  for ai in range(A+1):
    for bi in range(B+1):
      for ci in range(C+1):
        s = ai*500 + bi*100 + ci*50
        if s == target:
          count += 1                  
  return count

print(exist_combination(A,B,C,X))

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

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

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

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

bool solve() {
    VI a(3), b(3);
    VVI c(3, VI(3));
    REP(i, 0, 3) REP(j, 0, 3) cin >> c[i][j];
    for (a[0] = -100; a[0] <= 100; ++a[0]) {
        b[0] = c[0][0] - a[0];
        REP(i, 1, 3) b[i] = c[0][i] - a[0];
        REP(i, 1, 3) a[i] = c[i][0] - b[0];
        bool bo = true;
        REP(i, 1, 3) REP(j, 1, 3) {
            if (a[i] + b[j] != c[i][j])
                bo = false;
        }
        if (bo) {
            dump(a[0]);
            return true;
        }
    }
    return false;
}

signed main() {
    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)

#define vll    vector<ll>
#define vvll   vector<vector<ll>>
#define all(x) (x).begin(),(x).end()

int main()
{	
	//a_1～a_Nの最大公約数をGとおき、
	//
	//a_i = b_i * G (b_i >= 1)
	//
	//とおく。このとき、
	//
	//M = a_1 + ・・・ + a_N
	//  = b_1 * G + ・・・ + b_N * G
	//  = (b_1 + ・・・ + b_N) * G
	//
	//となる。よって以下3つがわかる。
	//
	//1.(b_1 + ・・・ + b_N)はMの約数
	//2.b_1 + ・・・ + b_N >= N
	//3.G = M / (b_1 + ・・・ + b_N)
	//
	//よって、N以上のMの約数のうち最小のものでMを割ればGを最大化できる。
	int N, M;
	cin >> N >> M;

	//Mの約数の計算
	//計算量はO(N^(1/2))
	vector<int> d;
	for (int i = 1; i * i <= M; i++)
	{
		if (M % i == 0)
		{
			d.push_back(i);
			if(i != M / i) d.push_back(M / i);
		}
	}

	//ソート
	sort(all(d));

	//2分探索でN以上の最小の約数を取得
	auto itr = lower_bound(all(d), N);

	if (itr != d.end())
	{
		cout << M / *itr << endl;
	}
	else
	{
		//取得できない場合は1
		cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll n, m;
	cin >> n >> m;
	vector<ll> v;
	v.push_back(0);
	for( int i = 0; i < n; ++i ){
		ll temp;
		cin >> temp;
		v.push_back((temp+v.at(i))%m);
	}
	/*
	a 個の同じ数に対して，区間のとり方は aC2 = a * (a-1) / 2 通りある
	v を左から見てある数が a 個並んでいるとき，a 個ある各数にたいして (a-1) を足しておいて，あとで 2 で割れば aC2 になる
	同じ数の個数はソートして二分探索して十分高速に計算できるため，これで AC できる(はず)
	*/
	sort(v.begin(), v.end());
	ll res = 0;
	for( auto target : v ){
		res += ( ( upper_bound( v.begin(), v.end(), target ) - lower_bound( v.begin(), v.end(), target ) ) ) - 1;	
	}
	res /= 2;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<double> p(n);
  rep(i,n)cin>>p[i];
  vector<vector<double>> dp(n,vector<double>(n+1));
  dp[0][0]=1-p[0];
  dp[0][1]=p[0];
  repeat(i,1,n) {
    dp[i][0]=dp[i-1][0]*(1-p[i]);
    repeat(j,1,n+1) {
      dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
    }
  }
  double ans=0;
  repeat(i,(n+1)/2,n+1) {
    ans+=dp[n-1][i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long n;
    cin >> n;
    vector<long long> a(3 * n);
    for(int i = 0; i < 3 * n; ++i) cin >> a[i];
    multiset<long long> st;
    vector<long long> mx(3 * n);
    long long sum = 0;
    for(int i = 0; i < 3 * n; ++i){
        sum += a[i];
        st.insert(a[i]);
        if(st.size() < n) continue;
        if(st.size() > n){
            auto f = st.begin();
            sum -= *f;
            st.erase(f);
        }
        mx[i] = sum;
    }
    sum = 0;
    priority_queue<long long> pq;
    vector<long long> mn(3 * n);
    for(int i = 3 * n - 1; i >= 0; --i){
        sum += a[i];
        pq.push(a[i]);
        if(pq.size() < n) continue;
        if(pq.size() > n){
            sum -= pq.top();
            pq.pop();
        }
        mn[i] = sum;
    }
    long long ans = -1e18;
    for(int i = n - 1; i < 2 * n; ++i){
        ans = max(ans, mx[i] - mn[i + 1]);
    }
    cout << ans;
}


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

using namespace std;

int main(){
    int N,X;
    cin>>N>>X;
    vector<int> x(N);
    for(int i=0;i<N;i++){
        int tmp;
        cin>>tmp;
        x[i] = abs(X-tmp);
    }

    int ans = 0;
    for(int i=0;i<N;i++)
        ans = __gcd(ans,x[i]);

    cout<<ans;
}


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

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

    vector<int> robo(200,0);

    for(int i=a; i<b ; i++){
        robo[i]++;
    }
    for(int j=c; j<d; j++){
        robo[j]++;
    }
    int sec = 0;
    for(int i=0; i<100; i++){
        if(robo[i] == 2){
            sec++;
        }
    }
    cout << sec << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i
m = gets.split.map(&:to_i)
acomb = Array.new
for i in 1..n
  acomb.concat(a.combination(i).to_a)
end
require 'set'
s = Set.new
l = acomb.length
for i in 0...l
  li = acomb[i].length
  sum = 0
  for j in 0...li
    sum += acomb[i][j]
  end
  s << sum
end
for i in 0...q
  if s.include? m[i]
    puts "yes"
  else
    puts "no"
  end
end

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

int rest(int a) {
  if (a%10 != 0) return a%10;
  else return 10;
}

int max_time(int a) {
  if (a%10 != 0) return ((a/10+1)*10);
  else return (a);
}




int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  int time = 0;
  
  time += max_time(a);
  time += max_time(b);
  time += max_time(c);
  time += max_time(d);
  time += max_time(e);
  
  int last = 10;
  int additional = min({rest(a),rest(b),rest(c),rest(d),rest(e)});
  if (additional == 10) {
    cout << time << endl;
  }
  else {
    cout << time - (10 - additional) << endl;
  }
}
  

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """ 根を見つける関数を定義（同時にxを直接根にくっつける操作も行う）"""
        tmp = []
        parents = self.parents
        while parents[x] >= 0:
            tmp.append(x)
            x = parents[x]
        for y in tmp:
            parents[y] = x
        return x

    def union(self, x, y):
        """ 二つの木をくっつける（子を多く持つ方を根とした親子関係）。これは破壊的操作を行う。"""
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        """ xとyが同じ根の子かを判定 """
        return self.find(x) == self.find(y)

    def size(self, x):
        """ xの根のparent（= 要素数）を返す """
        return -self.parents[self.find(x)]

    def members(self, x):
        """ xが属するグループの要素をリストとして返す """
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """ 全ての根の要素をリストとして返す """
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """ グループの数を返す """
        return len(self.roots())

    def size_list(self):
        """ 各グループの要素数のリストを返す(根の番号は返さない) """
        return [-x for x in self.parents if x < 0]

    def all_group_members(self):
        """ {根:[根の子のリスト],...}を辞書で返す """
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


##############################################################################################################
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
U = UnionFind(N)
for _ in range(M):
    t, a, b = map(int, input().split())
    if t==0: U.union(a, b)
    else: print(int(U.same(a, b)))

Measured memory_bytes: 75368
main = do
  [a,b,deg] <- (return . map (read::String->Double) . words) =<< getLine
  let rad = deg * pi / 180.0
  print $ a * b * (sin rad) * 0.5
  print $ a + b + (a**2 + b**2 - 2.0*a*b*(cos rad))**0.5
  print $ b * (sin rad)


Measured memory_bytes: 4144
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

bool ok[256];

int main()
{
	IO_OP;
	ok['A'] = ok['T'] = ok['C'] = ok['G'] = 1;
	string s;
	cin >> s;
	int mx = 0, c = 0;
	for(int i=0;i<s.size();i++) {
		if(ok[s[i]]) {
			c++;
		} else {
			mx = max(c, mx);
			c = 0;
		}
	}
	mx = max(c, mx);
	cout << mx << endl;
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<ll> num;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q;
    cin >> Q;
    for(ll i = 2; i <= 1e5; i++) {
        bool clear = false;
        ll product = 1;
        for(ll j = 2; j * j <= i; j++) {
            if(i % j != 0) continue;
            product *= j;
            if(j * j != i) product *= i / j;
            if(product >= 2 * i) clear = true;
        }
        if(clear) num.push_back(i);
    }
    while(Q--) {
        ll N;
        cin >> N;
        auto itr = upper_bound(num.begin(), num.end(), N);
        cout << distance(num.begin(), itr) << endl;
    }
    return 0;
}



Measured memory_bytes: 3948
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[][] a = new long[n][2];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            a[i][0] = sc.nextLong();
            a[i][1] = sc.nextLong();
        }
        Arrays.sort(a, (x, y) -> Long.compare(x[0], y[0]));
        for (int i = 0; i < n; i++) {
            if (a[i][1] < m) {
                ans += a[i][0] * a[i][1];
                m -= a[i][1];
            } else {
                ans += a[i][0] * m;
                break;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 94488
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
    cerr << "[";
    for (auto e : aux) cerr << e << ' ';
    cerr << "]";
    return cerr;
}

int n;

int main()
{
    //freopen("test.in","r",stdin);

    cin >> n;
    cout << (n * (n - 1)) / 2 - (n / 2)<< '\n';
    int target = (n % 2) ? n : n + 1;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (i + j == target) continue;
            cout << i << ' ' << j << '\n';
        }
    }


    return 0;
}


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

int main() {
	string n;

	cin >> n;

	if (n[0] == n[1]) {
		if (n[1] == n[2]) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else if (n[1] == n[2]) {
		if (n[2] == n[3]) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}
}


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

int main(void)
{
    int N;
    cin >> N;
    int r[N], l[N];
    
    for(int i = 0; i < N; i++){
        cin >> l[i] >> r[i];
    }

    int res = 0;
    for(int i = 0; i < N; i++){
        res += (r[i] - l[i] + 1);
    }

    cout << res << endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
int s[600000], dp[600000];

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (s[2] == s[1] && s[3] == s[2]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
N = input()
stringi = input()
t = 0
r = 0
R = "R"
B = "B"
b= 0
while(t <int(N)):
   if(stringi[t] == R):
      r+=1
   else:
      b+=1
   t+=1
if(r>b):
   print("Yes")
else:
   print("No")


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\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 rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 a;
  cin >> a;
  ANS(a + a * a + a * a * a);
  return 0;
}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int L = stdIn.nextInt();
		
		int sum = 0;
		int s = L;
		for(int i = 1; i <= N; i++) {
			sum += (L+i-1);
			if(Math.abs(L+i-1) < Math.abs(s)) {
				s = L+i-1;
			}
		}
		System.out.println(sum-s);

	}

}

Measured memory_bytes: 21972
s = input()
q = int(input())
q1 = [list(map(str,input().split())) for i in range(q)]

ap = ["", ""]
revCount = 0

for j in q1:
  if j[0] == "1":
    revCount = revCount ^ 1

  else:
    ind = revCount ^ int(j[1]) - 1
    ap[ind] = ap[ind] + j[2]

if revCount == 0:
  ap[0] = ap[0][::-1]
  print(ap[0] + s + ap[1])

else:
  aps = (s+ap[1])[::-1]
  print(aps + ap[0])


Measured memory_bytes: 40592
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);
	private static final int MAX = 101;
	private static int[] st = new int[MAX];
	private static int top;

	public static void main(String[] args){

		initialize();
		while(scan.hasNext()){
			String[] cmd = scan.nextLine().split(" ");
			for(int i = 0; i < cmd.length; i++){
				if(cmd[i].equals("+")){
					int n2 = pop();
					int n3 = pop();
					n2 = n3 + n2;
					push(n2);
				}else if(cmd[i].equals("-")){
					int n2 = pop();
					int n3 = pop();
					n2 = n3 - n2;
					push(n2);
				}else if(cmd[i].equals("*")){
					int n2 = pop();
					int n3 = pop();
					n2 = n3 * n2;
					push(n2);
				}else{
					int n = Integer.parseInt(cmd[i]);
					push(n);
				}
			}
			System.out.printf("%d\n", st[1]);
		}
	}

	public static void initialize(){
		top = 0;
	}
	private static boolean isEmpty(){
		return top == 0;
	}
	private static boolean isFull(){
		return top >= MAX - 1;
	}
	public static void push(int x){
		if(isFull())
			System.out.printf("%s\n", "???????????????????????§???");
		top++;
		st[top] = x;
	}
	public static int pop(){
		if(isEmpty())
			System.out.printf("%s\n", "??¢????????????????????§???");
		top--;
		return st[top+1];
	}
}

Measured memory_bytes: 26392
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  int N ; 
  cin >> N ;
  vector<int> A(N);
  rep(i,N) cin >> A.at(i) ;
  for(int i = N-1; i > 0; i--){
    if( A.at(i-1) > A.at(i) ) A.at(i-1)-- ;
  }
  //rep(i,N) cout << A.at(i) ;
  //cout << endl;
  if( N == 1 ) cout << "Yes" << endl;
  rep( i , N-1 ) {
    if( A.at(i) <= A.at(i+1) ){
      if( i == N-2 ) cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
      break;
    }
  }
}
 

Measured memory_bytes: 640
N = int(input())
S = input()

def check(l):
    D = set()
    for i in range(N - 2 * l + 1):
        D.add(S[i:i+l])
        if S[i+l:i+2*l] in D:
            return True

OK = 0
NG = N // 2 + 1

while abs(OK - NG) > 1:
    mid = (OK + NG) // 2
    if check(mid):
        OK = mid
    else:
        NG = mid

print(OK)

Measured memory_bytes: 6388
#include <stdio.h>
int main(void){   
// Your code here!   
int n,x,i,j,k,c;   
c=0;   
while(1){    
   scanf("%d %d",&n,&x);    
   if(n == 0 && x == 0)break;   
    for(i =1;i <n+1;i++){ 
          for(j=1;j < n+1;j++){  
             for(k=1;k<n+1;k++){
                   if(j !=k && i != j&& i != k&& i+j+k==x){
                    c=c+1;
                   }
               }
           }
       }
       printf("%d\n",c/6);
   c = 0;
   }
       
return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#define ft(i,a,b) for(int i=a; i<=b; ++i)

using namespace std;

long f[10005][100][3], d;
const int MOD = 1000000007;
string k;

long calc(const string &s) {
    int len=s.size();
    ft(x,1,9) {
        int st=((x==s[0]-'0')? 1 : ((x>s[0]-'0')? 2 : 0));
        f[1][x%d][st]++;
    }
    for(int i=1; i<=len; ++i) {
        for(int r=0; r<d; ++r) {
            for(int st=0; st<=2; ++st) {
                if (f[i][r][st]==0) continue;
                    for(int x=0; x<=9; ++x) {
                        int newr=(r+x)%d;
                        int newst=st;
                        if (st==1)
                        {
                            if (x>s[i]-'0') newst=2;
                            if (x==s[i]-'0') newst=1;
                            if (x<s[i]-'0') newst=0;
                        }
                        (f[i+1][newr][newst]+=f[i][r][st]) %= MOD;
                    }
            }
        }
    }

    long long ans=0;
    for(int i=1; i<=len; ++i) {
        for(int st=0; st<=((i==len)? 1 : 2) ; ++st) {
            (ans+=f[i][0][st] % MOD) %= MOD;
        }
    }
    return ans%MOD;
}

int main() {
//    freopen("INPUT.TXT","r",stdin);
//    freopen("OUTPUT.TXT","w",stdout);
    cin>>k>>d;
    cout<<calc(k);
    return 0;
}


Measured memory_bytes: 23680
from math import gcd
N=int(input())
A=list(map(int,input().split()))
g=gcd(A[0],A[1])
for i in A:
    g=gcd(g,i)
if g>1:
    print("not coprime")
    exit()
l=[0]*1000001
for i in A:
    l[i]+=1
for i in range(2,1000000):
    c=0
    for j in range(i,1000001,i):
        c+=l[j]
    if c>1:
        print("setwise coprime")
        break
else:
    print("pairwise coprime")

Measured memory_bytes: 197888
def main():
    n, m, X, Y = map(int, input().strip().split())
    x = list(map(int, input().strip().split()))
    y = list(map(int, input().strip().split()))

    if max(x) < min(y) and max(x) < Y and min(y) > X:
        print("No War")
    else:
        print("War")
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num;
        int ascore,bscore;
        int a=0,b=0;
        int i=0;
        
        
        while(sc.hasNext()){
            num = sc.nextInt();
            if(num == 0){
                break;
            }
            ascore=0;
            bscore=0;
            for(i = 1; i < num+1; i++){
                a = sc.nextInt();
                b = sc.nextInt();
                if(a > b)  {
                    ascore = ascore + a + b;
                }else if(a < b){
                    bscore = bscore + a + b;
                }else{
                    ascore += a;
                    bscore += b;
                }
            }
            System.out.println(ascore + " " + bscore);
        }
    }
}

Measured memory_bytes: 58160
n,*t=map(int,open(0).read().split())
c=sorted(t[-n:])
q=[0]
f=q*n
e=[[]for _ in f]
for a,b in zip(t[:-n:2],t[1:-n:2]):e[a-1]+=b-1,;e[b-1]+=a-1,
while q:
 v=q.pop();n-=1;f[v]=c[n]
 for w in e[v]:q+=[w]*(f[w]<1)
print(sum(c[:-1]),*f)

Measured memory_bytes: 6732
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int n = s.length(), flag(1), j(1);
    string s1(s);
    reverse(s1.begin(), s1.end());
    for (int i = 0; i < n; i++) {
        if (i < (n - 1) / 2) {
            flag = (flag & (s[i] == s[((n - 1) / 2) - i - 1]));
        }
        if (i >= ((n + 3) / 2) - 1) {
            flag = (flag & (s[i] == s[n - j]));
            j++;
        }
        flag = (flag & (s[i] == s[n - i - 1]));
        if (!flag) {
            break;
        }
    }
    if (flag) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
using namespace std;
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> 
void dbg_out(Head H, Tail... T) { 
    cerr << ' ' << H;
     dbg_out(T...); 
}
#define dbg(...) cerr << '(' << #__VA_ARGS__ << ')'<<':', dbg_out(__VA_ARGS__)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define on(val,pos) (val|(1<<pos))
#define off(val,pos) (val&(~(1<<pos)))
#define check(val,pos) (val&(1<<pos))
#define all(n) n.begin(),n.end()
//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
    int i,j,k,n,m,val,t=0,test;
    //freopen("000input.txt","r",stdin);
    cin>>n>>m;
    ll ans=0;
    int maxi=m;
    for(i=1;i<n;i++){
        cin>>val;
        if(maxi>=val)ans+=(ll)(maxi-val);
        else maxi=val;
    }
    cout<<ans<<endl;
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 3628
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

A, B = I()
S = list(input().split("-"))
n = len(S)

if n != 2:
    print("No")
else:
    a = len(S[0])
    b = len(S[1])
    if A == a and B == b:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9972
num = input()
result = 0

if len(num) != 1:
  result = int((len(num)-2)//2 * ("90") + "9")

if len(num) % 2 == 0:
  print(result)
else:
  numA = int("0" + (len(num) - 1) * "9")
  print(result + int(num) - numA)

Measured memory_bytes: 3060