akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl;
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl;



int main(){
	
	int N,M;
	cin >> N >> M;
	int dp[(1<<N)];
	FOR(i,0,1<<N)dp[i] = MOD;
	dp[0] = 0;
	vector<int> a(M),b(M),c(M,0);
	FOR(i,0,M){
		cin >> a[i] >> b[i];
		FOR(j,0,b[i]){
			ll x;
			cin >> x;
			x--;
			c[i] |= (1<<x);
		}
	}
	FOR(i,0,M){
		FORR(j,0,1<<N){
			dp[j|c[i]] = min(dp[j|c[i]],dp[j]+a[i]);
		}
	}
	if(dp[(1<<N)-1]==MOD)dp[(1<<N)-1]=-1;
	cout << dp[(1<<N)-1] << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

c = [STR() for _ in range(3)]
print(c[0][0] + c[1][1] + c[2][2])

Measured memory_bytes: 5188
n=int(input())
arr=list(map(int,input().split()))
ans=[0]*n
ans[0]=arr[0]
ans[1]=arr[0]
for i in range(1,n-1):
  if ans[i]<=arr[i]:
    ans[i+1]=arr[i]
  else:
    ans[i]=arr[i]
    ans[i+1]=ans[i]
print(sum(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{

 int n;
 scanf("%d",&n);
 int sum=n*n*n;
 printf("%d\n",sum);
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


const int MAX = 26000000;
int n;
ll dp[MAX];

ll sub(ll k, vector<P> v){
        memset(dp,0,sizeof(dp));

        for(P p : v){
                int cost = p.first;
                int val = p.second;
                if(val == 0) continue;
                for(ll i = 0; i < MAX; i++){
                        if(i- cost < 0) continue;
                        dp[i] = max(dp[i], dp[i-cost] + val);
                }
        }

        ll mx = 0;
        for(ll i = 0; i < k+1; i++){
                chmax(mx, dp[i]);
        }
        return mx + k;
}

int main(){

        int ax,bx,cx;
        int ay,by,cy;
        cin >> n >> ax >> bx >> cx >> ay >> by >> cy;

        vector<P> A;
        vector<P> B;
        if(ax < ay) {
                A.push_back(P(ax,ay-ax));
        }
        else{
                B.push_back(P(ay,ax-ay));
        }

        if(bx < by) {
                A.push_back(P(bx,by-bx));
        }
        else{
                B.push_back(P(by,bx-by));
        }

        if(cx < cy) {
                A.push_back(P(cx,cy-cx));
        }
        else{
                B.push_back(P(cy,cx-cy));
        }

        ll sum = n;
        sum = sub(sum,A);
        sum = sub(sum,B);
        cout << sum << endl;
        return 0;
}




Measured memory_bytes: 203392
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();

	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 150000 + 5;

struct node {
	LL a, b;
	node(LL _a = 0, LL _b = 0) {a = _a, b = _b;}
	bool operator < (const node &T) {
		if (a == T.a) return b < T.b;
		return a < T.a;
	}
};

int n; LL V;
std::vector<LL> w[N];
std::vector<int> v[N];
std::vector<node> S[N], zkx;

void dfs(int x) {
	//printf("%d\n", x);
	S[x].clear();
	if (!v[x].size()) {S[x].push_back(node(0, 0)); return;}
	int k = v[x][0], l = v[x][1];
	LL vk = w[x][0], vl = w[x][1];
	dfs(k); dfs(l);
	if (S[k].size() > S[l].size()) swap(k, l), swap(vk, vl);
	if (!S[k].size()) return;
	for (int i = 0, j = 0; i < S[k].size(); i++) {
		LL a = S[k][i].a, b = S[k][i].b;
		while (j + 1 < S[l].size() && b + S[l][j + 1].a + vk + vl <= V) j++;
		if (j < S[l].size() && b + S[l][j].a + vk + vl <= V) S[x].push_back(node(a + vk, S[l][j].b + vl));
	}
	for (int i = 0, j = 0; i < S[k].size(); i++) {
		LL a = S[k][i].a, b = S[k][i].b;
		while (j < S[l].size() && a + S[l][j].b + vk + vl > V) j++;
		if (j < S[l].size() && a + S[l][j].b + vk + vl <= V) S[x].push_back(node(S[l][j].a + vl, b + vk));
	}
	sort(S[x].begin(), S[x].end());
	zkx.clear();
	for (int i = 0; i < S[x].size(); i++) {
		int flag = 1;
		if (zkx.size() && zkx[zkx.size() - 1].a <= S[x][i].a && zkx[zkx.size() - 1].b <= S[x][i].b) flag = 0;
		if (flag) zkx.push_back(S[x][i]);
	}
	S[x].clear();
	for (int i = 0; i < zkx.size(); i++) S[x].push_back(zkx[i]);
	// printf("%d %d ", x, S[x].size());
	// for (int i = 0; i < S[x].size(); i++) printf("(%d, %d) ", S[x][i].a, S[x][i].b);
	// printf("\n");
}

int check(LL val) {
	V = val; dfs(1);
	return S[1].size() ? 1 : 0;
}

int main() {
	read(n);
	LL l = 0, r = 0, ans;
	LL x, y;
	for (int i = 2; i <= n; i++) {
		read(x), read(y);
		v[x].push_back(i);
		w[x].push_back(y);
		r += y;
	}
	// check(1441159);
	while (l <= r) {
		LL m = (l + r) >> 1;
		if (check(m)) {
			ans = m;
			r = m - 1;
		} else l = m + 1;
		//printf("%lld %lld\n", l, r);
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-a)<=d || abs(b-a)<=d && abs(c-b)<=d){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

int main(){
	string s;
	while(getline(cin,s)){
		string l = "#";
		for(int i = 0 ; i < s.size() ; i++)
			if( (s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z') ){
				l += s[i] & ~32;
			}
		l += "$";
		set<string> p;
		set<string> ban;
		for(int i = 1 ; i < l.size()-1 ; i++){
			string g = string(1,l[i]);
			int le = i-1 , ri = i+1;
			while(l[le] == l[ri]){
				ban.insert(g);
				g = string(1,l[le]) + g + string(1,l[ri]);
				le--,ri++;
			}
			p.insert(g);
		}
		for(int i = 1 ; i < l.size()-1 ; i++){
			string g = "";
			int le = i , ri = i+1;
			while(l[le] == l[ri]){
				ban.insert(g);
				g = string(1,l[le]) + g + string(1,l[ri]);
				le--,ri++;
			}
			p.insert(g);
		}
		int f = 1;
		for(set<string>::iterator it = p.begin(); it != p.end() ; ++it){
			if((*it).size() <= 2 || ban.count(*it)) continue;
			if(!f) cout << " ";
			cout << *it;
			f = 0;
		}
		cout << endl;
	}
}

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

int main() {
  long long n,k,t,s,ans;
  cin>>n>>k;
  int a[n],b[n+1];
  bool c[n+1];
  for(int i=0;i<n;i++){
    int l;
    cin>>l;
    a[i]=l;
    b[i+1]=0;
    c[i+1]=false;
  }
  b[0]=1;
  c[1]=true;
  for(int i=1;i<n+1;i++){
    if(c[a[b[i-1]-1]]==true){
      t=i;
      b[i]=a[b[i-1]-1];
      break;
    }
    else {
      c[a[b[i-1]-1]]=true;
      b[i]=a[b[i-1]-1];
    }
  }
  for(int i=0;i<t;i++){
    if(b[t]==b[i]){
      s=i;
      break;
    }
  }
  if(k<s)ans=b[k];
  else{
    k-=s;
    k=k%(t-s);
    ans=b[s+k];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    string a;
    cin >> a;
    int k = (int)a.size();
    int x = 0;
    for(int i = 0; i < (int)a.size(); ++i){
        if(a[i] == 'x')++x;
    }
    if(x > 7){
        cout <<"NO\n";
    }
    else {
        cout <<"YES\n";
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    if (b >= a) {
        cout << a << endl;
    } else {
        cout << a - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 1000000;
const int oo = 0x3f3f3f3f;
const int mod = 998244353;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

LL fac[N + 5], ifac[N + 5];
LL fpm(LL a, LL b) {
    LL res = 1;
    for(; b > 0; b >>= 1) {
        if(b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

void init() {
    fac[0] = 1;
    for(int i = 1; i <= N; ++i) fac[i] = fac[i-1] * i % mod;

    ifac[N] = fpm(fac[N], mod-2);
    for(int i = N; i >= 1; --i) ifac[i-1] = ifac[i] * i % mod;
}

LL ans;
LL C(int n, int k) { return fac[n] * ifac[k] % mod * ifac[n-k] % mod; }

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    init();
    int n = read<int>(), m = read<int>();

    if(n < m) swap(n, m);

    for(int i = 1; i <= m; ++i) {
        ans = (ans + C(i<<1, i) * C(n+m-(i<<1), n-i)) % mod;
    }

    printf("%lld\n", (ans*ifac[2]%mod*fpm(C(n+m, n), mod-2) + n) % mod);
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#include <iostream>
using namespace std;

int main() {
	ll int n,k;
	cin>>n>>k;
	vector<ll int> a(n);
	for(ll int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	ll int dp[n+1][k+1];
	memset(dp,0,sizeof(dp));
	//dp[0][0]=1;
/*	for(ll int i=0;i<=k;i++){
		dp[1][i]=i>a[0]?0:1;
	}*/
	
	ll int s=0;
	for(ll int i=1;i<=n;i++){
		s+=a[i-1];
		for(ll int j=0;j<=k;j++){
			if(j==0)dp[i][j]=1;
			if(j>s)break;
			else if(j!=0){
				dp[i][j]=((dp[i][j-1]%mod)+(dp[i-1][j]%mod)+dp[i][j]%mod)%mod;
			}
			if(j>a[i-1]){
				ll int t=j-a[i-1];
				dp[i][j]=mod+dp[i][j]%mod-dp[i-1][t-1]%mod;
			}
			dp[i][j]=dp[i][j]%mod;
		}
	}
	cout<<dp[n][k];
	return 0;
}

Measured memory_bytes: 79104
while 1:
    n = int(input())
    if n == 0: break
    s = input().split(' ')
    d = {}
    flag = 0
    for i in range(n):
        if s[i] in d:
            d[s[i]] += 1
        else:
            d[s[i]] = 1
        vote = sorted(d.values(), reverse=True)
        if len(vote) == 1:
            if n//2 < i+1:
                print(max(d.items(), key = lambda x:x[1])[0] + ' ' + str(i+1))
                flag = 1
                break
        elif vote[0] - vote[1] > n-i-1:
            print(max(d.items(), key = lambda x:x[1])[0] + ' ' + str(i+1))
            flag = 1
            break
    if flag == 0: print('TIE')



Measured memory_bytes: 5624
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int a = sc.nextInt();
        int b = sc.nextInt();
          

               
        out.println(max(2*max(a,b)-1,a+b));
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id,T;
//    P(int id, int T) {
//        this.id=id;
//        this.T=T;
//    }
//    public int compareTo(P p){
//        return id-p.id; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 20692
n,k = (int(_) for _ in input().split())
R,S,P = (int(_) for _ in input().split())
t = list(input())
a ={"r":P,"s":R,"p":S,"f":0}
Q = n//k
q = n%k
ans = 0
for i in range(n):
	ans+=a[t[i]]

for i in range(k,n):
	if t[i]==t[i-k]:
		ans-=a[t[i-k]]
		if t[i-k] is not "f":
			t[i]="f"
print(ans)


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

using namespace std;

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

    char k;
    cin >> k;
    int m = k - 'a';
    m++;
    char g = m + 'a';
    cout << g << '\n';
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long x, long y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        var A = LineInt().OrderBy(x => x);
        Console.WriteLine(A.Take(2).Sum());

    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13524
#include <iostream>
#include<cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
	double a, b;
	cin >> a >> b;
	cout << b - a + b;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a1, a2, a3; cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 > 21) cout << "bust";
    else cout << "win";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define int long long
using namespace std;
int k,a[1000];
__int128 s(__int128 x)
{
	__int128 ans=0;
	while (x) ans+=x%10,x/=10;
	return ans;
}
signed main()
{
	// __int128 wh;
	// wh=109999999999999;
	// int k=s(wh);
	// printf("%lld\n",k);
	// if (wh<1e12*s(wh)) printf("YES\n");
	// else printf("NO\n");
	scanf("%lld",&k);
	a[0]=9;a[1]=99;
	for (int i=2;i<=10;i++)
	{
		a[i]=i-1;
		for (int j=1;j<=i+1;j++) a[i]=a[i]*10+9;
	}
	a[11]=9999999999999;
	for (int i=12;i<=16;i++)
	{
		a[i]=i-2;
		for (int j=1;j<=i+1;j++) a[i]=a[i]*10+9;
	}
	// for (int i=1;i<=16;i++) printf("%lld\n",a[i]);
	// printf("\n");
	int now=1,cnt=0,x=0;
	for (int i=1;i<=k;i++)
	{
		x+=now;
		printf("%lld\n",x);
		if (x==a[cnt])
		{
			cnt++;
			now*=10;
		}
	}
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
using namespace std;

string moji[9]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(){
	string s,alt;
	int n;
	cin>>n;
	rep(a,n){
		cin>>s;
		alt="";
		vector<string> vec;
		rep(i,s.size()){
			if(s[i]=='0'){
				if(alt=="")continue;
				else vec.pb(alt);alt="";
			}else alt+=s[i];
		}
		string ans="";
		rep(i,vec.size()){
			int num=vec[i][0]-'0';
			ans+=moji[num-1][(vec[i].size()-1)%moji[num-1].size()];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main() {
    string s, t;
    cin >> s >> t;
    int l = s.size();
    bool ans = false;
    if(s == t) ans = true;
    else {
        rep(i, l) {
            s += s[0];
            s.erase(0, 1);
            if(s == t) {
                ans = true;
                break;
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,j,n) for(int i=j;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

int N,H[105];
signed main(){
	cin>>N;
	rep(i,N)cin>>H[i];
	int ans=0;
	rep(i,101){
		rep(j,N){
			if(H[j]>=i&&H[j+1]<i)ans++;
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3564
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, m, p, q, c;
vector<P> nodes, input[100010];
map<P, vector<pair<P,int>>> vec;
map<P, int> dist;
void dijkstra() {
	prique<pair<int, P>, vector< pair<int, P>>, greater<pair<int, P>>> que;
	que.push(make_pair(0, make_pair(1, -1)));
	dist[make_pair(1, -1)] = 0;
	while (!que.empty()) {
		auto p = que.top();
		que.pop();
		if (dist[p.second] < p.first)continue;
		for (auto e : vec[p.second]) {
			if (dist.find(e.first) == dist.end() || dist[e.first] > p.first + e.second) {
				dist[e.first] = p.first + e.second;
				que.push(make_pair(p.first + e.second, e.first));
			}
		}
	}
}
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> p >> q >> c;
		nodes.push_back(make_pair(p, c));
		nodes.push_back(make_pair(q, c));
		input[p].push_back(make_pair(q, c));
		input[q].push_back(make_pair(p, c));
		vec[make_pair(p, c)].push_back(make_pair(make_pair(q, c), 0));
		vec[make_pair(q, c)].push_back(make_pair(make_pair(p, c), 0));
	}
	for (P i : nodes) {
		vec[i].push_back(make_pair(make_pair(i.first, -1), 0));
	}
	REP(i, n) {
		for (P j : input[i]) {
			vec[make_pair(i, -1)].push_back(make_pair(j, 1));
		}
	}
	dijkstra();
	if (dist.find(make_pair(n, -1)) == dist.end())cout << -1 << endl;
	else cout << dist[make_pair(n, -1)] << endl;
}

Measured memory_bytes: 139496
#include<iostream>
#include<vector>
#include<climits>
#include<algorithm>
#define ll long long
using namespace std;
ll dp[401][401]; 
ll a[401];
int main() {
	ll n;
	cin>>n;
	for(int i=0; i< n; i++) {
		for(int j=0;j<n;j++) 
			dp[i][j] = LONG_MAX;
	}
	for(int i=0; i<n;i++) {
		cin>>a[i];
		if(i!=0)
			a[i] = a[i-1] + a[i];
		dp[i][i] = 0;
	}
	for(int len = 2; len <= n;len++) {
		for(int i = 0; i + len - 1 < n; i++) {
			int j = i + len -1 ;
			for(int k = i; k < j; k++) {
				dp[i][j] = min(dp[i][j],
						dp[i][k] + dp[k+1][j] 
					);
			}
			dp[i][j] += a[j] - (i==0? 0: a[i-1]);
		}
	}
	cout<<dp[0][n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1536
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-2-18 21:11:18
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

typedef tuple<int, int, int> state;

// const int C = 1e6+10;
// const ll M = 1000000007;

int H, W;
string S[100];

bool valid(int x, int y) {
  return (0 <= x && x < H && 0 <= y && y < W && S[x][y] == '.');
}

int main()
{
  cin >> H >> W;
  for (auto i = 0; i < H; i++)
  {
    cin >> S[i];
  }
  int cnt = 0;
  for (auto i = 0; i < H; i++)
  {
    for (auto j = 0; j < W; j++)
    {
      if (S[i][j] == '#')
        cnt++;
    }
  }
  queue<state> Q;
  Q.push(make_tuple(0, 0, 0));
  while (!Q.empty()) {
    int c = get<0>(Q.front());
    int x = get<1>(Q.front());
    int y = get<2>(Q.front());
    #if DEBUG == 1
    cerr << "x = " << x << ", y = " << y << endl;
    #endif
    Q.pop();
    if (x == H - 1 && y == W - 1)
    {
      cout << H * W - cnt - (c + 1) << endl;
      return 0;
    } else if (S[x][y] == '.') {
      S[x][y] = '#';
      for (auto k = 0; k < 4; k++)
      {
        int nc = c + 1;
        int nx = x + dx[k];
        int ny = y + dy[k];
        if (valid(nx, ny)) {
          Q.push(make_tuple(nc, nx, ny));
        }
      }
    }
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        sc.close();

        long ans = 1;
        int pos = 0;    //pos: 1 zero: 0, neg: -1
        for(int i=1; i<n; i++){
            if(pos == 0){
                if(a[i] - a[i-1] < 0){
                    pos = -1; 
                }else if(a[i] - a[i-1] > 0){
                    pos = 1;
                }
            }else if(pos == 1){
                if(a[i] - a[i-1] < 0){
                    ans++;
                    pos = 0;
                }
            }else if(pos == -1){
                if(a[i] - a[i-1] > 0){
                    ans++;
                    pos = 0;
                }
            }
        }
        System.out.println(ans);
    }
}        

Measured memory_bytes: 51592
#include <bits/stdc++.h>
#define INF INT_MAX
#define endl '\n'
#define ll long long int
#define N 1000005
using namespace std;

inline int redi() {
	int ret = 0,f = 0;char ch = getchar_unlocked();
	while (!isdigit (ch)) {
		if (ch == '-') f = 1;
		ch = getchar_unlocked();
	}
	while (isdigit (ch)) {
		ret = ret*10  + ch - 48;
		ch = getchar_unlocked();
	}
	return f?-ret:ret;
}
inline void print(int x) {
	if(x<0) {putchar_unlocked('-');x=-x;}
	int y=10,len=1;
	while(y<=x)    {y*=10;len++;}
	while(len--){y/=10;putchar_unlocked(x/y+48);x%=y;}
}

inline void init()
{
	ll n,m;
	cin >> n >> m;
	cout << ceil((double)n/(2*m+1)) << endl; 
}

inline void solve()
{
}

int main()
{
	//freopen("input.in","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	init();
	solve();
	cout << flush;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>



int main(void)
{
	//変数の宣言
	int a,b,c;
	int max;
	int ans;
	
	//データの読み込み
	scanf("%d %d %d",&a,&b,&c);
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	max=a;
	if(max<b) max=b;
	if(max<c) max=c;
	
	ans=max*9+a+b+c;
	
	
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
//Optimize
#pragma GCC optimize("Ofast")

//Head File
#include<bits/stdc++.h>
using namespace std;

#define il inline

//Variable
#define ll long long
#define ull unsigned long long
#define db double
#define lb long double
#define ui unsigned int

//Debug
#define B cerr<<"Break Point"<<endl;
#define P(x) cerr<<#x<<' '<<"="<<' '<<(x)<<endl;
#define p(x) cerr<<#x<<' '<<"="<<' '<<(x)<<' ';
#define ml(x) cerr<<"Size of array is "<<x*4/1024/1024<<" MB"<<endl;

//Vector
#define vc vector
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define vbe(x) x.begin(),x.end()

//Memset
#define ms(x) memset(x,0,sizeof(x))
#define MS(x) memset(x,0x3f3f3f3f,sizeof(x))

//Pair
#define fi first
#define se second

//File

#define fin(x) freopen(x,"r",stdin)
#define fou(x) freopen(x,"w",stdout)
void fio()
{
    #ifndef ONLINE_JUDGE
    freopen("sample.in","r",stdin);
    freopen("sample.out","w",stdout);
    #endif
}
void pti()
{
    double timeuse = clock()*1000.0/CLOCKS_PER_SEC;
    cerr<<"Timeuse "<<timeuse<<"ms"<<endl;
}
void end()
{
    pti();
    exit(0);
}

//Inf
#define INF 0x3f3f3f3f
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))

//IO
#define pc(s) putchar(s)
#define say(s) cout<<s<<endl
namespace io
{
    const int SIZ=55;int que[SIZ],op,qr;char ch;
    template<class I>
    il void gi(I &w)
    {
        ch=getchar(),op=1,w=0;while(!isdigit(ch)){if(ch=='-') op=-1;ch=getchar();}
        while(isdigit(ch)){w=w*10+ch-'0';ch=getchar();}w*=op;
    }
    template<class I>
    il void print(I w)
    {
        qr=0;if(!w) putchar('0');if(w<0) putchar('-'),w=-w;while(w) que[++qr]=w%10+'0',w/=10;
        while(qr) putchar(que[qr--]);
    }
}
using io::gi;
using io::print;

const int N=2e5+5;

int n,num;
string s[N],ans[N];
map<string,int>t;

int main()
{
    gi(n);
    int maxx=0;
    for(int i=1;i<=n;++i)
    {
        cin>>s[i];
        ++t[s[i]],maxx=max(maxx,t[s[i]]);
    }
    for(int i=1;i<=n;++i) if(t[s[i]]==maxx) ans[++num]=s[i],t[s[i]]=0;
    sort(ans+1,ans+num+1);
    for(int i=1;i<=num;++i) cout<<ans[i]<<endl;
    end();
}

Measured memory_bytes: 28288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	int [] ans_ar; 
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); //
	}
	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n/2+1];
		int[] b = new int[n/2+1];
		for (int i = 0; i < n/2; i++) {
			a[i] = Integer.parseInt(sc.next());
			b[i] = Integer.parseInt(sc.next());
		}
		a[n/2] = 1000000000;
		b[n/2] = 1000000000;
		Arrays.parallelSort(a);
		Arrays.parallelSort(b);
		int maxa = 0;
		int maxa2 = 0;
		int maxa_tmp = 1;
		int maxb2 = 0;
		int maxb = 0;
		int maxb_tmp = 1;
		int maxva = 0;
		int maxvb = 0;
		for (int i = 1; i <= n/2; i++) {
			if(a[i]==a[i-1])
			{
				maxa_tmp++;
			}
			else {
				if(maxa < maxa_tmp)
				{
					maxa2 = maxa;
					maxa = maxa_tmp;
					maxva = a[i-1];
				}
				else if(maxa2 < maxa_tmp)
				{
					maxa2 = maxa_tmp;
				}
				maxa_tmp = 1;
			}
			if(b[i]==b[i-1])
			{
				maxb_tmp++;
			}
			else {
				if(maxb < maxb_tmp)
				{
					maxb2 = maxb;
					maxb = maxb_tmp;
					maxvb = b[i-1];
				}
				else if(maxb2 < maxb_tmp)
				{
					maxb2 = maxb_tmp;
				}
				maxb_tmp = 1;
			}
		}
		if(maxva == maxvb)
		{
			out.println(Math.min(n-maxa-maxb2,n-maxa2-maxb));
		}
		else {
			out.println(n-maxa-maxb);
		}
		out.flush();
	}

	static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

Measured memory_bytes: 37460
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

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

Measured memory_bytes: 128
// -*- coding:utf-8-unix -*-

use proconio::input;

// n^p mod m (繰り返し二乗法)
fn repeat_square(n: u64, p: u64, m: u64) -> u64 {
    if p == 0 {
        1
    } else if p == 1 {
        n % m
    } else if p % 2 == 0 {
        repeat_square(n, p / 2, m).pow(2) % m
    } else {
        (n * repeat_square(n, p - 1, m)) % m
    }
}

fn main() {
    input! {
        n: u64,
    }
    if n == 1 {
        println!("0");
        return;
    }

    let divisor = 10_u64.pow(9) + 7;
    let ten = repeat_square(10, n, divisor);
    let nine = repeat_square(9, n, divisor);
    let eight = repeat_square(8, n, divisor);
    // println!("{} {}", nine, eight);
    let hiku = (((2 * nine) % divisor) + divisor - eight) % divisor;
    let ans = (ten + divisor - hiku) % divisor;
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#include <algorithm>
 
using namespace std;
 
#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
typedef long long ll;
 
const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;
 
void solve() {
  string S;
  int Q;
  cin >> S >> Q;
  string head = "";
  string tail = "";
  bool flag = false;
  for (int i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if (T == 1) {
      flag = !flag;
      swap(head, tail);
    } else {
      int F;
      char C;
      cin >> F >> C;
      if (F == 1) {
        head += C;
      } else {
        tail += C;
      }
    }
  }
  reverse(all(head));
  if (flag) {
    reverse(all(S));
  }
  cout << head + S + tail << endl;
}
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);
 
  solve();
 
  return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


typedef pair<double,double> Pd;

void countingSort(vector<int> &a, vector<int> &b, int k){
  vector<int> c(k+1, 0);

  for (int j=0; j<a.size(); j++) c[a[j]]++;

  for (int i=1; i<=k; i++) c[i] = c[i] + c[i-1];

  for (int j=a.size()-1; j>=0; j--){
    b[c[a[j]]-1] = a[j];
    c[a[j]]--;
  }
}

int main() {
  int n; cin >>n;
  vector<int> a(n); rep(i, n) cin >>a[i];
  vector<int> b(n);
  int k = 0;
  rep(i, n) chmax(k, a[i]);
  countingSort(a, b, k);
  rep(i, n){
    cout <<b[i];
    if (i == n-1) cout <<endl;
    else cout <<" ";
  }
}


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

int main()
{
    string s;
    int sm = 0;
    cin >> s;
    for(int i = 0; i < 4; i++)
    {
        if(s[i] == '+') sm++;
        else sm--;
    }
    cout << sm << endl;
}

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

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    ll times = x / d;
    if(times > k) {
        cout << x - k*d << endl;
        return 0;
    }

    x -= times * d;
    k -= times;
    k %= 2;
    if(k&1) x -= d;
    cout << abs(x) << endl;
}


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

bool sortbydesc(const pair<string, pair<int, int>>& a,
                const pair<string, pair<int, int>>& b)
                {
                    return (a.second.first > b.second.first);
                }
int main()
{
    int n, wi;
    cin >> n;
    
    unsigned int t = -1;

    vector<int> w;
    for (int i = 0; i < n; i++)
    {
        cin >> wi;
        w.push_back(wi);
    }

    int left_sum = 0, right_sum = 0;
    unsigned int min_diff = -1, diff;
    for (int j = 0; j < n; j++)
    {
        left_sum = accumulate(w.begin(), w.begin() + j, 0);
        right_sum = accumulate(w.begin() + j, w.end(), 0);
        diff = abs(left_sum - right_sum);
        if (diff < min_diff)
        {
            min_diff = diff;
        }

    }
    cout << min_diff << endl;

}


Measured memory_bytes: 256
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = [LIST() for i in range(n)]
a.sort(key=lambda x:x[1])
time = 0
for i in range(n):
        time += a[i][0]
        if(time>a[i][1]):
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 48124
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}

int main() {
    fastik();
    ll r,d,x;cin >> r>>d>>x;
    forn(i,10){
        x = r*x -d;
        cout << x << " ";
    }

}

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

int main()
{
    int n; cin >> n;
    string s; cin >> s;

    int m = n/2;

    if(m == n) {
        cout << "No" << endl;
        return 0;
    } 
    if (m*2 != n) {
        cout << "No" << endl;
        return 0;
    } 
   
    for(int i = 0; i< n/2; i++){
        if(s[i] != s[i+m]) {
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = (1e+9) + 1;
const int mod = 1000000007;
const double pi = 3.141592653589;
vector<int> a;
int n, k;
/* function */
bool check(int p) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
        // d = a[i]を全てp以下にするには何等分
        //   = a[i] / pの切り上げ
        int d = (a[i] + p-1) / p;
        // d等分を達成するには木を d - 1回切る必要がある
        sum += d - 1;
    }
    if(sum <= k) return true;
    return false;
}
/* main */
int main(){
    cin >> n >> k;
    int ok = MAX, ng = 0;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    // 達成できる最大値 を２分探索
    // (ng ,..., ok]
    // (0 ~ 1e+9]
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << '\n';

}

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



int main() {
  ll A,B;
  cin >> A >> B;
  ll x = A,j = 0;
  rep (i,B - A + 1)
  {
    ll y = x,x2 = 0;//x >> x2にする 
    rep (i,5)
    {
      ll a = y % 10;
      x2 += a * pow (10,4 - i);
      y = (y - a) / 10;
    }
    //cout << x2 << endl;
    if (x == x2)
    {
      j++;
    }
    x++;
  }
  cout << j << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int  N = sc.nextInt();
     long[] a=new long[N+1];
     int[] b=new int[N];
     long ans=0,answer=0;
     for(int i=0;i<N;i++){
       b[i]=sc.nextInt();
       a[b[i]]++;
     }
     for(int i=0;i<=N;i++){
       answer += (a[i]*a[i]-a[i])/2;
     }
     for(int i=0;i<N;i++){
       ans = answer-a[b[i]]+1;
       System.out.println(ans);
     }
   }
}


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


int main(){
  int n; cin>>n;
  vector<int> res;
  int a=-1;
  rep(i,500){
      res.push_back(i*(i+1)/2);
      if(i*(i+1)/2==n) a=i;
  }
  
      
  if(a==-1){
      cout<<"No"<<endl;
      return 0;
  }
  else {
      cout<<"Yes"<<endl;
  }
  int k=n*2/a;

  vector<int> ans[a+1];
  
  int num=1;
  rep(i,a+1){
      rep(j,i){
        ans[i].push_back(num);
        num++;
      } 
  }
  rep(i,a+1){
      rep(j,ans[i].size()){
        ans[j].push_back(ans[i][j]);
      } 
  }

   
  
  cout<<k<<endl;
  rep(i,a+1){
      cout<<a<<" ";
      rep(j,ans[i].size()){
         cout<<ans[i][j]<<" ";
      } 
      cout<<endl;
  }

   
}

Measured memory_bytes: 2304
# 整数の入力
N = int(input())
L = list(map(int,input().split()))

Lmax = max(L)

Lsum = 0

for i in range(N):
      Lsum = Lsum  +L[i]
Lsum = Lsum  -Lmax 
   

if Lmax < Lsum:
      print("Yes")
else:
      print("No")



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
void constructXOR(int A[], int n)
{
    // calculate xor of array
    int XOR = 0;
    for (int i = 0; i < n; i++)
        XOR ^= A[i];

    // update array
    for (int i = 0; i < n; i++)
        A[i] = XOR ^ A[i];
}

// Driver code
int main()
{   int n;
    cin>>n;
    int A[n+1];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    constructXOR(A, n);

    // print result
    for (int i = 0; i < n; i++)
        cout << A[i] << " ";
    return 0;
}


Measured memory_bytes: 4296
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[110][200010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    vector<ll> v;
    vector<ll> max_val;
    vector<ll> cnt;
    ll num = 0;
    for(ll i = 1; i * i <= N; i++){
        dp[1][i] = 1;
        v.push_back(i);
        num = i;
        max_val.push_back(N/i);
        cnt.push_back(1);
    }
    ll cur = num+1;
    ll idx = num+1;
    rrep(i,num,1){
        ll tt = N / i;
        if(i == num && tt == i) continue;
        ll diff = tt - cur + 1;
        // print(cur, i, diff);
        v.push_back(cur);
        dp[1][idx] = diff;
        idx++;
        cur = tt+1;
        max_val.push_back(i);
        cnt.push_back(diff);
    }
    // printa(v, v.size());
    // printa(max_val, max_val.size());
    // printa(cnt, cnt.size());
    ll sz = max_val.size();
    // print(sz);
    // rep(i,0,sz){
    //     cout << v[i] << "-" << v[i] + cnt[i]-1 << " \n"[i==sz-1];
    // }
    rep(i,1,K){
        rep(n,0,sz){
            ll val = max_val[n];
            ll pos = upper_bound(v.begin(), v.end(), val) - v.begin();
            // print(pos);
            dp[i+1][1] += dp[i][n+1];
            dp[i+1][pos+1] = (dp[i+1][pos+1] - dp[i][n+1] + MOD) % MOD;
            dp[i+1][1] %= MOD;
        }
        rep(n,1,sz) (dp[i+1][n+1] += dp[i+1][n] + MOD) %= MOD;
        rep(n,1,sz+1) (dp[i+1][n] *= cnt[n-1]) %= MOD;
    }
    ll ans = 0;
    rep(n,1,sz+1) (ans += dp[K][n]) %= MOD;
    print(ans);
}

Measured memory_bytes: 158188
def main():
    N, Y = (int(i) for i in input().split())
    for i in range(N+1):
        for j in range(N+1):
            k = (Y - 10000*i - 5000*j)//1000
            if k >= 0 and i+j+k == N and 10000*i+5000*j+1000*k == Y:
                return print(i, j, k)
    print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40940
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    S = input()
    T = input()

    if T.startswith(S):
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9040