akhauriyash/Code-Regression huggingface dataset:
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform:Practice 1  Vjudge

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

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007
// int n;
// vector<int> a;
// void solution() {
	// cin >> n;
	// a.resize(n);
	// for (auto& e:a) {
		// cin >> e;
	// }
// }

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	// int t;
	// cin >> t;	
	// while(t--) {
		// solution();
	// }
	int n;
	cin >> n;
	string s, p;
	cin >> s >> p;
	string ans = "";
	rep(i,0,n) {
		ans += s[i];
		ans += p[i];
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3580
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException
    {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        int sum;
        char c;
        while(true){
            String line = br.readLine();
            if(line.length() == 1 && line.charAt(0) == '0'){ break; }
            sum = 0;
            for(int i = 0; i < line.length(); i++){
                c = line.charAt(i);
                sum += (c - 48);
            }
            System.out.println(sum);
        }
    }
}


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

int main(){
  int N,M;
  cin >>N;
  vector<string> s(N);
  for(int i=0;i<N;i++)
    cin >>s[i];
  cin >>M;
  vector<string> t(M);
  for(int i=0;i<M;i++)
    cin >>t[i];
  int answer=0;
  for(int i=0;i<N;i++){
    int csn=1;
    for(int j=i+1;j<N;j++){
      if(s[i]==s[j])
        csn++;
    }
    for(int k=0;k<M;k++){
      if(s[i]==t[k])
        csn--;
    }
    answer=max(answer,csn);
  }
  cout <<answer <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
using ll=long long;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin>>N;
  ll A[N];
  memset(A,0,sizeof(A));
  for (int i=1; i<=N; i++) {
    cin>>A[i];
    A[i]+=A[i-1];
  }
  sort(A,A+N+1);
  ll ans=0,cnt=1;
  for (int i=1; i<=N; i++) {
    if (A[i-1]==A[i]) {
      cnt++;
    } else {
      ans+=cnt*(cnt-1)/2;
      cnt=1;
    }
  }
  ans+=cnt*(cnt-1)/2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
#if !DEBUG
    using System.IO;
#endif

public class Program {
    public static void Main() {
        #region SetAutoFlushIsFalse
#if !DEBUG
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
#endif
        #endregion

        var arr = ReadLib.ReadAsIntArray();
        var n = arr[0];
        var k = arr[1];

        if (k == 1) {
            Console.WriteLine(0);
        } else {
            Console.WriteLine(n - (k - 1) - 1);
        }
            

        #region Flush
#if !DEBUG
        Console.Out.Flush();
        sw.Close();
#endif
        #endregion
    }
}


static class ReadLib {
    public static long ReadAsLong() {
        return long.Parse(Console.ReadLine());
    }

    public static int ReadAsInt() {
        return int.Parse(Console.ReadLine());
    }

    public static int[] ReadAsIntArray() {
        return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    public static string[] ReadAsStringArray() {
        return Console.ReadLine().Split(' ');
    }

    public static int[] ReadNTimesAsInt(int n) {
        return Enumerable.Range(1, n).Select(s => int.Parse(Console.ReadLine())).ToArray();
    }

    public static int[][] ReadNTimesAsIntArray(int n) {
        return Enumerable.Range(1, n).Select(s => ReadAsIntArray()).ToArray();
    }

}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 
    int h, w; cin >> h >> w;
    vector<vector<int> > a(h + 2, vector<int> (w + 2, 1));
 
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> a[i][j];
        }
    }
 
    vector<vector<int> > dp(h + 1, vector<int> (w + 1, 0));
 
    int ans = 0;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
 
            if(a[i][j] == 1) dp[i][j] = 0;
            else{
                int v = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
                dp[i][j] = v;
 
                ans = max(ans, v);
            }
        }
    }
 
    cout << ans * ans << endl;
    return 0;
}


Measured memory_bytes: 18448
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 2147483647


int main() {
	ios_base::sync_with_stdio(false);

	int a, b; cin >> a >> b;
	if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
		cout << a * b << "\n";
	}
	else {
		cout << -1 << "\n";
	}
}


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

