akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<vector<ll>> a(n, vector<ll>(3));
	REP(i, n) cin >> a[i][0] >> a[i][1] >> a[i][2];
	vector<vector<ll>> dp(n, vector<ll>(3, 0));
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	FOR(i, 1, n) REP(j, 3) {
		REP(k, 3) {
			if(j == k) continue;
			dp[i][j] = max(dp[i][j], a[i][j] + dp[i - 1][k]);
		}
	}
	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;
	return 0;
}

/* --------------------------------------- */


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

vector<int>E[10000];
int in[10000];
bool used[10000];
int main() {
	int v, e; scanf("%d%d", &v, &e);
	rep(i, e) {
		int s, t; scanf("%d%d", &s, &t);
		E[s].push_back(t);
		in[t]++;
	}
	list<int>ls;
	queue<int>que;
	rep(i, v) {
		if (!used[i] && !in[i])que.push(i);
		while (!que.empty()) {
			int p = que.front(); que.pop();
			used[p] = true; ls.push_back(p);
			for (int u : E[p]) {
				in[u]--;
				if (!used[u] && !in[u])que.push(u);
			}
		}
	}
	for (int i : ls) {
		printf("%d\n", i);
	}
}

Measured memory_bytes: 4128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define x n
int main() {
  string s;
  cin >> s;
  
  vector<int> a(s.size()+1,0);
  int x=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='<'){
      x++;
      a.at(i+1)=x;
    }else{
      x=0;
      a.at(i+1)=x;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s.at(i)=='>'){
      x++;
      a.at(i)=max(a.at(i),x);
    }else{
      x=0;
      a.at(i)=max(x,a.at(i));
    }
  }
  
  ll int ans=0;
  for(int i=0;i<s.size()+1;i++){
    ans+=a.at(i);
  }
  cout << ans << endl;
}


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

struct edge{int s,t,n;}e[6010];
int n,h[3010],a[3010],d[3010],f[3010];
queue <int> Q;

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&a[i]);
	for (int i=1,u,v,tot=0; i<n; i++)
		{
			scanf("%d %d",&u,&v);
			e[++tot]=(edge){u,v,h[u]},h[u]=tot,d[u]+=a[u]>a[v];
			e[++tot]=(edge){v,u,h[v]},h[v]=tot,d[v]+=a[v]>a[u];
		}
	for (int i=1; i<=n; i++)  if (!d[i])  Q.push(i);
	for (int x,y,i; !Q.empty(); )
		for (i=h[x=Q.front()],Q.pop(); y=e[i].t,i; i=e[i].n)
			if (a[x]>a[y])  f[x]|=!f[y];
			else  if ((a[x]<a[y])&&(!(--d[y])))  Q.push(y);
	for (int i=1; i<=n; i++)
		if (f[i])  printf("%d ",i);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main()
{
  char *S[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  char input_s[10];
  int i, ret;

  ret = scanf("%s", input_s);
  for ( i=0; i<7; i++ ) {
    if ( strcmp(S[i], input_s) == 0 ) {
      printf("%d\n", 7-i);
      return 0;
    }
  }
}


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

int main(){

  int n,h,m,s,a;

  cin>>n;
  h=n/3600;
  a=n%3600;
  m=a/60;
  s=a%60;

  cout<<h<<":"<<m<<":"<<s<<endl;


  return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    vl s(3);
    rep(i, 3) cin >> s[i];
    sort(all(s));
    cout << s[0];
    repe(i, 1, 3) cout << " " << s[i];
    cout << endl;
}


Measured memory_bytes: 3204
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = int(1e5);
ll N, A[MAX_N];

void solve() {
    bool is_inc = false, is_dec = false;
    ll before = -1;
    ll sep = 0;
    REP(i, N) {
        if (before == -1) {

        } else if (A[i] > before) {
            if (is_dec) {
                is_dec = false;
                sep++;
            } else {
                is_inc = true;
            }

        } else if (A[i] < before) {
            if (is_inc) {
                is_inc = false;
                sep++;;
            } else {
                is_dec = true;
            }
        }
        before = A[i];
    }
    cout << sep + 1 << endl;
}

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    solve();
    return 0;
}

