akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline
    #区間の管理は　[a, b)で管理していることに注意

    # INT_MIN = -10 ** 18
    # MAX_N = 4 * 10 ** 5
    # MAX_N = 20


    # def init(n_):
    #     #簡単にするために2のべき乗に揃える
    #     n = 1
    #     while n <= n_:
    #         n *= 2
    #     return n

    #初期化
    N = int(input())
    # n = 1
    # while n <= N:
    #     n *= 2

    n = 262144
    data = [0] * (2 * n - 1)

    def update(k, a):
        k = k + n - 1
        # data[k] = a
        while k >= 0:
            data[k] = max(a, data[k])
            k = (k - 1) // 2
            # data[k] = max(data[2 * k + 1], data[2 * k + 2])

    def query(a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return data[k]
        else:
            return max(query(a, b, 2 * k + 1, l, (l + r)//2), query(a, b, 2 * k + 2, (l + r)//2, r))

    H = tuple(map(int, input().split()))
    A = tuple(map(int, input().split()))

    # ans = 0

    dp = [A[0]] + [0] * (N - 1)
    update(H[0] - 1, A[0])
    for i in range(1, N):
        # h = int(input())
        # a = int(input())
        dp[i] = query(0, H[i] - 1, 0, 0, n) + A[i]
        # h = H[i]
        # a = A[i]
        # tmp = query(1, h + 1) #[1, h)での最大値
        # print (h, tmp)
        update(H[i] - 1, dp[i])
        # ans = max(ans, tmp + a)
        # print (data)

    print (query(0, N, 0, 0, n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 122320
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int dp[N];
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n+1]={0};
  for(int i=1;i<=n;i++)
    cin>>a[i];
  memset(dp,-1,sizeof(dp));
  dp[0]=2;
  for(int i=1;i<=k;i++)
  {
    for(int j=1;j<=n;j++)
    {
       if(i-a[j]>=0)
       {
         if(dp[i-a[j]]==2)
           dp[i]=1;
       }
    } 
    if(dp[i]==-1)
      dp[i]=2;
  }
  if(dp[k]==1)
    cout<<"First"<<endl;
  else
    cout<<"Second"<<endl;
}
  

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

int main()
        {
ll n;
cin>>n;
ll a[n];
ll i;
for( i=0;i<n;i++)
  cin>>a[i];
  
  ll j=1,c=0,ans=0;
for( i=0;i<n;i++) 
  	{
	  if(a[i]==j)
  	  {j++;
  	  c++;
		}
	}
	
	
  if(c==n)
    ans=0;
  else if(c==0)
    ans=-1;
   else if(c>=1)
     ans=(n-c);
     
     cout<<ans<<endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct UnionFind {
    vector<int> par, s;
    UnionFind(int n=2e5) { init(n); }
    void init(int n) { 
        s.assign(n, 1); par.resize(n); 
        iota(par.begin(), par.end(), 0);
    }
    int find(int x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
        else par[y] = x, s[x] = s[x] + s[y];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return s[find(x)]; }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, q;
    cin >> n >> q;
    UnionFind uf(n);
    while(q--) {
        ll type;
        cin >> type;
        if(type == 0) {
            ll x, y;
            cin >> x >> y;
            uf.unite(x, y);
        } else {
            ll x, y;
            cin >> x >> y;
            cout << uf.same(x, y) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3280
import itertools

N = int(input())

all_list = list(itertools.product([0,1], repeat=N))

xy_list =[]

for i in range(N):
    for j in range(int(input())):
        x, y = map(int, input().split())
        xy_list.append((i+1,x,y))

#print(xy_list)

num_ok = 0
for i in all_list:
    #どの人の証言なのか
    flag = True

    for j in xy_list:
        if i[j[0]-1] == 1:
            if i[j[1]-1] != j[2]:
                flag = False        
                break

    if flag == True:
        if num_ok < i.count(1):
            num_ok = i.count(1)


print(num_ok)


            


Measured memory_bytes: 8820
# coding: utf-8
# Here your code !
import sys
import collections
#import numpy
import statistics
import unittest


def calculate_standard_deviation():
    lines = sys.stdin.readlines()
    data = []
    i = 0
    while(i < len(lines)):
        if(int(lines[i].rstrip()) == 0) :
            break
        else:
            data.append([ int(score) for score in lines[i+1].rstrip().split() ])
            i += 2

    for scores in data:
        mean = statistics.mean(scores)
        
        print(statistics.pstdev(scores))
#        print(numpy.std(scores))

def __input_error():
    print("input error")
    return -1

class __TestValueClass(unittest.TestCase):
    def testEqual(self,func,tuples):
        self.testFunction(self.assertEqual,func,tuples)
    
    def testFunction(self,assertfunc,func,tuples):
        #tuples[index] = ([*arguments of func], compared value)
        for item in tuples:
            try:
                if isinstance(item[0], collections.Iterable):
                    assertfunc(func(*item[0]),item[1])
                else:
                    assertfunc(func(item[0]),item[1])
            except Exception as msg:
                swidth = 15
                print("="*50)
                print("-- Assertion Error in '" + func.__name__ + "' --")
                print("arguments".ljust(swidth)+":",item[0])
                print("compared value".ljust(swidth)+":",item[1])
                print("message".ljust(swidth)+":")
                print(msg)
                sys.exit()
        print(func.__name__,": succeeded")
        
#test
if __name__ == "__main__" :

    calculate_standard_deviation()
#    test = __TestValueClass()

Measured memory_bytes: 11224
#include<stdio.h>
#include<math.h>

int main(){
	
	int N,i,a,aa,b,bb,c,cc;
	
	scanf("%d",&N);
	
for(i=0;i<N;i++){
	scanf("%d %d %d",&a,&b,&c);
	aa=a*a;
	bb=b*b;
	cc=c*c;
	
	if(aa==bb+cc || bb==aa+cc || cc==bb+aa){
		printf("YES\n");
	}
	else printf("NO\n");
}

return 0;

}

Measured memory_bytes: 580
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    int count = 0;
    for(int i = 1; i <= n; ++i) {
        if(i % 2 == 1 && a[i] % 2 == 1)
            count++;
    }

    cout << count << endl;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

int main(){
    string str; // 文字列
    int q; // 命令の数

    cin >> str;
    cin >> q;

    // cout << str << endl;
    // cout << q << endl;

    for(int i = 0; i < q; i++){
        // cout << str << endl;

        string meirei;
        cin >> meirei;
        // cout << meirei << endl;

        // switch(meirei){
        //     case "print":
        //         break;
        //     case "reverse":
        //         break;
        //     case "replace":
        //         break;
        // }

        if("print" == meirei){
            // cout << "print" << endl;
            int a, b;
            string str1;
            cin >> a >> b;
            // cout << a << " " << b << endl;
            str1 = str.substr(a, b - a + 1);
            cout << str1 << endl;
        } else if ("reverse" == meirei) {
            // cout << "reverse" << endl;
            int a, b;
            cin >> a >> b;
            // cout << a << " " << b << endl;

            string str1, str2;
            for(int i = a; i <= b; i++){
                str1 += str[i];
                str2 += str[i];
            }
            // cout << str1 << endl;
            // cout << str1.size() << endl;
            for(int i = 0; i < str1.size(); i++){
                // cout << str1[i] << endl;
                str2[i] = str1[str1.size() - 1 - i];
                // cout << str2[i] << endl;
            }
            // cout << str2 << endl;
            str = str.replace(a, b - a + 1, str2);

        } else if ("replace" == meirei) {
            // cout << "replace" << endl;
            // string a, b, p;
            int a, b;
            string p;

            cin >> a >> b >> p;
            // cout << a << " " << b << " " << p << endl;
            str = str.replace(a, b - a + 1, p);

        }
    }

    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
using ll = long long;
using P = pair<int, int>;

// a^n modを計算する
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;
}

// a^{-1}を計算する
long long modinv(long long a, long long mod)
{
  return modpow(a, mod - 2, mod);
}

long long choose(long long n, long long a)
{
  long long x = 1, y = 1; // x 分母 y 分子
  for (long long i = 0; i < a; i++)
  {
    x = (x * (n - i)) % MOD;
    y = (y * (i + 1)) % MOD;
  }
  return (x * modinv(y, MOD)) % MOD;
}

int main()
{
  long long n, a, b;
  cin >> n >> a >> b;
  long long ans = 0;
  ans = modpow(2, n, MOD) - 1;
  long long case_a, case_b;
  case_a = choose(n, a);
  case_b = choose(n, b);
  ans = ((ans - case_a) % MOD + MOD) % MOD;
  ans = ((ans - case_b) % MOD + MOD) % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=2e14;
const ll ms=(2e5) +5;


int main()
{
    idfc;
    string a,b,c;
    cin>>a>>b;
    int x,y;
    cin>>x>>y;
    cin>>c;
    if(c==a)x--;
    else y--;
    cout<<x<<" "<<y;
    return 0;
}

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

using namespace std;
int main()
{
	int N;
	cin >> N;

	vector<int> A(N);

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

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

    std::cout << A.at(N-1) - A.at(0); 
}

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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)

using VI = vector<int>;
using VVI = vector<VI>;
// clang-format on

const long long MOD = 1000000007;

int main()
{
  IOS;

  int H, W;
  cin >> H >> W;
  vector<string> grid(H);
  forn(i, 0, H) cin >> grid[i];

  VVI dp(H, VI(W));
  dp[0][0] = 1;
  forn(i, 0, H) forn(j, 0, W)
  {
    if (grid[i][j] == '#')
      continue;
    if (i > 0)
      dp[i][j] += dp[i - 1][j];
    if (j > 0)
      dp[i][j] += dp[i][j - 1];
    dp[i][j] %= MOD;
  }
  cout << dp[H - 1][W - 1] << endl;

  return 0;
}


Measured memory_bytes: 8212
import java.io.*;
import java.math.*;
import java.util.*;

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();

        int r = 1;
        for (int i = 1; i*i <= m; i++) {
            if (m % i == 0) {
                if (m / i >= n) r = Math.max(r, i);
                if (i >= n) r = Math.max(r, m / i);
            }
        }
        System.out.println(r);

        sc.close();
    }
}

Measured memory_bytes: 24916
fun main(args: Array<String>) = IO().exec {
    val n = int()
    val lst = mutableListOf<Long>()
    for (i in n) {
        val a = long()
        val j = bs(lst, a)
        if (j == lst.size) lst.add(a)
        else lst[j] = a
    }
    println(lst.size)
}

fun bs(arr: MutableList<Long>, x: Long): Int {
    var ok = arr.size
    var ng = -1
    while (Math.abs(ok - ng) > 1) {
        val mid = (ok + ng) / 2
        if (arr[mid] < x) {
            ok = mid
        } else {
            ng = mid
        }
    }
    return ok
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

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

int main()
{
    int n[3];
    cin>>n[0]>>n[1]>>n[2];
    for(int i=0;i<2;i++)
    {
        for(int i=0;i<2;i++)
        if(n[i]>n[i+1])
        {
            int j = n[i];
            n[i] = n[i+1];
            n[i+1] = j;
        }
    }
    cout<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
    return 0;
}

Measured memory_bytes: 3108
n=int(input())
a = list(map(int, input().split()))
ans=1

if 0 in a :
  ans=0
else:
  for i in range(n):
    if len(str(ans))>=19:
      ans='-1'
      break
    else:
      ans*=a[i]
if ans==1000000000000000000:
  ans=1000000000000000000
elif len(str(ans))>=19:
  ans=-1
print(ans)

Measured memory_bytes: 21720
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{int a,b,c;
 cin >> a >> b >> c ;
 
 
cout << (a*b)/2 << endl;

 
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i]){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		int total = 0;
		int cnt = 1;
		while(true) {
			total += cnt;
			cnt++;
			if(X <= total) {
				break;
			}
		}
		System.out.print(cnt-1);
	}
}

Measured memory_bytes: 22996
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,h = readInts()
a = [0] * n
b = [0] * n
for i in range(n):
    a_,b_ = readInts()
    a[i] = a_;b[i]=b_;
a = sorted(a,reverse = True)
b = sorted(b,reverse = True)
MAX = a[0]
ans = 0
for v in b:
    if h <= 0:
        break
    if v > MAX:
        ans += 1
        h -= v
    else:
        break
if h > 0:
    ans += (h+MAX-1)//MAX
print(ans)


Measured memory_bytes: 12208
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int, int> iP;
typedef pair<int, vector < int > > vP;

int main(){
  
  int n;
  while(cin >> n, n) {
    map< string, vP > sum;
    int same[31] = { 0 };
    
    for(int i = 0; i < n; i++) {
      string name;
      int m;
      cin >> name >> m;
      sum[name] = vP(0, vector< int >(0)); 
      for(int i = 0; i < m; i++) {
        int d; cin >> d; 
        sum[name].sc.push_back(d);
        same[d]++;
      }
    }
    
    int mini = INF;
    string minn = "";
    for(map< string, vP >::iterator it = sum.begin(); it != sum.end(); it++) {
      for(int i = 0; i < (*it).sc.sc.size(); i++) {
        (*it).sc.fr += n - (same[(*it).sc.sc[i]] - 1);
      }
      if((*it).sc.fr < mini) mini = (*it).sc.fr, minn = (*it).fr; 
    }
    cout << mini << " " << minn << endl;
  }
}

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

c=[0]*N

for i in range(N):
    if i>0:
        clist=[]
        for j in range(1,min(i+1,K+1)):
            clist.append(c[i-j]+abs(h[i]-h[i-j]))
        c[i]=min(clist)

print(c[N-1])


Measured memory_bytes: 52448
#include <algorithm>
#include <array>
#include <iostream>
#include <string>

std::string words[40];
const std::array<int, 5> N57577 = { 5, 7, 5, 7, 7 };

int main()
{
	while (true) {
		int n;
		std::cin >> n;

		if (n == 0) return 0;

		for (int i = 0; i < n; i++) {
			std::cin >> words[i];
		}

		for (int i = 0; i < n; i++) {
			int j = i;
			bool valid_tanka = true;

			for (int wn : N57577) {
				int count = 0;
				while (j < n) {
					count += words[j++].size();
					if (count >= wn) break;
				}
				if (count != wn) {
					valid_tanka = false;
					break;
				}
			}
			
			if (valid_tanka) {
				std::cout << (i + 1) << std::endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3224
import math
N = int(input())
A = list(map(int, input().split()))

left = [0]
gcd_left = 0
for a in A:
    gcd_left = math.gcd(gcd_left, a)
    left.append(gcd_left)
right = [0]
gcd_right = 0
for a in reversed(A):
    gcd_right = math.gcd(gcd_right, a)
    right.append(gcd_right)
right.append(0)
right = list(reversed(right))
# print(left)
# print(right)

max_gcd = 0
for i in range(1, N+1):
    sub_gcd = math.gcd(left[i-1], right[i+1])
    max_gcd = max(max_gcd, sub_gcd)
print(max_gcd)


Measured memory_bytes: 21380
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2,
  5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    A += [K+A[0]]
    ans = K
    for i in range(N):
        ans = min(ans, K - (A[i+1] - A[i]))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 77260
m[25],w[25],i,j,W,g;main(n){for(;scanf("%d",&n)*n;puts(g?"No":"Yes"))for(W=g=i=0;++i<999;)for(j=n;j--;w[j]-i||(W+=m[j],g|=W>i))i-1||scanf("%d%d",m+j,w+j);}

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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  bool exist = false;
  if (A < B)
  {
    for (int i = 0; i < A; ++i)
    {
      if (0 == (B*i + C)%A)
      {
        exist = true;
        break;
      }
    }
  }
  else
  {
    for (int i = 1; i <= B; ++i)
    {
      if (0 == (A*i - C)%B)
      {
        exist = true;
        break;
      }
    }
  }
  cout << (exist ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
class UnionFind
	def initialize(n)
		@parent = (0..n).to_a
	end

	def unite(x,y)
		while @parent[x] != @parent[y]
			x, y = y, x if @parent[x] > @parent[y]
			break @parent[x] = @parent[y] if x == @parent[x]
			@parent[x], x = @parent[y], @parent[x]
		end
	end

	def root(x)
		x = @parent[@parent[x]] while x != @parent[x]
		return x
	end
end

N, K, L = gets.split.map(&:to_i)

uf = UnionFind.new(N)
K.times { uf.unite(*gets.split.map(&:to_i)) }
road = 0.upto(N).map { |x| uf.root(x) }

uf = UnionFind.new(N)
$<.map{ |x| uf.unite(*x.split.map(&:to_i)) }


a = 1.upto(N).map { |i| road[i] << 20 | uf.root(i) }
puts a.map(&a.each_with_object(Hash.new(0)){ |k, h| h[k] += 1 })*" "


Measured memory_bytes: 22012
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
int main(){
  cin>>N;
  prin((N-2)*180);
  return 0;
}


Measured memory_bytes: 764
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wtr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n,s := scanInt(),scanText()

	ans := 0
	for i := 0; i < n; i++ {
		lcp := z(s[i:])
		for j := 0; j < len(lcp); j++ {
			ans = max(ans, min(lcp[j],j))
		}
	}
	fmt.Println(ans)
}

func z(s string) []int {
	n := len(s)
	res := make([]int, n)
	i, j := 1, 0
	for i<n {
		for i+j < n && s[j] == s[i+j] {
			j++
		}
		res[i] = j
		if j == 0 {
			i++
			continue
		}
		k := 1
		for i+k < n && k+res[k] < j {
			res[i+k] = res[k]
			k++
		}
			i += k
			j -= k
	}

	return res
}

func min(a,b int) int {
	if a<b {
		return a
	}
	return b
}

func max(a,b int) int {
	if a>b {
		return a
	}
	return b
}



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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

#define endl "\n"

int main()
{
	faster;
	
	int x,n;
	cin >> x >> n;
	map<int,int> a;

	for(int i= 0; i < n; i++){
		int input;
		cin >> input;

		a[input]++;
	}
	int mnN = 104,num=104;
	for(int i = 102; i >= 0; i--){
		if(abs(x-i) <= mnN && a.count(i) == 0) {
			mnN = abs(x-i);
			num = i;
		}
	}
	if(n == 0) num = x;
	cout << num << endl;

	return 0;
}

Measured memory_bytes: 3648
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;

const long long inf2 = (long long)1e18;
const long long mod = (long long)(1e9+7);
const long long inf1 =(long long)(1e6+1);
 
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, k; cin >> n >> k;
    readarr(a, n);
    sort(a+1, a+n+1);

    int ans = 0;
    if(k >= n) {cout << 0; return 0;}

    fori(i, 1, n-k) ans += a[i];

    cout << ans;
    return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> ab(n);
    rep (i, 0, n)
	cin >> ab[i].first >> ab[i].second;

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

    ll res = 0;
    ll count = 0;
    for (int i = 0; i < n; i++) {
	ll num;
	if (count + ab[i].second > m)
	    num = m - count;
	else
	    num = ab[i].second;

	res += ab[i].first * num;
	count += num;

	if (count == m)
	    break;
    }

    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
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)*}
    };
}

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

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, 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")
    };
}

fn main() {
    input! {
        A: usize,
        B: usize,
        K: usize,
    }

    let mut divs = Vec::new();
    use std::cmp::min;
    for i in 1..(min(A, B) + 1) {
        if A % i == 0 && B % i == 0 {
            divs.push(i);
        }
    }
    let l = divs.len();
    println!("{}", divs[l - K]);
}


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

int main() {
    int N;
    cin >> N;
    int x, y;
    int sum;
    sum = 0;

    for (int i = 0; i < N; i++) {
        cin >> x >> y;
        sum += (y - x) + 1;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3516
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,pair<int,int> > P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

int V,E;
struct edge{
    int to,cost;
};

vector<vector<edge> > G(MAXV);
vector<bool> used(MAXV,false);

int prim(){
    priority_queue<ii,vector<ii>,greater<ii> > que;
    que.push(ii(0,0));
    int res=0;
    while(!que.empty()){
        int cst=que.top().first;
        int v=que.top().second;
        que.pop();
        if(used[v]) continue;
        used[v]=true;
        res+=cst;
        for(int i=0;i<(int)G[v].size();i++){
            edge e=G[v][i];
            que.push(ii(e.cost,e.to));
        }
    }
    return res;
}

int main(){
    cin>>V>>E;
    for(int i=0;i<E;i++){
        int s,t,w;cin>>s>>t>>w;
        G[s].push_back(edge{t,w});
        G[t].push_back(edge{s,w});
    }
    int ans=prim();
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 2e5+10;

ll N, K;
ll A[MAX];
map<ll, vi> mod;

ll solve() {
    REP (i, N) A[i] = (A[i] + K - 1) % K;
    mod[0].push_back(0);
    ll s = 0;
    set<ll> used_index;
    REP (i, N) {
        s = (s + A[i]) % K;
        mod[s].push_back(i+1);
        used_index.insert(s);
    }
    ll ans = 0;
    for (auto it_index = used_index.begin(); it_index != used_index.end(); it_index++) {
        ll i = *it_index;
        for (auto it = mod[i].begin(); it != mod[i].end(); it++) {
            ll n = *it;
            auto it_limit = upper_bound(ALL(mod[i]), n+K-1);
            it_limit--;
            ans += distance(it, it_limit);
        }
    }
    return ans;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> A[i];
    cout << solve() << endl;
}

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

int main() {
int a,N;
int point[2];
  point[0]=0;
  point[1]=0;
  
  cin >> N;
  vector<int> vec ;
  for(int i=0;i<N;i++){
cin >> a;
    vec.insert(vec.begin()+i, a);
  }
        
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    for (int i = 0; i < vec.size(); i++) {
      int t;
      t=i%2;
      point[t]+= vec.at(i) ;
    }
  cout<<max(point[0],point[1])-min(point[0],point[1])<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int cnt = 0;
        for (int i = 3; i < n; i += 2) {
            if (n % i == 0) {
                // s- (i-1)/2 >= 1
                // 2s-1>= i
                int s = n / i;
                if (2 * s - 1 >= i) {
                    cnt++;
                }
            }
        }
        for (int i = 2; i < 2 * n; i += 2) {
            if ((2 * n) % i == 0 and (n % i) != 0) {
                int s = (2 * n) / i;
                // (s+1)/2-i/2 >= 1
                // s+1-i >= 2
                if (s >= i + 1) {
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 3044
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int p[M];
    string s[M];

    for(int i = 0; i < M; i++){
        cin >> p[i] >> s[i];
        p[i]--;
    }

    int cnt[N];
    bool found[N];
    fill(cnt, cnt + N, 0);
    fill(found, found + N, false);

    int ac = 0;
    int pena = 0;

    for(int i = 0; i < M; i++){
        if(found[p[i]]) continue;
        else {
            if(s[i] == "AC"){
                //cout << i << endl;
                ac++;
                pena += cnt[p[i]];
                found[p[i]] = true;
            }
            else if(s[i] == "WA"){
                cnt[p[i]]++;
            }
        }
    }

    cout << ac << " " << pena << endl;
    return 0;



}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define si3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld%lld%lld",&a,&b,&c)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)


map<string, int>m;
int main()
{
   ll t,n,i,j,k,l,mn=0, mx=1000;

   sl(t);

   string s;
   loop(t)
   {
       cin>>s;
       m[s]++;
   }

   cout<<"AC x "<<m["AC"]<<endl;
   cout<<"WA x "<<m["WA"]<<endl;
   cout<<"TLE x "<<m["TLE"]<<endl;
   cout<<"RE  x "<<m["RE"]<<endl;

}







Measured memory_bytes: 3696
#include <stdio.h>
#include <string.h>
char str[1000005];int n,beg,ret;
int main(){
	scanf("%s",&str);n=strlen(str);
	while(beg<n){
		if(str[beg]!='J') { beg++; continue;}
		int j=0,o=0,i=0;
		while(beg<n&&str[beg]=='J'){j++;beg++;}
		while(beg<n&&str[beg]=='O'){o++;beg++;}
		while(beg<n&&str[beg]=='I'){i++;beg++;}
		if(o<=j&&o<=i) ret=(ret<o?o:ret);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1948
#include<bits/stdc++.h>
using namespace std ; 
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  ll dp[n+1]={0};
  ll a[n+1]={0};
  ll i;
  for(i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  dp[1]=0;
  dp[2]=abs(a[1]-a[2]);
  i=3;
  while(i<=n)
  {
    dp[i]=min((dp[i-1] + abs(a[i]-a[i-1])),(dp[i-2] + abs(a[i]-a[i-2])) );
    i++;
  }
  cout<<dp[n];
  
  
  return 0;
}

Measured memory_bytes: 5060
N, M, Q = map(int, input().split())
N_Map = [[0 for _ in range(N + 1)] for _ in range(N + 1)]

for _ in range(M):
    a = list(map(int, input().split()))
    N_Map[a[0]][a[1]] += 1

for i in range(N, 0, -1):
    count = 0
    for j in range(1, N  + 1):
        count += N_Map[i][j]
        if i < N:
            N_Map[i][j] = N_Map[i + 1][j] + count
        else:
            N_Map[i][j] = count

Pi = []
for _ in range(Q):
    a = list(map(int, input().split()))
    Pi.append(a)

for p in Pi:
    print(N_Map[p[0]][p[1]])


Measured memory_bytes: 30908
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    string a,b,c; char tmp;
    cin >> a >> b;
    if(a.size() > 80 || b.size() > 80){
      cout << "overflow" << endl;
      continue;
    }
    if(a.size() < b.size()){swap(a,b);}
    for(int k = 0;k< a.size();k++)
      c[k] = '0';
     for(int k = 0;k < b.size();k++){
       c[k] = b[b.size()-1-k];
     }
     b.resize(a.size());
     for(int k = 0;k < a.size();k++)
       {b[k] = c[k]; c[k] = a[k];} 
     for(int k = 0;k < a.size();k++){
      	a[a.size()-k-1] = c[k];
     }
	
     tmp = '0';
     for(int k = 0;k < a.size();k++){
       c[k] = a[k] + b[k] + tmp -'0' -'0';
	  if(c[k] > '9'){ tmp = '1'; c[k] = c[k] - ':' + '0'; }
	  else {tmp = '0';}
     }
     if((a.size() <= 80 && tmp == '0') || (a.size() < 80 && tmp == '1') )
       {if(tmp == '1') cout << tmp;
	 for(int k = a.size()-1;k >=0;k--){
	   cout << c[k]; 
	 }
	 cout << endl;
       } else {cout <<"overflow" << endl;}
     
  }
}

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

using namespace std;

int main(void){

    string str;
    int q;
    cin >> str;
    cin >> q;
    int count = 0;

    for(int i = 0;i < q;i++){
        int n; cin >> n;
        if(n == 1){
            count++;
        }else{
            int f; cin >> f;
            string c; cin >> c;
            if(count % 2 != 0){
                if(f == 1) f = 2;
                else f = 1;
            }
            if(f == 1){
                str.insert(0, c);
            }else{
                str += c;
            }
        }
    }

    if(count % 2 != 0){
        string tmp = "";
        for(int i = 0;str[i] != '\0';i++){
            tmp += str[str.length()-1-i];
        }
        str = tmp;
    }

    cout << str << endl;

    return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;
//fibonacci
int binet(int n)
{
	return (pow((1+sqrt(5)),n-1)-pow((1-sqrt(5)),n-1))/(pow(2,n-1)*sqrt(5));
}


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	string str,str1,str2;
	cin>>str1>>str2>>str;
	cout<<str1[0]<<str2[0]<<str[0];
	return 0;
}
	

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, n) {
        rep(j, n) {
            if (s[i + j] != t[j]) break;
            if (i + j + 1 == n) {
                cout << i + n << endl;
                return 0;
            }
        }
    }
    cout << 2 * n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)



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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    if(a == b && b == c)
        cout << 1 << endl;
    else if(a == b || b == c || c == a)
        cout << 2 << endl;
    else
        cout << 3 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int n,s,t,c,a[1001];
bool used[1001];
vector<P>v[1001];
int dfs(int x){
    int res=0;
    used[x]=1;
    r(i,v[x].size())
      if(!used[v[x][i].first]){
        if(a[v[x][i].first])res+=v[x][i].second;
        else res+=min(v[x][i].second,dfs(v[x][i].first));
      }
    return res;
}
main(){
    cin>>n;
    r(i,n-1)cin>>a[i+1];
    r(i,n-1){
        cin>>s>>t>>c;
        v[s].push_back(P(t,c));
        v[t].push_back(P(s,c));
    }
    cout<<dfs(0)<<endl;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int pos[(1<<26)+20];
char s[maxn];
int dp[maxn];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	memset(pos,-1,sizeof(pos));
	for (int i=1;i<=len;i++)dp[i]=len;
	pos[0]=0;
	int x=0;
	for (int i=1;i<=len;i++){
		s[i]-='a';
		x^=(1<<s[i]);
		dp[i]=dp[i-1]+1;
		for (int j=0;j<26;j++){
			if (pos[x^(1<<j)]==-1)continue;
			dp[i]=min(dp[i],dp[pos[x^(1<<j)]]+1);
		}
		if (~pos[x])dp[i]=min(dp[i],dp[pos[x]]+1);
		if (pos[x]==-1)pos[x]=i;
		if (dp[i]<dp[pos[x]]) pos[x]=i;
	}
	printf("%d",dp[len]);
}

Measured memory_bytes: 263424
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, K; cin >> N >> K;
  vector<int> P(N);
  for (auto& p : P) {
    cin >> p;
  }

  vector<double_t> Q(N);
  for (int i = 0; i < N; ++i) {
    auto r = (1 + P[i]) * P[i];
    r /= 2;
    auto s = (long double) r / P[i];
    Q[i] = s;
  }

  vector<double_t> res(N);
  for (int i = 0; i < K; ++i) {
    res[0] += Q[i];
  }
  for (int i = 1; i < N; ++i) {
    if (i+K-1 >= N) break;
    res[i] = res[i-1];
    res[i] -= Q[i-1];
    res[i] += Q[i+K-1];
  }
  auto ans = *boost::max_element(res);
  cout 
    << std::fixed
    << std::setprecision(20)
    << std::setfill('0')
    << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 4224