using namespace std;
int main (){
    string S;
    cin >> S;
    bool flag=true;
    for (int i = 0; i < S.size(); i++){
        if(i%2==0){
            if(('R'!=S[i] && 'U'!=S[i] && 'D'!=S[i])) flag = false;
        }
        if(i%2==1){
            if((S[i]!='L'&&S[i]!='U'&&S[i]!='D')) flag = false;
        }
    }
    if(flag) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 384
import numpy as np

X= int(input())

ans = X
#x が素数か判定
def solve(x):
    for n in range( 2, int(np.sqrt(x))+1 ):
        if x%n ==0:
            return False
    return True

while True:
    if solve(ans):
        break
    ans += 1

print(ans)


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

int main()
{
    int hour, min, sec;

    cin >> sec;

    hour = sec / 3600;
    sec = sec - (hour * 3600);

    min = sec / 60;
    sec = sec - (min * 60);

    cout << hour << ":" << min << ":" << sec << endl;

    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string w;
  cin >> w;

  string s, ss;
  map<string, int> mp;
  while (getline(cin, s)) {
    if (s == "END_OF_TEXT")
      break;

    transform(s.begin(), s.end(), s.begin(), ::tolower);
    istringstream stream(s);
    while (getline(stream, ss, ' ')) {
      mp[ss]++;
    }
  }
  cout << mp[w] << endl;
}



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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

struct S{
    int w,s,v;
    void read(){
        cin>>w>>s>>v;
    }

    bool operator < (const S& b) const{
        return w+s < b.w + b.s;
    }
};

void solve()
{
    cin>>n;
    vector<S> in(n);

    for(int i=0;i<n;i++){
        in[i].read();
    }

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

    int MAX_S = 20123;
    vector<int> dp(MAX_S+1,0);
    for(S block: in){
        // tr(block.w, block.s, block.v);
        for(int i = min(block.s, MAX_S - block.w); i>=0; i--){
            // cout<<"1";
            dp[i + block.w] = max(dp[i+block.w],dp[i] + block.v);
        }
    }
    int answer = 0;
    for(int i=0;i<=MAX_S;i++){
        // tr(dp[i]);
        answer = max(answer, dp[i]);
    }
    cout<<answer;
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 384
#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() {
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (s < t) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
import itertools
n = input()
ans = 0

if len(n) < 3 or int(n) <= 356:
  pass
else:
  num = "753"
  for x in range(3,len(n)+1):
    for y in itertools.product(num, repeat=x):
      if "7" in y and "5" in y and "3" in y:
        if int("".join(y)) <= int(n):
          ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

int main(){
	int a,b;
	cin >> a >> b;
	cout << (a+b)%24 << endl;

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1000010;
int A[MAXN],B[MAXN];
int main()
{
	int a,b;
	cin>>a>>b;
	for (int i=0;i<=1000000;++i)
	{
		A[i]=0.08*i;
		B[i]=0.1*i;
	}
	int p=-1;
	for (int i=0;i<=1000000;++i)
		if (A[i]==a && B[i]==b)
		{
			p=i;
			break;
		}
	cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int main(){

	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;

	// bool ambos = a + b > a + (a-1) && a + b > b + (b-1);
	// bool duplo_a = a + (a-1) > a + b && a + (a-1) > b + (b-1);
	// bool duplo_b = b + (b-1) > a + b && b + (b-1) > a + (a-1);

	// if(ambos){
	// 	cout << " Ambos " << a + b << endl;
	// }
	// else if(duplo_a){
	// 	cout << " A + A-1 " << a + (a-1) << endl;
	// }
	// else if(duplo_b){
	// 	cout << " B + B-1 " << b + (b-1) << endl;
	// }
	// else{
	// 	cout << " Uarevi " << a + b << endl;
	// }

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

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			int C = in.nextInt();
			int D = in.nextInt();
			out.println(Math.min(A, B) + Math.min(C, D));
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


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

int main()
{

    int h, w;
    cin >> h >> w;
    vector<string> map;
    int l[h][w], r[h][w], u[h][w], d[h][w];
    int max = -1;

    for (auto i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        map.push_back(s);
    }

    for (auto i = 0; i < h; i++)
    {
        for (auto j = 0; j < w; j++)
        {
            if (map[i][j] == '#')
            {
                l[i][j] = 0;
            }
            else
            {
                if (j == 0)
                {
                    l[i][j] = 1;
                }
                else
                {
                    l[i][j] = l[i][j - 1] + 1;
                }
            }
        }
    }

    for (auto i = 0; i < h; i++)
    {
        for (auto j = w - 1; j >= 0; j--)
        {
            if (map[i][j] == '#')
            {
                r[i][j] = 0;
            }
            else
            {
                if (j == w - 1)
                {
                    r[i][j] = 1;
                }
                else
                {
                    r[i][j] = r[i][j + 1] + 1;
                }
            }
        }
    }

    for (auto i = 0; i < h; i++)
    {
        for (auto j = 0; j < w; j++)
        {
            if (map[i][j] == '#')
            {
                u[i][j] = 0;
            }
            else
            {
                if (i == 0)
                {
                    u[i][j] = 1;
                }
                else
                {
                    u[i][j] = u[i - 1][j] + 1;
                }
            }
        }
    }

    for (auto i = h - 1; i >= 0; i--)
    {
        for (auto j = 0; j < w; j++)
        {
            if (map[i][j] == '#')
            {
                d[i][j] = 0;
            }
            else
            {
                if (i == h-1)
                {
                    d[i][j] = 1;
                }
                else
                {
                    d[i][j] = d[i + 1][j] + 1;
                }
            }
        }
    }

    for (auto i = 0; i < h; i++)
    {
        for (auto j = 0; j < w; j++)
        {
            int ans = l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3;
            if(ans > max){
                max = ans;
            }
        }
        
    }

    cout << max << endl;

}

Measured memory_bytes: 66816
#include <bits/stdc++.h>
using namespace std;
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;
}


Measured memory_bytes: 256
str = gets.split
N,u,v = str[0].to_i, str[1].to_i, str[2].to_i

a = Array.new(N+1,-1)
a[u] = 0
b = Array.new(N+1,-1)
b[v] = 0

c = Array.new(N+1){Array.new(0)}
d = Array.new(N+1){Array.new(0)}
for ii in 1...N do
    str = gets.split
    e,f = str[0].to_i, str[1].to_i
    c[e].push(f)
    c[f].push(e)
    d[e].push(f)
    d[f].push(e)
end

g = Array.new(2){Array.new(0)}
while !c[u].empty?
    x = c[u].pop
    a[u] = 0
    g[1].push(x)
end
i = 1
while !g[i%2].empty?
    j = i%2
    k = (j+1)%2
    while !g[j].empty?
        x = g[j].pop
        y = a[x]
        a[x] = y == -1 ? i : y
        while !c[x].empty?
            g[k].push(c[x].pop)
        end
    end
    i += 1
end

g[0].clear
g[1].clear
while !d[v].empty?
    x = d[v].pop
    b[v] = 0
    g[1].push(x)
end
i = 1
while !g[i%2].empty?
    j = i%2
    k = (j+1)%2
    while !g[j].empty?
        x = g[j].pop
        y = b[x]
        b[x] = y == -1 ? i : y
        while !d[x].empty?
            g[k].push(d[x].pop)
        end
    end
    i += 1
end

answer = 0
for i in 1..N do
    if a[i] < b[i]
        answer = answer < b[i] ? b[i] : answer
    end
end
answer -= 1
puts answer

Measured memory_bytes: 22252
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] h = new int[N + 1];
    for (int i = 1; i <= N; i++) h[i] = scanner.nextInt();

    long[][] dp = new long[N + 1][N + 1];
    final long INF = 1_000_000_000_000L;
    for (int i = 0; i <= N; i++) for (int j = 0; j <= N; j++) dp[i][j] = INF;
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= i; j++) {
        for (int k = 0; k < i; k++) dp[i][j] = Math.min(dp[i][j], dp[k][j - 1] + Math.max(h[i] - h[k], 0));
      }
    }

    long min = INF;
    for (int i = 0; i <= N; i++) for (int j = N - K; j <= N; j++) min = Math.min(min, dp[i][j]);
    System.out.println(min);
  }
}