Measured memory_bytes: 1024
N,M=map(int,input().split())
S=input()
T=input()
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
g=gcd(N,M)
L=N*M//g
if all(S[i*N//g]==T[i*M//g]for i in range(g)):
  print(L)
else:
  print(-1)

Measured memory_bytes: 3316
n,m = [int(s) for s in input().split(' ')]
A,b,c = [],[],[]
[A.append([int(s) for s in input().split(' ')]) for i in range(n)]
[b.append(int(input())) for i in range(m)]

for Ai in A:
	ci = []
	for aij,bj in zip(Ai,b):
		ci.append(aij * bj)
	c.append(sum(ci))

[print(ci) for ci in c]

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


int main() {
  int N, D, X;
  cin >> N >> D >> X;
  
  int i = 0;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
    
  }
  
  int ans = X;
  rep(i, N) {
    ans += (D-1)/A[i] + 1;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		while (true) {
			int number = sc.nextInt();
			if (number == 0) {
				break;
			}

			int[] scores = new int[number];

			for (int i = 0; i < scores.length; i++) {
				scores[i] = sc.nextInt();
			}

			int max = 0, min = 1001;
			int maxtag = 0, mintag = 0;

			for (int i = 0; i < scores.length; i++) {
				if (scores[i] > max) {
					max = scores[i];
					maxtag = i;
				}
				if (scores[i] < min) {
					min = scores[i];
					mintag = i;
				}
			}

			scores[maxtag] = 0;
			scores[mintag] = 0;

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

			int average = sum / (scores.length - 2);

			System.out.printf("%d\n", average);

		}

		sc.close();
	}
}

Measured memory_bytes: 20972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    int N=S.size();
    bool ok=true;
    
    for(int i=0;i<N;i++){
        if(S[i]!=S[N-1-i]) ok=false;
    }
    
    for(int i=0;i<N/2;i++){
        if(S[i]!=S[N/2-1-i]) ok=false;
    }
    
    reverse(all(S));
    
    for(int i=0;i<N/2;i++){
        if(S[i]!=S[N/2-1-i]) ok=false;
    }
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int n,x,y;
map<int,int>mp;
int main()
{
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            mp[min(j-i,abs(i-x)+abs(y-j)+1)]++;
        }
    }
    for(int i=1;i<n;i++)
        cout<<(mp.find(i)!=mp.end()?mp[i]:0)<<"\n";
    return 0;
}



Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val d = (0 until n).map { sc.next().toInt() }
    println(problem085b(n, d))
}

fun problem085b(n: Int, d: List<Int>): Int {
    var count = 0
    var currentSize = Integer.MAX_VALUE
    d.sortedDescending().forEach {
        if (currentSize != it) {
            count++
        }
        currentSize = it
    }
    return count
}

Measured memory_bytes: 33996
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S;
  cin>>S;
  S+="H";
  ll N=S.size(),A[N];
  REP(i,N) A[i]=0;
  
  ll cnt=1;
  vector<pair<ll,ll>> L;
  RREP(i,N){
    if(S[i]!=S[i-1]){
      if(i==N) break;
      if(L.size()%2==0) L.PB(MP(cnt,i-1));
      else L.PB(MP(cnt,L[L.size()-1].second+1));
      cnt=1;
    }
    else cnt++;
  }
  
  REP(i,L.size()){
    if(i%2==0){
      A[L[i].second]=(L[i].first+1)/2+L[i+1].first/2;
    }
    else{
      A[L[i].second]=(L[i].first+1)/2+L[i-1].first/2;
    }
  }
  
  REP(i,N-1) cout<<A[i]<<" ";
  cout<<endl;
  return 0;
}

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

