akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <stack>
#include <queue>
#include <cstring>
#include <iterator>
#include <string>

#define FOR(n) for(int i=0;i<(n);++i)
#define FOR_R(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR_F(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)
#define MAXIMIZE(a, b) (a) = max((a),(b))
#define MINIMIZE(a, b) (a) = min((a),(b))

using namespace std;
typedef pair<int,int> P;
typedef pair<P, P> PP;
typedef long long ll;
int N;
vector<vector<int> > Graph;
vector<int> topArray;
vector<bool> visited;
vector<int> avalue;
void fill() {
  for(int i:topArray) {
    set<int> S;
    bool ok=true;
    for(int e:Graph[i]) {
      if (avalue[e]!=-1) {
        S.insert(avalue[e]);
      } else {
        ok=false;
      }
    }
    if (ok) {
      int k=0;
      while(S.count(k)>0)++k;
      avalue[i]=k;
    }
  }
}
void dfs(int at) {
  visited[at]=true;
  for(int e:Graph[at]) {
    if (!visited[e])
      dfs(e);
  }
  topArray.push_back(at);
}
bool check() {
  FOR(N) {
    set<int> S;
    for(int e:Graph[i]) {
      S.insert(avalue[e]);
    }
    int k=0;
    while(S.count(k)>0)++k;
    if (avalue[i]!=k)return false;
  }
  return true;
}
int main() {
  scanf("%d", &N);
  Graph.resize(N);
  visited.resize(N, false);
  avalue.resize(N, -1);
  FOR(N) {
    int p;
    scanf("%d", &p);--p;
    Graph[p].push_back(i);
  }
  FOR(N) {
    if (!visited[i])
      dfs(i);
  }
  fill();
  vector<int> back=avalue;
  int target,k1,k2;
  for(int i:topArray) {
    if (avalue[i]!=-1)continue;
    target=i;
    set<int> S;
    for(int e:Graph[i]) {
      if (avalue[e]!=-1) {
        S.insert(avalue[e]);
      }
    }
    int k=0;
    while(S.count(k)>0)++k;
    k1=k;
    ++k;
    while(S.count(k)>0)++k;
    k2=k;
    break;
  }
  avalue[target]=k1;
  fill();
  if (check()) {
    printf("POSSIBLE\n");
    return 0;
  }
  avalue=back;
  avalue[target]=k2;
  fill();
  if (check()) {
    printf("POSSIBLE\n");
    return 0;
  }
  printf("IMPOSSIBLE\n");
  return 0;

}


Measured memory_bytes: 20344
import bisect
primes = [0, 0] + [1] * 49999
for i in range(2, 225):
    if primes[i]:
        for j in range(i*i, 50001, i):
            primes[j] = 0