Measured memory_bytes: 24532
#include<cstdio>
const int MAXN=25;
int n,m,c,a[MAXN],b[MAXN],ans;
int main()
{
	scanf("%d %d %d",&n,&m,&c);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		int sum=c;
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&a[j]);
			sum+=a[j]*b[j];
		}
		if(sum>0) ans++;
	}
	printf("%d",ans);
	return 0;
}

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

int main()
{
	ll n;
	cin >> n;
	ll H[n];
	f(i, 0, n)
	cin >> H[i];
	if(n == 2)
	{
		cout << abs(H[0] - H[1]);
		return 0;
	}
	ll ans[n];
	ans[1] = abs(H[1] - H[0]);
	ans[0] = 0;
	f(i, 2, n)
	{
		ans[i]=min(ans[i-1]+abs(H[i]-H[i-1]),ans[i-2]+abs(H[i]-H[i-2]));
	}
	cout << ans[n-1];
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, l: "List[int]"):
    l.sort(reverse=True)
    ret = sum(l[:K])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    l = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, l)

if __name__ == '__main__':
    main()


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, m; cin >> n >> m;
	vector<int>x(m);
	rep(i, m)cin >> x[i];
	sort(x.begin(), x.end());


	vector<int>l(m);
	for (int i = 0; i < m - 1; i++) {
		l[i] = x[i + 1] - x[i];
	}
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());

	//compute
	int sum = 0;

	int ans = 0;
	if (n >= m) {
		cout << ans << endl;
		return 0;
	}
	else {
		rep(i, n - 1) {
			sum += l[i];
		}
		ans = x[m - 1] - x[0] - sum;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
X = int(input())

def solve():
  for A in range(-118, 120):
    for B in range(-119, 119):
      if A*A*A*A*A - B*B*B*B*B == X or A*A*A*A*A + B*B*B*B*B == X:
        print(A, B)
        return

solve()

Measured memory_bytes: 9160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

int main(void) {
	LL x, a, b;
	cin >> x >> a >> b;

	x -= a;
	cout << x%b << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace abc168_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputStrLen = Console.ReadLine();
            string inputStr = Console.ReadLine();
            int strLen = int.Parse(inputStrLen);

            if(inputStr.Length <= strLen)
            {
                Console.WriteLine(inputStr);
            }
            else
            {
                Console.WriteLine(inputStr.Substring(0, strLen) + "...");
            }
        }
    }
}


