akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX_N 100001

int N;
long int X;
long int x[MAX_N];

// bool is_multiple(long int D){
//     // 隣町までの距離がD以上であるかどうか
//     for (int i = 0; i < N; i++){
//         if ((x[i + 1] - x[i]) < D){
//             return false;
//         }
//     }
//     return true;
// }
// long int binary_search(long int left, long int right){
//     if (left == right){
//         return left;
//     }
//     cout <<left <<" " << right << endl;
//     long int D = (left + right) / 2;
//     if (D == left){
//         D = right;
//     }else if (D == right){
//         D = left;
//     }
//     if (is_multiple(D)){
//         // 隣町までがD以上→D以上が答え
//         return binary_search(D, right);
//     }else{
//         // Dより小さい
//         return binary_search(left, D - 1);
//     }
// }

long int D;

long int gcd(long int a, long int b) {
  if(a < b) return gcd(b, a);
  long int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    cin >> N >> X;
    for (int i = 0; i < N; i++){
        cin >> x[i];
    }
    // Xも含めて昇順にする
    x[N] = X;
    sort(x, x + N + 1);
    // cout <<left <<" " << right << endl;
    // D = binary_search(1,x[N] - x[0]);
    long int dis[MAX_N];
    for (int i = 0; i < N; i++){
        dis[i] = x[i + 1] - x[i];
    }
    D = dis[0];
    for (int i  = 1; i < N; i++){
        D = gcd(D, dis[i]);
    }
    cout << D << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n,m;cin >> n >> m;
    vector<bool> a(101000,true);
    rep(i,m){
        int t;cin >> t;
        a[t] = false;
    }
    vector<ll> dp(101000,0);
    dp[0] = 1;
    for(int i=0;i<n;i++){
        for(int j=1;j<=2;j++){
            if(a[i+j]){
                dp[i+j]+=dp[i];
                dp[i+j]%=MOD;
            }
        }
    }
    cout << dp[n]%MOD << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int ans=0;
int main(void){
	ll i,n,m;
	cin>>n>>m;
	ll x[n],y[n],z[n];
	for(i=0;i<n;i++)cin>>x[i]>>y[i]>>z[i];
	ll sum=0,tmp[n],ans=0;
	for(i=0;i<n;++i){
		tmp[i]=x[i]+y[i]+z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i)sum+=tmp[i];
  	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i){
		tmp[i]=x[i]+y[i]-z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i)sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i){
		tmp[i]=x[i]-y[i]+z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i)sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i){
		tmp[i]=x[i]-y[i]-z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i)sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i){
		tmp[i]=-x[i]+y[i]+z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i)sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i){
		tmp[i]=-x[i]+y[i]-z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i)sum+=tmp[i];
	ans=max(ans,sum);
	sum=0;
	for(i=0;i<n;++i){
		tmp[i]=-x[i]-y[i]-z[i];
	}
	sort(tmp,tmp+n);
	for(i=n-1;i>n-1-m;--i)sum+=tmp[i];
	ans=max(ans,sum);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,co;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c)
        co=1;
    else if(a!=b&&b==c)
        co=2;
    else if(a==b&&b!=c)
        co=2;
    else if(a==c&&b!=c)
        co=2;
    else 
        co=3;
    printf("%d",co);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<double> a(n);
    double s = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        s += a[i];
    }
    int ind = -1;
    double odl = 1000000000;
    for (int i = 0; i < n; ++i)
    {
        if (ind == -1 || abs((s / double(n)) - a[i]) < odl)
        {
            ind = i;
            odl = abs((s / double(n)) - a[i]);
        }
    }
    cout << ind;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} 
int main(void)
{
  int a,b,c,k;
  
  scanf("%d %d %d %d",&a,&b,&c,&k);
  
  if(k>=a+b)
  printf("%d",a-(k-a-b));
  else if(k>=a&&a+b>k)
  printf("%d",a);
  else if(k<a)
    printf("%d",k);
}


Measured memory_bytes: 1724
#pragma GCC optimize ("O3")

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

const int w=20003;

char s[10005];
int x,y,_x,len,p,sum,q,now=1;
bool wss[2][2][40009];