int main() {

  long long X;
  cin >> X;

  long long V = 100;
  long long answer = 0;

  while (V < X) {
    V += V / 100;
    answer++;
  }

  cout << answer << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl;
#define all(v) v.begin(), v.end()


int main() {
  int M;
  ll K;
  cin >> M >> K;
  if (K == 0) {
    rep(i,(1LL<<M)) {
      cout << i << " " << i << " ";
    }
    cout << endl;
    return 0;
  } else if (M == 1) {
    print(-1);
  } else if (K<(1LL<<M)) {
    rep(i,(1LL<<M)) {
      if (i == K)
        continue;
      cout << i << " ";
    }
    cout << K << " ";
    repr(i,(1LL<<M), 0) {
      if (i == K)
        continue;
      cout << i << " ";
    }
    cout << K << endl;
  } else {
    print(-1);
  }
  return 0;
}


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

int main(){
  char c[4][13];
  int cc[4][13],tramp[4][13];
  int num;
  
  cin >> num;


  for(int k=0;k<4;++k){
    for(int i=0;i<13;++i){
      if(k*13 + i < num){
	cin >> c[k][i]>> tramp[k][i];

	switch(c[k][i]){
	case 'S':
	    cc[k][i] = 0;
	    break;
	case 'H':
	    cc[k][i] = 1;
	    break;
	case 'C':
	    cc[k][i] = 2;
	    break;
	case 'D':
	    cc[k][i] = 3;
	    break;
	default:
	  cc[k][i] = 0;
	  break;
	}
      }else{
	c[k][i] = '0';
	tramp[k][i] = 0;
      }
    }
  }

  bool f_find = false;
  for(int i=0;i<4;++i){
    for(int k=0;k<13;++k){

      for(int l=0;l<4;++l){
	for(int m=0;m<13;++m){
	  if(cc[l][m] == i && tramp[l][m] == k + 1){
	    f_find=true;
	  }
	}
      }

      if(!f_find){
	switch(i){
	case 0:
	      cout << "S " << k + 1 << endl; 
	    break;
	case 1:
	      cout << "H " << k + 1 << endl; 
	    break;
	case 2:
	      cout << "C " << k + 1 << endl; 
	    break;
	case 3:
	      cout << "D " << k + 1 << endl; 
	    break;
	}
      }else{
	f_find = false;
      }
      
    }
  }
  
}



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

int main() {

	int K;
	cin >> K;

	int ans = 0;
	int x = 7 % K;
	for (int i = 0; i < K; i++) {
		x = x % K;
		ans++;
		if (x == 0) {
			cout << ans << endl;
			return 0;
		}
		else {
			x = 10 * x + 7;
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
	int age,cost;
	cin>>age>>cost;
	if(age>=13)
		{cout<<cost;}
	else if(age<=12 && age>=6)
		{cout<<(int)(cost/2);}
	else
		{cout<<"0";}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long int
#define f(i,a,b) for (int i= a; i <b; ++i)
using namespace std;

int dp[101][100005];

signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k,mod=1000000007;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int j=0;j<=k;j++)
    {
        if(j>a[0])
            dp[1][j]=0;
        else
            dp[1][j]=1;
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            dp[i][j]+=((dp[i][j-1]+dp[i-1][j])%mod);
            if(j-1-a[i-1]>=0)
            {
                dp[i][j]-=dp[i-1][j-1-a[i-1]];
            }
            dp[i][j]=(dp[i][j]+mod)%mod;
        }
    }
    cout<<dp[n][k];
}



Measured memory_bytes: 78336
//incomplete, tough
#include<bits/stdc++.h>
using namespace std;
int a[100010];
int b[100010];
int v[100010];

int main()
{
    int n,m,L=-1;
    cin>>n>>m;
    a[1]=1;v[1]=1;
    for(int i=2;i<=n;i++) b[i]=1,v[i]=1;

    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        if(v[x])
        {
            v[x]--;v[y]++;
        }

        if(a[x]) a[y]=1;
        if(v[x]==0 && a[x]==1) a[x]=0;
    }

    int ans=0;
    for(int i=1;i<=n;i++) ans+=a[i];
    cout<<ans;
}



Measured memory_bytes: 1408
#include<cstdio>
const int MaxN=100010;
int N,K,a[MaxN],ans;
struct edge{int to;edge*next;}E[MaxN],*fir[MaxN];
int Q[MaxN],fa[MaxN],dep[MaxN];
bool del[MaxN];
void dfs(int i){
	del[i]=1;
	for(edge*e=fir[i];e;e=e->next)
		if(e->to!=fa[i]&&!del[e->to])dfs(e->to);
}
int main(){
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++){
		scanf("%d",a+i);
		if(i==1){
			if(a[i]!=1)a[i]=1,ans++;
		}
		else E[i]=(edge){i,fir[a[i]]},fir[a[i]]=E+i;
	}
	int*h=Q,*t=Q+1;*Q=1;
	for(;h<t;h++)
		for(edge*e=fir[*h];e;e=e->next)
			if(e->to!=fa[*h])fa[*t++=e->to]=*h,dep[e->to]=dep[*h]+1;
	while(t-->Q){
		if(dep[*t]<=K)break;
		if(del[*t])continue;
		ans++;
		int i=*t;
		for(int j=K;--j;)i=fa[i];
		dfs(i);
	}
	printf("%d\n",ans);
}

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

void solve() 
{
    int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    int ans=0;
    if(a+b>c*2){
        int t=min(x,y);
        ans+=t*c*2;
        x-=t;
        y-=t;
    }else{
        ans+=a*x+b*y;
        cout<<ans<<endl;
        return;
    }
    ans+=min(x*a+y*b,(x+y)*2*c);
    cout<<ans<<endl;
}

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

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> num(n);
  for(int &x:num){
	cin>>x;
  }
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  int sum=0;
  for(int i=0;i<k;i++){
    sum+=num.at(i);
  }
  cout<<sum<<endl;
}

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

typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)

const ll MOD = 1e9+7;