Measured memory_bytes: 27564
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include<vector>
#include<algorithm>
using namespace std;

struct init{
	init(){
		cin.tie(0); ios::sync_with_stdio(false);
	}
}________init;
int main() {

#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	for (auto& it : a){
		cin >> it;
	}
	int res = 0;
	res = max(res, n - a[m - 1]);
	res = max(res, a[0] - 1);
	for (int i = 1; i < m; i++){
		res = max(res, (a[i] - a[i - 1]) / 2);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3240
l = [list(map(int, input().split())) for i in range(3)]

n = int(input())

for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if l[j][k] == b:
                l[j][k] = -1

r = False
for i in l:
    if sum(i) == -3:
        r = True
for i in range(3):
    if l[0][i] == l[1][i] == l[2][i] == -1:
        r = True
if l[0][0] == l[1][1] == l[2][2] == -1:
    r = True
if l[2][0] == l[1][1] == l[0][2] == -1:
    r = True
    
if r == True:
    print("Yes")
else:
    print("No")
        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  
  vector<pair<int , int>> cont(n);
  
  for(int i = 0 ; i < n ; i++){
    cin >> cont.at(i).first;
    cont.at(i).second = i+1;
  }
  
  sort(cont.begin() , cont.end());
  
  for(int i = 0 ; i < n ; i++){
    cout << cont.at(i).second << endl;
  }
  
}

Measured memory_bytes: 1536
N,K = map(int,input().split())
check = 0
S = input()
for i in range(N-1):
  if S[i] != S[i+1]:
    check += 1
ryouiki_num = check + 1
saiteki_ryouiki = ryouiki_num - 2*K
if saiteki_ryouiki < 1:
  print(N-1)
