akhauriyash/Code-Regression huggingface dataset:
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';
int32_t main(){
    boost;
        int n;
        cin>>n;
        
        int prime[n+2];
        zeros(prime);
        for(int i =2 ; i<= n ; i++ ){
            if(prime[i] == 0){
                prime[i] = i;
                for(int j = i*i ; j<= n ; j=j+i ){
                    prime[j]=i;   
                }
            }
        }
        // for(int)
        
        
        int ans=0;
        for(int i =1; i< n ; i++ )
        {
            
            int num = n - i;
            // map<int,int>cn;
            int res=1;
            while(num>1){
                    int cp = 0;
                    int p1=prime[num];
                    // cout<<num<<" "<<p1<<endl;
                    while(num > 1 && num%p1==0){
                        num/=p1;
                        // cout<<num<<" "<<p1<<endl;
                        cp++;
                    }
                    res=res*(cp+1);
            }
            
            ans=ans+res;
            
        }
        cout<<ans<<endl;
        
        
}

Measured memory_bytes: 11420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll,ll>> a(n);
    rep(i, 0, n) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());
    ll c = 0;
    ll ans = 0;
    ll i = 0;
    while(c < m){
        ans += a[i].first;
        a[i].second--;
        if(a[i].second < 1) i++;
        c++;
    }
    cout << ans << endl;
    return 0;
}

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


