akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
int f(std::string &s,int a, int b, int c){
	int i=s[a];
	return ((i!='s'&&i==s[b]&&i==s[c])?i:0);
}
int main(){
	std::string s;
	int i,j;
	while(getline(std::cin,s)){
		char c=(f(s,0,4,8)||f(s,2,4,6))?s[4]:0;
		if(!c){
			for(i=0;i<3;i++){
				c=f(s,i,i+3,i+6);
				if(c)break;
				j=i*3;
				c=f(s,j,j+1,j+2);
				if(c)break;
			}
			if(!c)c='d';
		}
		std::cout<<c<<"\n";
	}
}

Measured memory_bytes: 1164
m,d = map(int,input().split())
if len(str(d)) == 2:
	d1,d2 = str(d)[0],str(d)[1]

cnt = 0
m_list = [i+1 for i in range(m)]

if len(str(d)) == 2:
  for i in range(d+1):
    
    if i >= 20:
      d1,d2 = str(i)[0],str(i)[1]
      if d1=='1' or d2=='1':
        continue
      if int(d1)*int(d2) in m_list:
        cnt += 1
print(cnt)
    

Measured memory_bytes: 3064
use proconio::input;
fn main() {    
    input!{
        n: usize,
        a: [usize; n]
    }
    let mut m = vec![-1; n];
    (1..n).try_fold(a[0], |i, j| {
        if m[i-1] != -1 {None} else{
            m[i-1] = j as i32;
            Some(a[i-1])
        }        
    });
    println!("{}", m[1]);

}


Measured memory_bytes: 3864
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            System.out.println(a + b + c);
        }
    }
}



Measured memory_bytes: 26196
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    if (n == 1) {
      System.out.println("Hello World");
    } else {
      int a = sc.nextInt();
      int b = sc.nextInt();
      System.out.println(a + b);
    }

  }
}

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