else:
  print(N-saiteki_ryouiki)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int n,a[100001],x,y;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x>n) y++;
        else a[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==0) continue;
        if(a[i]<i) y+=a[i];
        else if(a[i]>i) y+=a[i]-i;
    }
    cout<<y;
    return 0;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    string S;
    cin >> S;
    vector<unsigned long> a(N);
    map<unsigned long, unsigned long> m;
    transform(S.begin(), S.end(), a.begin(), [&m](char c){++m[c - 49]; return c - 49;});
    if(m.size() == 1)return 0 & puts("0");
    unsigned long c{1};
    if(m.size() == 2 && !m.count(1))c = 2;
    unsigned long p2{1};
    while(p2 < N)p2 <<= 1;
    p2 >>= 1;
    for(unsigned long lim{N}; p2; ){
        lim -= p2;
        for(unsigned long i{0}; i + p2 < N; ++i)a[i] ^= a[i + p2];
        while(p2 >= lim)p2 >>= 1;
    }
    cout << (a[0] & c) << endl;
    return 0;
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define sort(array) sort(array,array+(sizeof(array)/sizeof(array[0])));
 
int main() {
  int n;
  cin>>n;
  cout<<((n%1000)?(1000-(n%1000)):(0))<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 100005

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int main(){
  int r,i,ans=0;
  scanf("%d",&r);

  printf("%d\n",r*r);
	return 0;
}


Measured memory_bytes: 128
//0 と 1 のみから成る 3 桁の番号 s が与えられます。1 が何個含まれるかを求めてください。
#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;

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

    int counter = 0;

    //check how to count number
    for(int i = 0; i < 3; ++i){
        if (s[i] == '1') ++counter;
    }

    cout << counter << endl;

}



Measured memory_bytes: 256
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
#define N 55
#define M 25
#define ND 60000000
#define EDGE 90000000
int n, l[N], c[N], pre[N];
char s[N][M], res[N][M];
int nex[EDGE], nu[EDGE];
ll dist[ND], va[EDGE];
bool flag[ND];
int st, cnt;
ll INF=1ll*1999999999*1999999999;
struct node{
	int n;
	ll dist;
	node (int n, ll dist): n(n), dist(dist){}
	bool operator <(const node &o) const {return this->dist<o.dist;}
	bool operator >(const node &o) const {return this->dist>o.dist;} 
};
priority_queue<node, vector<node>, greater<node> > q;
void add(int u, int v, int w){
	nex[++cnt]=nex[u];nex[u]=cnt;nu[cnt]=v;va[cnt]=w;
}
void dijkstra(){
	for (int i=1;i<=st;i++) dist[i]=INF, flag[i]=0;
	dist[st]=0;
	q.push(node(st,0));
	while (!q.empty()){
		node curNode=q.top();
		q.pop();
		int u=curNode.n;
		flag[u]=1;
		for (int j=nex[u];j;j=nex[j]){
			int v=nu[j];
			if (!flag[v] && dist[u]+va[j]<dist[v])
				dist[v]=dist[u]+va[j],
				q.push(node(v,dist[v]));
		}
		while (!q.empty() && flag[q.top().n]) q.pop();
	}
}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		scanf("%s", &s[i]);
		c[i]=read();
		l[i]=strlen(s[i]);
		pre[i]=pre[i-1]+l[i];
		for (int j=0;j<l[i];j++) res[i][j]=s[i][l[i]-1-j];
	}
	#define get(i,j,x,y) (pre[i-1]+j+1)*1010+pre[x-1]+y+1
	ll ans=INF;
	for (int beg=1;beg<=n;beg++){
		st=1005*1010, cnt=st;
		for (int i=1;i<=cnt;i++) nex[i]=0;
		for (int y=1;y<=n;y++)
			if (s[beg][0]==res[y][0])
				add(st,get(beg,0,y,0),c[beg]+c[y]);
		for (int i=1;i<=n;i++)
			for (int k=1;k<=n;k++)
				for (int j=0;j<l[i];j++)
					for (int p=0;p<l[k];p++){
						int u=get(i,j,k,p);
						if (j<l[i]-1 && p<l[k]-1){
							if (s[i][j+1]==res[k][p+1]){
								int tj=j, tp=p;
								while (tj<l[i]-1 && tp<l[k]-1 && s[i][tj+1]==res[k][tp+1]) 
									tj++, tp++;
								add(u,get(i,tj,k,tp),0);
							}
						}
						else if (j<l[i]-1){
							for (int x=1;x<=n;x++)
								if (s[i][j+1]==res[x][0]) 
									add(u,get(i,j+1,x,0),c[x]);
						}
						else if (p<l[k]-1){
							for (int x=1;x<=n;x++)
								if (s[x][0]==res[k][p+1]) 
									add(u,get(x,0,k,p+1),c[x]);
						}
						else{
							for (int x=1;x<=n;x++)
								for (int y=1;y<=n;y++)
									if (s[x][0]==res[y][0])
										add(u,get(x,0,y,0),c[x]+c[y]);
						}
					}
		dijkstra();
		ll res=INF;
		for (int x=1;x<=n;x++)
			res=min(res,dist[get(x,l[x]-1,beg,l[beg]-1)]);
		ans=min(ans,res);
	}
	if (ans==INF) ans=-2;
	cout<<ans/2<<endl;
    return 0;
}

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