inline void in() {}
template<class T, class... Ts>
inline void in(T& x, Ts&... xs) {
	int c, s=0; x=0;
	while (c=getchar(), c!='-'&&(c<'0'||c>'9'));
	if (c=='-') s=1, c=getchar();
	do x=x*10+(c-'0'); while (c=getchar(), c>='0'&&c<='9');
	if (s) x=-x;
	in(xs...);
}
inline void ins(char *s) {
    char c; while(c=getchar(), c<33); do *s++=c; while(c=getchar(), c>32); *s=0;
}

int main() {
	ll x[3];
	in(x[0],x[1],x[2]);
	sort(x,x+3);
	rep(i,0,3)if(x[i]%2==0)printf("0\n"),exit(0);
	printf("%lld\n",x[0]*x[1]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int A, B;
    cin >> A >> B;
    Yes((A * B) % 2);
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int,int> P;

int w,h,ans;
int depart[50][50];
bool d[50][50][50][50];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
struct cost{
  P tp,kp;
  int cnt;
};

void solve(struct cost c){
  queue<struct cost> q;
  q.push(c);
  ans=-1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<h;k++){
	for(int l=0;l<w;l++){
	  d[i][j][k][l]=false;
	}
      }
    }
  }

  while(!q.empty()){
    struct cost now=q.front(),next;
    q.pop();
    int tx=now.tp.second;
    int ty=now.tp.first;
    int kx=now.kp.second; 
    int ky=now.kp.first;
    next.cnt=now.cnt+1;
    if(d[ty][tx][ky][kx]){
      continue;
    }else{
      d[ty][tx][ky][kx]=true;
    }
    if(now.cnt==100){
      break;
    }
    if(tx==kx && ty==ky){
      ans=now.cnt;
      break;
    }
    
    for(int i=0;i<4;i++){
      int tnx=tx+dx[i];
      int tny=ty+dy[i];
      int knx=kx-dx[i];
      int kny=ky-dy[i];
      if(tnx<0 || tny<0 || tnx>=w || tny>=h || depart[tny][tnx]){
	P tp(ty,tx);
	next.tp=tp;
      }else{
	P tp(tny,tnx);
	next.tp=tp;
      }
      if(knx<0 || kny<0 || knx>=w || kny>=h || depart[kny][knx]){
	P kp(ky,kx);
	next.kp=kp;
      }else{
	P kp(kny,knx);
	next.kp=kp;
      }
      q.push(next);
    }
  }
}

int main(){
  while(cin>> w>> h,w||h){
    int tx,ty,kx,ky;
    cin>> tx>> ty;
    cin>> kx>> ky;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>> depart[i][j];
      }
    }
    
    struct cost c;
    P tp(ty-1,tx-1),kp(ky-1,kx-1);
    c.tp=tp;
    c.kp=kp;
    c.cnt=0;
    solve(c);
    if(ans==-1){
      cout<< "NA"<< endl;
    }else{
      cout<< ans<< endl;
    }
  }
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int N,M;
  cin >> N;
  map<string,int> s;
  froop1(0,N){
    string s2;
    cin >> s2;
    if(s.count(s2)){
      s[s2]++;
    }else{
      s[s2] = 1;
    }
  }
  cin >> M;
  froop1(0,M){
   string s2;
    cin >> s2;
    if(s.count(s2)){
      s[s2]--;
    }else{
      s[s2] = -1;
  }
  }
  int max = 0;
  for(pair<string,int> p : s){
    if(p.second > max) max = p.second;
      
  }
  cout << max << endl;
return 0;
}

Measured memory_bytes: 3600
import math
n = int(input())
ten_counter = 0
exp_index = math.log(10 ** 18, 5)
if n % 2 == 0:
    n //= 2
    # rangeの範囲をlogとったら if: break 不要
    for i in range(1, int(exp_index) + 1):
        if n // (5 ** i) == 0:
            break
        else:
            ten_counter += n // (5 ** i)
    # else:
    #     print("finish")
else:
    pass

print(ten_counter)

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

