akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  vector<int> B(N + 1);
  B[0] = INF;
  repp(i, 1, N - 1) cin >> B[i];
  B[N] = INF;

  int ans = 0;
  rep(i, N) {
    ans += min(B[i], B[i + 1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import copy
h,w,k=map(int, input().split())
mat = []
for i in range(h):
  s = list(input())
  mat.append(s)
total = 0
for y in range(2**h):
  for x in range(2**w):
    mat2 = copy.deepcopy(mat)
    y_bin = bin(y)[2:].zfill(h)
    x_bin = bin(x)[2:].zfill(w)
    # print(y_bin, x_bin)
    for r in range(len(y_bin)):
      if y_bin[r] == "1":
        for c in range(w):
          mat2[r][c] = "."
    for c in range(len(x_bin)):
      if x_bin[c] == "1":
        for r in range(h):
          mat2[r][c] = "."
    count = 0
    for r in range(h):
      for c in range(w):
        if mat2[r][c] == "#":
          count += 1
          # print(r, c)
    if count == k:
      total += 1
print(total)


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

#define INF 200000000
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

int dp[100001];

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

	fill(dp, dp + 100001, INT_MAX);

	int n;

	cin >> n;

	int a;
	int length = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (dp[length - 1] < a)
		{
			dp[length++] = a;
		}
		else
		{
			(*lower_bound(dp, dp + length, a)) = a;
		}
	}

	cout << length << endl;
	
	return 0;
}


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

namespace _031_Weight
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] weight = { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };

			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int inputNum = int.Parse (inputStr);
				List<int> output = new List<int> (weight.Length);

				int index = 0;
				while (inputNum != 0)
				{
					int item = weight[index];

					if (item <= inputNum)
					{
						output.Add (item);
						inputNum -= item;
					}

					index++;
				}

				for (int lp = output.Count - 1; lp >= 1; lp--)
				{
					Console.Write (output[lp] + " ");
				}
				Console.WriteLine (output.First ());
			}
		}
	}
}

Measured memory_bytes: 9512
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL L[100];

LL ans = 0;

void solve(){
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			for(int k=j+1;k<N;k++){
				if(L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k]){
					if(L[i]+L[j]>L[k] && L[j]+L[k]>L[i] && L[k]+L[i]>L[j]){
						ans++;
					}
				}
			}
		}
	}
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> L[i];

    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<stdlib.h>

#define MAX 10000