int main(){
    int x1,x2,x3,x4,x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    int ans=0;
    if(x1 == 0) ans = 1;
    if(x2 == 0) ans = 2;
    if(x3 == 0) ans = 3;
    if(x4 == 0) ans = 4;
    if(x5 == 0) ans = 5;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#!/usr/bin/env python3
from fractions import gcd
from functools import reduce

N = int(input())

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

MOD = 10**9+7

L = reduce((lambda x, y: x // gcd(x, y) * y), A) % MOD

res = 0

def modulo(x, y):
  tmp = x % y
  if tmp < 0: tmp += y
  return tmp

def extgcd(x, y):
  if x < y:
    a, b = extgcd(y, x)
    return b, a
  if y == 0 or x % y == 0: return 0, 1
  a, b = extgcd(y, modulo(x , y))
  return (b, -(x // y) * b + a)

def inv(x):
  a, _ = extgcd(x,MOD)
  return modulo(a, MOD)

for a in A:
  res = (res + L* inv(a) % MOD) % MOD

print(res)


Measured memory_bytes: 124888
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n,*w = [int(i) for i in read().split()]
#n,*t = map(int,read().split())

#n = int(input())
#s = input()
n,k = [int(i) for i in readline().split()]
h = [int(i) for i in readline().split()]

h.sort()

if k >= n:
    print(0)
else:
    print(sum(h[:n-k]))



Measured memory_bytes: 26028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int number;
  int sum;
  int current;
  
  cin >> number;
  current = number;
  
  while(current) {
    sum += current % 10;
    current /= 10;
  }
  
  if (number % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,i,j;
  scanf("%d",&a);
  for(i=1;i<=9;i++){
    for(j=1;j<=9;j++){
      if(i*j==a){
      	printf("Yes");
        return 0;
      }
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 128
N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N-1)]
px = [list(map(int, input().split())) for i in range(Q)]
cnt = [0] * N

for p, x in px:
    cnt[p-1] += x
for a, b in sorted(ab):
    cnt[b-1] += cnt[a-1]

print(*cnt)

Measured memory_bytes: 113604
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 3005;
const int mod = 1000000007; 
using namespace std;

int n, m, f[N][N][2], ans; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
	n = read <int> (), m = read <int> ();
	for(int i = 1; i <= n; i++)
		f[0][i][0] = 1;
	f[0][0][1] = 1;
	for(int i = 1; i <= m; i++)
		for(int j = 0; j <= n; j++)
		{
			if(!j)
			{
				f[i][j][1] = f[i - 1][j][1];
				if(j < n) f[i][j][1] = (1ll * f[i][j][1] + f[i - 1][j + 1][1] + f[i - 1][j + 1][0]) % mod; 
			}
			else if(j == 1)
			{
				if(j < n) f[i][j][0] = (f[i][j][0] + f[i - 1][j + 1][0] + f[i - 1][j][0]) % mod; 
				f[i][j][1] = (1ll * f[i - 1][j][1] + f[i - 1][j][0] + f[i - 1][j - 1][1]) % mod;
				if(j < n) f[i][j][1] = (1ll * f[i - 1][j + 1][1] + f[i][j][1] + f[i - 1][j][1]) % mod; 
			}
			else
			{
				f[i][j][0] = (1ll * f[i - 1][j][0] + f[i - 1][j - 1][0]) % mod; 
				f[i][j][1] = (1ll * f[i - 1][j][1] + f[i - 1][j - 1][1]) % mod;
				if(j < n)
				{
					f[i][j][0] = (1ll * f[i][j][0] + f[i - 1][j][0] + f[i - 1][j + 1][0]) % mod;
					f[i][j][1] = (1ll * f[i][j][1] + f[i - 1][j][1] + f[i - 1][j + 1][1]) % mod;
				}
			}
		}
	for(int i = 0; i <= n; i++)
		ans = (1ll * ans + f[m][i][1]) % mod; 
	printf("%d\n", ans); 
	return 0; 
}


Measured memory_bytes: 70656
#include "stdio.h"
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

#include <list>
#include <iterator>

using namespace std;

enum {INS, MOVE, DEL};

class Puzzle
{
public:

	int N;
	//vector<long> list;
	list<int> data;

	void input()
	{
		cin >> N;
	}


	void play()
	{
		int q;
		long d;
		//int cs = 0;
		list<int>::iterator itr = data.begin();

		for (int qi = 0; qi < N; qi++) {
			cin >> q;
			switch (q) {
			case INS:
				cin >> d;
				itr = data.insert(itr,d);
				break;
			case MOVE:
				cin >> d;
				advance(itr, d);
				//itr = itr + 5;
				break;
			case DEL:
				itr = data.erase(itr);
				break;
			}
		}

		for (auto d : data) {
			printf("%d\n", d);
		}
	}


};


int main()
{
	Puzzle puz;

	puz.input();
	puz.play();

    return 0;
}




Measured memory_bytes: 18568
#include <iostream>
#include <assert.h>
#include <list>
#include <algorithm>
#include <vector>
#include <cmath>

void ff( std::list< std::vector< std::string > > & c )
{
    // ??¢???
    std::for_each( c.begin(), c.end(),
        []( std::vector< std::string> & elem )
        { }
    ) ;

    // ?°????
    std::for_each( c.begin(), c.end(),
        []( auto & elem )
        {  }
    ) ;
}

template < typename Printer >
void f( Printer && p )
{
    p( 123 ) ;
    p( 1.23 ) ;
    p( "123" ) ;
}


void operator delete( void *, std::size_t ) noexcept ;
void operator delete[]( void *, std::size_t ) noexcept ;

template < typename T >
constexpr T sqrt( T s )
{
    T x = s / 2.0 ; // ??????????????????
    T prev = 0.0 ;

    while ( x != prev )
    { // ???????????????????????????????????§????????????2?????°?????????
        prev = x ;
        x = (x + s / x ) / 2.0 ; // ????????????2
    }
    return x ;
}


// 1927426???1927428???WA???????????????????????????????????§???
auto dodo() {

  assert(std::abs(sqrt(2.0) - std::sqrt(2)) < 1e-9);

    f( []( auto && elem ){ assert(1 && elem) ; } ) ;
  auto x = 0b101;
  assert(x == 5);
  auto k = 1.2'3'4'5'6'789;
  assert(![ x = 0 ](){ return x ; }()) ;

  auto f = []( auto x ) { return x ; } ;

  f( 0 ) ;
  f( 0.0 ) ;
  f( 'A' ) ;
  f( "hello" ) ;

  int i = 10;
  decltype(auto) a = i ;



  assert(1.23456789==k);
  for(auto i=0; i<9; i++)
    for(auto j=0; j<9; j++)
      std::cout << i+1 << 'x' << j+1 << '=' << (i+1)*(j+1) << std::endl;
}

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

Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

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

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;
vector<vector<ll>> par;
vector<vector<ll>> dp;
vector<ll> d;


int main() {
    

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll a, b;
    cin >> a >> b;
    
    cout << a * b << endl;
    
    
    return 0;
}

Measured memory_bytes: 3652
N = int(input())

dict = [0] * N
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            t = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if t > N:
                break
            else:
                dict[t-1] += 1

for ans in dict:
    print(ans)

Measured memory_bytes: 9136
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BAnOddProblem {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> A(N);
        for(auto&  a : A) in>>a;
        int cnt = 0;
        REP(i, N){
            if(i%2==0 and A[i]%2==1) ++cnt;
        }
        out<<cnt<<'\n';
    }
};


int main() {
	BAnOddProblem solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3620
/**
 *     ____              _    
 *    / __ \____ _____  (_)___
 *   / /_/ / __ `/ __ \/ /_  /
 *  / _, _/ /_/ / /_/ / / / /_
 * /_/ |_|\__,_/ .___/_/ /___/
 *            /_/             
 *           code@rapiz.me
*          Sat, 24 Aug 2019 20:32:13 +0800
 */
#include <bits/stdc++.h>
#define xxx(x) cerr<<(#x)<<": "<<x<<endl;
#define iosfast ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
typedef long long ll;
using namespace std;
const int N = 2010;
const int MOD = 1e9 + 7;
ll n, k, a[N], rev[N], val[N];
ll qpow(ll a,ll r){
  a%=MOD;
	ll res=1,fac=a;
	while(r){
		if(r&1) res*=fac, res%=MOD;
		fac*=fac,r>>=1;
    fac%=MOD;
	}
	return res;
}
ll mrev(ll x) {
  return qpow(x, MOD - 2);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    val[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      if (a[i] < a[j]) {
        rev[i]++;
      }
    }
  }
  for (int i = 1; i < N; i++) val[i] += val[i-1];
  ll ans = 0;
  ll divtwo = mrev(2);
  for (int i = 1; i <= n; i++) {
    ans += ll(val[a[i]-1])*k%MOD*(k-1ll)%MOD*divtwo%MOD + ll(rev[i])*k%MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll p = a / d, q = c / b;
  if(a % d != 0) p++;
  if(c % b != 0) q++;
  if(q <= p) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
    int a[5]={1,2,3,4};
	int t[10],n[10001],c[90000],i;
	a[1]=6000;
	a[2]=4000;
	a[3]=3000;
	a[4]=2000;
	for(i=0;i<4;i++){
	    scanf("%d %d",&t[i],&n[i]);
		c[i]=a[t[i]]*n[i];
	}
	for(i=0;i<4;i++){
	    printf("%d\n",c[i]);
	}
	return 0;
}

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

int main()
{


        int H;
        int N;

        cin >> H >> N;

        int A[N];

        for (int i = 0; i < N; ++i) {
                cin >> A[i];
        }

        for (int i = 0; i < N; ++i) {
                H -= A[i];
        }

        if (H <= 0) {
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }




}


Measured memory_bytes: 640
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

class PriorityQueue
    attr_accessor:heap,:n
    def initialize(n)
        @n=0
        @heap=array(n,INF)
    end

    def push(x)
        i=@n
        @n+=1
        while i>0
            p=(i-1)/2
            break if @heap[p]>=x
            @heap[i]=@heap[p]
            i=p
        end
        @heap[i]=x
    end

    def pop()
        i=0
        ret=@heap[0]
        @n-=1
        x=@heap[@n]
        while i*2+1<@n
            l=i*2+1
            r=i*2+2
            l=r if r<@n and @heap[l]<@heap[r]
            break if @heap[l]<=x
            @heap[i]=@heap[l]
            i=l
        end
        @heap[i]=x
        return ret
    end

    def empty?()
        return @n.zero?
    end
end
N,M=get_i
A=get_i
pq=PriorityQueue.new(N)
A.each do|a|
    pq.push(a)
end
M.times do|i|
    v=pq.pop/2
    pq.push(v)
end
ans=0
until pq.empty?
  ans+=pq.pop
end
puts ans

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

int main() {
	int a, b;
	cin >> a >> b;
	string s = "Yay!";
	if (a > 8 || b > 8) s = ":(" ;
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3560
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();

		int[] interbal = new int[N];
		int[] start = new int[N];
		int[] second = new int[N];
		int[] ans = new int[N];

		for(int i=0; i<N-1; i++) {
			interbal[i] = in.nextInt();
			start[i] = in.nextInt();
			second[i] = in.nextInt();
			ans[i] = 0;
		}

		ans[N-1] = 0;

		for(int i=0; i<N-1; i++) {
			ans[i] = start[i] + interbal[i];
			for(int j=i + 1; j<N-1; j++) {
				int s = Math.max(ans[i], start[j]);
				if(s % second[j] > 0) {
					s = ((s / second[j]) + 1) * second[j];
				}
				ans[i] = s + interbal[j];
			}
		}

		for(int i : ans) {
			System.out.println(i);
		}
	}

}


Measured memory_bytes: 26760
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

int main()
{
  uint64_t K;
  cin >> K;

  queue<uint64_t> q;
  N_TIMES(i, 9) { q.emplace(i + 1); }

  N_TIMES(k, K - 1) {
    uint64_t x = q.front(); q.pop();
    uint64_t d = x % 10, y = (x * 10) + d;
    
    if (d > 0) { q.push(y - 1); }
    q.push(y);
    if (d < 9) { q.push(y + 1); }
  }

  cout << q.front() << endl;
  
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner( System.in);
		int N,A,B,C;
		int a=0,b=0,c=0,d=0;
            
		for(int i=0;i<4;i++) {
			N=stdin.nextInt() ;
			if(N==1&&a==0)a++;
			if(N==9&&b==0)b++;
			if(N==7&&c==0)c++;
			if(N==4&&d==0)d++;
							
		}
     if(a+b+c+d>=4) {
    	 System.out.print("YES");
     }else {
    	 System.out.print("NO");
     }

            
           

	}
}


Measured memory_bytes: 21588
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}



int main() {
	string S;
	cin >> S;
	rep(S.size())
		S[i] = 'x';
	cout << S;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 8; i++)
		s.pop_back();
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char S[10],T[10],U[10];
  int A,B;
  scanf("%s %s",S,T);
  scanf("%d %d",&A,&B);
  scanf("%s",U);
  if(S[0]==U[0])A--;
  else B--;
  printf("%d %d",A,B);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
int n,x;
int main() {
	scanf("%d",&n);
	int min=0x7FFFFFFF,ans=0;
	for (int i=1;i<=n;++i) {
		scanf("%d",&x);
		if (x<min) {++ans; min=x;}
	}
	printf("%d",ans);
	return 0;
} 

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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define pu push
#define pb push_back
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
const ll MOD = 1000000007;
const int inf = 1000000001;
const ll INF = 1e16;
ll i,j,k;
// #define max 105

int main(){
    fio();
    ll N,M,a,b,c,d;
    cin>>N>>M;
    vector< pair<ll,ll> > arrN(53);
    vector< pair<ll,ll> > arrM(53);
    vector<ll> ans(53);
    // int ans[53];
    // rep(i,arrN.size()){
    //     arrN[i].first = i;
    //     arrN[i].second = i+100;
    
    // }
    // rep(i,arrN.size()){
    //     cout<<i<<" "<<arrN[i].first<<" "<<arrN[i].second<<" "<<endl;
    // }


    rep(i,N){
        cin>>a>>b;    
        arrN[i].first = a;
        arrN[i].second = b;
    }
    rep(i,M){
        cin>>c>>d;
        arrM[i].first = c;
        arrM[i].second = d;
    }
    ll min = 1000000000;
    ll x1,x2,y1,y2,dis;
    rep(i,N){
        min = 1000000000;
        x1 = arrN[i].first; 
        y1 = arrN[i].second;
        rep(j,M){
            x2 = arrM[j].first;
            y2 = arrM[j].second;
            dis = abs(x1-x2) + abs(y1-y2);
            if(dis<min){
                min = dis;
                ans[i] = j;
            }
        }
    }

    rep(i,N){
        cout<<ans[i]+1<<endl;
    }
    // rep(i,N){
    //     cout<<i<<" "<<arrN[i].first<<" "<<arrN[i].second<<" "<<endl;
    // }
    // rep(i,M){
    //     cout<<i<<" "<<arrM[i].first<<" "<<arrM[i].second<<" "<<endl;
    // }








}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<queue>
#include<tuple>
#include<cstdio>
#include<string>
#include<vector>
#include<cassert>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int n, a[100009];
int main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	if (a[n - 1] - a[0] >= 2) { cout << "No" << endl; }
	else if (a[n - 1] - a[0] == 0) {
		if (n / a[0] >= 2 || a[0] == n - 1)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		int T = 0; for (int i = 0; i < n; i++) { if (a[i] != a[n - 1])T++; }
		int rem = (a[n - 1] - T);
		if (rem <= 0)cout << "No" << endl;
		else {
			if ((n - T) / rem >= 2)cout << "Yes" << endl;
			else cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon
{

    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string input = Console.ReadLine();
            Console.ReadLine();

            char before = ' ';
            long ans = 1;
            int state = 0; //0: start 1:tate 2:yoko
            bool isrenzoku = false;
            foreach(char ch in input)
            {
                if(before == ' ')
                {
                    
                }
                else if (ch == before)
                {
                    isrenzoku = true;
                }
                else
                {
                    if (isrenzoku)
                    {
                        isrenzoku = false;
                        if (state == 0)
                        {
                            ans = (ans * 6) % 1000000007;
                        }
                        else if (state == 1)
                        {
                            ans = (ans * 2) % 1000000007;
                        }
                        else
                        {
                            ans = (ans * 3) % 1000000007;
                        }
                        state = 2;
                    }
                    else
                    {
                        if (state == 0)
                        {
                            ans = (ans * 3) % 1000000007;
                        }
                        else if (state == 1)
                        {
                            ans = (ans * 2) % 1000000007;
                        }
                        else
                        {
                        }
                        state = 1;
                    }                       
                }
                before = ch;
            }
            if (isrenzoku)
            {
                isrenzoku = false;
                if (state == 0)
                {
                    ans = (ans * 6) % 1000000007;
                }
                else if (state == 1)
                {
                    ans = (ans * 2) % 1000000007;
                }
                else
                {
                    ans = (ans * 3) % 1000000007;
                }
                state = 2;
            }
            else
            {
                if (state == 0)
                {
                    ans = (ans * 3) % 1000000007;
                }
                else if (state == 1)
                {
                    ans = (ans * 2) % 1000000007;
                }
                else
                {
                }
                state = 2;
            }
            Console.WriteLine(ans);
        }
    }

}

Measured memory_bytes: 13140
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		int n=s.nextInt();
		int[]a=INTS(n).toArray();

		System.out.println(REP(1,100).map(i->{
			return Arrays.stream(a).map(j->(i-j)*(i-j)).sum();
		}).min().getAsInt());
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 26708
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
	int h,w,k,ans=114514;
	cin>>h>>w>>k;
	vector<string>grid(h);
	rep(i,h)cin>>grid[i];//データの入力
	int hor=pow(2,h-1);//横分割の組み合わせ
	vector<int>shki(h-1);
	int bocnt;
	vector<vector<int>>boes(10,vector<int>(w));
	vector<int>tate(h);
	int koe,cuth,cutw,pow2,dame;
	
	rep(i,hor){//全ての横分割について
	    dame=0;
	    rep(a,10){
	        rep(b,w)boes[a][b]=0;
	    }
	    bocnt=0;//棒初期化
	    rep(k2,h)tate[k2]=0;
	    rep(j,h-1){
	        pow2=pow(2,j);
	        shki[j]=(i/pow2)%2;//下からj>=0桁目
	    }
	    cuth=count(shki.begin(),shki.end(), 1);
	    cutw=0;//切った回数cuth+cutw
	    rep(c,h){
	        rep(d,w){
	            boes[bocnt][d]+=(grid[c][d]-'0');
	            if (boes[bocnt][d]>k)dame=1;
	        }
	        if(c<h-1){
	            if(shki[c])bocnt++;
	        }
	    }//横分割
	    if(dame==0){
	        rep(s,w){
	            koe=0;
	            rep(t,bocnt+1){//超えcheck
	                tate[t]+=boes[t][s];
	                if (tate[t]>k)koe=1;
	            }
	            if(koe){
	                rep(t,bocnt+1){
	                    tate[t]=boes[t][s];
	                }
	                cutw++;
	            }
	        }
	        ans=min(ans,cuth+cutw);
	    }
	    
	}
	cout<<ans;
	return 0;
}



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

using namespace std;

int main() {
  char s[200][11];
  int n[200];
  char tmps[11];
  int N, M;
  int k,d = 1;
  int max = -1;

  scanf("%d", &N);

  for (int i = 0; i < 200; i++) n[i] = 0;

  for (int i = 0; i < N; i++) {
    scanf("%s", tmps);
    for (k = 0; k < d; k++) {
      if (strcmp(tmps, s[k]) == 0) {
        n[k] += 1;
      }
    }
    if (k == d) {
      strcpy(s[d], tmps);
      n[d] += 1;
      d += 1;
    }
  }

  scanf("%d", &M);


  for (int i = 0; i < M; i++) {
    scanf("%s", tmps);
    for (k = 0; k < d; k++) {
      if (strcmp(tmps, s[k]) == 0) {
        n[k] -= 1;
      }
    }
    if (k == d) {
      strcpy(s[d], tmps);
      n[d] -= 1;
      d += 1;
    }
  }

  for (int i = 0; i < d; i++) {
    if (n[i] > max) {
      max = n[i];
    }
  }

  if (max < 0) {
    printf("0\n");
  } else {
    printf("%d\n", max);
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
				//	0	1  2  3	 4	5  6  7	 8	9 10 11	12
const int grupo[] = {-1, 0, 3, 0, 2, 0, 2, 0, 0, 2, 0, 2, 0};

int main(){
	int x, y;
	cin >> x >> y;
	if(grupo[x] == grupo[y])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        a: i64,
        b: i64,
    }

    let mut ans = 0;
    if 5 < a && a < 13 {
        ans = b / 2;
    } else if a >= 13 {
        ans = b;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
// Code for C - Walking Takahashi
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define MOD 1000000007
#define mod(x) ( (x) % MOD + MOD ) % MOD

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T, typename U> void view(const std::map<T, U>& m){ for(const auto& e : m){ std::cout << e.first << "=>" << e.second << " "; } std::cout << std::endl; }

int main() {
  ll X, K, D;
  cin >> X >> K >> D;

  ll a = abs(X);
  ll d = a / D;

  // debug(X);
  // debug(K);
  // debug(D);

  // debug(a);
  // debug(d);

  if (d < K) {
    // debug(a - D * d);
    // debug(abs(a - D * d - D));

    if ( (K - d) % 2 == 0 ) {
      cout << a - D * d << endl;
    } else {
      cout << abs(a - D * d - D) << endl;
    }
  } else {
    cout << a - D * K << endl;
  }

  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
 
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;
 
 
 
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
 
 
//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}
 
 
 
int main() {

	long long N,A[100];

	cin >> N;
	for (int i=0;i<N;i++){
		cin >> A[i];
	}

	long long bankroll=1000;

	for (int i=0;i<N-1;i++){
		if (A[i]<A[i+1]){
			bankroll+=(bankroll/A[i])*(A[i+1]-A[i]);
		}
	}

	cout << bankroll << endl;
 
	return 0;
 
 
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> V(n);
  vector<int> vis(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --v;
    --u;
    V[v].push_back(u);
    V[u].push_back(v);
  }
  int res = 0;
  for (int i = 0; i < n; ++i)
    if (!vis[i]) {
      function<void(int)> dfs = [&](int u) {
        vis[u] = 1;
        for (int v : V[u])
          if (!vis[v]) {
            dfs(v);
          }
      };
      dfs(i);
      res++;
    }
  cout << res - 1;

  return 0;
}
//2020.09.26 20:03:45


Measured memory_bytes: 10328
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n; cin>>n;
    vector<int> odd(n/2);
    vector<int> even(n/2);
    for(int i=0; i<n ; i++){
        if( i%2 == 0){
            cin>>even[i/2];
            //cout << "i is "<<i<< " even" << i/2 <<" is "<<even[i/2]<< endl;
        }
        else{
            cin>>odd[i/2];
            //cout << "i is "<<i<< " odd" << i/2 <<" is "<<odd[i/2]<< endl;
        }
    }
    sort(odd.begin(),odd.end());
    sort(even.begin(),even.end());

    vector<pair<int,int>> ov;
    vector<pair<int,int>> ev;
    int odd_tmp_num=0;
    int even_tmp_num=0;

    for(int i=0 ; i<n/2 ; i++){
        odd_tmp_num--;
        even_tmp_num--;
        if(i == n/2 -1 || odd[i] != odd[i+1]){
            ov.push_back(make_pair(odd_tmp_num,odd[i]));
            odd_tmp_num=0;
        }
        if(i == n/2 -1 || even[i] != even[i+1]){
            ev.push_back(make_pair(even_tmp_num,even[i]));
            even_tmp_num=0;
        }
    }
    sort(ov.begin(),ov.end());
    sort(ev.begin(),ev.end());
    /*
    for(int j=0;j<ov.size();j++){
        cout<<ov[j].first << "  "<<ov[j].second<<endl;
    }
    cout<<"aaa"<<endl;
    for(int j=0;j<ev.size();j++){
        cout<<ev[j].first << "  "<<ev[j].second<<endl;
    }
    */
    
    int ans=0;
    if(ov[0].second != ev[0].second){
        ans = n + ev[0].first + ov[0].first;
    }else{
        // oddの方が多い場合
        if(ov[0].first < ev[0].first){
            ans = n + ov[0].first + ev[1].first;
        }else if (ov[0].first > ev[0].first){
            ans = n + ov[1].first + ev[0].first;
        }else{
            int ret = (ov[1].first < ev[1].first) ? ov[1].first: ev[1].first;
            ans = n + ov[0].first + ret;
        }
    }
    
    cout << ans <<endl;
     return 0;   

}

Measured memory_bytes: 1660
#include <cstdio>
#include <algorithm>
using namespace std;
int dp[3001][3001]={};
int x[3001][2];
int n,t,s,ans=0;
int main(){
        scanf("%d %d %d",&n,&t,&s);
        for(int i=1;i<=n;i++){
            scanf("%d %d",&x[i][0],&x[i][1]);
        }
        for(int i=x[1][1];i<=t;i++){
          dp[1][i]=x[1][0];
        }
        for(int i=1;i<n;i++){
            for(int j=0;j<=t;j++){
                if(j-x[i+1][1]<0){
                if(j==0){
                    dp[i+1][j]=dp[i][j];
                }else{
                    dp[i+1][j]=max(dp[i+1][j-1],dp[i][j]);
                }
                }else{
                    if(j>s && j-x[i+1][1]<s){
                    dp[i+1][j]=max(dp[i+1][j-1],dp[i][j]);
                    }else{
                    dp[i+1][j]=max(dp[i][j],dp[i][j-x[i+1][1]]+x[i+1][0]);
if(j!=0){
dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-1]);
}
                    }/*DEGwer*/
                }
                ans=max(ans,dp[i+1][j]);
                }
            }
        printf("%d\n",ans);
        return 0;
    }

Measured memory_bytes: 36220
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;


int main(){
    int n; cin >> n;
    vector<int> v(n);
    int countWrong=0;
    rep(i,n) cin >> v[i];
    rep(i,n){
        if(v[i] != i+1) countWrong++;
    }
    if(countWrong ==0 || countWrong==2) cout << "YES"; else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

int dp[50][500][500];

signed main()
{
  int n,ma,mb; cin>>n>>ma>>mb;
  vi a, b, c;
  rep(i,n)
  {
    int ai, bi, ci; cin>>ai>>bi>>ci;
    a.pb(ai); b.pb(bi); c.pb(ci);
  }
  rep(i,50) rrep(j,500) rrep(k,500)
  {
    dp[i][j][k]=INF;
  }
  dp[0][0][0]=0;
  rep(i,n) rrep(j,500) rrep(k,500)
  {
    if(dp[i][j][k]==INF) continue;
    dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
    dp[i+1][j+a[i]][k+b[i]]=min(dp[i][j][k]+c[i],dp[i+1][j+a[i]][k+b[i]]);
  }
  int ans=INF;
  reps(i,1,500) reps(j,1,500)
  {
    if(i*mb==j*ma) ans=min(ans,dp[n][i][j]);
  }
  if(ans==INF) ans=-1;
  print(ans);

  return 0;
}

Measured memory_bytes: 49152
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  FOR(i,1,S.size()/2){
    string s1=S.substr(0,S.size()/2-i);
    string s2=S.substr(S.size()/2-i,S.size()/2-i);
    // cout<<s1<<" "<<s2<<endl;
    if(s1==s2){
      cout<<s1.size()*2<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
#  C. Christmas Eve
# https://atcoder.jp/contests/abc115/tasks/abc115_c

from heapq import heapify, heappop, heappush

n, k = map(int, input().split())
H = [int(input()) for _ in range(n)]
H.sort()

stack = []

for i in range(k):
  heappush(stack, H[i])

r = stack[-1] - stack[0] 

for i in range(k, n):
  heappop(stack)
  heappush(stack, H[i])
  r = min(r, stack[-1] - stack[0])

print(r) 





Measured memory_bytes: 8060
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  vector<int> dp1(1000000, INF);
  vector<int> dp2(1000000, INF);
  dp1[0] = 0;
  dp2[0] = 0;
  for (int i = 1; i * (i + 1) * (i + 2) / 6 <= 1000000; i++){
    int t = i * (i + 1) * (i + 2) / 6;
    for (int j = t; j <= 1000000; j++){
      dp1[j] = min(dp1[j], dp1[j - t] + 1);
    }
    if (t % 2 == 1){
      for (int j = t; j <= 1000000; j++){
        dp2[j] = min(dp2[j], dp2[j - t] + 1);
      }
    }
  }
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    cout << dp1[N] << ' ' << dp2[N] << endl;
  }
}


Measured memory_bytes: 10528
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll rui[411111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  string s;
  cin>>s;
  vi num;
  vi num2;
  for(int i=0;i<s.size();i++){
    ll cnt=0;
    while(i<s.size()&&s[i]=='0'){
      cnt++;i++;
    }
    num.pb(cnt);
    cnt=0;
    while(i<s.size()&&s[i]=='1'){
      cnt++;i++;
    }
    i--;
    num2.pb(cnt);
  }
  ll ans=0;
  for(int i=0;i<num.size();i++){
    rui[i*2+1]+=rui[i*2]+num[i];
    rui[i*2+2]+=rui[i*2+1]+num2[i];
  }
  for(int i=num.size()*2+1;i<411111;i++)
    rui[i]=rui[i-1];
  for(int i=1;i<111111;i++){
   
    if(i%2==1)
      ans=max(ans,rui[i+k*2-1]-rui[i-1]);
    else
      ans=max(ans,rui[i+k*2]-rui[i-1]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4564
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var [h,w]=arr.shift().split(" ").map(Number);
   if(h==0 && w==0)break;
   var k={};
   for(var i=0;i<h;i++){
      var r=arr.shift().split("");
      for(var j=0;j<w;j++){
         k[r[j]]=[i,j];
      }
   }
   var [s,sum,y,x]=[arr.shift().split(""),0,0,0];
   s.forEach(v=>{
      sum+=Math.abs(y-k[v][0])+Math.abs(x- k[v][1])+1;
      [y,x]=[k[v][0],k[v][1]];
   });
   console.log(sum);
}


Measured memory_bytes: 20576
aa = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
c = input()
n = aa.index(c)
n += 1
print(aa[n])

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxn = 1e5+100;
int C[maxn][100];

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    FOR(i,0,maxn) {
        C[i][0] = 1;
        FOR(j,1,min(i+1,100)) {
            C[i][j] = C[i-1][j-1] + C[i-1][j];
            C[i][j] %= mod;
        }
    }
    int n,m;
    while (cin >> n >> m) {
        LL ans = 1;
        for (int i = 2; i*i <= m; i++) {
            int cnt = 0;
            while (m%i == 0) {
                cnt++; m /= i;
            }
            if (cnt) {
                ans *= C[cnt+n-1][cnt];
                ans %= mod;
            }
        }
        if (m != 1) {
            ans *= C[1+n-1][1];
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 39424
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
	while(1){
		int a,b,c;
		int max,name=0;
		char na[6]="ABCDE";
		cin >> b >> c;
		if(b==0 && c==0)break;
		max=b+c;
		for(a=1;a<=4;a++){
			cin >> b >> c;
			if(b+c>max)name=a,max=b+c;
		}
		cout << na[name] << " " << max << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N;
	cin >> N;
	double A[N];
	for(int i=0;i<N;i++)cin >> A[i];
	double B = 0;
	for(int i=0;i<N;i++)B += 1/A[i];
	double ans = 1/B;
	cout << fixed << setprecision(10) << ans << endl;
}

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

using namespace std;

int main(){
	string str;
	int ans = 0;
	cin >> str;
	for (int i = 0; i < str.size()-1; i++){
		if (str[i] != str[i+1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512