using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    if(A==1 && B==2){
        cout<<3;
    }
    if(A==2 && B==1){
        cout<<3;
    }
    if(A==2 && B==3){
        cout<<1;
    }
    if(A==3 && B==2){
        cout<<1;
    }
    if(A==1 && B==3){
        cout<<2;
    }
    if(A==3 && B==1){
        cout<<2;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll n;
	cin >> n;
	
	vector<ll> ans(1e5 + 10, 0);
	for(ll x = 1; x <= 100; ++x) {
		for(ll y = 1; y <= 100; ++y) {
			for(ll z = 1; z <= 100; ++z) {
				ll c = x * x + y * y + z * z + x * y + y * z + z * x;
				ans[c]++;
			}
		}
	}	

	for(ll i = 1; i < n + 1; ++i) {
		cout << ans[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}



int main(){
    ll n;
    cin >> n;
    ll x=0,y=0,T=0;
    for (ll i=0;i<n;i++){
        ll t,a,b;
        cin >> t >> a >> b;
        if (t-T>=abs(x-a)+abs(y-b) and ((t-T)-(abs(x-a)+abs(y-b)))%2==0){
            T=t;
            x=a;
            y=b;
            continue;
        }
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
  while (y != 0) {
    ll r = x % y; x = y; y = r;
  }
  return x;
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i*i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) { ret[n]++; }
  return ret;
}

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

  ll g = gcd(a, b);

  cout << prime_factor(g).size() + 1 << endl;

  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];

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

	ll mi = inf;
	for (int i = 0; i < n - k + 1; i++) {
		mi = min(mi, h[i + k - 1] - h[i]);
	}

	cout << mi << en;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int a, b, c;

    scanf ("%d%d%d", &a, &b, &c);
    if ((a * c) <= b){
        printf("%d", c);
    } 
    else {
        printf("%d", (b / a));
    }
    
    return (0);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 2000005, M = 30000005;
using namespace std;
typedef long long ll;
int n, e, ter[M], nxt[M], lnk[N], dfn[N], low[N], tot, top, cnt;

ll c[N];
int d[N];

bool vis[N], ins[N]; int bel[N], tr[N], st[N];
struct poi { int x, y; } a[N];

void pre() {
	c[0] = d[0] = 0;
	rep(i, 1, n) c[++ c[0]] = a[i].x*(1ll<<30)+2*i, c[++ c[0]] = a[i].y*(1ll<<30)+2*i+1;
	sort(c + 1, c + c[0] + 1);
	for (int i=1;i<=c[0];i++) {
		d[i]=c[i]>>30;
		if (c[i]&1) a[(c[i]&((1<<30)-1))/2].y=i;
		else a[(c[i]&((1<<30)-1))/2].x=i;
	}
	d[0]=c[0];
//	rep(i,1,n) printf("%d %d\n",a[i].x,a[i].y);
/*	for (int i = 1, j; i <= c[0]; i = j) {
		d[++ d[0]] = c[i];
		for (j = i + 1; j <= c[0] && c[i] == c[j]; ++ j);
	}*/
//	rep(i, 1, n) a[i].x = findl(a[i].x), a[i].y = findl(a[i].y);
}
void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e;
	ter[++ e] = x^1, nxt[e] = lnk[y^1], lnk[y^1] = e;
}
void build(int p, int l, int r) {
	tr[p] = ++ cnt; ++ cnt; 
	if (l == r) { add(tr[p], l<<1|1); return ; }
	int mid = (l + r) / 2;
	build(p << 1, l, mid), build((p << 1) + 1, mid + 1, r);
	add(tr[p], tr[p << 1]), add(tr[p], tr[(p << 1) + 1]);
}
void modify(int p, int l, int r, int lx, int rx, int fr) {
	if (l == lx && r == rx) { add(fr, tr[p]); return ; }
	int mid = (l + r) / 2;
	if (rx <= mid) modify(p << 1, l, mid, lx, rx, fr); else
	if (lx > mid) modify((p << 1) + 1, mid + 1, r, lx, rx, fr); else
	modify(p << 1, l, mid, lx, mid, fr), modify((p << 1) + 1, mid + 1, r, mid + 1, rx, fr);
}
void tarjan(int p) {
	dfn[p] = low[p] = ++ tot, vis[p] = false;
	st[++ top] = p, ins[p] = true;
	for (int i = lnk[p]; i; i = nxt[i]) {
		if (vis[ter[i]]) tarjan(ter[i]), low[p] = min(low[p], low[ter[i]]);
			else if (ins[ter[i]]) low[p] = min(low[p], dfn[ter[i]]);
	}
	if (low[p] == dfn[p]) {
		for ( ; st[top] != p; -- top) bel[st[top]] = p, ins[st[top]] = false;
		bel[st[top]] = p, ins[st[top]] = false, -- top;
	}
}
bool solve(int ave) {
//	printf("%d\n",ave);
	rep(i, 1, cnt) lnk[i] = 0;
	rep(i, 1, e) nxt[i] = 0;
	e = 0;
	cnt = 2 * d[0] + 1;
	build(1, 1, d[0]);
	rep(i, 1, d[0]) {
		int l = lower_bound(d+1,d+2*n+1, d[i] - ave + 1)-d, r = lower_bound(d+1,d+2*n+1,d[i] + ave)-d-1;
		if (l < i && i > 1) modify(1, 1, d[0], l, i - 1, i<<1);
		if (i < r && i < d[0]) modify(1, 1, d[0], i + 1, r, i<<1);
	} 
	rep(i, 1, n) add(a[i].x<<1|1, a[i].y<<1), add(a[i].x<<1, a[i].y<<1|1);
	memset(vis, true, sizeof(vis));
	memset(ins, false, sizeof(ins));
	tot = top = 0;
	rep(i, 2, cnt) if (vis[i]) tarjan(i);
	rep(i, 1, d[0]) if (bel[i<<1] == bel[i<<1|1]) { return false; }
	return true;
}
int main() {
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d%d", &a[i].x, &a[i].y);
	pre();
	int l = 0, r = d[d[0]] - d[1], ans = 0;
	for ( ; l <= r; ) {
		int mid = (l + r) / 2;
		if (solve(mid)) ans = mid, l = mid + 1;
			else r = mid - 1;
	} 
	printf("%d\n", ans);  
	return 0;
}