int main(void){
    int N; cin >> N;
    set<int> A;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        A.insert(a);
    }

    cout << A.size() << endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  cin>>n;
  cin.ignore();
  rep(j,n){
    string s;
    getline(cin,s);
    int n;
    while(n=s.find("Hoshino"),n!=string::npos)s[n+6]='a';
    //rep(i,s.size()-6)if(s.substr(i,7)=="Hoshino")s.replace(i,7,"Hoshina");
    cout<<s<<endl;
  }


}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

    ll upper_bound(ll query) {
        return distance(sums.begin(), std::upper_bound(sums.begin(), sums.end(), query));
    }

};


int main() {
    int n, q;

    cin >> n >> q;

    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    set<ll> used;
    multiset<ll> used_m;

    vector<ll> ans;

    for (int r = 0; r < q; r++) {
        used.insert(numbers[r]);
        used_m.insert(numbers[r]);
    }
    ans.push_back(*used.begin());

    for (int k = 0; k + q < n; k++) {
        used.insert(numbers[k + q]);
        used_m.insert(numbers[k + q]);

        used_m.erase(used_m.find(numbers[k]));
        if (used_m.count(numbers[k]) == 0) {
            used.erase(numbers[k]);
        }
        ans.push_back(*used.begin());
    }
    print_line(ans);

}



Measured memory_bytes: 28452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,f=0,g=1;
  cin >> N;
  for(int k=0;k<8;k++){
    	f+=N/g%10;
    	g*=10;
  }
  if(N%f==0) cout << "Yes" << endl; else cout << "No" << endl; 
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	string s, t; cin >> s >> t;
	int ret  = 0;
	for (int i=0; i<3; i++) if (s[i]==t[i]) ret++;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3624
#![allow(bare_trait_objects)]
#![allow(unused_imports)]
#![allow(dead_code)]

use std::fmt::Debug;
use std::io::BufRead;
use std::io::Stdin;
use std::io::StdinLock;
use std::str::FromStr;

pub struct Scanner<'a> {
    buf_read: Box<BufRead + 'a>,
    tokens: Vec<String>,
}

impl<'a> Scanner<'a> {
    pub fn new(buf_read: StdinLock<'a>) -> Self {
        Scanner {
            buf_read: Box::new(buf_read),
            tokens: Vec::new(),
        }
    }

    // pub fn from_stdin() -> Self {
    //     let stdin = Box::leak(Box::new(std::io::stdin()));
    //     Self {
    //         buf_read: Box::new(stdin.lock()),
    //         tokens: Vec::new(),
    //     }
    // }

    pub fn next(&mut self) -> String {
        while self.tokens.is_empty() {
            let mut s = String::new();
            if self.buf_read.read_line(&mut s).is_err() {
                panic!()
            }
            self.tokens = s
                .split_whitespace()
                .filter(|s| !s.is_empty())
                .rev()
                .map(str::to_string)
                .collect();
        }
        self.tokens.pop().unwrap()
    }

    pub fn next_g<T: FromStr>(&mut self) -> T
    where
        T::Err: Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn next_vec_g<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: Debug,
    {
        (0..n).map(|_| self.next_g()).collect()
    }

    pub fn usize(&mut self) -> usize {
        self.next_g()
    }

    pub fn i64(&mut self) -> i64 {
        self.next_g()
    }

    pub fn vec_i64(&mut self, n: usize) -> Vec<i64> {
        self.next_vec_g(n)
    }