int main()
{
  i64 n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  vector<i64> edge[n];
  for (i64 i = 0; i < n - 1; i++)
  {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  queue<i64> que;
  vector<i64> ufar(n, 1e9), vfar(n, 1e9);
  ufar[u] = 0;
  que.push(u);
  while (que.size())
  {
    i64 p = que.front();
    que.pop();
    for (i64 i : edge[p])
      if (ufar[p] + 1 < ufar[i])
      {
        ufar[i] = ufar[p] + 1;
        que.push(i);
      }
    if (ufar[p] == 0)
      ufar[p] = 1e9;
  }
  vfar[v] = 0;
  que.push(v);
  while (que.size())
  {
    i64 p = que.front();
    que.pop();
    for (i64 i : edge[p])
      if (vfar[p] + 1 < vfar[i])
      {
        vfar[i] = vfar[p] + 1;
        que.push(i);
      }
  }
  i64 ans = vfar[u] / 2;
  for (i64 i = 0; i < n; i++)
  {
    if (ufar[i] < vfar[i])
      ans = max(ans, vfar[i] - 1);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i,n) cin >> a[i];
   sort(a.rbegin(),a.rend());

   ll ans=0;
   int t = n-1;
   rep(i,n){
      int lim = 2;
      if(i==0) lim=1;
      rep(j,lim){
         if(t>0){
            ans += a[i];
            t--;
         }
      }
   }
   cout << ans << endl;
   return 0;  
}

Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int num[]={0,2,5,5,4,5,6,3,7,6};
string judge(string s,string t,char p){
  if(t==".")return s;
  t+=p;
  string res=t;
  int n=s.length();
  int m=t.length();
  bool ss=n>m;
  if(n!=m){
    if(ss)res=s;
    return res;
  }
  rep(i,n){
    if(s[i]==t[i])continue;
    else{
      ss=s[i]>t[i];
      goto FINE;
    }
  }
  FINE:
  if(ss)res=s;
  return res;
}
signed main(){
  int n,m;cin>>n>>m;
  vector<int> a(m);
  rep(i,m)cin>>a[i];
  vector<string> dp(n+1,".");
  vector<pair<int,int>> input(m);
  rep(i,m){
    input[i].second=num[a[i]];
    input[i].first=a[i];
  }
  sort(input.begin(),input.end());
  reverse(ALL(input));
  dp[0]='0';
  rep(i,m){
    rep(j,n+1){
      if(j<input[i].second)continue;
      dp[j]=judge(dp[j],dp[j-input[i].second],(char)(input[i].first+'0'));
    }
  }
  int num=dp[n].length()-1;
  string res;
  rep1(i,num){
    res+=dp[n][i];
  }
  //sort(res.begin(),res.end());
  //reverse(ALL(res));
  //cout<<dp[n]<<"\n";
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 45184
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,x; cin >> n >> x;
	vector<int> a(n);
	cinf(n,a);
	ll ans=0;
	if(a[0]> x){
		ans+=a[0]-x;
		a[0]=x;
	}
	for(int i=0;i<n-1;i++){
		if(a[i+1]+a[i]>x){
			ans+=a[i+1]+a[i]-x;
			a[i+1]=x-a[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int sheep =s.nextInt();
        int wolf=s.nextInt();
        if(sheep>wolf){
            System.out.println("safe" );
        }else {
            System.out.println("unsafe");
        }
    }
}

Measured memory_bytes: 35692
#!/usr/bin/env python3
import math

x_org, k, d = map(int, input().split())

x = abs(x_org)
ans = 0 

def a(n):
    global x
    global d
    ret = x-d*(n-1)
    return ret 

n = x//d
l = math.floor(n)
r = l+1 

if n > k:
    ans = abs(x-k*d)
    print(ans)
    exit()

if (x//d)%2 == k%2:
    ans = abs(x-d*l)
    print(ans)
    exit()
else:
    ans = abs(x-d*r)
    print(ans)
    exit()


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

if a <= 0 and b >= 0:
  print('Zero')

if a > 0:
  print('Positive')
  
if b < 0:
  if (a - b + 1) % 2 == 0:
    print('Positive')
  else:
    print('Negative')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	string str;
	rl(n);
	cin>>str;
	if(n<3200)
		cout<<"red"<<endl;
	else
		cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main implements Runnable{
    
    private void solve()throws IOException{
        int h=nextInt();
        int w=nextInt();
        int n=nextInt();
        out.println((int)(Math.ceil(1.0d*n/max(h,w))));
    }

     
    ///////////////////////////////////////////////////////////

    final long mod=(long)(1e9+7);
    final int inf=(int)(1e9+1);
    final int maxn=(int)(1e6);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    } 
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 21076
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n,ans=0;cin>>n;
  map<ll,ll> m;
  rep(i,0,n){
    ll a;cin>>a;
    m[a]++;
  }
  for(auto x:m){
    if(x.second%2){
      ans++;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 9876
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
int read()
{
	int ret=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret;
}
char s[105];
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	scanf("%s",s);
	int ans=0x3f3f3f3f,len=strlen(s);
	for(char i='a';i<='z';i++)
	{
		int pos=-1,tempans=0;
		for(int j=0;j<len;j++)
		{
			if(s[j]==i)
			{ 
				tempans=max(j-pos-1,tempans);
				pos=j;
			}
		}
		tempans=max(len-pos-1,tempans);
		ans=min(ans,tempans);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 256
def check(graph,seen,now):
    seen[now] = True 
    for i in range(len(graph[now])):
        if seen[i] :
            continue
        if graph[now][i] == 0 :
            continue
        check(graph,seen,i)
    return seen


#入力
N,M = map(int,input().split())
para = [[i for i in map(int,input().split())] for j in range(M)]
graph =[[0 for i in range(N)] for  j in range(N)]
for i in range(M):
    graph[para[i][0]-1][para[i][1]-1] = 1
    graph[para[i][1]-1][para[i][0]-1] = 1 

#seen = [False]*(N)
ans = 0
for i in range(M):
    seen = [False]*(N)
    graph[para[i][0]-1][para[i][1]-1] = 0
    graph[para[i][1]-1][para[i][0]-1] = 0
    if False in check(graph,seen,0):
        ans += 1
    graph[para[i][0]-1][para[i][1]-1] = 1
    graph[para[i][1]-1][para[i][0]-1] = 1 

print(ans)


Measured memory_bytes: 3188
n=int(input())
h=list(map(int,input().split()))

dp=[float('inf')]*n
dp[0]=0#初期条件を設定

for i in range(1,n):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    #i=1の時i-2<0となるので先にここを計算する
    if i>=2:
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
        
print(dp[-1])

Measured memory_bytes: 13980
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define _max(_x, _y) ((_x)>(_y)?(_x):(_y))
#define _min(_x, _y) ((_x)>(_y)?(_y):(_x))

int main(void)
{
  char S[100000];
  int diff = 0;
  int same = 0;
  int len, index;
  scanf("%s", &S);
  len = strlen(&S);

  for (index = 0; index < len; ++index) {
    if (S[index]-0x30 == index % 2) {
      same++;
    } else {
      diff++;
    }
  }
  printf("%d\n", _min(same, diff));

  return 0;
}

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

int main(){
	int days;
	string season;//文字変数にseasonを設定
	cin >> season;//seasonに3つ入力する
	bool p = season[0] == 'R';//season[0]がRならtrueを返す_bool型はtrue or false
	bool q = season[1] == 'R';
	bool r = season[2] == 'R';

	if(p and q and r){//p,q,r全てがtrueなら
		cout << 3 << endl;
	}else if((p and q) or (q and r)){//p,qまたはq,rがtrueなら
		cout << 2 << endl;
	}else if(p or q or r){//p,q,rいずれか1つだけがtrueなら
		cout << 1 << endl;
	}else{//上記までのifを満たさない場合
		cout << 0 << endl;
	}
	
	return 0;

}

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

int main() {
  vector<int> A(3);
  for (int i = 0; i < 3; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  cout << A.at(0) * A.at(1) / 2 << "\n";
}

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

typedef long long ll;

int N, M;
int V[100010];
vector<int> adj[100010];

int vis[100010];
vector<multiset<int> > Comp;

void dfs(int u) {
    vis[u] = 1;
    Comp.back().insert(V[u]);

    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(vis[v]) continue;
        dfs(v);
    }
}

vector<int> ord;
ll ans = 0;

int main() {
    scanf("%d %d", &N, &M);

    for(int i = 0; i < N; i++) {
        scanf("%d", &V[i]);
    }

    for(int i = 0; i < M; i++) {
        int u, v; scanf("%d %d", &u, &v);

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    for(int i = 0; i < N; i++) if(!vis[i]) {
        Comp.push_back(multiset<int>());
        dfs(i);
    }

    if(Comp.size() == 1) {
        printf("0");
        return 0;
    }

    int sum = 0;
    for(int i = 0; i < Comp.size(); i++) {
        sum += Comp[i].size();
    }

    if(sum < 2 * ((int)Comp.size() - 1)) {
        printf("Impossible");
        return 0;
    }

    ll ans = 0;
    for(int i = 0; i < Comp.size(); i++) {
        ans += *Comp[i].begin();
        Comp[i].erase(Comp[i].begin());

        while(Comp[i].size()) {
            ord.push_back(*Comp[i].begin());
            Comp[i].erase(Comp[i].begin());
        }
    }

    sort(ord.begin(), ord.end());

    for(int i = 0; i < (int)Comp.size() - 2; i++) {
        ans += ord[i];
    }

    printf("%lld", ans);
}


Measured memory_bytes: 15280
import sys
alpha = "abcdefghijklmnopqrstuvwxyz"
dic = {c:0 for c in alpha}

t = sys.stdin.read()
for s in t:
    s = s.lower()
    if s in alpha :
        dic[s] += 1

for key in sorted(dic):
    print("{} : {}".format(key,dic[key]))

Measured memory_bytes: 7436
#include <stdio.h>

long max(long a,long b);
int main(){
	long n,w,i,j;
	scanf("%ld %ld",&n,&w);
	long dp[n+10][w+10];//short,mass
	for(i=0;i<=w;i++){
		dp[0][i]=0;
	}
	long wight[n+10];
	long value[n+10];
	for(i=1;i<=n;i++){
		scanf("%ld %ld",&wight[i],&value[i]);
		for(j=0;j<=w;j++){
			dp[i][j]=dp[i-1][j];//基本は1つ前の値
			if( j >= wight[i]){
				dp[i][j]=max(dp[i-1][j- wight[i]]+ value[i], dp[i][j]);//重さを足してもオーバーしなければ小さい方に
			}
		}
	}
	/*
	for(i=0;i<=n;i++){
		for(j=0;j<=w;j++){
			printf("%9ld ",dp[i][j]);
		}
		printf("\n");
	}
	*/	
	
	printf("%ld\n",dp[n][w]);
	return 0;
}
long max(long a,long b){
	if(a <b){
		return (b);
	}else{
		return (a);
	}
}

Measured memory_bytes: 80896
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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


ll dist[2600];
int main()
{
  ll N, M, P; cin >> N >> M >> P;
  vector<vector<pair<ll, ll>>> v(N);
  REP(i, M) {
    ll a, b, c; cin >> a >> b >> c;
    a--; b--;
    v[a].PB(MP(b, c-P));
  }

  REP(i, 2600) dist[i] = -LLINF;
  dist[0] = 0;
  REP(i, N - 1) {
    REP(j, N) {
      if (dist[j] == -LLINF) continue;
      for (auto e : v[j]) {
        if (dist[e.first] < dist[j] + e.second) {
          dist[e.first] = dist[j] + e.second;
        }
      }
    }
  }

  vector<bool> ng(N, false);
  REP(i, N - 1) {
    REP(j, N) {
      if (dist[j] == -LLINF) continue;
      for (auto e : v[j]) {
        if (dist[e.first] < dist[j] + e.second) {
          dist[e.first] = dist[j] + e.second;
          ng[e.first] = true;
        }
        if (ng[j]) ng[e.first] = true;
      }
    }
  }
  if (ng[N-1]) cout << "-1" << endl;
  else cout << max(0LL, dist[N-1]) << endl;

  return 0;
}


Measured memory_bytes: 512
n, *a = map(int, open(0).read().split())

def gcd(p, q):
    if p % q == 0:
        return q
    else:
        return gcd(q, p % q)
cd = a[0]
for i in range(n - 1):
    cd = gcd(cd, a[i + 1])
print(cd)

Measured memory_bytes: 14052
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	map<string, ll>mp;
	ll n;
	string s[114514];
	cin >> n;
	bool f = 1;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		mp[s[i]]++;
		if (mp[s[i]] == 2)f = 0;
		if (i){
      if (s[i - 1][s[i - 1].size() - 1] != s[i][0])f = 0;
	   }
}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5+7;
string s1, s2;
int r[300],vis[300];
int no(){std::cout << "No" << '\n';return 0;}
int main(){
   std::cin >> s1 >> s2;
   memset(r, -1, sizeof r);
   // printf("set %c to %c\n", s1[i], s2[i]);
   for(int i = 0; i<(int)s1.size(); i++){
     if(r[s1[i]]==-1) {
       if(vis[s2[i]]) return no();
       r[s1[i]] = s2[i];vis[s2[i]]=1;
     }
     else if(r[s1[i]]!=s2[i]){
       return no();
     }
   }
   std::cout << "Yes" << '\n';
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}


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

	int k, x; cin >> k >> x;
    int cnt = 0;
    for(int i=max(-1000000, x-k+1); i<=min(x+k-1, 1000000); ++i){
        if(cnt) cout << " ";
        cout << i;
        ++cnt;
    }
    cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	for(int i=0;i<2;i++)
		for(int j=i+1;j<3;j++)
			if(a[i]<a[j])
				swap(a[i],a[j]);
	cout<<a[0]-a[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int r, D, x;
    cin >> r >> D >> x;
    int i = 10;
    while(i) {
        int tmp = r*x - D;
        cout << tmp << endl;
        x = tmp;
        i--;
    }

    return 0;
}

Measured memory_bytes: 256
n = input()
t = len(n)+1
dp1 = [0] * t
dp2 = [0]*t
dp2[0] = 1

for i in range(t-1):
    x = int(n[i])
    dp1[i + 1] = min(dp1[i] + x, dp2[i] + 10 - x)
    x += 1
    dp2[i+1] = min(dp1[i]+x, dp2[i]+10-x)
print(dp1[-1])

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

int main() {

    ll N, K;
    cin >> N >> K;
    ll t =  N % K;
    cout << min(t, K - t) << endl;
    return 0;
}

Measured memory_bytes: 3636
// Sat May  2 17:37:17 IST 2020         
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353 
#define pb                 push_back
#define f1                 first 
#define s1                 second    
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()
const double pi=3.141592653589793238;
using namespace std ;     
using namespace __gnu_pbds;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
// const int N = 2e5; 
const int INF = 2e9;
int tests(){
    int64 n;
    int64 A,B;
    cin >> A >> B ;
    cin >> n ;
    // for(int i = 1 ; i <= 10 ; i++ ){
    //     cout << i << ' ' << (A*i)/B-A*(i/B) << " | "; 
    //     cout << (i+10) << ' ' << (A*(i+10))/B-A*((i+10)/B) << " | ";
    //     cout << (i+20) << ' ' << (A*(i+20))/B-A*((i+20)/B) << " | "; 
    //     cout << (i+30) << ' ' << (A*(i+30))/B-A*((i+30)/B) << " | "; 
    //     cout << (i+40) << ' ' << (A*(i+40))/B-A*((i+40)/B) << "\n";    
    // }   
    int64 x = min(B-1,n);
    cout << (A*x)/B-A*(x/B) << '\n';
    return 0;
}   
int32_t main(){
    I__O ;    
    int cases = 1 ; 
    // cin >> cases ; 
    forn(iii,1,cases+1){   
        // cout << "Case #" << iii << ": ";
        tests(); 
    }
    return 0 ; 
}
 
// -Wall -Wextra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long A[100];
    
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    
    sort(A,A+N);
    
    
    cout << A[N-1]-A[0] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define int long long
const int N=1e6+5;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int n,m,a[N];
vector<int>g[N];
void dfs(int u,int fa)
{
	for(int i=0;i<g[u].size();i++)
	{
		int v=g[u][i];
		if(v==fa)continue;
		a[v]+=a[u];
		dfs(v,u);
	}
}
signed main()
{
	n=read();m=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		g[x].push_back(y);
		g[y].push_back(x);
	}
	while(m--)
	{
		int x=read(),y=read();
		a[x]+=y;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)printf("%lld ",a[i]);
}

Measured memory_bytes: 44672
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

void jump(int index, int K, const vector<int> &pillar, vector<int> &dp, const int int_max = INT32_MAX) {
	if (index == 0) {
		dp[0] = 0;
		return;
	}
	// 実装エラー
	if (index == pillar.size()) {
		cout << "implementation error" << endl;
		return;
	}
	int begin_index = max(index - K, 0);
	int end_index = index;
	dp[index] = int_max;
	for (int i = begin_index; i < end_index; ++i) {
		dp[index] = min(dp[index], dp[i] + abs(pillar[index] - pillar[i]));
	}
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> pillar(N, 0);
	for (int i = 0; i < N; ++i) {
		cin >> pillar[i];
	}
	vector<int> dp(N, 0);
	for (int i = 0; i < N; ++i) {
		jump(i, K, pillar, dp);
	}
	cout << dp[N - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   N : Integer;
   Ans : Integer;
begin
   Get (N);
   Ans := (N+1000-1)/1000*1000-N;
   Put_Line (Integer'Image (Ans));
end Solve;

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();

		if(x < 1200){
			System.out.println("ABC");
		}
		else {
			System.out.println("ARC");
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
	double a,b;
	while(cin>>a>>b,a){
		printf("%.10f\n",(a*a)+2*a*sqrt(((a/2)*(a/2)+b*b)));
	}
}

Measured memory_bytes: 3168
#include <iostream>

using namespace std;

#define EPS (1e-8)
#define EQ(a,b) ((a) - EPS < (b) && (b) < (a) + EPS)

int p, q, a;
double lhs; // left hand side

int solve(int n, int d, int prod, double sum) {
  int cnt=0;
  for (int i=d; prod*i<=a; i++) {
    double rhs = sum + 1.0/i; // right hand side
    if (lhs < rhs - EPS) { continue; }
    if (EQ(lhs, rhs)) { cnt++; continue; }
    if (n == 1) { continue; }
    cnt += solve(n-1, i, prod * i, rhs);
  }

  return cnt;
}

int main() {
  int n;
  while (cin >> p >> q >> a >> n, (p || q || a || n)) {
    lhs = (double)p / (double)q;
    cout << solve(n, 1, 1, 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

import Debug.Trace

main :: IO ()
main = do
  [n, m] <- readInts
  g <- replicateM m $ readInts >>= (\[x, y] -> return (x-1, y-1))
  let gs = remove1 g
      remove1 [] = []
      remove1 (x:xs) = xs : map (x:) (remove1 xs)
  print $ length (filter (not . connected n) gs)

connected :: Int -> [(Int, Int)] -> Bool
connected n g = let visited = loop (True : replicate (n-1) False)
                 in all id visited
  where loop visited =
          let visited' = flip map [0..n-1] $ \w ->
                flip any g $ \(a, b) -> w `elem` [a, b] && (visited !! a || visited !! b)
          in if visited == visited' then visited else loop visited'



------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"

Measured memory_bytes: 2300
a, b, c = map(int, (input().split()))
if c - a - b < 0:
    print('No')
    exit()
l = ((a ** 2) + (b ** 2) + (c ** 2))
m = (a * b) + (a * c) + (b * c)
print('Yes' if l > 2 * m else 'No')


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

#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int V = 1e5+1;
long long dp[V][101];
int in[101][2];
int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n , w ; cin >> n >> w ;
	for(int i = 1 ; i <= n ; ++i)
		cin >> in[i][0] >> in[i][1];
	int ans ;
	for(int i = 1 ; i < V ; ++i)
		for(int j = 0 ; j < 101 ; ++j)
			dp[i][j] = INT_MAX;
	for(int i = 1 ; i < V ; ++i)
	{
		for(int j = 1 ; j <= n ; ++j)
		{	
			dp[i][j] = min(dp[i][j-1] , (i-in[j][1]>=0?(in[j][0] + dp[i-in[j][1]][j-1]) : INT_MAX));
			if(dp[i][j] <= w) ans = i;
		}
	}
	cout << ans ;
	return 0;
}

Measured memory_bytes: 79232
usrCount = int(input())
usrNumbers = input().split()
usrList = []

guusuList = []

okCount = 0

for n in range(len(usrNumbers)):
    usrList.append(int(usrNumbers[n]))

for m in range(len(usrList)):
    if usrList[m] % 2 == 0:
        guusuList.append(usrList[m])

for l in range(len(guusuList)):
    if guusuList[l] % 3 == 0 or guusuList[l] % 5 == 0:
        okCount = okCount + 1

if okCount >= len(guusuList):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
def main():
    import sys
    input = sys.stdin.buffer.readline
    H, W = (int(i) for i in input().split())
    A = [[int(i) for i in input().split()] for j in range(H)]
    ans = []
    for h in range(H):
        for w in range(W):
            if A[h][w] % 2 == 1:
                if w != W-1:
                    A[h][w] -= 1
                    A[h][w+1] += 1
                    ans.append((h+1, w+1, h+1, w+2))
                elif h != H-1:
                    A[h][w] -= 1
                    A[h+1][w] += 1
                    ans.append((h+1, w+1, h+2, w+1))

    print(len(ans))
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74844
def read():
    N = int(input().strip())
    B = list(map(int, input().strip().split()))
    return N, B


def solve(N, B):
    ans = 0
    for i in range(N):
        if i == 0:
            a = B[i]
        elif i == N-1:
            a = B[i-1]
        else:
            a = min(B[i-1], B[i])
        ans += a
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Measured memory_bytes: 9048
#include<stdio.h>
int main()
{
    long long int n,i,j,sum=0;
    scanf ("%lld",&n);
    for (i=1;i<=n;i++)
    {
        for (j=i;j<=n;j=j+i)
        {
            sum=sum+j;
        }
    }
    printf ("%lld",sum);
    return 0;

}


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

int main(){ 
  int n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
  return 0;
} 

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

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a>b) cout<<"a > b"<<endl;
    if(a<b) cout<<"a < b"<<endl;
    if(a==b) cout<<"a == b"<<endl;
    
    return 0;
}


Measured memory_bytes: 3088
s = input()

flag = 0

while(len(s)>0):
  if (s[-6:] == 'eraser'):
    s = s[:-6]
  elif (s[-5:] == 'erase'):
    s = s[:-5]
  elif (s[-7:] == 'dreamer'):
    s = s[:-7]
  elif (s[-5:] == 'dream'):
    s = s[:-5]
  else:
    flag = 1
    break

if (flag == 0):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9036
import java.util.Scanner;


	public class Main {
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] h = new int[n+1];
			int[] a = new int[m+1];
			int[] b = new int[m+1];
			boolean[] ret = new boolean[n+1];
			
			for(int i=0;i<n+1;i++) {
				ret[i]=true;
			}
			
			for(int i=1;i<=n;i++) {
				h[i] = sc.nextInt();
			}
			
			for(int i=1;i<=m;i++) {
				a[i]=sc.nextInt();
				b[i]=sc.nextInt();
			}
			
			
			
			for(int j=1;j<=m;j++) {
				if(h[b[j]]>=h[a[j]]) {
					ret[a[j]]=false;
				}
				if(h[a[j]]>=h[b[j]]) {
					ret[b[j]]=false;
				}
			}
			
			int res = 0;
			
			for(int i=0;i<n+1;i++) {
				if(ret[i]) {
					res++;
				}
			}
			
			System.out.println(res-1);
			
			
			
		}
		
		
	}


Measured memory_bytes: 61204
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;
int dp[1<<26+2];
main(){
    string ss;cin>>ss;
    int n=ss.size();

    vec s;
    rep(i,n){
        s.pb((int)(ss[i]-'a'));
    }
    int counter=0;
    rep2(i,0,n-1){
        counter^=1<<s[i];
        dp[counter]=INF;
        rep(j,26){
            dp[counter^(1<<j)]=INF;
        }
    }
    int flag=1;
    rep(i,26)if(counter&&(1<<i))flag--;
    if(flag>=0){
        cout<<1<<endl;return 0;
    }
    counter=0;
    dp[0]=0;
    rep(i,n+1){
        rep(j,26){
            int tmp=counter^(1<<j);
            dp[counter]=min(dp[counter],dp[tmp]+1);
        }
        if(i<n)
        counter^=1<<s[i];
        else
        cout<<dp[counter]<<endl;
    }
    return 0;
}



Measured memory_bytes: 265464
def main():
    s, t = input(), input()

    s_dic, t_dic = {}, {}
    for i, j in zip(s, t):
        if i in s_dic and s_dic[i] != j:
            print("No")
            exit()

        if j in t_dic and t_dic[j] != i:
            print("No")
            exit()

        s_dic[i], t_dic[j] = j, i

    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3632
import bisect
import math
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def ans(l, con):
  if con == n - 1:
    return 0
  k = bisect.bisect_right(sorted(l[con:]),l[con])
  return k*math.factorial(n - 1 - con) + ans(l, con + 1)
print(abs(ans(p, 0)-ans(q,0)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a[200005];
set<ll>s;
int main()
{
	SPEED;
	cin>>n;
	s.insert(0);
	s.insert(n+1);
	for(int i=1,x;i<=n;i++)
		cin>>x,a[x]=i;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		auto j=s.lower_bound(a[i]);
		ll R=*j;
		j--;
		ll L=*j;
		R--,L++;
		ans=ans+i*1ll*(R-a[i]+1)*(a[i]-L+1);
		s.insert(a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11264
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = min(a)+min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1]+b[y-1]-c)

print(ans)


Measured memory_bytes: 70764
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,kk;
int main()
{
	cin>>a>>b>>c;
	if(b>=a)
	{
		cout<<1<<endl;
		exit(0);
	}
	if(c>=b)
	{
		cout<<-1<<endl;
		return 0;
	}
	if((a-b)%(b-c)>=1)kk=1;
	cout<<((a-b)/(b-c)+kk)*2+1<<endl;
}

Measured memory_bytes: 256
#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)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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 K;
  cin >> K;
  cout << ((K + 1) / 2) * (K / 2) << endl;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    char a, b;
    cin >> a >> b;
    if(a == 'H'){
        if(b == 'H'){
            cout << 'H' << endl;
        }else{
            cout << 'D' << endl;
        }
    }else{
        if(b == 'H'){
            cout << 'D' << endl;
        }else{
            cout << 'H' << endl;
        }
    }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N=int(input())

A=list(map(int,input().split()))

if N==2:
    print(max(0,A[0],A[1]))
    exit()
if N==3:
    print(max(0,A[0],A[1],A[2]))
    exit()

dp=[[-10**18 for i in range(N)] for j in range(3)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]

for n in range(3):
    for index in range(N):
        if dp[n][index]!=-1:
            if n!=2 and index+3<N:
                dp[n+1][index+3]=max(dp[n+1][index+3],dp[n][index]+A[index+3])
            if n==0 and index+4<N:
                dp[n+2][index+4]=max(dp[n+2][index+4],dp[n][index]+A[index+4])
            if index+2<N:
                dp[n][index+2]=max(dp[n][index+2],dp[n][index]+A[index+2])

a=(dp[0][-1])
b=(dp[1][-1])
c=(dp[2][-1])

print(max(a,b,c))


        


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

using namespace std;
typedef vector<int> vi;

#define pb push_back
#define mp make_pair

string ispal(string str){
   if(str.length()==1) return "Yes";
   string s="";
   for(int x = str.length()-1; x>=0;x--){
      s.append(1,str[x]);
   }
   // cout<<s<<" ";
   if(s!=str) return "No";
   else 
   return "Yes";
}
int main(){
   string str;
   cin>>str;
   // cout<<str<<" ";

   if(ispal(str)=="Yes"){
      if(ispal(str.substr(0,(str.length()/2)))=="Yes" && ispal(str.substr(str.length()/2 + 1,str.length()/2)) == "Yes"){
      cout<<"Yes";
      }
      else{
      cout<<"No";
      }
   } 
   else{
      cout<<"No";
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n],b[n];
  rep(i,n) {
    R a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  ll m=n-1;
  rep(i,n) {
    if(a[i]<=b[m/2]) pr(b[m/2+1]);
    else pr(b[m/2]);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

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

    cout << a * b << endl;
    return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<pair<int,int>>> Edge;
vector<int> node;

bool bellman_ford(int n,int s) {
	node = vector<int>(n,INF);
	node[s] = 0;
	REP (i,n) {
		REP (j,Edge.size()) {
			REP (k,Edge[j].size()) {
				int from = j,to = Edge[j][k].F;
				int cost = Edge[j][k].S;
				if (node[from] != INF && node[to] > node[from] + cost) {
					node[to] = node[from] + cost;
					if (i == n - 1 && to == n - 1) return true;
				}
			}
		}
	}
	return false;
}

signed main() {
	int n;
	cin >> n;
	int odd = 0;
	int eveven = 0;
	REP (i,n) {
		int x;
		cin >> x;
		if (x % 2 == 1) {
			odd++;
		}
		if (x % 4 == 0) {
			eveven++;
		}
	}
	if ((odd + eveven == n && odd - 1 <= eveven) || odd <= eveven) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int h,w,d[2000][1001],r[2001][1002];
vec dx={0,0,1,-1},dy={1,-1,0,0};
char C[1001][1001];
queue<int> que;
void bfs(){
    while (!que.empty()) {
        int vx=que.front();
        que.pop();
        int vy=que.front();
        que.pop();
        rep(i,4) {
            int nx=vx+dx[i],ny=vy+dy[i];
            if(nx<0||nx>=h||ny<0||ny>=w||C[nx][ny]=='#'||r[nx][ny]) continue; 
            r[nx][ny]++;
            d[nx][ny]=d[vx][vy]+1;
            que.push(nx);
            que.push(ny);
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>h>>w;
    rep(i,h)rep(j,w){
        cin>>C[i][j];
        if(C[i][j]=='#') que.push(i),que.push(j);
    }
    bfs();
    int ans=0;
    rep(i,h)rep(j,w) ans=max(ans,d[i][j]);
    cout<<ans;
}

Measured memory_bytes: 16964
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,k,d;
    cin >> x >> k >> d;
    if (x<0){
        x = x*(-1);
    }
    if (x==0){
        if (k%2==0){
            cout << 0 << "\n";
        } else {
            cout << d << "\n";
        }
        return 0;
    }
    ll temp = x / d;
    ll temp2 = x - (temp*d);
    ll temp3 = temp2 - d;
    if (temp>=k){
        cout << (x - (k*d)) << "\n";
    } else {
        if ((k - temp)%2==0){
            cout << temp2 << "\n";
        } else {
            cout << -temp3 << "\n";
        }
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b;
  cin >> a >> b;
  cout << (a+b)%24 << endl;
  return 0;
}

Measured memory_bytes: 256
X=input()
idx=0
motolenx=len(X)
lenx=len(X)
scount=0
while idx<motolenx:

    if X[idx]=="S":
        scount+=1
    if X[idx]=="T" and scount>0:
        scount-=1
        lenx-=2
    idx+=1


print(lenx)


Measured memory_bytes: 3500
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

	int ans = 0;
	REP(a, 1, k+1) {
		REP(b, 1, k+1) {
			REP(c, 1, k+1) {
				int x = gcd(a, b);
				x = gcd(x, c);
				ans += x;
			}
		}
	}

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

Measured memory_bytes: 3632