Measured memory_bytes: 41856
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    LR = [[int(x) for x in input().split()] for _ in range(K)]

    MOD = 998244353

    dp = [0] * (N + 1)
    dp[1] = 1

    c = 0
    for i in range(1, N):
        if i >= 3:
            dp[i] += c
        for l, r in LR:
            if i + l <= N:
                dp[i + l] += dp[i]
                dp[i + l] %= MOD
            if i + r + 1 <= N:
                dp[i + r + 1] -= dp[i]
                dp[i + r + 1] %= MOD
        if i >= 2:
            c = dp[i]

    dp[N] += c


    print(dp[N] % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69496
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vs a;
vvi g;

void dfs(int v,int d){
	cout<<string(d,'.')<<a[v]<<endl;
	for(auto u:g[v]) dfs(u,d+1);
	
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		cin>>n;
		g=vvi(n);
		a=vs(n);
		for(int i=0;i<n;i++){
			int v;
			cin>>v>>a[i];
			if(i) g[v-1].push_back(i);
		}
		dfs(0,0);
		break;
	}
}


Measured memory_bytes: 3460
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;

ll N, M;

void input() {
    cin >> N >> M;
}

const ll MOD = 1e9+7;
ll mod(ll x) {
    return x % MOD;
}

ll pow_mod(ll x, ll p) {
    ll res = 1;
    ll u = x;
    while (p) {
        if (p & 1) {
            res = mod(res * u);
        }
        u = mod(u * u);
        p >>= 1;
    }
    return res;
}

ll div_mod(ll x) {
    return pow_mod(x, MOD - 2);
}


void solve() {
    vector<ll> fact(2e5);
    fact[0] = 1;
    fact[1] = 1;
    for (ll i = 2; i < fact.size(); i++) {
        fact[i] = mod(fact[i-1] * i);
    }
    vector<ll> ifact(fact.size());
    for (ll i = 0; i < ifact.size(); i++) {
        ifact[i] = div_mod(fact[i]);
    }
    
    auto comb_mod = [&fact, &ifact](ll a, ll b) {
        return mod(mod(fact[a] * ifact[b]) * ifact[a-b]);
    };
    
    ll ans = 1;
    ll m = M;
    for (ll n = 2; n <= M; n++) {
        ll count = 0;
        while (m % n == 0) {
            count++;
            m /= n;
        }
        if (count == 0)
            continue;
        ans = mod(ans * comb_mod(count + N - 1, count));
        
        if (m == 1)
            break;
    }
    cout << ans << endl;
}




int main() {
    input();
    solve();
    
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

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

  cin >> a >> b >> c >> d;

  if (a + b == c + d) {
    cout << "Balanced" << endl;
    return 0;
  }

  string result = (a + b > c + d) ? "Left" : "Right";

  cout << result << endl;
  return 0;
}

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

int main()
{
	int n ,i,j;cin>>n;
   vector<double>v(n);
	for(i=0;i<n;i++) cin>>v[i];
  //setprecision (10);
	double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
	dp[1][0] = 1-v[0];
	dp[1][1] = v[0];
	for(i=2;i<n+1;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(j==0)
			{
				dp[i][j] = dp[i-1][j]*(1-v[i-1]);
			}
			else if(j==i)
			{
				dp[i][j] = dp[i-1][j-1]*(v[i-1]);
			}
			else
			{
				dp[i][j] = dp[i-1][j]*(1-v[i-1]);
				dp[i][j] += dp[i-1][j-1]*(v[i-1]);
			}
	 }
	}
	double sum=0;
	for(i=n/2+1;i<=n;i++)
	{
		sum+=dp[n][i];
	}
	cout<<setprecision(10)<<fixed << sum;
  return 0;

}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  long long int A;
  long long int B;
  long long int C;
  long long int K;
  long long int sum = 0;
  cin>>A;
  cin>>B;
  cin>>C;
  cin>>K;
  if(K != 0){
    //K = K - (min(A,K));
    if(min(A,K) == A){
      sum += (A * 1);
    }else{
      sum += (K * 1);
    }
    K = K - (min(A,K));
  }
  if(K != 0){
    //K = K - (min(B,K));
    if(min(B,K) == B){
      sum += (B * 0);
    }else{
      sum += (K * 0);
    }
    K = K - (min(B,K));
  }
  if(K != 0){
    //K = K - (min(C,K));
    if(min(C,K) == C){
      sum += (C * -1);
    }else{
      sum += (K * -1);
    }
    K = K - (min(C,K));
  }
  cout<<sum<<'\n';
}