values = [i for i, k in enumerate(primes) if k]
while True:
    n = int(input())
    if n == 0:
        break
    I = bisect.bisect(values, n//2)
    print(sum(primes[n-i] for i in values[:I]))

Measured memory_bytes: 8132
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, i = 1; cin >> n;
	while(i * (i + 1) / 2 < n) i++;
	int bad = i * (i + 1) / 2 - n, sum = 0;
	for(int j = 1; j <= i; j++){
		if(j == bad) continue;
		cout << j << endl;
		sum += j;
	}
	assert(sum == n);
	return 0;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

ll gcd(ll a, ll b) {
  while(a^=b^=a^=b%=a);
  return b;
}

void solve() {
  ll A, B, C, D;
  in(A, B, C, D);
  ll ans = B - A + 1;
  ans -= (B / C) - ((A - 1) / C);
  ans -= (B / D) - ((A - 1) / D);
  ll l = C * D / gcd(C, D);
  ans += (B / l) - ((A - 1) / l);
  print(ans);
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    REP(i,N-1) cin >> C[i] >> S[i] >> F[i];
    int ans = 0;
    REP(i,N){
        ll ans = 0;
        for(int j=i;j<N-1;j++){
            if(ans < S[j]) ans = S[j];
            else if(ans % F[j] != 0) ans = ans + F[j] - ans % F[j];
            ans += C[j];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            a, b, c = L[i], L[j], L[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c:
                ans += 1

print(ans)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int div(int n){
    int c=1,temp=7;
    while(temp%n!=0){
        temp=(temp%n)*10+7;
        c++;
    }
    return c;
}
int main()
{
    int n;
    cin>>n;
    if(n%2==0 || n%5==0){
        cout<<-1;
        return 0;
    }
    cout<<div(n);
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int func(int a){
	return (a>0)?a:-a;
}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int diff[3]={func(c-b),func(c-a),func(b-a)};
	sort(diff,diff+3);
	cout<<diff[0]+diff[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
in_a = input()
in_b = input()
in_c = input()
in_x = input()

A = int(in_a)
B = int(in_b)
C = int(in_c)
X = int(in_x)

count = 0
for i in range(A+1):
    for j in range(B+1):
        k = ( X - 500*i - 100*j ) / 50
        # print(f'k：{k}')
        if k < 0:
            break;
        elif k.is_integer() and k <= C:
            count +=1
            # print('clear', k, count)

print(count)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



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


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

int main() {
	string from;
	while (getline(cin,from)) {
		for (int j = 1; j <= 26; j++) {
			for (int i = 0; i < from.size(); i++) {
				if (from[i] != '.'&&from[i] != ' ') {
					if (from[i] + 1 > 122)from[i] = from[i] + 1 - 26;
					else from[i] = from[i] + 1;
				}
			}
				if ((int)from.find("the") != -1)break;
				if ((int)from.find("this") != -1)break;
				if ((int)from.find("that") != -1)break;
		}
		cout << from << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
/*
  AOJ 2060
  Title:Tetrahedra
  @kankichi573
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define max(x,y) (((x)>(y))?(x):(y))
int NN;
double a[15];

is_triangle(double a1,double a2,double a3)
{
  return (a1<a2+a3) && (a2<a3+a1) && (a3<a1+a2);
}

double simen_volume(double a1,double a2,double a3,
		    double a4,double a5,double a6)
{
  double v,a12,a22,a32,a42,a52,a62;

  if(is_triangle(a1,a2,a4) &&
     is_triangle(a2,a3,a5) &&
     is_triangle(a1,a3,a6) &&
     is_triangle(a4,a5,a6))
    {
      a12=a1*a1;
      a22=a2*a2;
      a32=a3*a3;
      a42=a4*a4;
      a52=a5*a5;
      a62=a6*a6;
      v =a12*a52*(a22+a32+a42+a62-a12-a52);
      v+=a22*a62*(a12+a32+a42+a52-a22-a62);
      v+=a32*a42*(a12+a22+a52+a62-a32-a42);
      v-=a12*a22*a42;
      v-=a22*a32*a52;
      v-=a32*a12*a62;
      v-=a42*a52*a62;
      if(v>0.0)
	return(sqrt(v)/12);
      else
	return(0);
    }
  else
    return(0);
}
double simen_volume2(double aa[])
{
  return simen_volume(aa[0],aa[1],aa[2],aa[3],aa[4],aa[5]);
}

double solve(double args[],int count,int used)
{
  int i;
  unsigned int mask;
  double max_,ret,prev,vol;

  //printf(" %d\n",used);
  if(count==6)
    {
      vol=simen_volume2(args);
#ifdef DEBUG
      if(vol!=0.0)
	{
	  for(i=0;i<6;i++)
	    printf("%2.0f:",args[i]);
	  printf("%lf %d\n",vol,used);
	}
#endif
      return(vol);
    }

  max_=0;
  prev=0.0;
  for(i=0,mask=1;i<NN;i++,mask<<=1)
    {
      if((used & mask) ==0)
	{
	args[count]=a[i];
	ret=solve(args,count+1,used|mask);
	max_=max(max_,ret);
	}
    }
  return(max_);
}

main()
{
  int i;
  double ret,args[6];

  while(scanf("%d",&NN)  && (NN   ))
    {
      for(i=0;i<NN;i++)
	scanf("%lf",&a[i]);
      ret=solve(args,0,0);
      printf("%5.7lf\n",ret);
    }
  
  return(0);

}

Measured memory_bytes: 656
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
int X[1000000],Y[1000000];
signed main() {
    int H,W;
    cin >> H >> W;
    vector<string>S(H);
    for(int i = 0; i < H; i++) {
        cin >> S[i];
    }
    UnionFind uf(H*W);
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W-1; j++) {
            if(S[i][j] != S[i][j+1]) {
                uf.unite(i*W+j,i*W+j+1);
            }
        }
    }
    for(int i = 0; i < W; i++) {
        for(int j = 0; j < H-1; j++) {
            if(S[j][i] != S[j+1][i]) {
                uf.unite(j*W+i,j*W+i+W);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(S[i][j] == '.') {
                X[uf.find(i*W+j)]++;
            }
            else {
                Y[uf.find(i*W+j)]++;
            }
        }
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            ans+=X[i*W+j]*Y[i*W+j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8472
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(void){
  string s;
  ll k;
  cin >> s;
  cin >> k;
  vector< ll > succ;
  ll cnt = 1LL;
  for(int i = 1;i < (int)s.size();++i){
    if(s[i] == s[i-1]){
      ++cnt;
    }else{
      succ.push_back(cnt);
      cnt = 1LL;
    }
  }
  succ.push_back(cnt);
  /*
  for(int i : succ){
    cout << i << " ";
  }
  cout << endl;
  */
  if(succ.size() == 1){
    cout << (succ[0] * k) / 2 << endl;
  }else if(s[0] == s[s.size()-1]){
    assert(succ.size() >= 3);
    ll res = 0LL;
    ll cnt = 0LL;
    for(int i = 1;i < (int)succ.size()-1; ++i){
      cnt += succ[i]/2;
    }
    res += cnt * k;
    res += ((succ[0] + succ[succ.size()-1]) / 2) * (k-1);
    res += succ[0] / 2;
    res += succ[succ.size()-1] / 2;
    cout << res << endl;
  }else{
    ll res = 0;
    for(int i = 0;i < (int)succ.size(); ++i){
      res += succ[i]/2;
    }
    cout << res * k << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;


int main(void) {
    vector<int> arr(5);
    // 一番最後に端数の小さなものにする
    int lastMod = 100000;
    int lastIndex = -1;
    for(int i = 0 ; i < arr.size() ; ++i) {
        cin >> arr[i];

        int mod = arr[i] % 10;
        if (mod && lastMod > mod) {
            lastMod = mod;
            lastIndex = i;
        }
    }
    int sum = 0;
    for(int i = 0 ; i < arr.size() ; ++i) {
        if(lastIndex == i) {
            sum += arr[i];
        } else {
            int mod = arr[i] % 10;
            if (mod) {
                arr[i] += (10 - mod);
                
            }
            sum += arr[i];
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
  
  int X,A,N,B;
  
  int result0,result1;

  cin >> N >> A >> B;

  result0 = N * A;
  result1 = N * A;

  if((N*A)> B){
    cout << B << endl;
  }else{
    cout << N*A << endl;
  }
 
  return(0);
}


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

int main(){
    long long N;
    cin >> N;
    long long A=1,B=1;
    for(int i=0;i<100000;i++){
        if(i%2==0){
            A=i*i;
            if(A>N){
                cout << B << endl;
                break;
            }
        }
        else{
            B=i*i;
            if(B>N){
                cout << A << endl;
                break;
            }
        }
    }
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  string s;cin>>s;
  ans(s[0]==s[1]||s[1]==s[2]||s[2]==s[3],"Bad","Good");

  return 0;
}

Measured memory_bytes: 256
import math
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
a,b = na()
R,C = 100,100
G = [["#" for i in range(C)] for j in range(R)]
for i in range(R):
    for j in range(50,100):
        G[i][j] = "."

a-=1
b-=1
p_a = a//25
r_a = a%25
p_b = b//25
r_b = b%25


for i in range(0,2*p_a,2):
    for j in range(0,50,2):
        G[i][j] = "."
for i in range(0,2*r_a,2):
    G[2*p_a][i]="."
for i in range(0,2*p_b,2):
    for j in range(51,100,2):
        G[i][j] = "#"
for i in range(51,50+2*r_b,2):
    G[2*p_b][i]="#"

#print(G)
print(100, 100)
for i in range(R):
    print("".join(G[i]))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
int  pow(int x,int n) {int res=1; while(n){if(n&1) res=(res*x);x=(x*x);n>>=1;}return res;}
	int n, k; 
 
 int solve(vi &a){

 		int dp[n+1] = {};

 		dp[1] = 0;

 		for(int i=2 ;i<=n;++i){
 		 dp[i] = INT_MAX;
 			for(int j=1 ;j<=k;++j){
 				if(i - j > 0){
 			dp[i] = min(dp[i], abs(a[i] - a[i-j]) + dp[i-j]);
 	
 				}
 			}

 		}

 		return dp[n];
 }
int32_t main()
{
	
	//Paawan Singal
	FIO;
	cin >> n >> k;

	vi a(n+1);

	for(int i=1 ;i<=n;i++)
		cin >> a[i];

	cout << solve(a) << '\n';
	return 0;
}

Measured memory_bytes: 1792
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x << endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
int dig(int n){return (int)(log10(n) + 1);}
int abc(char x){return (int)(x)-(int)('a');} // 0~25
char abc(int x){return (char)(x+(int)('a'));} 
int ABC(char x){return (int)(x)-(int)('A');}
char ABC(int x){return (char)(x+(int)('A'));}
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
	int N, a, b;
	int ans = 0;
	int tmp = 0;
	int f = 1;
	string S;
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << ' '  << X << ' ' << Y << endl;
	//if (f) cout << "Yes" << endl;
	//else cout << "No" << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
#define int long long
	int n;
	cin >> n;
	vector<vector<int>> wow;
	vector<vector<int>> scores;
	for (int i = 0;i < n;++i) {
		vector<int> now;
		REP(q, 10) {
			int tmp;
			cin >> tmp;
			now.push_back(tmp);
		}
		wow.push_back(now);
	}
	for (int i = 0;i < n;++i) {
		vector<int> now;
		REP(q, 11) {
			int tmp;
			cin >> tmp;
			now.push_back(tmp);
		}
		scores.push_back(now);
	}
	long long ans = -LONG_INF;
	for (int i = 1;i < 1024;++i) {
		long long pre_ans = 0;
		for (int q = 0;q < wow.size();++q) {
			int cnt = 0;
			int copy = i;
			for (int j = 0;j < 10;++j) {
				if (wow[q][j] == 1 && copy % 2 == 1) cnt++;
				copy /= 2;
			}
			pre_ans += scores[q][cnt];
		}
		if (ans < pre_ans) {
			ans = max(ans, pre_ans);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    ll A;
    string B;
    cin >> A >> B;
    ll ans = 0;
    ll tmp = 0;
    ans += A*(B[0]-'0');
    ans += (A/10)*(B[2]-'0');
    tmp += (A-A/10*10)*(B[2]-'0')*10;
    ans += (A/100)*(B[3]-'0');
    tmp += (A-A/100*100)*(B[3]-'0');
    ans += tmp/100;
    cout << ans << endl;
}

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

int main(void){
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        int a; cin >> a;
        A[i]=a-(i+1);
    }

    sort(A.begin(), A.end());
    int b=A[(N-1)/2];
    ll ans=0;

    for(int i=0; i<N; i++) ans+=abs(A[i]-b);

    cout << ans << endl;
}

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

int main(){
  long long n, k; cin >> n >> k;
  long long ans = 0;
  for (int i = 0; i < k; i++) {
    long long u = n / k + (n % k >= i && i != 0);
    if (((k-i)*2) % k != 0) continue;
    long long v = n / k + (n % k >= i && i != 0);
    ans += u * v * v;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<17;

int main(){
    int V,E;
    cin >> V >> E;
    int dist[V][V];
    int dp[1<<V][V];
    for(int i=0;i<(1<<V);i++){
        for(int j=0;j<V;j++){
            dp[i][j]=INF;
        }
    }
    for(int i=0;i<V;i++){
        for(int j=0;j<V;j++){
            dist[i][j]=INF;
        }
    }
    for(int i=0;i<E;i++){
        int s,t,d;
        cin >> s >> t >> d;
        dist[s][t]=d;
    }
    dp[0][0]=0;
    for(int S=0;S<(1<<V);S++){
        for(int j=0;j<V;j++){
            if(dp[S][j]==INF) continue;
            for(int k=0;k<V;k++){
                if((S>>k)&1) continue;
                dp[S|(1<<k)][k]=min(dp[S|(1<<k)][k],dp[S][j]+dist[j][k]);
            }
        }
    }
    int ans=INF;
    ans=dp[(1<<V)-1][0];
    if(ans==INF) puts("-1");
    else cout << ans << endl;
    return 0;
}


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

const ll INF = 1LL << 60;

ll H, W;

char c[110][110];
ll dp[110][110];

int main() {
    cin >> H >> W;
    rep(i, H)rep(j, W) cin >> c[i][j];

    rep(i, H)rep(j, W) dp[i][j] = INF;

    if (c[0][0] == '#') {
        dp[0][0] = 1; 
    } else {
        dp[0][0] = 0;
    }

    rep(i, H)rep(j, W) {
        // 右の遷移
        dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (c[i][j] == '.' && c[i][j + 1] == '#' ? 1 : 0));

        // 下の遷移
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (c[i][j] == '.' && c[i + 1][j] == '#' ? 1 : 0));
    }

    cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

    void solve(Scanner sc) {
        char[] n = sc.next().toCharArray();
        boolean f = false;
        for (int i = 1; i < n.length; i++) {
            if (n[i] != '9') {
                f = true;
                break;
            }
        }

        if (f) {
            int ans = Integer.parseInt(String.valueOf(n[0])) - 1 + 9 * (n.length - 1);
            System.out.println(ans);
        } else {
            int ans = Integer.parseInt(String.valueOf(n[0])) + 9 * (n.length - 1);
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  int n;
  map<string,int>rep;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    rep[s]++;
  }
  cout<<"AC x "<<rep["AC"]<<endl;
  cout<<"WA x "<<rep["WA"]<<endl;
  cout<<"TLE x "<<rep["TLE"]<<endl;
  cout<<"RE x "<<rep["RE"]<<endl;
  return 0;
}


Measured memory_bytes: 3652
n = gets.chomp.to_i
s = []
hash = {}

for i in 1..n do
    word = gets.chomp.split("").sort.join
    if hash.key?(word) 
        hash[word] += 1
    else
        hash[word] = 1
    end
end

sum = 0
hash.each{ |key,value| 
    sum += value*(value-1)/2
}
p sum

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[1<<18];

int L[1<<18],R[1<<18];

void calcL(int l,int r){
    if(l+1==r){
        if(A[l])chmax(L[l],A[l]);
        return;
    }
    int m=(l+r)/2;
    calcL(l,m);
    for(int i=0;i<m-l;i++)chmax(L[m+i],L[l+i]);
    calcL(m,r);
}

void calcR(int l,int r){
    if(l+1==r){
        if(A[l])chmin(R[l],A[l]);
        return;
    }
    int m=(l+r)/2;
    calcR(m,r);
    for(int i=0;i<r-m;i++)chmin(R[l+i],R[m+i]);
    calcR(l,m);
}

vpint lis[1<<19];

bool ex[1<<19];

vint calc(int l,int r){
    if(l+1==r)return {A[l]};
    int m=(l+r)/2;
    vint X=calc(l,m);
    vint Y=calc(m,r);

    vint Z;
    rep(i,X.size()){
        Z.pb(X[i]);
        Z.pb(Y[i]);
    }
    return Z;
}

signed main(){
    cin>>N;
    rep(i,1<<N)cin>>A[i];
    rep(i,1<<N)if(A[i])ex[A[i]]=true;
    fill_n(L,(1<<N),1);
    fill_n(R,(1<<N),(1<<N));

    calcL(0,1<<N);
    calcR(0,1<<N);

    rep(i,1<<N){
        if(A[i]==0)lis[R[i]].pb({L[i],i});
        else{
            if(L[i]>R[i]){
                cout<<"NO"<<endl;
                return 0;
            }
        }
    }

    priority_queue<pint>que;
    for(int i=1<<N;i>0;i--){
        for(auto &w:lis[i])que.push(w);
        if(ex[i])continue;
        if(que.size()==0||que.top().fi>i){
            cout<<"NO"<<endl;
            return 0;
        }
        pint w=que.top();
        que.pop();
        A[w.se]=i;
    }

    vint ans=calc(0,1<<N);
    cout<<"YES"<<endl;
    rep(i,1<<N){
        if(i)cout<<" ";
        cout<<ans[i];
    }cout<<endl;
    return 0;
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  using P = pair<int, int>;
  vector<vector<P> > G(n);
  for(int i=1;i<n;i++){
    int u,v,w;
    cin>>u>>v>>w;
    G[u].emplace_back(v,w);
    G[v].emplace_back(u,w);
  }

  vector<int> dp(n);
  auto dfs=[&](auto &&f,int v,int p,int d)->P{
    P res(d,v);
    for(auto e:G[v]){
      int u,c;
      tie(u,c)=e;
      if(u==p) continue;
      chmax(res,f(f,u,v,d+c));
    }
    return res;
  };
  
  int pos=dfs(dfs,0,-1,0).second;
  cout<<dfs(dfs,pos,-1,0).first<<endl;
  
  return 0;
}



Measured memory_bytes: 12596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int d;
    cin >> d;
    if(d == 25) cout << "Christmas";
    else if(d == 24) cout << "Christmas Eve";
    else if(d == 23) cout << "Christmas Eve Eve";
    else cout << "Christmas Eve Eve Eve";
    return 0;
}

Measured memory_bytes: 256
import collections

def comb2(n):
    return int(n * (n - 1) / 2)

def combdict(dic, dp):
    ans = 0
    for v in dic.values():
        ans += dp[v]
    return ans

def solve(a, dic, dp):
    allsum = combdict(dic,dp)
    for i in a:
        print(allsum - dp[dic[i]] + dp[dic[i]-1])

def main():
    dp = [comb2(i) for i in range(2 * ( 10 ** 5) + 1)]
    n = int(input())
    a = list(map(int,input().split()))
    d = collections.Counter(a)
    solve(a, d, dp)

if __name__ == '__main__':
    main()

Measured memory_bytes: 34868
#include <stdio.h>
int main(){
  int a, b;
  scanf("%d %d", &a, &b);
    if (a < b){
       for(int i = 0; i < b; i++){
          printf("%d", a);
       }
    }else {
       for(int i = 0; i < a; i++){
          printf("%d", b);
       }
    }
    printf("\n");
    return 0;    
}


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

int main(){
  int N;
  cin >> N;
  int cont=0;
  vector<int> count(N);
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      if(i%j==0){
        count.at(i-1)+=1;
      }
    }
    if(count.at(i-1)==8){
      if(i%2==1){
        cont+=1;
      }
    }
  }
  cout << cont << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int  tmp,n,p[1000][3],i,j,a,b,c,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d%d%d",&p[i][0],&p[i][1],&p[i][2]);

    if(p[i][0] > p[i][1]){
      tmp = p[i][0];
      p[i][0] = p[i][1];
      p[i][1] = tmp;
    }
    if(p[i][1] > p[i][2]){
      tmp = p[i][1];
      p[i][1] = p[i][2];
      p[i][2] = tmp;
    }
    if(p[i][0] > p[i][1]){
      tmp = p[i][0];
      p[i][0] = p[i][1];
      p[i][1] = tmp;
    }

  
    
    a = p[i][0];
    b = p[i][1];
    c = p[i][2];

    // printf("%d%d%d\n",a,b,c);
    
    for(j=0;j<i;j++){
      //  printf("%d\n",p[j][0]);
      if(a == p[j][0] && b == p[j][1] && c == p[j][2]){
	count++;
	break;
      }
    }

  }

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

  return 0;

}

Measured memory_bytes: 608
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r,a,b;
    cin>> W >> H >> x >> y >> r;
    a=W-r;
    b=H-r;
    if(a>=x&&r<=x&&b>=y&&r<=y){
    cout << "Yes" <<endl;
}else{
    cout << "No" <<endl;
}
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int N;
  vector<long long> A;
  vector<long long> B;
  
  cin >> N;
  A.resize(N+1);
  B.resize(N);
  for (int i = 0; i <= N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) cin >> B[i];
  
  unsigned long long ans = 0;
  for (int i = 0; i < N; ++i) {
    int a0 = min(A[i], B[i]);
    A[i] -= a0;
    B[i] -= a0;
    int a1 = min(A[i+1], B[i]);
    A[i+1] -= a1;
    B[i] -= a1;
    ans += a0 + a1;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
A = int(input())
from operator import itemgetter
B = []
for i in range(A):
    B.append(list(map(int,input().split())))
B.sort(key=itemgetter(1))
now = 0
for i in range(A):
    now += B[i][0]
    if now > B[i][1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 53720
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

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

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

  ll n;
  std::cin>>n;

  std::string s;
  std::cin>>s;

  ll ans=0;
  rep(i,0,n-2){
    if(s.substr(i,3)=="ABC")ans++;
  }

  std::cout<<ans<<"\n";

  return 0;
}

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

int main(){
    int n,l;
    cin>>n>>l;
    vector<string> s;
    for(int i=0;i<n;i++){
        string a;
        cin>>a;
        s.push_back(a);
    }
    sort(s.begin(),s.end());
    string ans;
    for(int i=0;i<s.size();i++){
        ans+=s[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  ll ans=mod;
  for(ll i=0;i<=n;i++){
    ll tmp=0;
    ll t=i;
    while(t>0){
      tmp+=t%6;
      t/=6;
    }
    t=n-i;
    while(t>0){
      tmp+=t%9;
      t/=9;
    }
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    if(c < b && c > a || a > c && c > b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int P1 = 29;
const int P2 = 31;
const int MOD = 1e9 + 7;

struct Hashs 
{
	vector<int> hashs;
	vector<int> pows;
	int P;
	int MOD;

	Hashs() {}

	Hashs(string &s, int P, int MOD) : P(P), MOD(MOD) 
	{
		int n = s.size();
		pows.resize(n+1, 0);
		hashs.resize(n+1, 0);
		pows[0] = 1;
		for(int i=n-1;i>=0;i--) 
		{
			hashs[i]=(1LL * hashs[i+1] * P + s[i] - 'a' + 1) % MOD;
			pows[n-i]=(1LL * pows[n-i-1] * P) % MOD;
		}
		pows[n] = (1LL * pows[n-1] * P)%MOD;
	}
	int get_hash(int l, int r) 
	{
		int ans=hashs[l] + MOD - (1LL*hashs[r+1]*pows[r-l+1])%MOD;
		ans%=MOD;
		return ans;
	}
};


int n;
string s;
Hashs h1, h2;

int check(int x)
{
	map<pair<int, int> , vector<int> > m;
	for(int i = 0; i + x - 1 < s.size(); i++)
	{
		int hash1 = h1.get_hash(i, i + x - 1);
		int hash2 = h2.get_hash(i, i + x - 1);
		m[{hash1, hash2}].push_back(i);
	}
	for(auto &it:m)
	{
		int lo = it.second[0];
		int hi = it.second.back();
		if(hi - lo >= x)
			return 1;
	}
	return 0;
}

int binsearch(int lo, int hi)
{
	while(lo < hi)
	{
		int mid = (lo + hi + 1) / 2;
		if(check(mid))
			lo = mid;
		else
			hi = mid - 1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	cin >> n >> s;
	h1 = Hashs(s, P1, MOD);
	h2 = Hashs(s, P2, MOD);
	int ans = binsearch(0, n / 2);
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
from bisect import bisect_left

n = 100010
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

X = int(input())
print(primes[bisect_left(primes,X)])

Measured memory_bytes: 103076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N = 2000; 

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int sx,sy,tx,ty,dx,dy;
	cin>>sx>>sy>>tx>>ty;
	cout<<string(ty-sy,'U')<<string(tx-sx,'R');
	cout<<string(ty-sy,'D')<<string(tx-sx,'L');
	cout<<'L'<<string(ty-sy+1,'U')<<string(tx-sx+1,'R')<<'D';
	cout<<'R'<<string(ty-sy+1,'D')<<string(tx-sx+1,'L')<<'U'<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

const ll MAX = (ll)1e5 + 55;
vector<vector<ll>> dp(MAX, vector<ll>(110, -1));
vector<pair<ll, ll>> ar(MAX, {0, 0});

ll func(ll w, ll n)
{
    if (n == 0)
    {
        return 0;
    }
    if (w <= 0)
    {
        return 0;
    }
    else if (dp[w][n] != -1)
    {
        return dp[w][n];
    }
    else
    {
        if (w - ar[n].second >= 0)
            dp[w][n] = max(ar[n].first + func(w - ar[n].second, n - 1), func(w, n - 1));
        else
        {
            dp[w][n] = func(w, n - 1);
        }

        return dp[w][n];
    }
}

int main()
{
    ll n, w;
    cin >> n >> w;
    for (int x = 1; x <= n; x++)
    {
        ll a, b;
        cin >> a >> b;
        ar[x] = {b, a};
    }
    func(w, n);
    cout << dp[w][n] << endl;
}

Measured memory_bytes: 91776
a,b=map(int,input().split())
def p(n):
    a = set([1])
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a
s=p(a)
l=list(s)
for x in l:
  if b%x!=0:
    s.remove(x)
print(len(s))

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, k, a, dp[2][100004];

int main() {
	cin>>n>>k;
	memset(dp,0,sizeof(dp));
	cin>>a;
	for(int i = 0;i<=100000;i++)
		if(i<=a)
			dp[1][i] = 1+dp[1][i-1];
		else
			dp[1][i] = dp[1][i-1];
	for(int i = 2;i<=n;i++){
		cin>>a;
		int tog1 = i%2, tog2 = (i+1)%2;
		for(int j = 0;j<=100000;j++){
			if(j>a)
				dp[tog1][j] = (dp[tog2][j]+mod-dp[tog2][j-a-1])%mod;
			else
				dp[tog1][j] = (dp[tog2][j]+mod)%mod;
			dp[tog1][j] = (dp[tog1][j]+dp[tog1][j-1])%mod;
		}
	}
	cout<<(dp[n%2][k]-dp[n%2][k-1]+mod)%mod;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

vector<int> R,G,B;
unordered_set<int> Rs,Gs,Bs;

int main(void) {
  int N; cin >> N;
  string S; cin >> S;
  
  rep(i,N){
    if (S[i]=='R'){
      R.push_back(i);
      Rs.insert(i);
    }
    if (S[i]=='G'){
      G.push_back(i);
      Gs.insert(i);
    }
    if (S[i]=='B'){
      B.push_back(i);
      Bs.insert(i);
    }
  }
  
  ll res = 0;
  
  rep(i,N){
    for (int j = i+1; j < N; j++){
      if ((S[i]=='R' && S[j]=='G')||(S[j]=='R' && S[i]=='G')){
        int num = B.end() - upper_bound(all(B), j);
        res += num;
        if (Bs.find(2*j-i) != Bs.end()) res--;
      }
      if ((S[i]=='R' && S[j]=='B')||(S[j]=='R' && S[i]=='B')){
        int num = G.end() - upper_bound(all(G), j);
        res += num;
        if (Gs.find(2*j-i) != Gs.end()) res--;
      }
      if ((S[i]=='B' && S[j]=='G')||(S[j]=='B' && S[i]=='G')){
        int num = R.end() - upper_bound(all(R), j);
        res += num;
        if (Rs.find(2*j-i) != Rs.end()) res--;
      }
    }
  }
  
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 3800
#include<iostream>
#include<cstdio>
#define N 12345
#define ll long long
using namespace std;
ll n,a[N],b[N],sum1,sum2;
int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) scanf("%lld",a+i);
	for(ll i=1;i<=n;i++) scanf("%lld",b+i);
	for(ll i=1;i<=n;i++)
	{
		if(a[i] > b[i]) sum1 += (a[i] - b[i]);
		if(a[i] < b[i]) sum2 += (b[i] - a[i])/2;
	}
	if(sum1>sum2) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N,A[200001],Asum[200001]={0};
	ll toori=0;
	scan(N);
	rep(i,N){
		scan(A[i]);
	}
	rep1(i,N){
		Asum[i]=Asum[i-1]+A[i-1];
	}
	sort(Asum,Asum+N+1);
	ll nownum=Asum[0];
	ll count=1;
	rep1(i,N){
		if(Asum[i]==nownum){
			count++;
		}
		else{
			nownum=Asum[i];
			toori+=(ll)count*(count-1)/2;
			count=1;
		}
	}
	toori+=count*(count-1)/2;
	prin(toori);
	return 0;
}


Measured memory_bytes: 3328
# coding=utf-8


class Dice(object):

    def __init__(self, list_):
        self.label = list_

    def getLabel(self, i):
        return self.label[i - 1]

    def _rotateS(self):
        self.label = [self.getLabel(i) for i in [5, 1, 3, 4, 6, 2]]

    def _rotateN(self):
        self.label = [self.getLabel(i) for i in [2, 6, 3, 4, 1, 5]]

    def _rotateE(self):
        self.label = [self.getLabel(i) for i in [4, 2, 1, 6, 5, 3]]

    def _rotateW(self):
        self.label = [self.getLabel(i) for i in [3, 2, 6, 1, 5, 4]]

    def _spinPos(self):
        self.label = [self.getLabel(i) for i in [1, 4, 2, 5, 3, 6]]

    def _spinNeg(self):
        self.label = [self.getLabel(i) for i in [1, 3, 5, 2, 4, 6]]

    def rotate(self, rotates):
        for r in rotates:
            if r == 'S':
                self._rotateS()
            elif r == 'N':
                self._rotateN()
            elif r == 'E':
                self._rotateE()
            elif r == 'W':
                self._rotateW()
            elif r == 'T':
                self._spinPos()
            elif r == 'B':
                self._spinNeg()

    def matchTopFront(self, top, front):
        iTop = self.label.index(top) + 1
        topRot = {1: '', 2: 'N', 3: 'W', 4: 'E', 5: 'S', 6: 'SS'}
        self.rotate(topRot[iTop])

        iFront = self.label.index(front) + 1
        frontRot = {2: '', 3: 'B', 4: 'T', 5: 'TT'}
        self.rotate(frontRot[iFront])

    def copy(self):
        return Dice(self.label[:])

    def __eq__(self, other):
        for rs in ['', 'S', 'N', 'W', 'SS']:
            tmp = self.copy()
            for r in rs:
                tmp.rotate(r)
            top = tmp.getLabel(1) == other.getLabel(1)
            bottom = tmp.getLabel(6) == other.getLabel(6)
            side, n = False, 3
            while not side and n > 0:
                if tmp.label[1:6] == other.label[1:6]:
                    side = True
                else:
                    tmp.rotate('T')
                    n -= 1
            if top and bottom and side:
                return True
        else:
            return False


def main():
    face1 = map(int, raw_input().split())
    face2 = map(int, raw_input().split())
    # ????????????????????????????????´?????????????????´???
    if set(face1) != set(face2):
        print 'No'
    # ???????????????????????´???
    elif len(face1) == len(set(face1)):
        d1 = Dice(face1)
        d2 = Dice(face2)
        d2.matchTopFront(d1.getLabel(1), d1.getLabel(2))
        print 'Yes' if d1.label == d2.label else 'No'
    # ???????????????????????´???
    else:
        d1 = Dice(face1)
        d2 = Dice(face2)
        print 'Yes' if d1 == d2 else 'No'

if __name__ == '__main__':
    main()

Measured memory_bytes: 4416
s = input()
if len(s) % 2 != 0:
    s = s[:-1]
else:
    s = s[: -2]
flag = False
while not flag:
    m = len(s) // 2
    if s[:m] == s[m:]:
        flag = True
    else:
        s = s[:-2]

print(len(s))

Measured memory_bytes: 3060