int main(){
    register int i;
    scanf("%s%d%d",s+1,&x,&y),len=strlen(s+1),x+=w,y+=w;
    while(now<=len&&s[now]=='F') ++now,++_x;
    wss[0][0][w+_x]=true,wss[1][0][w]=true;
    while(now<=len){
        ++now,sum=0,p^=1,q^=p;
        while(now<=len&&s[now]=='F') ++sum,++now;
        for(int i=w-len;i<=w+len;++i) wss[p][q][i]=wss[p][q^1][i+sum]|wss[p][q^1][i-sum];
    }
    if(p==1&&wss[0][q^1][x]&&wss[1][q][y]||p==0&&wss[0][q][x]&&wss[1][q][y]) puts("Yes");
    else puts("No");
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  int dp[2][202][202];
  rep(i, 202) rep(j, 202) {
    dp[0][i][j] = -inf;
    dp[1][i][j] = inf;
  }
  reps(len, 1, s.size()+1) {
    rep(i, s.size()+1-len) {
      int j = i + len;
      if(len == 1 && isdigit(s[i])) {
	dp[0][i][j] = dp[1][i][j] = s[i]-'0';
      }

      if(len < 3) continue;

      if(len > 3) { // a+<(b>?????????????????????a+<(b+c>???ok / ()???????????????????????????4??\???
	if(s[i] == '(') {
	  chmax(dp[0][i][j], dp[0][i+1][j]);
	  chmin(dp[1][i][j], dp[1][i+1][j]);
	} else if(s[j-1] == ')') { // <a)>+b <z+a)>+b
	  chmax(dp[0][i][j], dp[0][i][j-1]);
	  chmin(dp[1][i][j], dp[1][i][j-1]);
	}
      }


      reps(k, i+1, j-1) {
	if(s[k] == '+') {
	  chmax(dp[0][i][j], dp[0][i][k]+dp[0][k+1][j]);
	  chmin(dp[1][i][j], dp[1][i][k]+dp[1][k+1][j]);
	} else if(s[k] == '-') {
	  chmax(dp[0][i][j], dp[0][i][k]-dp[1][k+1][j]);
	  chmin(dp[1][i][j], dp[1][i][k]-dp[0][k+1][j]);
	}
      }
    }
  }
  //rep(i, s.size()) reps(j, i+1, s.size()+1) cout << dp[0][i][j]<<endl;
  cout << dp[0][0][s.size()] << endl;

  return 0;
}

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