int n;
void CountingSort(int *A,int *B){
  int i,j;
  int C[MAX+1];
  for(i=0;i<=MAX;i++) C[i]=0;
  for(j=0;j<n;j++) C[A[j]]++;
  for(i=1;i<=MAX;i++) C[i]=C[i]+C[i-1];
  for(j=n-1;j>=0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}
int main(void){
  int *A;
  int *B;
  int i;
  scanf("%d",&n);
  A=malloc((n+1)*sizeof(int));
  B=malloc((n+1)*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  CountingSort(A,B);
  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 16272
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int x,n,a[1000],ans[1000],cnt;
void check()
{
	int anss=1;
	for (int i=1;i<=n;i++)
		anss=anss*ans[i];
	if (!(anss&1))
	{
		cnt++;
	}
}
void dfs(int now)
{
	if (now>n)
		check();
	else
	{
		ans[now]=a[now];
		dfs(now+1);
		ans[now]=a[now]-1;
		dfs(now+1);	
		ans[now]=a[now]+1;
		dfs(now+1);
	}
}
main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	dfs(1);
	printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
using namespace std;
inline int maxx(int a,int b,int c) {
    if(a <= b) {
        if(b <= c) return c;
        else return b;
    }
    else {
        if(a <= c) return c;
        else return a;
    }
}

int main() {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",a + b + c - maxx(a,b,c));
    return 0;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    int ans = 0;
    int t;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        t = a[i];
        while (t % 2 == 0) {
            t /= 2;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#枚数
a, b, c, k = map(int, input().split())
 
A = a
B = 0
C = -1 * c
 
if k - a >= 0:
    if k -a -b >= 0:
        print(a + (-1)*(k -a -b) )
    else:
        print(a)
else:
    print(k)
 

Measured memory_bytes: 61772
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1234;
long long f[maxn];
int u[maxn];
int main(){
  int n, m; cin >> n >> m;
  vector<tuple<int,int,int> > ed;
  for(int i = 0; i < m; i++){
    int x, y, z; cin >> x >> y >> z;
    ed.push_back(make_tuple(x, y, z));
  }
  const long long inf = 1ll<<60;
  for(int i = 1; i <= n; i++) f[i] = -inf;
  f[1] = 0;
  for(int j = 0; j <= n; j++)
    for(int i = 0; i < m; i++){
      int x, y, z; tie(x, y, z) = ed[i];
      if(f[x] == -inf) continue;
      f[y] = max(f[y], f[x] + z);
    }
  for(int j = 0; j < n; j++)
    for(int i = 0; i < m; i++){
      int x, y, z; tie(x, y, z) = ed[i];
      if(f[x] == -inf) continue;
      if(f[y] < f[x] + z){
		f[y] = f[x] + z;
        u[y] = 1;
      }
      if(u[x]) u[y] = 1;
    }
  if(u[n]) cout << "inf" << endl;
  else cout << f[n] << endl;
  return 0;
}
  


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

int main() {
  int a,b;
  cin >> a >> b;
  int ans;
  if (a == b){
    for(int i = 0; i < a; i++){
      cout<<a;
    }
  }      
  else if(a < b) {
    for(int i = 0; i < b; i++){
     cout<<a;
    }
  }
  else {
     for(int i = 0; i < a; i++){
       cout<<b;
     }
  }
}



Measured memory_bytes: 256
import sys
import math

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

A, B = map(float, input().split())
A = int(A)
B_tmp = int(B * 10**2 + 0.5)

total = A * B_tmp
total //= 100
# total = math.floor(total)
print(int(total))


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int gcd(int x,int y){
  if(x<=y){
    swap(x,y);
  }
  if(x%y==0) return y;
  else{
    return(gcd(y,x%y));//最大公約数
  }
}

int main(){
    int n,a;
    cin >> n >> a;
    int ans = a;
    FOR(i,1,n){
        int b;
        cin >> b;
        ans = gcd(ans,b);
    }
    cout << ans << endl;
    return 0;
}    


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int ll;
const ll mod=1e9+7;
ll ksm(ll a,ll b){
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	ll a;
	scanf("%lld",&a);
	ll ans=0;
	ans=(ksm(10,a)+ksm(8,a)%mod-2*ksm(9,a))%mod+mod;
	printf("%lld\n",ans%mod);
}

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long MOD = 1000000007;

vector<int> places[210000];
long long dp[210000];
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
    // 入力
    int N; cin >> N;
    vector<int> c(N);
    for (int i = 0; i < N; ++i) cin >> c[i];

    // places[i] := (c[j] = i となるような j の集まり)
    for (int i = 0; i < 210000; ++i) places[i].clear();
    for (int i = 0; i < N; ++i) places[c[i]].push_back(i);

    // DP
    dp[0] = 1;
    for (int i = 1; i <= N; ++i) {
        // 特に操作しない場合
        add(dp[i], dp[i-1]);

        // 操作する場合
        int color = c[i-1];
        int it = lower_bound(places[color].begin(), places[color].end(), i-1)
            - places[color].begin(); // itは c[i-1] が color 色の何番目の要素か
        if (it > 0) {
        	//もしもc[i-1]が color 色の1番目以上だったら
            int j = places[color][it - 1]; // c[j] = c[i] となる j
            if ((i-1) - j > 1) add(dp[i], dp[j+1]);
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 13824
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    for(int i=a;i<=b;i++){
        string s = to_string(i);
        bool flag = 1;
        rep(i,2){
            if(s[i]!=s[4-i]){
                flag = 0;
            }
        }
        if(flag)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  cin>>n;
  using P = pair<Int, Int>;
  vector<P> v(n);
  for(Int i=0;i<n;i++){
    Int h,p;
    cin>>h>>p;
    v[i]=P(h+p,h);
  }
  sort(v.begin(),v.end());
  Int INF=1LL<<55LL;
  vector<vector<Int> > dp(n+1,vector<Int>(n+1,INF));
  dp[0][0]=0;
  int ans=0;
  for(Int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      if(dp[i][j]<=v[i].second){
	dp[i+1][j+1]=min(dp[i+1][j+1],
			 dp[i][j]+v[i].first-v[i].second);
	ans=max(ans,j+1);
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


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

long long inputs[200005];
long long oddsum[200005];
long long evensum[200005];

int main(){
   int n,m,x;
   cin >> n ;
   int ara[n+10];
   vector<int>vec;
   for(int i=1; i<=n; i++)
   {
       cin >> ara[i];
       vec.push_back(ara[i]);
   }
   sort(vec.begin(),vec.end());
   int fst = vec[n/2],sec = vec[n/2 -1];
   //cout << fst << " " << sec << endl;

   for(int i=1; i<=n; i++)
   {
       int val = ara[i];
       int l = 0 , r = n-1,pos;
       while(l<=r)
       {
           int mid = (l+r)/2;
           if(val>vec[mid])
           {
               l = mid+1;
           }
           else if(val<vec[mid])
           {
               r = mid - 1;
           }
           else
           {
               pos = mid+1;
               break;
           }
       }
     //  cout << val << " " ;
       //cout << pos << endl;
       if(pos<=n/2)
        cout << fst << endl;
       else cout << sec << endl;

   }


}


Measured memory_bytes: 4944
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, ans;
char s[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++){
		ans += s[i] - '0';
	}
	if(ans == 1){
		printf("10\n");
	}else
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  int aa=a,bb=b;
  b+=a;
  rep(i,20000){
    if(c <= a){cout<<c<<endl;return 0;}
    else if(c < b) c+=60;
    a+=aa+bb;
    b+=aa+bb;
  }
  cout<<-1<<endl;
 
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> h.at(i);
    }

    int tmp = -1;
    for (int i = 0; i < n; i++)
    {
        if(tmp <= h.at(i))
        {
            count++;
            tmp = h.at(i);
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define in insert
#define rev reverse
#define all(x) (x).begin(),(x).end()
#define pf push_front
#define pob pop_back
#define pof pop_front
#define u_b upper_bound
#define l_b lower_bound
#define ios ios_base::sync_with_stdio(0);cin.tie();
#define mod 998244353
#define Max 200005

using namespace std;


int main()
{
    ios;
    ll n;
    cin >> n;
    int x = n / 500;
    int y = n % 500;
    y /= 5;

    cout << (x * 1000) + (y * 5) << endl;

   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> road;
#define UPPER 100000000

bool able = true;  //構築可能か？
int N, M;
vector<int> sign(100010, -1); //道しるべ  1へたどり着けない町存在⇒-1存在
vector<int> dist(100010, UPPER); //町1との距離
vector<vector<int>> dest(100010);  //行き先
queue<int> q;

/*深さ優先探索？*/
int main(){
  cin >> N >> M;

  int s, e;
  for(int i = 0; i < M; i++){
    cin >> s >> e;
    dest[s].push_back(e); dest[e].push_back(s);
  }

  dist[1] = 0;  //町1基準
  q.push(1);  //始まり
  while(!q.empty()){
    int par = q.front(); q.pop();
    for(int i = 0; i < dest[par].size(); i++){  //par接続の町すべて
      int d = dest[par][i];  //行き先
     
      if(dist[d] > dist[par]+1){ 
        dist[d] = dist[par]+1; 
        sign[d] = par;  //dの道しるべをpar 
        q.push(d);  //par接続からの改善可能性：dに進む 
      }else if(dist[d] <= dist[par]+1) ;  //改善不可：par接続からの改善可能性なし
    }
  }

  for(int i = 2; i <= N; i++){
    if(sign[i] < 0){ able = false; break; }
  }

  if(able){
    cout << "Yes" << endl;
    for(int i = 2; i <= N; i++) cout << sign[i] << endl;
  }else  cout << "No" << endl;

  return 0;
}

  
 /* cout << "d : " << d << " par : " << par << " dist[" << par <<"] : " << dist[par] << " dist[" << d << "] : " << dist[d] << endl; */







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


int main() {
	int n,N=1,a,b;
	vector<int> v;
	cin >> n;
	for(int i=0;i<n;i++){
		N*=2;
	}
	n=N/2;
	
	for(int i=0;i<n;i++){
		cin >> a >> b;
		v.push_back(abs(a-b));
	}
	
	while(n!=1){
		vector<int> v2;
		for(int i=0;i<n;i+=2){
			v2.push_back(abs(v[i]-v[i+1]));
		}
		v=v2;
		n/=2;
	}
	
	cout << v[0] << endl;
	return 0;
}
 

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


int D[100][6];
//回転を定義
void spin(int n,char c)
{
    if(c=='E'){
        swap(D[n][0],D[n][3]);swap(D[n][3],D[n][5]);swap(D[n][5],D[n][2]);
    }
    else if(c=='W'){
        swap(D[n][0],D[n][2]);swap(D[n][2],D[n][5]);swap(D[n][5],D[n][3]);
    }
    else if(c=='S'){
        swap(D[n][0],D[n][1]);swap(D[n][0],D[n][4]);swap(D[n][4],D[n][5]);
    }
    else if(c=='N'){
        swap(D[n][0],D[n][1]);swap(D[n][1],D[n][5]);swap(D[n][5],D[n][4]);
    }
}

int main() {
    //ダイスを一括で入力
    int ans = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n ; i++) {
        for (int j = 0; j < 6; j++) {
            cin >> D[i][j];
        }
    }
    for (int i = 0; i < n ; i++) {
        for (int j = i + 1; j <= n; j++) {
            //i個目のダイスとj個目のダイスを比較
            //回転して前面を合わせる
            char SWS[10]={"SSSSWSSSS"};
            for(int k=0; k<10; k++){
                if(D[i][1] == D[j][1]) break;
                spin(j, SWS[k]);
            }
            //回転して上面を合わせる
            for(int k=0; k<4; k++){
                if(D[i][0] == D[j][0]){
                    if(D[i][1] == D[j][1] && D[i][2] == D[j][2] && D[i][3] == D[j][3] && D[i][4] == D[j][4] && D[i][5] == D[j][5])
                        ans++;
                }
                spin(j, 'W');
            }
        }
    }
    //出力

    if (ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct Process{
    char name[500];
    int time;
};

int main(){
    int n = 0, quantum;
    int remain = 0;
    int finishTime = 0;
    queue<Process> q;
    scanf("%d%d", &n, &quantum);
    // 5 100
    // 150 80 200 350 20
    // p1 p2 p3 p4 p5
    while(n--){
        Process tmp;
        scanf("%s", tmp.name);
        scanf("%d", &tmp.time);
        q.push(tmp);
    }
    while(q.size() > 0){
        remain = q.front().time - quantum;
        if(remain <= 0){ // finished
            finishTime += q.front().time;
            printf("%s %d\n", q.front().name, finishTime);
        }
        else{ // not finished
            finishTime += quantum;
            Process tmp;
            strcpy(tmp.name, q.front().name);
            tmp.time = remain;
            q.push(tmp);
        }
        q.pop();
    }
    return 0;
}



Measured memory_bytes: 28520
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll a[n];
  bool win_s=true;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2!=0)win_s=false;
  }
  if(win_s) cout <<"second\n";
  else cout <<"first\n";
  
}


Measured memory_bytes: 1024
# coding: utf-8
N=int(input())
a=0
m=float('inf')
for i in range(N):
    s=int(input())
    a+=s
    if s%10!=0:
        m=min(m,s)

if m>100:
    print(0)
else:
    if a%10==0:
        print(a-m)
    else:
        print(a)

Measured memory_bytes: 38384
from collections import defaultdict
N = int(input())
A = [int(x) for x in input().split()]
d = defaultdict(lambda:0)
cumu=[0]
d[0]+=1
for i in A:
    cumu.append(cumu[-1]+i)
    last = i
    d[cumu[-1]]+=1
ans = 0
for i in d.values():
    ans+=i*(i-1)//2
print(ans)


Measured memory_bytes: 39040
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	int ans = n;
	for (int i = 1; i < n; i++){
		if (s.at(i) == s.at(i - 1)){
			ans--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
int main(int argc, char *argv[])
{
	int W;
	int H;
	int x;
	int y;
	int r;
	scanf("%d %d %d %d %d\n", &W, &H, &x, &y, &r);
	if (((0+r) <= x) && (x <= (W-r)) &&
	    ((0+r) <= y) && (y <= (H-r))    )
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 588
#define taskname ""

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>

using namespace std;
#define long long long

const int N = 1e3 + 10;
const int MOD = 1e9 + 7;

int m, n, f[N][N];
char s[N][N];

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);

    scanf("%d%d", &m, &n);
    for (int i = 1; i <= m; ++i) scanf("%s", s[i] + 1);

    f[1][1] = 1;
    for (int i = 1; i <= m; ++i)
        for (int j = 1; j <= n; ++j) {
            if (s[i - 1][j] == '.') f[i][j] = (f[i][j] + f[i - 1][j]) % MOD;
            if (s[i][j - 1] == '.') f[i][j] = (f[i][j] + f[i][j - 1]) % MOD;
        }
    cout << f[m][n];

    return 0;
}


Measured memory_bytes: 5120
d=list(map(int,input().split()))
t=[d[i] for i in [0,1,5,4]]
y=[d[i] for i in [0,2,5,3]]

for i in input():
    if i == 'N' or i=='S':
        if i=='S':
            t.insert(0,t.pop())
        else:
            t.append(t.pop(0))
        y[0],y[2]=t[0],t[2]
    if i == 'W' or i=='E':
        if i=='E':
            y.insert(0,y.pop())
        else:
            y.append(y.pop(0))
        t[0],t[2]=y[0],y[2]
print(t[0])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> v(n+1);
	for(int i=1;i<=n;i++) {
		int t;
		cin>>t;
		v[i] = t;
	}
	int ans = 0;
	for(int i=1;i<=n-1;i++) {
		if(v[i]==i) {
			int t;
			t = v[i];
			v[i] = v[i+1];
			v[i+1] = t;
			ans++;
		}
	}
	if(v[n]==n) {
		int t;
		t = v[n];
		v[n] = v[n-1];
		v[n-1] = t;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
# 提出結果　
# n 料理の種類
# a 料理名
# b 満足度
# c 料理 a + 1を食べた時の満足度

n = gets.chomp.to_i
a_foods = gets.chomp.split(" ").map(&:to_i)
b_sfn = gets.chomp.split(" ").map(&:to_i)
c_bonus_sfn = gets.chomp.split(" ").map(&:to_i)

return if n < 2 || 21 < n

total_sfn = 0
one_of_just_before = -1

a_foods.each_with_index do |a, index|
  total_sfn += b_sfn[a-1]
  total_sfn += c_bonus_sfn[one_of_just_before-1] if one_of_just_before == a - 1
  one_of_just_before = a
  # p("追加ポイント: #{b_sfn[one_of_just_before-1]}")
  # p("総和: #{total_sfn}")
  # p("before_one: #{one_of_just_before}")
end

p total_sfn

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

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

const int INF = 1<<29;

int dp[201][201];
int T[201];
int A[201], B[201], C[201];

int main(){
	int D, N;
	cin >> D >> N;
	rep(i, D) cin >> T[i];
	rep(i, N) cin >> A[i] >> B[i] >> C[i];

	memset(dp, -1, sizeof(dp));
	rep(i, D){
		rep(j, N){
			if(A[j] > T[i] || B[j] < T[i]) continue;
			if(i == 0){
				dp[i][j] = 0;
			}else{
				rep(k, N){
					if(dp[i-1][k] == -1) continue;
					dp[i][j]= max(dp[i][j], dp[i-1][k]+abs(C[j]-C[k]));
				}
			}
		}
	}
	cout << *max_element(dp[D-1], dp[D-1]+201) << endl;

    return 0;
}

Measured memory_bytes: 1328
#include<cstdio>
#include<algorithm>
#define NIL -1
using namespace std;

int countp, A[101], B[101];

int linearSearch(int S[], int key){
	int i = 0;
	while(S[i] != key)
		i++;
	return i;
}

void reconstruction(int l, int r){
	int c = 200, m, i;
	if(l >= r)
		return;
	for(i = l;i < r;i++)
		c = min(c, linearSearch(A, B[i]));
	m = linearSearch(B, A[c]);
	reconstruction(l, m);
	reconstruction(m + 1, r);
	if(countp)
		printf(" ");
	countp++;
	printf("%d", A[c]);
}

int main(void){
	int n, i;
	scanf("%d", &n);
	for(i = 0;i < n;i++)
		scanf("%d", &A[i]);
	for(i = 0;i < n;i++)
		scanf("%d", &B[i]);
	reconstruction(0, n);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2740
from collections import deque
 
N, *AB = map(int, open(0).read().split())
 
E = [set() for _ in range(N + 1)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a].add((b, i))
    E[b].add((a, i))
K = max(len(e) for e in E)
A = [0] * (N - 1)
Q = deque([(-1, 1)])
while Q:
    p, v = Q.popleft()
    C = (c for c in range(1, K + 1) if c != p)
    for u, i in E[v]:
        E[u].remove((v, i))
        c = next(C)
        Q.append((c, u))
        A[i] = c
 
print(K)
for a in A:
    print(a)

Measured memory_bytes: 107536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	int n;
	string t, s;
	cin >> n >> t >> s;
	string sum;

	for (int i = 0; i < n; i++) {
		sum += t[i];
		sum += s[i];
	}

	printf("%s", sum.c_str());

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    string S;
    cin >> S;
    if((int)S.size() % 2 == 0){
        for(int i = 0; i < (int)S.size(); i++){
            if(i % 2 == 0){
                if(S[i] != 'h'){
                    cout << "No" << endl;
                    return 0;
                }
            }
            else{
                if(S[i] != 'i'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }

        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <numeric>

using namespace std;

vector<int> parent, urank;

int root(int x) { return (parent.at(x) == x ? x: parent.at(x) = root(parent.at(x))); }

bool in_same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
        if (urank.at(x) < urank.at(y)) parent.at(x) = y;
        else {
            parent.at(y) = x;
            if (urank.at(x) == urank.at(y)) ++(urank.at(x));
        }
    }
}

int main() {
    int n, m, ans = 0;
    scanf("%d%d", &n, &m);
    vector< pair<int, int> > d(m);
    parent.resize(n + 1);
    urank.resize(n + 1);
    for (int i = 0; i < m; ++i) scanf("%d%d", &d.at(i).first, &d.at(i).second);
    for (int i = 0; i < m; ++i) {
        iota(parent.begin(), parent.end(), 0);
        fill(urank.begin(), urank.end(), 0);
        for (int j = 0; j < m; ++j) {
            if (i == j) continue;
            unite(d.at(j).first, d.at(j).second);
        }
        if (!in_same(d.at(i).first, d.at(i).second)) ++ans;
    }
    printf("%d\n", ans);
    return 0;
}


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

#define MAX_N 200000

int n;
int a[MAX_N] = {0};

void solve(){
    deque<int> di;
    for(int i = 0; i < n; ++i){
        if(i % 2 == 0){
            di.push_back(a[i]);
        }else{
            di.push_front(a[i]);
        }
    }
    if(n % 2 == 1){
        for(int i = n-1; i>=1; i--){
            cout << di[i] << " ";
        }
        cout << di[0] << "\n";
    }else{
        for(int i = 0; i < n-1; ++i){
            cout << di[i] << " ";
        }cout << di[n-1] << "\n";
    }
    return ;
}


int main(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    solve();
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

long long bellmanFord(const WGraph &G, const int s, const int t) {
    int N = (int)G.size();
    std::vector<long long> dis(N, LINF);

    // seek shortest path
    dis[s] = 0;
    for (int i=0; i<N-1; ++i) {
        for (int j=0; j<N; ++j) {
            for (auto e : G[j]) {
                if (dis[e.first] > dis[j] + e.second) dis[e.first] = dis[j] + e.second;
            }
        }
    }

    // find negative loop
    for (int i=0; i<N; ++i) {
        for (int j=0; j<N; ++j) {
            for (auto e : G[j]) {
                if (dis[e.first] > dis[j] + e.second) {
                    if (e.first == t) return -LINF;
                    dis[e.first] = dis[j] + e.second;
                }
            }
        }
    }

    return dis[t];
}

void solve() {
    int N, M;
    cin >> N >> M;
    WGraph G(N);
    for (int i=0; i<M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a-1].push_back({b-1, -c});
    }

    ll res = -bellmanFord(G, 0, N-1);
    if (res == LINF) cout << "inf" << '\n';
    else cout << res << '\n';
}

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

    solve();

    return 0;
}


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

int main(void) {
    int N; cin >> N;
    int ans = N/2;
    if(ans*2 < N) ans +=1;
    cout << ans << endl;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int n,m,ans=1e18,a[10005];

signed main()
{
	n=read();
	for ( int i=1;i<=n;i++ ) a[i]=read();
	for ( int i=1;i<=100;i++ ) 
	{
		int sum=0;
		for ( int j=1;j<=n;j++ ) 
			sum+=(a[j]-i)*(a[j]-i);
		ans=min(ans,sum);
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

    int y = x;

    int sum = 0;
    while(y>0){
        sum += y%10;
        y /= 10;
    }

    if(x%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, q;
	int cnt = 0;
	int s[10000] = { 0 };
	int t[500] = { 0 };
	int i, j;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &s[i]);
	}
	
	scanf("%d",&q);

	for (i = 0; i < q; i++) {
		scanf("%d", &t[i]);
		for (j = 0; j < i ;j++) {
			if (t[i] == t[j]) {
				i--;
				break;
			}
		}
	}

	for (i = 0; i < q ; i++) {
		for (j = 0; j < n ;j++) {
			if (t[i] == s[j]) {
				cnt++;
				break;
			}
		}
	}

	printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 2104
n, t = [int(w) for w in input().split()]
lt = [int(w) for w in input().split()]

s_on = lt[0]
end = s_on+t
ans = t
for _t in lt[1:]:
    if _t <= end:
        ans += _t+t-end
    else:
        ans += t
    end = _t+t

print(ans)


Measured memory_bytes: 30752
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double h_deg = 0.5 * M + 30.0 * H;
    double m_deg = 6.0 * M;

    double deg = min(abs(h_deg - m_deg), 360.0 - abs(h_deg - m_deg));
    // cout << deg << endl;

    double ans = sqrt(A * A + B * B - 2 * A * B * cos(deg * (M_PI / 180.0)));

    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}

Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	long long sum=(n*(2*l+(n-1)))/2;
	int a, min=999999;
	long long ans=0;
	for(int i=0;i<n;++i){
		long long x=l+i;
		long long sum1=sum-x;
		a=(abs(sum-sum1));
		if(a<min){
			ans=sum1;
			min=a;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
t = [0] + list(map(int, input().split()))

ans = 0

for i in range(2, N+1):
    dif_t = t[i] - t[i-1]
    if dif_t > T:
        ans += T
    else:
        ans += dif_t

ans += T
print(ans)


Measured memory_bytes: 25196
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
inline int read() {
    int x=0;
    char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}

const int N=1e5+10;
struct Item {
    bool operator<(const Item&t)const {
        return v<t.v;
    }
    int v,id;
};
Item a[N],b[N];
int n;
bool check()
{
    for(int i=0;i<n-1;++i)
        if(a[i+1].v<=b[i].v)
            return true;
    int cnt=1;
    int st=0;
    int nex=a[0].id;
    while(nex!=st)
    {
        ++cnt;
        nex=a[nex].id;
    }
    if(cnt==n)
        return false;
    return true;
}

int main() {

    n=read();
    for(int i=0; i<n; ++i)
        a[i].v=read();

    for(int i=0; i<n; ++i) {
        b[i].v=read();
        b[i].id=i;
    }
    sort(b,b+n);
    for(int i=0;i<n;++i)
        a[b[i].id].id=i;
    sort(a,a+n);

    bool flag=true;
    for(int i=0; i<n; ++i)
        if(a[i].v>b[i].v) {
            flag=false;
            break;
        }
    if(flag)
    {
        if(check())
            puts("Yes");
        else puts("No");
    }
    else puts("No");

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int A, B, C, D;
   cin >> A >> B >> C >> D;
   cout << min(A, B) + min(C, D) << endl;
   return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type UnionFind struct {
	par  []int // parent
	rank []int // height of the tree
}

func (u *UnionFind) Init(n int) {
	u.par = make([]int, n)
	u.rank = make([]int, n)
	for i := range u.par {
		u.par[i] = i
	}
}

func (u *UnionFind) Find(x int) int {
	// x is the root of the tree
	if u.par[x] == x {
		return x
	}
	u.par[x] = u.Find(u.par[x])
	return u.par[x]
}

func (u *UnionFind) Same(x, y int) bool {
	return u.Find(x) == u.Find(y)
}

func (u *UnionFind) Unite(x, y int) {
	x = u.Find(x)
	y = u.Find(y)
	if x == y {
		return
	}

	if u.rank[x] < u.rank[y] {
		u.par[x] = y
	} else {
		u.par[y] = x
		if u.rank[x] == u.rank[y] {
			u.rank[x]++
		}
	}
}

func main() {
	var n, q int
	fmt.Scan(&n, &q)
	var u UnionFind
	u.Init(n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < q; i++ {
		sc.Scan()
		c, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		y, _ := strconv.Atoi(sc.Text())
		if c == 0 {
			u.Unite(x, y)
		} else {
			if u.Same(x, y) {
				fmt.Println(1)
			} else {
				fmt.Println(0)
			}
		}
	}
}



Measured memory_bytes: 2428
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

// UnionFind {{{
struct UnionFind {
    vector<int> tree;
    explicit UnionFind(size_t n) : tree(n + 5, -1) {}

    int size(int i) { return (-tree[root(i)]); }

    int root(int x) { return (tree[x] < 0) ? x : tree[x] = root(tree[x]); }

    bool same(int x, int y) { return root(x) == root(y); }

    bool unite(int x, int y) {
        return (x = root(x)) == (y = root(y)) ? false : (tree[x] += tree[y], tree[y] = x, true);
    }
};
// }}}

size_t N, M;
auto g = make_v(false, 50, 50);
vector<bool> seen;

void dfs(size_t now_node) {
    seen[now_node] = true;
    for (size_t node = 0; node < N; ++node) {
        if (!seen[node] && g[now_node][node]) {
            dfs(node);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> M;

    vector<size_t> a(M), b(M);
    for (size_t i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }

    size_t res = 0;
    for (size_t i = 0; i < M; ++i) {
        g[a[i]][b[i]] = g[b[i]][a[i]] = false;
        seen.assign(N, false);
        dfs(0);
        for (size_t node = 0; node < N; ++node) {
            if (!seen[node]) {
                res++;
                break;
            }
        }
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
if A < B:
    B = A
if B < C:
    C = B
if C < D:
    D = C
if D < E:
    E = D
print(5 + (N - 1) // E)


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

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

bool has_key_using_count(map<char, char> &m, char n){
    if (m.count(n) == 0){
        return false;
    }
    else{
        return true;
    }
}

int main()
{
	//ifstream cin("sample.txt");

	int n = 4, sumA = 0, sumB = 0, t = 0, ans = 0;
	
	rep(i, n) {
		cin >> t;
		sumA += t;
	}
	rep(i, n) {
		cin >> t;
		sumB += t;
	}

	ans = (sumA >= sumB ? sumA : sumB);
	//cout << ans << endl;
	std::cout << ans << endl;

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a = n % 10;
    if (a == 3) { 
        cout << "bon" << endl;
    } else if (a == 0 || a == 1 || a == 6 || a == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    return 0;
}

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

using namespace std;

string s;
typedef pair<int,string> P;

bool is_palindrome(const string &str){
  int size = str.size();
  for(int i = 0 ; i < size/2 ; i++){
    if(str[i] != str[size-i-1]) return false;
  }
  return true;
}

bool check(string a,string b){
  int alen = a.size(),blen = b.size();
  if(alen % 2 && blen % 2 == 0) return true;
  if(alen % 2 == 0 && blen % 2) return true;
  if(alen == blen) return true;
  if(alen > blen) swap(a,b),swap(alen,blen);
  int p = 0;
  while(true){
    if(p*2+alen == blen) break;
    p++;
  }
  for(int i = p ; i < p+alen ; i++){
    if(a[i-p] != b[i]) return true;
  }
  return false;
}

int main(){
  string in;
  while(getline(cin,in)){
    int size;
    set<P> st;
    set<string> ans;
    s.clear();
    
    for(int i = 0 ; i < (int)in.size() ; i++){
      if(isalpha(in[i])){
        s += toupper(in[i]);
      }
    }
    size = s.size();
    for(int i = 0 ; i < size ; i++){
      for(int j = size ; j > i ; j--){
        string str = s.substr(i,j-i);
        if(is_palindrome(str) && j-i >= 3){
          st.insert(P(str.size(),str));
        }
      }
    }
    bool ok[1145] = {false};
    int ii,jj;
    set<P>::iterator i,j;
    for(ii = 0,i = st.begin() ; i != st.end() ; ++i,++ii){
      for(jj = 0,j = st.begin() ; j != st.end() ; ++j,++jj){
        if(i == j) continue;
        if(!check(i->second,j->second)){
          if(i->first > j->first){
            ok[jj] = true;
          }else{
            ok[ii] = true;
          }
        }
      }
    }
    for(ii = 0,i = st.begin() ; i != st.end() ; ++i,++ii){
      if(ok[ii]) continue;
      ans.insert(i->second);
    }
    bool flg = false;
    set<string>::iterator k;
    for(k = ans.begin() ; k != ans.end() ; ++k){
      if(flg) cout << " ";
      flg = true;
      cout << *k;
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
    int K, ans;
    
    cin >> K;
    
    if(K % 2 == 0)
        ans = (K / 2) * (K / 2);
    else
        ans = (K + 1) / 2 * (K - 1) / 2;
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
#a = x1 b = x2 c = y1 d = y2
x_dis = c-a
y_dis = d-b
A = c-y_dis
B = d+x_dis
C = a-y_dis
D = b+x_dis
print(A,B,C,D)

Measured memory_bytes: 3060
#shell sort
import math
count = 0


def printout(array, n):
    output = ""
    for i in range(n - 1):
        output += str(array[i]) + " "
    output += str(array[n - 1])
    print(output)


def insertionSort(A, n, g):
    global count
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j+g] = v


def shellSort(A, n):
    a = 1
    G = []
    while a <= n:
        G.append(a)
        a = 3*a + 1
    G.reverse()
    m = len(G)
    print(m)
    printout(G,m)
    for i in range(m):
        insertionSort(A, n, G[i])
    print(count)
    for i in range(n):
        print(A[i])


N = int(input())
array = []
for i in range(N):
    array.append(int(input()))
shellSort(array,N)


Measured memory_bytes: 45588
(* O(n) *)
Scanf.scanf " %d" @@ fun n ->
  let g = Array.make n [] in
  for _ = 1 to n - 1 do
    Scanf.scanf " %d %d %d" @@ fun u v w ->
      let u, v = u - 1, v - 1 in
      g.(u) <- (v, w mod 2) :: g.(u);
      g.(v) <- (u, w mod 2) :: g.(v);
  done;
  let cs = Array.make n 0 in
  let rec dfs v p c =
    cs.(v) <- c;
    let f (v2, w) = if v2 <> p then dfs v2 v @@ c lxor w in List.iter f g.(v) in
  dfs 0 (-1) 0;
  cs |> Array.iter @@ Printf.printf "%d\n"

Measured memory_bytes: 20224
S = input()
N = len(S)
A = [0]*N
BC = [0]*N
count = 0
i = 0
while i < N:
  if S[i] == "A":
    A[count] += 1
    i += 1
  elif i<N-1 and  S[i] == "B" and S[i+1] == "C":
    BC[i] += A[count]
    i += 2
  else:
    count += 1
    i += 1
print(sum(BC))

Measured memory_bytes: 44000
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    X = iRaw()

        
    print((360)//math.gcd(X,360))




main()


Measured memory_bytes: 67504
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll k;
    cin >> k;
    rep(i, k) cout << "ACL";
    cout << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int k,x;
signed main(){
    cin>>k>>x;
    if(500*k>=x)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256