Measured memory_bytes: 3612
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans_ar = []
for i in range(N-K+1):
    ans_ar.append(min(abs(X[i]), abs(X[i+K-1])) + (X[i+K-1] - X[i]))
print(min(ans_ar))

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

using namespace std;

int main()
{
    long long n;
    string s;
    cin >> n >> s;
    if (n % 2 == 1)
    {
        cout << "No" << endl;
        return 0;
    }
    bool flag = true;
    for (long long i = 0; i < n / 2; i++)
    {
        if (s[i] != s[i + n / 2])
            flag = false;
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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; }

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

	lint n;
	cin >> n;
	co((lint)pow((lint)sqrt(n), 2));
	gc();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
 

struct RollingHash{
	ll M;
	vector<ll> H,B;
	RollingHash(string s,ll b=1009LL,ll m=1000000007LL){
		M = m;
		ll n = s.size();
		B.resize(n+1);
		H.resize(n+1,0);
		B[0] = 1;
		for(ll i=0;i<n;i++){
			B[i+1] = (B[i]*b)%M;
			H[i+1] = (H[i]*b%M+s[i])%M;
		}
	}
	ll GetHash(ll l,ll r){ // [l,r)
		return (H[r]+(M-B[r-l]*H[l]%M))%M;
	}
};


 
int main(){
	string t,p;
	cin >> t >> p;
	RollingHash T(t);
	RollingHash P(p);

	ll lt = t.size();
	ll lp = p.size();
	FOR(i,0,lt-lp+1){
		if(T.GetHash(i,i+lp)==P.GetHash(0,lp)){
			cout << i << endl;
		}
	}
}


Measured memory_bytes: 20620
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Tue Jan  1 01:13:11 2019
//
package main

import "fmt"

func main() {
	var X, A, B int
	fmt.Scan(&X, &A, &B)
	fmt.Println((X - A) % B)
}


Measured memory_bytes: 512
class Factorial():
    def __init__(self, n, mod):
        self.mod = mod
        self.fct = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.fct[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.fct[i + 1] = self.fct[i] * (i + 1) % mod
        self.inv[n] = pow(self.fct[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod

    def comb(self, m, k):
        if m < k: return 0
        return self.fct[m] * self.inv[k] * self.inv[m - k] % self.mod

def ex_euclid(x, y):
    c0, c1 = x, y
    a0, a1 = 1, 0
    b0, b1 = 0, 1
    while c1:
        a0, a1 = a1, a0 - c0 // c1 * a1
        b0, b1 = b1, b0 - c0 // c1 * b1
        c0, c1 = c1, c0 % c1
    return c0, a0, b0

MOD = 998244353
N, A, B, K =map(int,input().split())

f = Factorial(N, MOD)
c, a, b = ex_euclid(A, B)

if K == 0:
    print(1)

elif K % c != 0:
    print(0)

else:
    lo = -10**18
    hi = 10**18
    while hi - lo > 1:
        mid = (hi + lo) // 2
        if a * K // c + mid * B // c >= 0:
            hi = mid
        else:
            lo = mid
    x0 = a * K // c + hi * B // c

    lo = -10**18
    hi = 10**18
    while hi - lo > 1:
        mid = (hi + lo) // 2
        if b * K // c - mid * A // c >= 0:
            lo = mid
        else:
            hi = mid
    y0 = b * K // c - lo * A // c

    res = 0
    x = x0
    y = (K - A * x0) // B

    while True:
        res += f.comb(N, x) * f.comb(N, y)
        res %= MOD
        if y == y0:
            break
        x += B // c
        y -= A // c

    print(res)

Measured memory_bytes: 121900
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    #_max = int(math.ceil((b - r) / g) - 1) * g + r
    _max = b + r - g
    #_max = ((math.ceil((b - r) / g)) * g) + r - g
    #_max = ((b - r + g - 1)//g) * g + r - g
    if c < _max:
        print('No')
    else:
        print('Yes')


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

int main() {
    int x,y;
    cin >> x >> y;
    int answer = 0;
    if (x == 1 && y == 1) {
        answer+=400000;
    }

    if (x == 1) {
        answer+=300000;
    } else if (x == 2) {
        answer+=200000;
    } else if (x == 3) {
        answer+=100000;
    }

    if (y == 1) {
        answer+=300000;
    } else if (y == 2) {
        answer+=200000;
    } else if (y == 3) {
        answer+=100000;
    }

    cout << answer << endl;
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

string s;
int k;
set<string> t;

void solve() {
	fi(0, sz(s) - 1) {
		fj(1, sz(s) - i) {
			string s1 = s.substr(i, j);
			if (t.find(s1) != t.end()) {
				continue;
			} else {
				if (sz(t) < k) {
					t.insert(s1);
				} else {
					string s2 = (*t.rbegin());
					if (s2 < s1) {
						break;
					} else if (s2 > s1) {
						t.erase(s2);
						t.insert(s1);
					}
				}
			}
		}
	}
	assert(sz(t) == k);
	string ans = (*t.rbegin());
	printf("%s\n", ans.c_str());
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> s;
	cin >> k;  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, k, ans = 0;
    cin >> n >> k;
    repi(i, n, 0)
    {
        int h;
        cin >> h;
        if (h >= k)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

vector<int> edge[int(1e5+1)];
vector<int> indegree(1e5+1,0);

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

    int n,m;
    cin>>n>>m;
    int u,v;
    for(int i=0;i<m;++i){
        cin>>u>>v;
        edge[u].push_back(v);
        indegree[v]++;
    }

    for(int i=1;i<=n;++i)   pq.push(make_pair(indegree[i], i));

    vector<int> dp(1e5+3,0);//dp array that keeps track of maximum length of path till that point
    queue<int> q;
    while(pq.top().first == 0){
        // cout<<pq.top().second<<"\n";
        q.push(pq.top().second);
        pq.pop();
    }
   
    int ind;
    // cout<<"start\n";
    while(q.size()){
        // cout<<ind<<"\n";
        ind = q.front();
        q.pop();
        for(auto i:edge[ind]){
            dp[i] = max(dp[i], dp[ind] + 1);
            indegree[i]--;
            if(!indegree[i])    q.push(i);
        }
    }
    // cout<<"end\n";

    int ans = 0;
    // for(int i=1;i<=n;++i)   cout<<dp[i]<<" ";
    // cout<<"\n";
    for(int i=1;i<=n;++i)   ans = max(ans, dp[i]);

    cout<<ans<<"\n";

    return 0;
}

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

int main() {
  ll a,b;
  cin>>a>>b;
  if(b%a==0){
    cout<<a+b<<endl;
  }
  else{
    cout<<b-a<<endl;
  }
      
    
  
  return 0;
}
                             
    


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int a,b;
  cin >> a >> b;
  int maxi = max(a+b,a-b);
  maxi = max(maxi,a*b);
  cout << maxi;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int L[300];

int main() {

	int N;

	scanf("%d",&N);

	int i;

	for (i = 0; i < 2 * N; i++) {
		scanf(" %d",&L[i]);
	}
	sort(L,L+(2*N));

	int ans = 0;

	for (i = 0; i < 2 * N; i++) {
		if (i % 2 == 0) {
			ans += L[i];
		}
	}
	printf("%d\n",ans);

	return 0;
}

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



// 上下左右でそれぞれ行ける最大の位置を求める


int main()
{
    int H, W, N;
    int sr, sc;
    cin >> H >> W >> N;
    cin >> sr >> sc;
    string S, T;
    cin >> S;
    cin >> T;



    bool isInMatrix = true;
    int maxi = sr, mini = sr;
    int maxj = sc, minj = sc;

    // 右方向でどうか
    for( int i = 0; i < N; ++i ){
        if( S[i] == 'R' ) ++maxj;
        if( maxj > W ){
            cout << "NO" << endl;
            return 0;
        }
        if( T[i] == 'L' and maxj > 1 ) --maxj;
    }

    // 左方向でどうか
    for( int i = 0; i < N; ++i ){
        if( S[i] == 'L' ) --minj;
        if( minj < 1 ){
            cout << "NO" << endl;
            return 0; 
        }
        if( T[i] == 'R' and minj < W ) ++minj;
    }

    // 上方向でどうか
    for( int i = 0; i < N; ++i ){
        if( S[i] == 'U' ) --mini;
        if( mini < 1 ){
            cout << "NO" << endl;
            return 0; 
        }
        if( T[i] == 'D' and mini < H ) ++mini;
    }

    // 下方向でどうか
    for( int i = 0; i < N; ++i ){
        if( S[i] == 'D' ) ++maxi;
        if( maxi > H ){
            cout << "NO" << endl;
            return 0; 
        }
        if( T[i] == 'U' and maxi > 1 ) --maxi;
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 776