int main(){

double a,b,h,m;
double  c;
cin >> a >> b >> h >> m;

double x = h*60+m;
x = fmod(x * 5.5, 360);
if (x > 180) x = 360 - x;

c = sqrt((a * a) + (b * b) - (2 * a * b *cos(x / 180 * PI)));

cout << setprecision(15) << c <<endl;
  
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll int n;
	cin >> n;
	ll int prev, curr, sum = 0;
	for(int i = 0; i < n; i++) {
		if(i == 0)
			cin >> prev;
		else {
			cin >> curr;
			if(curr < prev)
				sum += (prev - curr);
			else
				prev = curr;
		}
	}
	cout << sum;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


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

    int ans = 0;
    while (ans*ans<=n) {
        ans++;
    }
    ans--;
    ans *= ans;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int a = in.nextInt();
        int b = in.nextInt();
        int c = a+b;
        if(c%2==0) out.println(c/2);
        else out.println("IMPOSSIBLE");
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 22996
#include <stdio.h>
int main()
{
	int N,K;
    scanf("%d",&N);
    scanf("%d",&K);
    int data[N];
  int cnt=0;
  for(int i=0;i<N;i++)
  {
  	scanf("%d",&data[i]);
    if(data[i]>=K) cnt++;
    
  }
  printf("%d",cnt);
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>


bool is_dead = false;

void replace(char a, char b, std::vector<char> &s, std::vector<char> &t) {
    for (size_t i = 0; i != s.size(); ++i) {
        if (s[i] == a) {
            if (t[i] == a) {
                is_dead = true;
                break;
            }
            s[i] = b;
        } else if (s[i] == b) {
            if (t[i] == b) {
                is_dead = true;
                break;
            }
            s[i] = a;
        }

    }
}


int main() {
    std::vector<char> s, t;
    char ch;
    while(std::cin >> ch) {
        s.push_back(ch);
    }
    int len = (s.end() - s.begin()) / 2;
    for (size_t i = 0; i != len; ++i) {
        t.push_back(s[s.size() - 1]);
        s.pop_back();
    }
    std::reverse(t.begin(), t.end());
    for (size_t i = 0; i != len; ++i) {
        if (s[i] != t[i]) {
            replace(s[i], t[i], s, t);
            if(is_dead)
                break;
        }
    }
    if (is_dead) {
        std::cout << "No\n";
    } else {
        std::cout << "Yes\n";
    }
}

Measured memory_bytes: 1144
#include<stdio.h>
#define N 50000

int a[N],n1,n2,number,count=0;

int searchNumber(int);

int searchNumber(int x){
  int i;
  for(i=0;i<n1;i++){
    if( a[i] == x ) return a[i];
  }
  return -1;
}

int main(){

  int i,j;
  int b[500];
  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&b[i]);
  }

  for(i=0;i<n2;i++){
    number = searchNumber(b[i]);
    if( number != -1 ) count++;
  }
  printf("%d\n",count);
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<int> C(N + 1), S(N + 1), F(N + 1);
  for (int i = 1; i < N; ++i) {
    scanf("%d %d %d", &C[i], &S[i], &F[i]);
  }
  for (int i = 1; i < N; ++i) {
    int t = S[i] + C[i];
    for (int j = i + 1; j < N; ++j) {
      if (t <= S[j]) { t = S[j] + C[j]; }
      else {
        int x = (t - S[j] + F[j] - 1) / F[j];
        t = S[j] + F[j] * x + C[j];
      }
    }
    printf("%d\n", t);
  }
  printf("0\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int (i) = (x); (i) <= (y); (i) ++)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; 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(); }
	return x * f;
}
const int N = 5e5 + 10;
int n, a, b, c, d;
ll f[N][2];
int main()
{
	n = read();
	a = read();
	b = read();
	c = read();
	d = read();
	f[1][0] = c;
	f[1][1] = d;
	rep(i, 2, n)
		f[i][0] = f[i - 1][0] + c, f[i][1] = f[i - 1][1] + d;
	rep(i, 0, n - 1)
		if (f[i][0] - f[n-i - 1][1] <= b - a && b - a <= f[i][1] - f[n - i - 1][0])
		{
			puts("YES");
			return 0;
		}
	puts("NO");
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int main() {

	int r, c, a[101][101] = {0};

	cin >> r >> c;

	for (int i = 0; i < r;i++) {

		for (int j = 0; j < c;j++) {

			cin >> a[i][j];
			a[i][c] += a[i][j];
		}
	}

	for (int i = 0; i < c;i++) {

		for (int j = 0; j < r;j++) {

			a[r][i] += a[j][i];
		}
	}

	for (int i = 0; i < r; i++) {

		for (int j = 0; j < c; j++) {

			a[r][c] += a[i][j];
		}
	}

	for (int i = 0; i < r + 1;i++) {

		for (int j = 0; j < c + 1;j++) {

			cout << a[i][j];
			if (j != c)cout << " ";
		}
		cout << endl;
	}

	//cin >> /*変数他*/;
	//cout << /*文字列*/ << endl;
	return 0;
}


Measured memory_bytes: 3104
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        Arrays.sort(a, Collections.reverseOrder());
        long ans = a[0];
        int limit = (n - 2) / 2;
        for (int i = 1; i <= limit; i++) {
            ans += 2 * a[i];
        }
        if ((n - 2) % 2 != 0) {
            ans += a[limit + 1];
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 64048
#import <stdio.h>
#import <Foundation/Foundation.h>

int main(int argc, char **argv) {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  BOOL isValid = !(A == B && B == C) && !(A != B && B != C && C != A);
  printf("%s", isValid ? "Yes" : "No");
  return 0;
}

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

#define ll long long
using namespace std;

int main() {
    string s;
    cin >> s;
    bool a = 1;
    if(s.size()%2==0){
      for(int j = 0; j < s.size(); j = j + 2) {
        if(s[j] != 'h' || s[j + 1] != 'i') {
            a = 0;
            break;
        }
    }
    if(a) {
        cout << "Yes" << endl;

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


Measured memory_bytes: 256
function main(){
  var localInput = input;
  var f = [];
  for(var y=-2;y<12;y++){
    f[y] = [];
    for(var x=-2;x<12;x++){
      f[y][x] = 0;// initialize:undefined -> 0
    }
  }
  
  var len = localInput.length - 1;
  for(;len--;){
    var l = localInput[len];
    var ix = parseInt(l[0]);
    var iy = parseInt(l[2]);
    switch(l[4]){
    case '3': // no-break case;
      f[iy+2][ix]++;
      f[iy-2][ix]++;
      f[iy][ix-2]++;
      f[iy][ix+2]++;
    case '2':
      f[iy+1][ix-1]++;
      f[iy+1][ix+1]++;
      f[iy-1][ix-1]++;
      f[iy-1][ix+1]++;
    case '1':
      f[iy+1][ix]++;
      f[iy][ix-1]++;
      f[iy][ix]++;
      f[iy][ix+1]++;
      f[iy-1][ix]++;
      break;
    }
  }
  
  var nd=0;//not dropped
  var md=0;//most dropped
  var y = 10;
  for(;y--;){
    var x = 10;
    for(;x--;){
      nd += !(f[y][x]);
      md = mx(f[y][x], md);
    }
  }
  
  console.log(nd);
  console.log(md);
}
   
function mx(a, b){
 var t = (a-b);
 return a - (t & (t >> 31));
}

var
input = '';
  
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 7644
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

dp = [{} for i in range(N+1)]

def swap_ok(last4):
	# print(last4)
	for i in range(4):
		t = list(last4)
		if i >= 1:
			t[i-1], t[i] = t[i], t[i-1]
		if ''.join(t).count("AGC") >= 1:
			return False
	return True

def dfs(current, last3):
	if last3 in dp[current]:
		return dp[current][last3]
	if current == N:
		return 1
	ret = 0
	for c in 'AGCT':
		if swap_ok(last3 + c):
			ret = (ret + dfs(current + 1, last3[1:] + c)) % MOD
	dp[current][last3] = ret
	return ret

print(dfs(0, 'ATC'))


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

int main()
{
    int n;
    cin>>n;
    if(n>=195){
        cout<<5;
    }
    else if(n>=189){
        cout<<4;
    }
    else if(n>=165){
        cout<<3;
    }
    else if(n>=135){
        cout<<2;
    }
    else if(n>=105){
        cout<<1;
    }
    else{
        cout<<0;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  int A[N];
  rep(i,N){
    cin >> A[i];
    A[i] -= i+1;
  }
  sort(A,A+N);
  ll ans1 = 0, ans2 = 0;
  rep(i,N) ans1 += abs(A[N/2]-A[i]);
  
  cout << ans1 << endl;
  
  //rep(i,N) cout << A[i] << endl;
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4260
import itertools
h,w,k = map(int, input().split())
a = [0]*h
ai= [0]*w*h
bn = 0

for i in range (h):
    a[i] = str(input())

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            bn +=1

nums = [0,1]
hn = itertools.product(nums, repeat=w+h)

ans = 0

for hi in hn:

    rn =0
    for i in range(h):
        for j in range(w):

            if hi[i]+hi[h+j] >= 1 and a[i][j] == "#":
                rn +=1

   
    if rn == bn-k:
        ans +=1


print(ans)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
vvi adj;
vi dist[2];

void dfs(int root,int type,int prev = -1){
    for(auto x : adj[root]){
        if(x != prev){
            dist[type][x] = dist[type][root] + 1LL;
            dfs(x,type,root);
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,u,v;
    cin >> n >> u >> v;
    --u,--v;
    adj.resize(n);
    dist[0].resize(n);
    dist[1].resize(n);
    ffor(i,n - 1){
        int x,y;
        cin >> x >> y;
        --x,--y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    dfs(u,0);
    dfs(v,1);

    int ans = 0;
    ffor(i,n){
        if(dist[1][i] > dist[0][i]){
            ans = max(ans,dist[1][i]);
        }
    }

    cout << ans - 1;
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

// 

ll n, k;
vl a;
map<ll, sl> t;
set<pair<ll, ll> > s;

void solve(vl b) {
	vector<bool> erased(sz(b), false);
	map<ll, sl> bt; 
	rep(i,0,sz(b)) {
		if(bt[b[i]].empty()) {
			bt[b[i]].insert(i);
		} else {
			int j = *bt[b[i]].begin();
			for(; j < i; ++j) {
				bt[b[j]].clear();
			}
		}
	}

	set<ll> ret;
	for(auto it = bt.begin(); it != bt.end(); ++it) {
		if((it->S).empty()) continue;
		ret.insert(*(it->S).begin());
	}
	for(auto it = ret.begin(); it != ret.end(); ++it) {
		cout << b[*it] << ' ';
	}
	cout << endl;
}

int main(void) {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt", "r", stdin);

	cin >> n >> k;
	a.resize(n);
	rep(i,0,n) {
		cin >> a[i];
	}

	if(n == 1) {
		if(k%2 == 0) {
			return 0;
		} else {
			cout << a[0] << endl;
			return 0;
		}
	}

	rep(i,0,n) {
		t[a[i]].insert(i);
	}

	ll pre = 0;
	ll idx = 0;
	bool finished = true;
	while(idx < n * k) {
		//cout << idx << endl;
		pre = idx;
		ll p = idx / n;
		ll q = idx % n;
		sl&b = t[a[q]];
		auto it = b.upper_bound(q);
		if(it == b.end()) {
			idx = n * (p+1) + *b.begin() + 1;
		} else {
			idx = n * p + *it + 1;
		}
		if(idx < n * k && idx % n == 0) {
			finished = false;
			break;
		}
	}

	if(finished) {
		idx = pre;
		//cout << idx << endl;
		ll c = idx % n;
		solve(vl(a.begin()+c, a.end()));
		return 0;
	}
	
	ll p = (n*k) / idx;
	if(n*k % idx == 0) {
		p--;
	}
	idx = p * idx;
	while(idx < n * k) {
		//cout << idx << endl;
		pre = idx;
		ll p = idx / n;
		ll q = idx % n;
		sl&b = t[a[q]];
		auto it = b.upper_bound(q);
		if(it == b.end()) {
			idx = n * (p+1) + *b.begin() + 1;
		} else {
			idx = n * p + *it + 1;
		}
	}
	idx = pre;
	//cout << idx << endl;
	ll c = idx % n;
	solve(vl(a.begin()+c, a.end()));
	return 0;
}

Measured memory_bytes: 70272
t = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
a = sum(v)
b = sum(c)
mxx = a-b
for i in range(t):
    temp = a-b
    a1 = a - v[i]
    b1 = b - c[i]
    if((a1-b1)>temp):
        a = a1
        b = b1
        mxx = a-b
        
print(mxx)  


Measured memory_bytes: 3064
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
check = [[False]*W]*H
dx = -1,0,1,0
dy = 0,-1,0,1

for h in range(H):
  for w in range(W):
    bcount = 0 #隣接する黒ますの個数
    if s[h][w] == "#":
      for i in range(4):
        if 0 <= h+dx[i] <= H-1 and 0 <= w+dy[i] <= W-1 and s[h+dx[i]][w+dy[i]] == "#":
            bcount += 1
      if bcount == 0:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int x, y;
	cin >> x >> y;
	int ans = 0;
	if(x==1){
		ans += 300000;
	} else if(x==2){
		ans += 200000;
	} else if(x==3){
		ans += 100000;
	}
	if(y==1){
		ans += 300000;
	} else if(y==2){
		ans += 200000;
	} else if(y==3){
		ans += 100000;
	}
	if(x==1&&y==1){
		ans += 400000;
	}
	cout << ans << endl;

	return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,m;
    cin >>n >>m;

    vector<int> a(n),b(n),c(m),d(m);
    rep(i,n) cin >>a[i] >>b[i];
    rep(i,m) cin >>c[i] >>d[i];

    rep(i,n)
    {
        int ans = -1;
        int nearest = 1234567890;

        rep(j,m)
        {
            int D = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(nearest > D)
            {
                ans = j+1;
                nearest = D;
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void)
{
   int n,i;
   double D1=0,D2=0,D3=0,Dinf=0,x[101]={},y[101]={},z[101]={},c[101]={};
   
   scanf("%d",&n);
   for(i=0;i<n;i++) scanf("%lf",&x[i]);
   for(i=0;i<n;i++) scanf("%lf",&y[i]);
   for(i=0;i<n;i++)
   {
       z[i]=x[i]-y[i];
       c[i]=fabs(z[i]);
       D1+=fabs(c[i]);
       D2+=pow(c[i],2.0);
       D3+=pow(c[i],3.0);
       if(fabs(c[i])>Dinf) Dinf=fabs(z[i]);
   }
   
   D2=pow(D2,1.0/2.0);
   
   D3=pow(D3,1.0/3.0);
   

   printf("%f\n%f\n%f\n%f\n",D1,D2,D3,Dinf);
   
    return 0;
}



Measured memory_bytes: 2104
/*input
10
1 2 1 3 2 4 2 5 8 1
*/

#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <numeric>
#include <utility>
#include <tuple>
#include <climits>
#include <fstream>
#include <bitset>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <random>
#include <chrono>
#include <ios>
#include <iomanip>
#include <functional>
#include <array>

using namespace std;

#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORA(i, a) for (auto &i : a)
#define FORB(i, a, b) for (int i = a; i >= b; --i)
#define SZ(a) ((int) a.size())
#define ALL(a) begin(a), end(a)

typedef int64_t ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fi first
#define se second

// start of code

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

	int N;
	cin >> N;
	vector<pii> vec(N + 1);
	vec[0] = pii(0, 0);
	FOR(i, 1, N) {
		cin >> vec[i].fi;
		vec[i].se = i;
	}

	sort(ALL(vec));
	vl ans(N + 1);
	FOR(i, 1, N) {
		ans[vec[i].se] = (ll) (vec[i].fi - vec[i - 1].fi) * (N - i + 1);
	}

	int curMin = N + 1;
	FORB(i, N, 1) {
		curMin = min(curMin, vec[i].se);
		if (curMin != vec[i].se) {
			ans[curMin] += ans[vec[i].se];
			ans[vec[i].se] = 0;
		}
	}
	FOR(i, 1, N) cout << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 2688
n,k = map(int,input().split())
p = [0]*k + list(map(int,input().split()))
ans = 0
for i in range(k,len(p)):
    p[i] = p[i]*(p[i]+1)/2 / p[i]
    p[i] = p[i] + p[i-1]
for i in range(len(p)-1,k-1,-1):
    p[i] = p[i] - p[i-k]
# print(p)
print(max(p))

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

int main() {
  //宣言
  int N;
  vector<int> D;
  int ans =0;
  vector<int> K;
  
  //入力
  cin >> N;
  D = vector<int>(N);
  for(int i=0;i<N;i++){
  cin >> D.at(i);
  }
  K = vector<int>(N,1);
  
  //処理
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(D.at(i)==D.at(j)){K.at(j) =0;
      }
    }
    ans += K.at(i);
  }
  
  //出力
  cout << ans << endl;
  
}

Measured memory_bytes: 256
N=gets.to_i
s=Array.new
N.times do 
  s << gets.chomp
end
maxlen=0
result=Array.new
s.group_by{|i| i}.values.map{|i| maxlen=i.length if maxlen < i.length}
s.group_by{|i| i}.values.map{|i| result<<i[0] if i.length==maxlen}

result.sort.each do |e|
  puts e
end

Measured memory_bytes: 90332
N = int(input())
h = list(map(int, input().split()))

cnt = 0
while True:
  f = 0
  if list(set(h)) == [0]:
    break
  for i in range(N):
    if h[i] == 0:
      if f == 1:
        f = 0
        cnt += 1
    else:
      h[i] -= 1
      f = 1
  if f == 1:
    cnt += 1
  
    
print(cnt)


Measured memory_bytes: 39408
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
main(){
    ll N,cnt;
    cin >> N;
    cnt = N / 11 * 2;
    if(N % 11){
        if(N % 11 <= 6){
            cnt += 1;
        }else{
            cnt += 2;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cctype>
using namespace std;
#define G getchar()
int read()
{
	int x=0; char ch=G;
	for (;!isdigit(ch);ch=G);
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return x;
}
#undef G

int n; char s[1000010];
int pre[1000010],bin[1000010];
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++) s[i]--;
	for(int i=0;i<=19;i++) bin[1<<i]=i;
	for (int i=1;i<=n;i++) pre[i]=pre[i-1]+bin[i&-i];
	bool mrk=0;
	for (int i=1;i<=n;i++) if (s[i]=='1') if (pre[n-1]-pre[i-1]-pre[n-i]==0) mrk^=1;
	if (mrk) return puts("1"),0;
	for (int i=1;i<=n;i++) if (s[i]=='1') return puts("0"),0;
	mrk=0;
	for (int i=1;i<=n;i++) if (s[i]=='2') if (pre[n-1]-pre[i-1]-pre[n-i]==0) mrk^=1;
	puts(mrk?"2":"0");
	return 0;
}

Measured memory_bytes: 6912
a, b, c, d = map(int, input().split())
if a<=0 and b>=0:
    xlist = [a,0,b]
else:
    xlist = [a,b]
if c<=0 and d>=0:
    ylist = [c,0,d]
else:
    ylist = [c,d]

ans = -1001001001001001001
for x in xlist:
    for y in ylist:
        ans = max(ans, x*y)
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1e9 + 7
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
ll xornum(ll a) {
    if(a < 0)
        return 0;
    if(a % 4 == 0)
        return a;
    else if(a % 4 == 1)
        return 1;
    else if(a % 4 == 2)
        return a + 1;
    return 0;
}
int main() {
    ll a, b;
    cin >> a >> b;
    cout << (xornum(b)^xornum(a - 1));
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
    char a[3];
    cin>>a;
    int cnt[3] = {0};
    for(int i = 0; i < 3; i++)
    {
        cnt[a[i] - 'a']++;
    }
    if(cnt[0] == cnt[1] && cnt[2] == 1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, a, b; cin >> n >> a >> b;

	LL ans = 0;

	LL prev; cin >> prev;

	for (int i = 1; i < n; i++) {
		LL now; cin >> now;

		LL diff = now - prev;

		if (diff*a < b) {
			ans += diff*a;
		}
		else {
			ans += b;
		}

		prev = now;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import heapq
K=int(input())
G=[[((i+1)%K,1)] for i in range(K)]
for i in range(K):
    a=(i*10)%K
    G[i].append((a,0))
def dijkstra(G,s):#Gはi->jの辺をG[i]=[(j,cost),...]で保存
  INF=10**19
  n=len(G)
  d=[INF]*n#n=node数
  d[s]=0
  visited={s}
  que=[(0,s)]
  while(que):
    p=heapq.heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heapq.heappush(que,(d[node],node))
  return d

d=dijkstra(G,1)
print(d[0]+1)


Measured memory_bytes: 44396
import java.util.*;
 
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 <a.length; i++) {
  		a[i] = sc.nextInt();
  	}
  	Arrays.sort(a);
  	int sum = 0;
  	for(int i =0; i<a.length-1; i++) {
  		sum= sum + a[i];
  		
  	}
  	if(sum<=a[a.length-1]) {
  		System.out.println("No");
  	}
  	else {
  		System.out.println("Yes");
  	}
  	
  }
  
}

Measured memory_bytes: 35752
N, K = map(int, input().split())
s = input() + '#'
D = []
b = s[0]
cnt = 0
for c in s:
    if c == b:
        cnt += 1
    else:
        D.append((b, cnt))
        cnt = 1
        b = c

zero_start = False
if D[0][0] == '0':
    zero_start = True
    D.insert(0,(1, 1)) #indexが複雑になるので1スタートに無理やりする。

lend = len(D)
l = lend // 2 #0集団の個数
ans = -1
if K >= l:
    ans = N
else:
    sm = sum([x[1] for x in D[:2 * K + 1]])
    ans = sm
    if zero_start :
        ans -= 1 #本来存在しない最初の1を減らしておく

    for i in range(2 * K + 1, lend, 2): #最初に加える0集団をスタートとする
        sm += D[i][1]
        if i + 1 < lend:
            sm += D[i + 1][1]
        sm -= D[i - 2 * K][1]
        sm -= D[i - 2 * K - 1][1]

        ans = max(ans, sm)

print(ans)

Measured memory_bytes: 11004
#include <cmath>
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std;

//-----------------------------------------
string happy_753(int X){

    string str;
    if(X==7 || X==5|| X==3){
        str = "YES"; 
    }else{
        str = "NO";
    };

    return str;
}

int main() {
    // I/O format
    int X; cin >> X;
    string out;

    out = happy_753(X);
    cout << out << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int pow(int base, int n) {
    if (n == 0) {
        return 1;
    } else {
        return pow(base, n - 1) * base;
    }
}

int main(void) {
    int D;
    int N;
    cin >> D >> N;

    int ans = pow(100, D) * N;
    if (N == 100) {
        ans += pow(100, D);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string s,t,ans;
	cin >> s >> t;
	ans = s;
	int x = 0;
	for(int i=0;i<N;i++){
		//i番目から一致したとする
		int start = i;
		for(int j=0;j<N;j++){
			if(s[start]==t[j]){
				start++;
				if(start == N){
					/*
					cout << s;
					for(int x=j+1;x<N;x++)cout << t[x];
					cout << endl;
					*/
					cout << N + N - (j+1) << endl;
					return 0;
				}
			}else break;
		}
	}
	cout << N + N << endl;
}

Measured memory_bytes: 256
# include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  if(N%1000==0) cout << 0;
  else cout << 1000 - N%1000;
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(){
  int i;
  int num[10000];
  for(i = 0;i < 10000;i++){
    scanf("%d", &num[i]);
    if(num[i] == 0) break;
  }
  for(i = 1;i <= 10000;i++){
    if(num[i-1] == 0) break;   
    printf("Case %d: %d\n", i, num[i-1]);
  }
  return 0;
}



Measured memory_bytes: 2036
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
if n < 3:
    print(ans)
else:
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                if l[k] < l[i] + l[j] and l[i] != l[j] and l[j] != l[k]:
                    ans += 1
                
    print(ans)


Measured memory_bytes: 68016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    int A,B;
    cin>>A>>B;
    
    cout<<max(A+B,max(A-B,A*B))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
     
int main() {
  char c1[10];
  char c2[10];
  scanf("%s", c1);
  scanf("%s", c2);
  if (c1[0] == c2[2] && c1[2] == c2[0] && c1[1] == c2[1]) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    int tyo=0,hisi=0;
    while(scanf("%d,%d,%d",&a,&b,&c)!=EOF)
    {
        if(a*a+b*b==c*c)tyo++;
        else if(a==b)hisi++;
    }
    cout<<tyo<<endl<<hisi<<endl;
    return 0;
}

Measured memory_bytes: 1208
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] li = new int[n];
        for(int i = 1; i <= n; i++){
            li[sc.nextInt()-1] = i;
        }
        int i = 0;
        for (int k : li){
            if(i != n-1){
                System.out.print(li[i] + " ");
            }else{
                System.out.println(li[i]);
            }
            i++;
        }
    }
}


Measured memory_bytes: 63356
#include<stdio.h>
int w, h;
int xs, ys, xg, yg;
int map[100][100];
int scolor;

int visit(int x, int y) {
  static int d[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
  int nx, ny, i;
  if(map[y][x] == scolor) {
    map[y][x] = 0;
    if(x == xg && y == yg) return 1;
    for(i = 0; i < 4; i++) {
      nx = x + d[i][0];
      ny = y + d[i][1];
      if(nx >= 0 && nx < w && ny >= 0 && ny < h && map[ny][nx] != 0) {
	if(visit(nx, ny) == 1) return 1;
      }
    }
  }
  return 0;
}

int main(){
  int n;
  int c, d, x, y;
  int i, j,k;

  int temp1, temp2;

  while(1){
    
    for(i=0;i<100;i++){
      for(j=0;j<100;j++){
	map[i][j]=0;
      }
    }
    
    scanf("%d %d", &w, &h);
    if(w==0 && h==0) break;

    scanf("%d %d", &xs, &ys);
    scanf("%d %d", &xg, &yg);
    xs--;
    ys--;
    xg--;
    yg--;

    scanf("%d", &n);

    for(i=0;i<n;i++){
      scanf("%d %d %d %d", &c, &d, &x, &y);

      if(d == 0) {
	temp1 = 2;
	temp2 = 4;
      } else {
	temp1 = 4;
	temp2 = 2;
      }
      for(j = 0; j < temp1; j++)
	for(k = 0; k < temp2; k++)
	  map[y-1+j][x-1+k] = c;
    }
    scolor = map[ys][xs];

    if(visit(xs, ys) == 1) {
      printf("OK\n");
    } else {
      printf("NG\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define FO(i,a,b) for(int i=a;i<=b;i++)
#define FE(i,a,b) for(int i=a;i<b;i++)
#define Edge(i,v,a) for(int i=head[a],v=to[i];i!=-1;i=nxt[i],v=to[i])
#define R(i) i=read()
using namespace std;
char s[1000];
char read_c() {
	char c=getchar();
	while(c<'a'||c>'z') c=getchar();
	return c;
}
int four,two,one;
int n,m,cnt[30];
char c;
int main() {
//	freopen("1.in","r",stdin);
	cin>>n>>m;
	FO(i,1,n)
		FO(j,1,m) c=read_c(),cnt[c-'a']++;
	if((n%2==0)&&(m%2==0)) {
		FE(i,0,26)
			if(cnt[i]%4) {cout<<"No";return 0;}
		cout<<"Yes";
	}
	else if((n+m)&1) {//
		if(m&1) swap(n,m);
		FE(i,0,26)
			four+=cnt[i]/4*4,two+=(cnt[i]%4)/2*2;
		if(four+two<n*m) cout<<"No";
		else if(two>m) cout<<"No";
		else cout<<"Yes";
	}
	else {
		FE(i,0,26)
			four+=cnt[i]/4*4,two+=(cnt[i]%4)/2*2,one+=(cnt[i]%4)&1;
		if(one>1) cout<<"No";
		else if(two>(n/2*2+m/2*2)) cout<<"No";
		else cout<<"Yes";
	}
	return 0;
}

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

int H,W;
char F[610][610];
int main(){
    cin >> H >> W;
    for(int i=0;i<=H+1;i++) for(int j=0;j<=W+1;j++) F[i][j] = '.';
    for(int i=1;i<=H;i++) for(int j=1;j<=W;j++) cin >> F[i][j];
    vector<pair<double,int>> v;
    for(int i=0;i<=H;i++){
        for(int j=0;j<=W;j++){
            double arg = atan2(H-i,j);
            if(F[i][j]=='#' && F[i+1][j]=='.' && F[i][j+1]=='.' && F[i+1][j+1]=='.') v.push_back({arg,1});
            if(F[i][j]=='.' && F[i+1][j]=='#' && F[i][j+1]=='#' && F[i+1][j+1]=='#') v.push_back({arg,1});
            if(F[i][j]=='.' && F[i+1][j]=='.' && F[i][j+1]=='.' && F[i+1][j+1]=='#') v.push_back({arg,-1});
            if(F[i][j]=='#' && F[i+1][j]=='#' && F[i][j+1]=='#' && F[i+1][j+1]=='.') v.push_back({arg,-1});
        }
    }
    sort(v.begin(),v.end());
    int now = 1,ans = 0;
    for(auto x:v){
        now += x.second;
        ans = max(ans,now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5548
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;


int main() {
   string st;
   cin>>st;
   int n = st.length();
   if(st[n-1] == 's')
   st += "es";
   else
   st += "s";
   cout<<st;
   return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
int main(){
  int x, n;
  cin >> x >> n;
  vector<bool> arr(102, true);
  if(n == 0){
   cout << x << endl;
   return(0);
  }
  int num, ans = 0, sub = 100;
  while(cin >> num){
    arr[num] = false;
  }
  rep(i, 102){
    if(arr[i] == true && abs(x - i) < sub){
        ans = i;
        sub = abs(x - i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}
 
class Sol{
	public void Solve(){
		
		
		long[][] B = new long[N][];
		for(int i=0;i<N;i++) B[i] = new long[N];
		for(int i=0;i<N;i++){
			B[i][0] = A[i];
			for(int j=1;j<N;j++){
				B[i][j] = Math.Min(B[i][j-1],A[(i+j)%N]);
			}
		}
		
		long ans = A.Sum();
		for(int t=1;t<N;t++){
			long sum = 0;
			for(int i=0;i<N;i++){
				sum += B[i][t];
			}
			sum += (long)t * X;
			ans = Math.Min(ans,sum);
		}
		
		Console.WriteLine(ans);
	}
	
	static long dist(int f, int t){
		
		if( t >= f ) return (long)t - (long)f;
		return (long) (N - f + t);
		
		
		
	}
	
	static int N,X;
	long[] A;
	public Sol(){
		var d = ria();
		N = d[0]; X = d[1];
		A = rla();
	}
 
	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

Measured memory_bytes: 35288
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int main(){
    int N, K;
    vector <int> x;
    int sub;
    int ans = INT_MAX;
    
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> sub;
        x.push_back(sub);
    }
    
    for(int i = 0; i < N - K + 1; i++){
        ans = min({ans, abs(x[i]) + abs(x[i + K - 1] - x[i]), abs(x[i + K - 1]) + abs(x[i + K - 1] - x[i])});
    }
    
    cout << ans << endl;
}

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

using namespace std;

void Main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); ++i) {
        cout << "x";
    }
    cout << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256