    pub fn vec_usize(&mut self, n: usize) -> Vec<usize> {
        self.next_vec_g(n)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let h = sc.usize();
    let w = sc.usize();

    let mut s = Vec::new();
    for _ in 0..h {
        s.push(sc.next().chars().collect::<Vec<_>>());
    }

    let mut dp = vec![vec![vec![1 << 29; 2]; w]; h];
    if s[0][0] == '#' {
        dp[0][0][1] = 1;
    } else {
        dp[0][0][0] = 0;
    }
    for y in 0..h {
        for x in 0..w {
            for i in 0..2 {
                let c = s[y][x];
                let v = dp[y][x][i];
                for d in 0..2 {
                    let x = x + (d + 1) % 2;
                    let y = y + (d + 1) / 2;
                    if x >= w || y >= h {
                        continue;
                    }
                    let j = if s[y][x] == '#' { 1 } else { 0 };
                    let c = if s[y][x] == '#' && c == '.' { 1 } else { 0 };
                    dp[y][x][j] = std::cmp::min(dp[y][x][j], v + c);
                    // eprintln!("{} {} {} {}", y, x, j, dp[y][x][j]);
                }
            }
        }
    }
    println!("{}", dp[h - 1][w - 1].iter().min().unwrap());
}


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

int main()
{
int i;
int j;
int s;
int t;
int A;
int B;
int C;
int D;
int E;
int F;
int iW;
int iS;
int iWt;
int iSg;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> E;
	cin >> F;

	iS = 0;
	iW = 100 * A;
	for( i = 0; ; i++ )
	{
		iWt = 100 * A * i;
		if( iWt >= F ) break;

		for( j = 0; ; j++ )
		{
			iWt = 100 * A * i + 100 * B * j;
			if( iWt <= 0 ) continue;
			if( iWt >= F ) break;

			for( s = 0; ; s++ )
			{
				iSg = C * s;
				if( 100 * iSg > E * iWt ) break;
				if( iWt + iSg > F ) break;

				for( t = 0; ; t++ )
				{
					iSg = C * s + D * t;
					if( 100 * iSg > E * iWt ) break;
					if( iWt + iSg > F ) break;

					if( iSg * iW > iS * iWt )
					{
						iS = iSg;
						iW = iWt;
					}
				}
			}
		}
	}

	cout << iW + iS << " " << iS << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  while(a > 0 || b > 0) {
    c-=b;
    if(c<=0) {
      cout<<"Yes"<<endl;
      break;
    }
    a-=d;
    if(a<=0) {
      cout<<"No"<<endl;
      break;
    }
    
  }
}

Measured memory_bytes: 3636
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
s = SR(n)
for i in range(n):
    for j in range(len(s[i])):
        while s[i][j] in s[i][:j]:
            s[i][j] = "0"+s[i][j]
ans = set(s[0])
for i in range(1,n):
    ans &= set(s[i])
ans = sorted(list(ans))
if len(ans) == 0:print()
else:
    for i in range(len(ans)):
        ans[i] = ans[i][-1]
    ans.sort()
    for i in range(len(ans)-1):
        print(ans[i],end = "")
    print(ans[-1])
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 4592
#include <cstdio>
#include <iostream>

int main()
{
	int N;
	scanf("%d", &N);
	int A[N] = {0};

	int l;
	while(std::cin >> l) {
		A[l-1]++;
	}

	for(int i = 0; i < N; i++) {
		printf("%d\n", A[i]);
	}

	return 0;
}

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

int dfs(vector< vector<int> > &G, vector<int> &A, vector<int> &B, int v, int d, int c){
  int ret = 0;
  if(B[v] >= d) return ret;
  B[v] = d;
  if(!A[v]) A[v] = c, ++ret;
  for(int i = 0; i < G[v].size(); ++i){
    int v_ = G[v][i];
    if(B[v_] >= d-1) continue;
    ret += dfs(G,A,B,v_,d-1,c);
  }
  return ret;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector< vector<int> > G(N);
  for(int i = 0; i < M; ++i){
    int a,b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  // vector< vector< vector<int> > > H(N, vector< vector<int> >(11,vector<int>()));
  // for(int i = 0; i < N; ++i){
  //   vector<bool> used(N,false);
  //   H[i][0].push_back(i);
  //   used[i] = true;
  //   for(int j = 0; j < 10; ++j){
  //     for(int k = 0; k < H[i][j].size(); ++k){
  //       int v = H[i][j][k];
  //       for(int l = 0; l < G[v].size(); ++l){
  //         if(used[G[v][l]]) continue;
  //         used[G[v][l]] = true;
  //         H[i][j+1].push_back(G[v][l]);
  //       }
  //     }
  //   }
  // }
  int Q;
  cin >> Q;
  vector<int> V(Q), D(Q), C(Q);
  for(int i = 0; i < Q; ++i) cin >> V[i] >> D[i] >> C[i];
  reverse(V.begin(), V.end());
  reverse(D.begin(), D.end());
  reverse(C.begin(), C.end());
  vector<int> A(N,0), B(N,-1);
  int colored = N;
  for(int i = 0; i < Q; ++i){
    int v = V[i], d = D[i], c = C[i];
    --v;
    colored -= dfs(G,A,B,v,d,c);
    if(!colored) break;
  }
  for(int i = 0; i < N; ++i) cout << A[i] << endl;
  return 0;
}


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

int main(){
    string p,q;
    cin>>p>>q;
    int m = p.length();
    int n = q.length();
    int dp[m+1][n+1];
    for(int i=0;i<=m;i++) {
        for(int j=0;j<=n;j++) {
            if(i==0||j==0) {
                dp[i][j] = 0;
            }
            else if(p[i-1] == q[j-1]) {
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }   
    int index = dp[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (p[i-1] == q[j-1]) 
      { 
          lcs[index-1] = p[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      }   
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   }  
    cout<<lcs;
    return 0;
}

Measured memory_bytes: 35456
import java.io.*;
import java.util.*;

public class Main {
    FastScanner in;
    PrintWriter out;

    long gcd(long x, long y) {
        return x == 0 ? y : gcd(y % x, x);
    }

    long lcm(long x, long y) {
        return x / gcd(x, y) * y;
    }

    void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        char[] a = in.next().toCharArray();
        char[] b = in.next().toCharArray();
        long len = lcm(n, m);
        for (int i = 0; i < n; i++) {
            long pos = i * (len / n);
            if (pos % (len / m) == 0) {
                long j = pos / (len / m);
                if (a[i] != b[(int) j]) {
                    out.println(-1);
                    return;
                }
            }
        }
        out.println(len);
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}

Measured memory_bytes: 25812
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int mx = 0;
	rep(i, n) {
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	int cnt = 0;
	int mx2 = 0;
	rep(i, n) {
		if (a[i] == mx) cnt++;
		if (a[i] == mx) continue;
		mx2 = max(mx2, a[i]);
	}
	if (cnt >= 2) {
		rep(i, n) {
			cout << mx << endl;
		}
	}
	else {
		rep(i, n) {
			if (a[i] != mx) {
				cout << mx << endl;
			}
			else {
				cout << mx2 << endl;
			}
		}
	}
	
	
	return 0;
}


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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int dp[100005][13];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    int n = s.size();
    dp[n][0] = 1;
    int mul = 1;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='?'){
            for(int k=0;k<13;k++){
                for(int j=0;j<10;j++){
                   (dp[i][(mul*j + k)%13] += dp[i+1][k])%=mod;
                }
            }
        }else{
            int c = s[i] - '0';
            for(int k=0;k<13;k++){
                (dp[i][(mul*c + k)%13] += dp[i+1][k])%=mod;
            }
        }
        mul*=10;
        mul%=13;
    }
    cout << dp[0][5] << endl;
}

Measured memory_bytes: 5584
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
#include <unistd.h>
using namespace std;

#define int long long

signed main(){
	int n;
	cin >> n;
	for(int i = 0; i < 20; i++){ // i は，払う千円札の枚数
		if(i*1000 >= n){
			cout << i*1000 - n << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int n ;
  int a, b ;
  cin >> n ;
  if(n==1){
    cout <<"Hello World"<<endl ;
  }
  else if(n==2){
    cin >> a >> b ;
    cout << a+b <<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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

int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}

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

Measured memory_bytes: 256