akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)

ll a,b;

ll gcd(ll a,ll b){
	if((0==a)||(0==b)) return 0;
	
	while(a!=b){
		if(a>b) a -= b;
		else b -= a;
	}
	return a;
}

ll lcm(ll a,ll b){
	if((a==0)||(b==0)) return 0;
	
	return ((a/gcd(a,b)) * b);
}

int main(){
	while(cin>>a>>b){
		cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#解説チラ見
n = int(input())
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
now = [0]
scr = list(map(int,input().split()))
scr.sort()
scr.reverse()
ans = [0 for _ in range(n)]
ans[0] = scr[0]
pin = 1
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if ans[y] == 0:
        ans[y] = scr[pin]
        pin += 1
        now.append(y)
print(sum(scr[1:]))
print(' '.join(list(map(str,ans))))

Measured memory_bytes: 6008
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int L,N;
  cin >> N >> L;
  vector<string> S(N);
  for(int i=0;i<N;++i) cin >> S.at(i);
  sort(S.begin(),S.end());

  for(int i=0;i<N;++i) cout << S.at(i);
  cout << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <cassert>
#include <iostream>
#include <string>
int main(int argc, char *argv[]) {
	constexpr size_t N = 3;
	std::string s;
	std::cin >> s; assert(s.size() == N);
	unsigned int acc = 0;
	for (size_t i = 0; i < N; i++) {
		assert(s[i] == '0' || s[i] == '1');
		acc += (s[i] == '1') ? 1 : 0;
	}
	std::cout << acc << std::endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
 
s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()
 
 
X, Y = ds_in()
print(X + Y//2)


Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int x[26],y[26];
char str1[200005],str2[200005];
int main()
{

    scanf("%s %s",str1,str2);
    for(int i=0;str1[i]!='\0';i++)
    {
        x[str1[i]-'a']++;
        y[str2[i]-'a']++;
    }
    sort(x,x+26);
    sort(y,y+26);
    for(int i=0;i<26;i++)
    {
        if(x[i]!=y[i])
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");

}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

void change(string &s,int num){
  int length = (int)s.size();
  char ch = num + '0';

  for(int i = 0 ; i < length ; i++){
    if(s[i] == 'X'){
      s[i] = ch;
    }
  }

}

bool check(char ch,int size){
  if(ch == 'X' && size > 1) return true;
  return false;
}

char calc(char x,char y,char z,bool &C){
  int a = x - '0',b = y - '0',c = z - '0';
  int d = a + b + c;

  if(d >= 10){
    C = true;
    d -= 10;
  }

  return d + '0';
}

string sum(string a,string b){
  string res = "";

  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());

  int length;
  if((int)a.size() > (int)b.size()){
    length = (int)a.size();
    
    for(int i = (int)b.size() ; i < length ; i++){
      b += '0';
    }

  }
  else{
    length = (int)b.size();

    for(int i = (int)a.size() ; i < length ; i++){
      a += '0';
    }

  }

  for(int i = 0 ; i <= length ; i++)
    res += '0';

  for(int i = 0 ; i < length ; i++){
    bool C = false;
    res[i] = calc(a[i],b[i],res[i],C);
    if(C) res[i+1] = ((res[i+1]-'0') + 1) + '0';
  }

  for(int i = length ;; i--){
    
    if(res[i] == '0'){
      res.erase(res.begin()+i);
    }
    else{
      break;
    }
    
  }

  reverse(res.begin(),res.end());  

  return res;
}

int main(){
  string str;

  while(cin >> str){
    if(str == "X+X=X"){
      cout << "0" << endl;
      continue;
    }

    int pos_plus = str.find('+'),pos_equal = str.find('=');    

    string x = str.substr(0,pos_plus);
    string y = str.substr(pos_plus+1,pos_equal-pos_plus-1);
    string z = str.substr(pos_equal + 1);

    int start = 0;
    if(check(x[0],x.size()) || 
       check(y[0],y.size()) || 
       check(z[0],z.size())) {

      start = 1;

    }    

    int ans;
    bool found = false;
    for(int i = start ; i < 10 ; i++){
      string a = x, b = y, c = z;
   
      change(a,i); change(b,i); change(c,i);

      if(sum(a,b) == c){
	found = true;
	ans = i;
	break;
      }
    }

    if(found) cout << ans << endl;
    else cout << "NA" << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

void print(vector<long> & res) {
    cout << "---print" << endl;
    for (int i = 0; i < res.size(); i++) cout << res[i] << endl;
    cout << "---" << endl;
}

int L = 0;
bool insert(vector<long> & res, long val) {
    if (res[L] > val) return false;
    int l = L;
    while (l > 0 && res[l - 1] < val) {
        res[l] = res[l - 1];
        l--;
    }
    res[l] = val;
    if (L < res.size() - 2) L++;
    //print(res);
    return true;
}

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<long> A(X), B(Y), C(Z);
    for (int x = 0; x < X; x++) cin >> A[x];
    for (int y = 0; y < Y; y++) cin >> B[y];
    for (int z = 0; z < Z; z++) cin >> C[z];

    sort(A.begin(), A.end(), [](long a, long b) { return a > b; });
    sort(B.begin(), B.end(), [](long a, long b) { return a > b; });
    sort(C.begin(), C.end(), [](long a, long b) { return a > b; });

    vector<long> res(K + 1);
    for (int x = 0; x < X; x++) {
        for (int y = 0; y < Y; y++) {
            bool flagY = false;
            for (int z = 0; z < Z; z++) {
                if (!insert(res, A[x] + B[y] + C[z])) break;
                flagY = true;
            }
            if (!flagY) break;
        }
    }

    for (int k = 0; k < K; k++) {
        cout << res[k] << endl;
    }

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int price = 800;
    int bonas = 200;
    int x,y;
    x = N * price;
    y = ( (N - N % 15) / 15 ) * bonas;
    int ans = x - y;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string str;
  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  int count;
  
  cin >> count;
  
  for (int i = 0; i < count; i++)
  {
  	cin >> str;
    if(str=="AC") ac++;
    else if(str=="WA") wa++;
    else if(str=="TLE") tle++;
    else re++;
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    string S;
    cin>>S;
    if(S[2]==S[3]&&S[4]==S[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
package main

import (
  "fmt"
  "math"
)

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

func main() {
  var n, k int
  fmt.Scan(&n, &k)
  xs := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&xs[i])
  }
  result := math.MaxInt32
  for i := 0; i < n-k+1; i++ {
    left := xs[i]
    right := xs[i+k-1]
    fromLeft := diff(0, left) + diff(left, right)
    fromRight := diff(0, right) + diff(left, right)
    var distance int
    if fromLeft < fromRight {
      distance = fromLeft
    } else {
      distance = fromRight
    }
    if distance < result {
      result = distance
    }
  }
  fmt.Println(result)
}

Measured memory_bytes: 5504
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut xyh = vec![(0, 0, 0); n];

    for i in 0..n {
        xyh[i].0 = read::<i64>();
        xyh[i].1 = read::<i64>();
        xyh[i].2 = read::<i64>();
    }

    for i in 0..101 {
        for j in 0..101 {
            let mut needH = -1;

            for k in 0..n {
                if xyh[k].2 > 0 {
                    let tmp = xyh[k].2 + (i - xyh[k].1).abs() + (j - xyh[k].0).abs();
                    if needH == -1 {
                        needH = tmp;
                    } else {
                        if needH != tmp {
                            needH = -2;
                            break;
                        }
                    }
                }
            }
            if needH == -2 {
                continue;
            }

            for k in 0..n {
                if xyh[k].2 == 0 {
                    let dist = (i - xyh[k].1).abs() + (j - xyh[k].0).abs();
                    if needH > dist {
                        needH = -2;
                    }
                }
            }

            if needH == -2 {
                continue;
            }

            println!("{} {} {}", j, i, needH);
        }
    }
}

Measured memory_bytes: 4352
a, b, c = map(int, input().split())
if (a, b, c) == (5, 5, 7):
  print("YES")
elif (a, b, c) == (5, 7, 5):
  print("YES")
elif (a, b, c) == (7, 5, 5):
  print("YES")
else:
  print("NO")

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int v[3];
  v[0] = A;
  v[1] = B;
  v[2] = C;

  sort(v,v + 3);

  if((v[2] - v[1]) % 2 == 0 && (v[2] - v[0]) % 2 == 0){
    cout << (v[2] - v[1]) / 2 + (v[2] - v[0]) / 2;
  }else if((v[2] - v[1]) % 2 != 0 && (v[2] - v[0]) % 2 == 0){
    cout << 1 + (v[2] + 1 - v[1]) / 2 + (v[2] - v[0]) / 2;
  }else if((v[2] - v[1]) % 2 == 0 && (v[2] - v[0]) % 2 != 0){
    cout << 1 + (v[2] - v[1]) / 2 + (v[2] + 1 - v[0]) / 2;
  }else{
    cout << (v[2] - v[1] - 1) / 2 + (v[2] - v[0] - 1) / 2 + 1;
  }
  return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dx[] = {1,0,-1,0};
ll dy[] = {0,1,0,-1};
string str = "LDRU";

int main(){
	int n;cin >> n;
	
	vector<pair<ll,ll>> v;
	bool parity[2] = {};
	
	REP(i,n){
		ll a,b;cin >> a >> b;
		parity[(a+b)%2] = true;
		v.PB(MP(a,b));
	}
	
	if(parity[0] & parity[1]){
		cout << -1 << endl;
		return 0;
	}
	
	vector<ll> ans;
	ll sum = 0;
	for(int i = 35;i >= 0;i--){
		ans.PB(1LL << i);
		sum += (1LL << i);
	}
	if(parity[0]){
		ans.PB(1);
		sum++;
	}
	
	cout << ans.size() << endl;
	REP(i,ans.size()){
		cout << ans[i];
		if(i != ans.size()-1)cout << ' ';
	}
	cout << endl;
		
	REP(i,n){
		ll x = v[i].FI;
		ll y = v[i].SE;
		ll nsum = sum;
		REP(j,ans.size()){
			nsum -= ans[j];
			REP(k,4){
				ll nx = x + dx[k] * ans[j];
				ll ny = y + dy[k] * ans[j];
				
				if(abs(nx) + abs(ny) <= nsum){
					x = nx;
					y = ny;
					cout << str[k];
					break;
				}
			}
		}
		cout << 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;
using ll = long long;

int main() {
  int W, a, b;
  cin >> W >> a >> b;

  cout << max(0, abs(a - b) - W) << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int total = 0;
		for (int i = 1; i <= N; i++) {
			total += (i <= K)?X:Y;
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 22612
import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int k = scan.nextInt();
        String s = scan.next();

        if (s.length() <= k) {
            System.out.println(s);
        } else {
            String n = s.substring(0, k).concat("...");
            System.out.println(n);
        }

    }


}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  int l = 0, r = n - 1;
  while (l < r) {
    if (s[l] == 'W') {
      while (l < r) {
        if (s[r] == 'R') break;
        r--;
      }
      if (l < r) {
        cnt++;
        r--;
      }
    }
    l++;
  }
  cout << cnt << endl;
  return 0;
}


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

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> p(n);
  int i;
  int low, mid, high;
  low = 0;
  mid = 0;
  high = 0;
  for(i = 0; i < n; i++)
  {
    cin >> p.at(i);
    if(p.at(i)<=a)low++;
    else if(p.at(i)>=b+1)high++;
    else mid++;
  }
  cout << min(high, min(low, mid)) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            //Yの初期手札
            int W = Convert.ToInt32(input[2]);

            input = Console.ReadLine().Split(' ');

            //カード列
            int[] a = new int[input.Length];
            for (int i = 0; i < input.Length; i++) a[i] = Convert.ToInt32(input[i]);

            int result = (a.Length >= 2) ? Math.Max(Math.Abs(a[a.Length - 1] - W), Math.Abs(a[a.Length - 2] - a[a.Length - 1])) : Math.Abs(a[a.Length - 1] - W);

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13328
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, d[10000], v[10000];
int main()
{
	while (scanf("%d", &n), n)
	{
		for (int i = 0; i < n; ++i)
			scanf("%d%d", d+i, v+i);

		int g;
		ll nume, deno;	// time
		g = gcd(d[0], v[0]);
		nume = d[0] / g;
		deno = v[0] / g;
		for (int i = 1; i < n; ++i)
		{
			g = gcd(d[i], v[i]);
			int td = d[i] / g;
			int tv = v[i] / g;
			nume = lcm(nume, td);
			deno = gcd(deno, tv);
		}

		for (int i = 0; i < n; ++i)
			printf("%lld\n", (nume*v[i]/deno) / d[i]);
	}

	return 0;
}

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

int main()
{
    int building_num = 4;
    int floor_num = 3;
    int room_num = 10;

    int input_num;
    cin >> input_num;

    vector<vector<vector<int>>> people_num(building_num, vector<vector<int>>(floor_num, vector<int>(room_num)));

    for (int i=0; i<input_num; i++)
    {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        people_num.at(b-1).at(f-1).at(r-1)+=v;
    }

    for (int b=0; b<building_num; b++)
    {
        for (int f=0; f<floor_num; f++)
        {
            for (int r=0; r<room_num; r++)
            {
                cout << " " <<people_num.at(b).at(f).at(r);
            }
            cout << endl;
        }
        if (b < building_num-1)
        {
            cout << "####################" << endl;
        }
        
    }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;
  
int main() {
    ll n;
    cin >> n;
    ll a,b,c;
    ll cnt = 0;
    for(int a=1;a<=1000000;a++){
        for(int b=1;a*b<=1000000;b++){
            c = n-a*b;
            if(c>=1&&c<=1000000){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std ;

#define rg register
#define dbg(v) cerr << #v << " " << v ;
typedef long long ll ;

int main() {
   ll n ;
   cin >> n ;
   int len = floor(log2(n)) + 1 ;
   ll sum = 0 ;
   for(int i = 0 ; i < len ; i++) sum += (1ll << i) ;
   cout << sum << "\n" ;

}

/*
 Empty set of troubles.
*/


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

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <cassert>

using namespace std;

class atcoderD {
public:
    void solve(istream& in, ostream& out) {
        int64_t N, A, B;
        in >> N >> A >> B;
        
        vector<int> X(N);
        for (int i = 0; i < N; ++i) {
            in >> X[i];
        }
        
        vector<int64_t> dp(N);
        dp[0] = 0;
        for (int i = 1; i < N; ++i) {
            dp[i] = min(A * (X[i] - X[i-1]), B) + dp[i-1];
        }
        out << dp[N-1] << endl;
    }
};


int main() {
	std::ios::sync_with_stdio(false);

	atcoderD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define N 100010
ll n,l,t;
ll x[N],w[N],ans[N];
int main(){
  cin>>n>>l>>t;
  for(int i=0;i<n;i++)cin>>x[i]>>w[i];
  ll hosl=x[0];
  for(int i=0;i<n;i++)x[i]-=hosl;
  bool hosf=(w[0]==2);
  if(hosf)for(int i=0;i<n;i++){
    w[i]=3-w[i];
    x[i]=(l-x[i])%l;
  }
  vector<ll> v;
  ll cnt=0,v0;
  for(int i=0;i<n;i++){
    if(w[i]==1){
      ll val=(x[i]+t)%l;
      v.push_back(val);
      if(i==0)v0=val;
      continue;
    }
    ll val=(x[i]-t)%l; if(val<0)val+=l;
    v.push_back(val);
    cnt+=t*2/l;
    ll rem=t*2%l;
    if(x[i]<=rem)cnt++;
    //cout<<"#"<<i<<" "<<cnt<<endl;
  }
  cnt%=n; if(hosf)cnt=(n-cnt)%n;
  //cnt...v0がans[cnt]
  sort(v.begin(),v.end());
  ll pnt=-1;
  for(int i=0;i<n;i++){
    if(v[i]==v0)pnt=i;
  }
  //cout<<v0<<" "<<pnt<<" "<<cnt<<endl;
  for(int i=0;i<n;i++){
    ans[cnt]=v[pnt];
    cnt++; cnt%=n;
    if(hosf)pnt+=n-1,pnt%=n;
    else pnt++,pnt%=n;
  }
  if(hosf)for(int i=0;i<n;i++)ans[i]=(l-ans[i])%l;
    
  for(int i=0;i<n;i++){
    ans[i]=(ans[i]+hosl)%l;
    cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 4468
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();

		List<String> listA = new ArrayList<String>(); 
        
        for (int i=0; i<n; i++) {
			listA.add((scan.next()));
        }

        List<String> listB = new ArrayList<String>(new HashSet<>(listA));

//        System.out.println(listA);
//        System.out.println(listB);

        System.out.println(listB.size());
	    scan.close();	
    }
}

Measured memory_bytes: 78448
# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N):
    mod = 10 ** 9 + 7
    dp = [{} for _ in range(N + 1)]
    dp[0].setdefault('TTT', 1)

    def check(last4):
        for i in range(4):
            x = list(last4)
            if i > 0:
                x[i], x[i - 1] = x[i - 1], x[i]
            if ''.join(x).count('AGC') >= 1:
                return False
        return True

    for i in range(1, N + 1):
        for last3, count in dp[i - 1].items():
            for c in 'AGCT':
                if check(last3 + c):
                    new_last3 = last3[1:] + c
                    dp[i].setdefault(last3[1:] + c, 0)
                    dp[i][new_last3] = (dp[i][new_last3] + count) % mod

    print(sum(dp[-1].values()) % mod)


if __name__ == '__main__':
    N = int(input())
    solve(N)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 9608
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,x,y;
  cin>>n>>k;
  int a=1;
  for(int i=0;i<n;i++){
    x=a*2;
    y=a+k;
    if(x>y){
      a=y;
    }else{
      a=x;
    }
  }
  cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)
#define endl '\n'
	
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

int main(){
	fast_io; cout_precision;
	int x,n;	cin >> x >> n;int ans = 0;
  	int sum = 0;	for(int i=0; i<n; i++){
	int num;	cin >> num;	ans+=num;
    }
	ans = x-ans;
  	if(ans <0)	cout << -1 <<endl;
  else	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

#define INF (int)(1e9)
#define MAX_V 110

struct edge{ int to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

int V, E;

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to,cap,(int)G[to].size()});
	G[to].push_back((edge){from, 0, (int)G[from].size()-1});
}

int dfs(int v, int t, int f){
	if(v == t) return f;
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			int d = dfs(e.to, t, min(f,e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for(;;){
		memset(used, 0,sizeof(used));
		int f = dfs(s,t,INF);
		if(f == 0) return flow;
		flow += f;
	}
}

int main(){
	int u, v, c;
	
	cin>>V>>E;
	
	for(int i = 0; i < E; i++){
		cin>>u>>v>>c;
		add_edge(u,v,c);
	}
	
	cout<<max_flow(0,V-1)<<endl;
	
	return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<string, pair<int, int>>> s(n);
    rep(i, n){
        cin >> s[i].first >> s[i].second.first;
        s[i].second.first *= -1;
        s[i].second.second = i+1;
    }
    sort(all(s));
    rep(i, n)cout << s[i].second.second << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <vector>

using namespace std;

void select(vector<bool>& visited, vector<pair<int64_t, int64_t>>& vs, pair<int64_t, int64_t> pq, int i)
{
    visited[i] = true;
    for (int j = 0; j < vs.size(); j++)
    {
        if (!visited[j] && vs[i].first + pq.first == vs[j].first && vs[i].second + pq.second == vs[j].second)
        {
            select(visited, vs, pq, j);
        }
        else if (!visited[j] && vs[i].first - pq.first == vs[j].first && vs[i].second - pq.second == vs[j].second)
        {
            select(visited, vs, pq, j);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    vector<pair<int64_t, int64_t>> vs(n);
    for (auto& v : vs)
    {
        cin >> v.first >> v.second;
    }

    if (n == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        vector<pair<int64_t, int64_t>> pq_list;
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                pq_list.emplace_back(vs[i].first - vs[j].first, vs[i].second - vs[j].second);
            }
        }

        int min_dist = numeric_limits<int>::max();

        for (auto pq : pq_list)
        {
            int dist = 0;
            vector<bool> visited(n, false);
            for (int i = 0; i < n; i++)
            {
                if (!visited[i])
                {
                    dist++;
                    select(visited, vs, pq, i);
                }
            }
            min_dist = min(min_dist, dist);
        }
        cout << min_dist << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<29
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int d[201][201];
int N,M,R,r[9];
int res;
bool used[9];
void dfs(int cnt,int las,int dist){
	if(cnt==R){
		res=min(dist,res);
		return;
	}
	rep(i,R){
		if(!used[i]){
			used[i]=true;
			if(las==-1)//初めなら
				dfs(cnt+1,i,0);
			else{
				dfs(cnt+1,i,dist+d[r[las]][r[i]]);
			}
				used[i]=false;
		}
	}


}
int main(){
	cin>>N>>M>>R;
	rep(i,R){
		cin>>r[i];
		r[i]--;
	}
	rep(i,N)
		rep(j,N)
			d[i][j]=INF;
	rep(i,N)
		d[i][i]=0;
	rep(i,M){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		d[a][b]=d[b][a]=c;
	}

			rep(k,N){
	rep(i,N){
		rep(j,N){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	//rep(i,N)rep(j,N)
	//	cout<<d[i][j]<<endl;
	res=INF;
	dfs(0,-1,0);
	cout<<res<<endl;
		
	return 0;
}



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

using namespace std;
const int MAXN = 30;

int n, v[MAXN], c[MAXN];

inline void solve () {
	int mx = 0;

	for (int i = 0; i < (1 << n); ++i) {
		
		int a = 0, b = 0;
		
		for (int j = 0; j < n; ++j) {

			if ((i & (1 << j))) {
				a += v[j];
				b += c[j];
			
				// cout << v[j] << ' ';
			}
		}
		// cout << endl;
		mx = max (mx, a - b);
	}
	
	cout << mx << '\n';

}

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	cin >> n;

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

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


	solve ();







	return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

template<typename String> bool isPalindrome(const String &s) {
  int n = s.size();
  rep(i, n / 2) if (s[i] != s[n - 1 - i]) return false;
  return true;
}

template<typename String> bool isPalindromeOf(String s, const String &t) {
  reverse(all(s));
  return s == t;
}

main {
  int n, l;
  cin >> n >> l;
  vs s(n);
  cin >> s;
  vi used(n);
  V<string> palis;
  rep(i, n) {
    if (used[i]) continue;
    loop(j, i + 1, n) {
      if (used[j]) continue;
      if (isPalindromeOf(s[i], s[j])) {
        used[i] = used[j] = true;
        string t = s[i];
        reverse(all(t));
        palis.emplace_back(min(t, s[i]));
        goto next;
      }
    }
  next:;
  }
  string midS = string(1, char('z' + 1));
  rep(i, n) {
    if (used[i]) continue;
    if (!isPalindrome(s[i])) continue;
    cmin(midS, s[i]);
  }
  sort(all(palis));
  for (auto &t : palis) cout << t;
  if (midS != string(1, char('z' + 1))) cout << midS;
  reverse(all(palis));
  for (auto t : palis) {
    reverse(all(t));
    cout << t;
  }
  cout << endl;
}



Measured memory_bytes: 3320
#include<iostream>
using namespace std;
int N;
int A[1<<17];
int cnt;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;)
	{
		cnt++;
		int j=i;
		while(j<N&&A[i]==A[j])j++;
		if(j==N)break;
		if(A[i]<A[j])
		{
			while(j+1<N&&A[j]<=A[j+1])j++;
		}
		else
		{
			while(j+1<N&&A[j]>=A[j+1])j++;
		}
		i=j+1;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2) {
		puts("-1");
		return 0;
	}
	ll cnt  = 0;
	ll plus = (n - 1) * (n - 2) / 2 - k;
	vector<P> ans;
	for (int i = 1; i <= n - 1; i++) {
		ans.emplace_back(i, n);
	}
	for (int i = 1; i < n - 1; i++) {
		for (int j = i + 1; j <= n - 1; j++) {
			if (cnt >= plus) break;
			ans.emplace_back(i, j);
			cnt++;
		}
	}
	dump(ans.size());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	return 0;
}


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

S = dict()
for i in range(N):
    tmp = input()
    if tmp in S:
        S[tmp] += 1
    else:
        S[tmp] = 1

max_v = 0
for k, v in S.items():
    if max_v < v:
        max_v = v

S = sorted(S.items(), key=lambda x:x[0])
        
for k, v in S:
    if v == max_v:
        print(k)

Measured memory_bytes: 44764
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;


int main()
{
	int n, h;
	int ans = 0;
	vector<int> a, b;

	cin >> n >> h;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}

	// 打撃最強武器のindex //
	int attack_max_index = -1;

	for (int i = 0; i < n; i++) {
		if (attack_max_index == -1 || a[attack_max_index] < a[i] || (a[attack_max_index] == a[i] && b[attack_max_index] > b[i])) {
			attack_max_index = i;
		}
	}

	// 打撃最強の武器の戦闘力 //
	int attack_max_a = a[attack_max_index];
	int attack_max_b = b[attack_max_index];

	// 投げる用武器のリスト //
	vector<int> throw_list;

	for (int i = 0; i < n; i++) {
		if (attack_max_index != i && attack_max_a < b[i]) {
			throw_list.push_back(b[i]);
		}
	}

	sort(throw_list.begin(), throw_list.end(), std::greater<int>());

	// 選んだ武器で殴る //
	int damage = 0;
	for (int i = 0; i < throw_list.size(); i++) {
		if (damage >= h) {
			continue;
		}

		damage += throw_list[i];
		ans++;
	}

	while (damage < h) {
		if (damage + attack_max_b >= h) {
			damage += attack_max_b;
		}
		else {
			damage += attack_max_a;
		}
		ans++;
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1780
l = [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
]
N = int(input())
print(l[N-1])

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

int abs(int x)
{
	if (x > 0)
		return x;
	else
		return -x;
}

int main()
{
	int N;
	std::vector<int> W;
	int right = 0;
	
	std::cin >> N;
	W.resize(N);
	for (auto& w : W) {
		std::cin >> w;
		right += w;
	}

	int result = right;
	int left = 0;
	for (auto& w : W) {
		right -= w;
		left += w;
		result = std::min(result, abs(right - left));
	}
	
	std::cout << result << "\n";
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 998244353
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


long long rev(long long k) {
	long long x = MOD - 2;
	long long re = 1;
	while (x > 0) {
		if (x % 2 == 1) {
			re = (re*k) % MOD;
		}
		k = (k*k) % MOD;
		x /= 2;
	}
	return re;
}


int main() {
	long long a[N];
	f(i, N)a[i] = 0;
	long long n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld", &n);
	n /= 2;
	x = 1;
	f(i, n)x = (x * 2) % MOD;
	y = x;
	z = 1;
	ans = 0;
	f(i, n+1) {
		if (i > 0) {
			x = (x*(n - i + 1)) % MOD;
			x = (x*rev(i)) % MOD;
			x = (x*rev(2)) % MOD;
			y = (x+y) % MOD;
			if (i > 1) {
				z = (z*(n - i + 2)) % MOD;
				z = (z*rev(i-1)) % MOD;
				z = (z * 2) % MOD;
			}
			y = (y - z + MOD) % MOD;
		}
		s = ((2 * y) - x + MOD) % MOD;
		s = (s*x) % MOD;
		ans = (ans + s) % MOD;
	}
	printf("%lld\n", ans);


	return 0;
}

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

const int N = 2e3 + 5;
const int MOD = 1e9 + 7;

int n, m;
int a[N], b[N];
int cache[N][N];

int dp(int i, int j)
{
	if(i > n)
		return 0;
	if(j > m)
		return 0;
	int &ans = cache[i][j];
	if(ans != -1)
		return ans;
	if(a[i] == b[j])
		ans = 1 + dp(i + 1, j) + dp(i, j + 1);
	else
		ans = dp(i + 1, j) + dp(i, j + 1) - dp(i + 1, j + 1);
	ans += MOD;
	ans %= MOD;
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= m; i++)
		cin >> b[i];
	int ans = dp(1, 1);
	ans++;
	ans %= MOD;
	cout << ans;
	return 0;
}


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

#define pb push_back
#define lli long long int

int main ()
{
    string a , b , e;
    cin >> a ;
    cin >> b ;
    int c , d ;
    cin >> c >> d ;
    cin >> e ;

    if (e == a)
    {
        c--;
    }
    else if (e == b)
    {
        d--;
    }

    cout << c << " " <<  d << endl ;
    return 0 ;
}

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

using namespace std;

int main()
{
    long long N, K;
    long long ans = 0;
    cin >> N >> K;
    if(N % K < abs(N % K - K)){
        ans = (N % K);
    }
    else{
        ans = abs(N % K -K);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int H,W; cin>>H>>W;
    std::vector<str> S;
    vector<vector<int> > v(H, vector<int>(W, 0));
    for(int i=0; i<H;i++){
      str s; cin>>s;
      S.push_back(s);
    }
    for(int i=0; i<H;i++){
      for(int j=0; j<W;j++){
        int cnt =0;
        for(int x=-1; x<=1; x++){
          for(int y=-1; y<=1; y++){
            if(0 <= i+x &&  i+x<H && 0 <= j+y &&  j+y<W ){
              if( S[i+x][j+y] == '#') cnt++;
            }
          }
        }
        if(S[i][j]=='.') v[i][j] = cnt;
        else v[i][j] = 10;
      }
    }
    for(int i=0; i<H;i++){
      for(int j=0; j<W;j++){
        if(v[i][j]==10) cout<<"#";
        else cout<<v[i][j];
      }
      cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	static Scanner in;
	static PrintWriter out;

	static void solve() {
		String S = in.next();
		int L = S.length() / 2;
		for (int i = 0; i < L; i++) {
			S = S.substring(0, (S.length() - 2));
			String s1 = S.substring(0, S.length() / 2);
			String s2 = S.substring((S.length() / 2), S.length());
			if (s1.equals(s2)) {
				out.println(S.length());
				break;
			}
		}

	}

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
		out.close();
		in.close();
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int main(void){
    int h,w;
    cin>>h>>w;
    string s[h];
    rep(i,h){
        cin>>s[i];
    }
    rep(i,w+2) cout<<"#";
    cout<<endl;
    rep(i,h){
        cout<<"#";
        cout<<s[i];
        cout<<"#";
        cout<<endl;
    }
    rep(i,w+2) cout<<"#";
    cout<<endl;
    return 0;
}

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

int main(){
   string s,t;
  cin >> s;
  t=s.substr(0,4);
  s=s.substr(4,8);
  cout << t+" "+s << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  
void solve(void)
{
  int N;
  cin>>N;
  vector<pair<int,int> > Red,Blue;
  for (int i = 0; i < N; i++)
  {
    int A,B;
    cin>>A>>B;
    Red.emplace_back(A,B);
  }
  for (int i = 0; i < N; i++)
  {
    int A,B;
    cin>>A>>B;
    Blue.emplace_back(A,B);
  }
  sort(ALL(Red));
  sort(ALL(Blue));
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    int X = Blue[i].first;
    int Y = Blue[i].second;
    int index = -1;
    int MIN = -1;
    for (int j = 0; j < N; j++)
    {
      int S = Red[j].first;
      int T = Red[j].second;
      if(S < X)
      {
        if(T < Y)
        if(chmax(MIN,T))
        {
          index = j;
        }
      }
    }
    if(index != -1)
    {
      ANS++;
      Red[index].first = INF;
      Red[index].second = INF;
    }
    
  }
    
  cout<<ANS<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

string s;
int n, l;
long long a, b;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> s >> n;
	l = s.size();
	if(l == 1){
		if(s[0] - '0' == n) cout << "U\n";
		else cout << "I\n";
		return 0;
	}
	a = s[0] - '0';
	for(int i=2; i<l; i+=2){
		if(s[i-1] == '+') a += s[i] - '0';
		else a *= s[i] - '0';
	}
	for(int i=0; i<l; i+=2){
		long long t = s[i] - '0';
		while(i+2 < l && s[i+1] == '*'){
			t *= s[i+2] - '0';
			i += 2;
		}
		b += t;
	}
	if(n == a){
		if(n == b) cout << "U\n";
		else cout << "L\n";
	}else{
		if(n == b) cout << "M\n";
		else cout << "I\n";
	}
//	cout << a << " " << b << "\n";
}


Measured memory_bytes: 3196
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int a[4], b[2];
	
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	cin >> b[0] >> b[1];
	
	sort(a, a + 4);
	sort(b, b + 2);
	
	int ans = a[1] + a[2] + a[3] + b[1]; 
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

class CumulativeSumClass {
public:
    CumulativeSumClass(vector<ll> const data) :
        Sum(data.size()+1, 0)
    {
        for (size_t i = 0; (i < data.size()); ++i) {
            Sum[i+1] = Sum[i] + data[i];
        }
    }
    ll GetSum(size_t const leftIdx, size_t const rightIdx) const
    {
        return Sum[rightIdx+1] - Sum[leftIdx];
    }
private:
    vector<ll> Sum;
};

int main()
{
    ll n, k;
    string str;
    cin >> n >> k >> str;
    vector<ll> ary;

    char prev = 0xff;
    if (str[0] == '0') {
        ary.push_back(0);
        prev = '1';
    }
    for (ll i = 0; (i < n); i++) {
        char curr = str[i];
        if (prev != curr) {
            prev = curr;
            ary.push_back(1);
        } else {
            ary[ary.size()-1]++;
        }
    }
    if (str[n-1] == '0') ary.push_back(0);

  CumulativeSumClass sum(ary);

    ll maxv = 0;
    for(ll i = 0; (i < ary.size()); i+=2) {
        ll left = i;
        ll right = min((ll)(ary.size()-1), i+k*2);
        maxv = max(maxv, sum.GetSum(left, right));
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 2932
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_5_A&lang=jp
#  Sorting Tuples : python3
#  2018.11.25 yonezawa

import sys
input = sys.stdin.readline

def main():
    l = []
    for i in range(int(input())):
        (a,b,c,d,e) = map(str,input().split())
        l.append((int(a),int(b),c,int(d),e))
    for a,b,c,d,e in sorted(l):
        print (a,b,c,d,e)
if __name__ == '__main__':
    main()


Measured memory_bytes: 32100
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int a,b;
	cin>>a>>b;
	if ((a*b)%2==0)
	{
		cout<<"Even"<<endl;
	}
	else {
		cout<<"Odd"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def check(i,j):
    c=0
    try:
        if i!=0 and j!=0:
            if S[i-1][j-1]=="#":
                c+=1
    except:
        pass
    try:
        if i!=0:
            if S[i-1][j]=="#":
                c+=1
    except:
        pass
    try:
        if i!=0:
            if S[i-1][j+1]=="#":
                c+=1
    except:
        pass
    try:
        if j!=0:
            if S[i][j-1]=="#":
                c+=1
    except:
        pass
    try:
        if S[i][j+1]=="#":
            c+=1
    except:
        pass
    try:
        if j!=0:
            if S[i+1][j-1]=="#":
                c+=1
    except:
        pass

    try:
        if S[i+1][j]=="#":
            c+=1
    except:
        pass
                            
    try:
        if S[i+1][j+1]=="#":
            c+=1
    except:
        pass
    return c

h,w=map(int,input().split())
S=[input() for i in range(h)] 
#print(S)
for i in range(h):
    s=""
    for j in range(w):
        #print(i,j)
        if S[i][j]=="#":
            s+="#"
        else:
            count=check(i,j)
            #print(count)
            s+=str(count)
    print(s)
            

Measured memory_bytes: 3188