akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

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

   if((a != b)&&(b != c)&&(a != c)) cout << 3 << endl;
   else if((a == b)&&(b == c)) cout << 1 << endl;
   else cout << 2 << endl;



   return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut s = read_one::<String>().chars().collect::<Vec<char>>();
    s.sort();
    if s[0] == s[1] && s[2] == s[3] && s[1] != s[2] { println!("Yes"); }
    else { println!("No"); }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const int MAXN = 205;

int n,flag = 1;
int dis[MAXN][MAXN],col[MAXN],g[MAXN][MAXN];
char s[MAXN];

void dfs(int u,int c){
	col[u] = c;
	for(int i = 1;i <= n;i++){
		if(g[u][i]){
			if(col[i] == c)
				flag = 0;
			if(col[i] == -1)
				dfs(i,c ^ 1);
		}
	}
}

int main(){
	//freopen("1.in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%s",s + 1);
		for(int j = 1;j <= n;j++)
			g[i][j] = (s[j] - '0');
	}
	memset(col,-1,sizeof(col));
	for(int i = 1;i <= n;i++){
		if(col[i] == -1)
			dfs(i,1);
		if(!flag){
			printf("-1\n");
			return 0;
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++)
			dis[i][j] = (g[i][j] ? 1 : INF);
		dis[i][i] = 0;
	}
	for(int k = 1;k <= n;k++){
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++)
				dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
		}
	}
	int ans = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if(dis[i][j] < INF)
				ans = max(ans,dis[i][j]);
		}
	}
	printf("%d\n",ans + 1);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i,n){
        cin >> l[i];
    }
    sort(l.rbegin(),l.rend());
    int ans = 0;
    rep(i,k){
        ans += l[i];
    }
    cout << ans << endl;
}

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

struct edge {
  long long time;
  long long cost;
  int to;
};
struct item {
  long long time;
  int cur;
  long long num;
  bool operator>(const item& rhs) const {
    return time > rhs.time;
  }
};
struct change {
  long long rate;
  long long time;
};

int main() {
  long long n, m, s;
  cin>>n>>m>>s;
  vector<edge> g[n];
  for (int i=0; i<m; i++) {
    int u, v, a, b;
    cin>>u>>v>>a>>b;
    --u;
    --v;
    g[u].push_back({b, a, v});
    g[v].push_back({b, a, u});
  }
  change c[n];
  for (int i=0; i<n; i++) cin>>c[i].rate>>c[i].time;

  long long d[n][2501];
  bool used[n][2501];
  for (int i=0; i<n; i++) {
    for (int j=0; j<2501; j++) {
      d[i][j] = 1e15;
      used[i][j] = false;
    }
  }
  s = min(s, 2500LL);
  priority_queue<item, vector<item>, greater<item>> pq;
  pq.push({0LL, 0, s});
  d[0][s] = 0;
  while (!pq.empty()) {
    auto top = pq.top();
    pq.pop();
    long long time = top.time;
    int cur = top.cur;
    long long num = top.num;
    if (used[cur][num]) continue;
    used[cur][num] = true;
    long long time2 = time + c[cur].time;
    long long num2 = num + c[cur].rate;
    if (num2 <= 2500 && !used[cur][num2]) {
      if (time2 < d[cur][num2]) {
        d[cur][num2] = time2;
        pq.push({time2, cur, num2});
      }
    }
    for (auto e: g[cur]) {
      long long e_time = e.time;
      long long e_cost = e.cost;
      int e_to = e.to;
      long long to_num = num - e_cost;
      long long to_time = time + e_time;
      if (to_num < 0 || used[e_to][to_num]) continue;
      if (to_time < d[e_to][to_num]) {
        d[e_to][to_num] = to_time;
        pq.push({to_time, e_to, to_num});
      }
    }
  }
  for (int i=1; i<n; i++) {
    long long ans = 1e15;
    for (int j=0; j<2501; j++) {
      ans = min(d[i][j], ans);
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 7492
INF = 1<<31
n = input()
dp = [[[INF]*2 for _ in xrange(n/2+2)] for _ in range(2)]
dp[1][1][0] = dp[1][0][1] = 0
for i in range(2,n+1):
    x = i % 2
    s = input()
    t = min(i,n/2)
    for j in range(1,t+1):
        dp[x][j][0] = min(dp[1-x][j-1][0], dp[1-x][j-1][1] + s)
        dp[x][j][1] = min(dp[1-x][j][0] + s, dp[1-x][j][1])
print min(dp[0][n/2])

Measured memory_bytes: 8224
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef long long int ll;
using namespace std;
const int M=1e9+7;
ll bm[300005],bM[300005],cm[300005],cM[300005];
int main() {
    ios;
    ll n;cin>>n;
    ll a[n];
   map<ll,ll> ma;
   bool p=false;
  for(ll i=0;i<n;++i)
  {
    ll x;cin>>x;
    ++ma[x];
    if(ma[x]>1)
    {
      p=true;
    }
  }
  if(!p)
    cout<<"YES";
  else
    cout<<"NO";
  
  
}

Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
char a[10005],b[10005];
int n;
int main()
{
	cin>>n;
	cin>>a+1>>b+1;
	for(int i=1;i<=n;i++)
		putchar(a[i]),putchar(b[i]);
	return 0;
}

Measured memory_bytes: 256
# pythonで青くなるブログ
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
lamps = [list(map(lambda x:int(x)-1, input().split()))[1:]
         #1個目は繋がっているスイッチの個数
         #2個目以降が繋がっているスイッチの番号、0始まりに
         for _ in range(M)]
p = list(map(int, input().split()))
# on になっているスイッチの個数を2で割った余りがpiに等しい時に点灯
ans = 0

# bit全探索(スイッチの入れ方を全探索する)
for i in range(1 << N):#2^N分、Bit検索
    for r in range(M):  # 全てのランプがついてるかチェック
        on_sum = 0  # ランプrにおいて、onのスイッチの数。電球はM個。
        for j in range(N):  # スイッチのj番目について
            if i >> j & 1 and j in lamps[r]:
            #j番目のフラグが立って、電球rのj番目のスイッチが入っていれば
                on_sum += 1  
                # スイッチjがランプrに繋がってて、onならon_sum+=1
        if on_sum % 2 != p[r]:  # on_off check
            break  # 一つでもoffなら次のbitに
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int min(int a,int b){
    if(a<b)return a;
    return b;
}
int cgcolor(int num){
    if(num==0)return 3;
    return num;
}

int main(void){
    int N,K,x,y;
    int i;
    scanf("%d %d",&N,&K);
    for(i=0;i<K;i++){
        scanf("%d %d",&x,&y);
        printf("%d\n",cgcolor(min(min(x,N-x+1),min(y,N-y+1))%3));
    }
    return 0;
}

Measured memory_bytes: 596
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
m = abs(a-(t-h[0]*0.006))
ans = 0

for i in range(1, n):
    num = abs(a-(t-h[i]*0.006))
    if num < m:
        ans = i
        m = num

print(ans+1)

Measured memory_bytes: 3064
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
int H, W, N, a[100009], b[100009]; long long c[12]; pair<int, int> r[100009];
int main() {
	cin >> H >> W >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i]; a[i]--, b[i]--;
		r[i] = make_pair(b[i], a[i]);
	}
	sort(r, r + N);
	set<pair<int, int> > s;
	for (int i = 0; i < N; i++) {
		for (int j = -2; j <= 0; j++) {
			for (int k = -2; k <= 0; k++) {
				int tx = b[i] + k, ty = a[i] + j;
				if (0 <= tx && tx + 2 < W && 0 <= ty && ty + 2 < H) {
					if (s.find(make_pair(tx, ty)) != s.end()) continue;
					int cnt = 0;
					for (int sy = ty; sy < ty + 3; sy++) {
						for (int sx = tx; sx < tx + 3; sx++) {
							if (binary_search(r, r + N, make_pair(sx, sy))) cnt++;
						}
					}
					c[cnt]++;
					s.insert(make_pair(tx, ty));
				}
			}
		}
	}
	c[0] = 1LL * (H - 2) * (W - 2) - s.size();
	for (int i = 0; i < 10; i++) cout << c[i] << endl;
	return 0;
}

Measured memory_bytes: 44032
def main
  n = gets.chomp.to_i
  a,b = gets.chomp.split(' ').map(&:to_i)
  c,d = gets.chomp.split(' ').map(&:to_i)

  min = n * 2
  1.upto(n) do |w|
    ax,ay = position(w, a)
    bx,by = position(w, b)
    ab = distance(ax, ay, bx, by)
    cx,cy = position(w, c)
    dx,dy = position(w, d)
    cd = distance(cx, cy, dx, dy)
    min = [(ab + cd), min].min
  end
  puts min
end

def distance x1, y1, x2, y2
  (x1 - x2).abs + (y1 - y2).abs
end

def position width, order
  x = (order - 1) / width
  y = (order - 1) % width
  [x, y]
end

main

Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
int h[100100],n;
int main(){	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&h[i]);
	h[n+1]=2100000000;
	int maxx=-1;
	for(int i=1;i<=n;i++){
		maxx=max(maxx,h[i]);
		if(maxx-h[i]>1){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {
	public static void main(String args[]){	

	Scanner scan = new Scanner(System.in);

	double x1 = scan.nextDouble();
	double y1 = scan.nextDouble();
	double x2 = scan.nextDouble();
	double y2 = scan.nextDouble();
	
	
	
	double ans = Math.sqrt(Math.pow((x2 - x1),2) + Math.pow((y2 - y1),2));

	System.out.println(ans);
	}
}

Measured memory_bytes: 28096
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
//MACROS
#define _crt_secure_no_warnings
#define FREEELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F3F3F3F3FLL
#define MAX 200001
#define MOD 998244353
#define ALPHABET 128
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
typedef unordered_set<int> usi;
typedef unordered_multiset<int> usmi;
struct node{
    ll sum, add;
    node(){
        add = 0;
    }
} st[4 * MAX];
ll dp[MAX];
void Build(ll v, ll l, ll r){
    if (l == r) { st[v].sum = dp[l]; st[v].add = 0; return; }
    ll mid = (l + r) / 2;
    Build(2 * v, l, mid);
    Build(2 * v + 1, mid + 1, r);
    st[v].sum = st[2 * v].sum + st[2 * v + 1].sum;
    st[v].add = 0;
}

void Push(ll v, ll l, ll mid, ll r){
    if (st[v].add != 0){
        st[2 * v].add += st[v].add % MOD;
        st[2 * v + 1].add += st[v].add % MOD;
        st[2 * v].sum += ((mid - l + 1) * st[v].add) % MOD;
        st[2 * v + 1].sum += ((r - mid) * st[v].add) % MOD;
        st[v].add = 0;
    }
}

void Update(ll v, ll l, ll r, ll i, ll j, ll d){
    if (i > j) return;
    if (l == i && r == j) {
        st[v].add = (st[v].add + d) % MOD;
        st[v].sum = (st[v].sum + 1LL * (j - i + 1) * d % MOD) % MOD;
        return;
    }
    ll mid = (l + r) / 2;
    Push(v, l, mid, r);
    Update(2 * v, l, mid, i, min(mid, j), d);
    Update(2 * v + 1, mid + 1, r, max(mid + 1, i), j, d);
    st[v].sum = (st[2 * v].sum % MOD + st[2 * v + 1].sum % MOD) % MOD;
}

ll Sum(ll v, ll l, ll r, ll i, ll j){
    if (i > j) return 0;
    if (l == i && r == j) return st[v].sum;
    ll mid = (l + r) / 2;
    Push(v, l, mid, r);
    return (Sum(2 * v, l, mid, i, min(mid, j)) % MOD + Sum(2 * v + 1, mid + 1, r, max(i, mid + 1), j) % MOD) % MOD;
}

umii m;
int main() {
    FREEELO
    int n, k; cin >> n >> k;
    dp[1] = 1;
    vector<ii> steps(k + 1);
    loop(i, k){
        cin >> steps[i].F >> steps[i].S;
    }
    if (n == 1) { cout << 0; return 0; }
    Build(1, 1, n);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j < sz(steps); j++){
            int k1 = i + steps[j].F;
            if (k1 > n) continue;
            int k2 = i + steps[j].S;
            if (k2 > n) k2 = n;
            Update(1, 1, n, k1, k2, Sum(1, 1, n, i, i));
        }
    }
    cout << Sum(1, 1, n, n, n) << endl;

}

Measured memory_bytes: 16060
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	long min = Integer.MAX_VALUE;
      	sc.close();
      	if(b - a >= 2019){
        	System.out.print(0);
        }
      	else{
      	for(long i = a; i < b; i ++){
          	for(long j = i + 1; j <= b; j ++){
            	if(min > ((i * j) % 2019)){
                	min = (i * j) % 2019;
                }
              	if(min == 0){
                	break;
                }
            }
        }
          System.out.print(min);
        }
      	
      	
    }
 
}

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

using namespace std;

int main(void){

  int n;
  while( cin >> n , n ){

    int h,b,a;
    int lunch = 0,cnt_l = 0;
    int dinner = 0,cnt_d = 0;
    int midnight = 0,cnt_m = 0;
    int in8;

    for(int i = 0 ; i < n ; i++ ){
      scanf("%d:%d %d",&h,&b,&a);
      int ok = 0;
      if( a >= b && a - b <= 8 ) ok++;
	else if( a < b && 60 - b + a <= 8 ) ok++;

      if( 11 <= h && h < 15 ){
	lunch++;
	cnt_l += ok;
      }    
      else if( 18 <= h && h < 21 ){
	dinner++;
	cnt_d += ok;
      }
      else if( (21 <= h && h <= 24 ) || ( 0 <= h && h < 2 ) ){
	midnight++;
	cnt_m += ok;
      }
    }

   if(lunch){
            printf("lunch %d\n", cnt_l * 100 / lunch);
        }else{
            printf("lunch no guest\n");
        }
        if(dinner){
            printf("dinner %d\n", cnt_d * 100 / dinner);
        }else{
            printf("dinner no guest\n");
        }
        if(midnight){
            printf("midnight %d\n", cnt_m * 100 / midnight);
        }else{
            printf("midnight no guest\n");
        }
    
  }
  return 0;
}

Measured memory_bytes: 1228
/*氏名：保坂優介, 学籍番号：200441141
  概要：無いカードを表示する*/

#include<stdio.h>

int char_to_int(char suit)
{
    int suit_num;
    if (suit == 'S')
    {
        suit_num = 0;
    }
    if (suit == 'H')
    {
        suit_num = 1;
    }
    if (suit == 'C')
    {
        suit_num = 2;
    }
    if (suit == 'D')
    {
        suit_num = 3;
    }
    return suit_num;
}

char int_to_char(int suit_num)
{
    char suit;
    if (suit_num == 0)
    {
        suit = 'S';
    }
    if (suit_num == 1)
    {
        suit = 'H';
    }
    if (suit_num == 2)
    {
        suit = 'C';
    }
    if (suit_num == 3)
    {
        suit = 'D';
    }
    return suit;
}

int main(void)
{
    int i, j, k, n, rank, suit_num, junk, N_A[4][14] = {0};
    char suit;

    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%c%c%c%d", &junk, &suit, &junk, &rank);

        suit_num = char_to_int(suit);

        N_A[suit_num][rank] = 1;
    }

    for (i = 0; i < 4; i++)
    {
        for (j = 1; j <= 13; j++)
        {
            if (N_A[i][j] == 0)
            {
                suit = int_to_char(i);

                printf("%c %d\n", suit, j);
            }
        }
    }


    return 0;
}


Measured memory_bytes: 2100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        long[] a = nla(7);

        long ans = a[1] * 2;
        
        boolean b1 = a[0] > 0;
        boolean b2 = a[3] > 0;
        boolean b3 = a[4] > 0;

        ans += a[0] / 2 * 4;
        a[0] %= 2;

        ans += a[3] / 2 * 4;
        a[3] %= 2;

        ans += a[4] / 2 * 4;
        a[4] %= 2;

        if (a[0] + a[3] + a[4] == 3) {
            ans += 6;
        } else if (a[0] + a[3] + a[4] == 2 && b1 && b2 && b3) {
            ans += 2;
        }

        out.println(ans / 2);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


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


//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);

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

int main() {

    int a, b;
    cin >> a >> b;
    if (a + b >= 10) {
        cout << "error" << endl;
        return 0;
    }

    cout << a + b << endl;

}

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

int main(void) {
    std::string s;
    std::string temp;
    std::string p;
    std::getline(std::cin, temp);
    std::getline(std::cin, p);
    s = temp + temp;
    int match = (int)(s.find(p));
    if (match == -1) {
        std::cout << "No" << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3180
/*
auhtor:hbohra98
chandigarh univeristy
*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define VP vector < pair < ll , ll > >
#define VI vector< ll >
#define VS vector< string >
#define mk make_pair

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}
template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

using namespace std;
bool check(long double x) 
{   
  long double xx = sqrt(x); 
  return ((xx-floor(xx))==0); 
} 
int main(){

int n,d;
cin>>n>>d;
int a[n][d];
for(int i=0;i<n;i++){
  for(int j=0;j<d;j++){
    cin>>a[i][j];
  }
}
int c=0;
for(int i=0;i<n;i++){
  
  for(int j=i+1;j<n;j++){
  long double xx=0;
        for(int k=0;k<d;k++){
              xx+=abs(a[i][k]-a[j][k])*abs(a[i][k]-a[j][k]);
               //cout<<a[i][k]<<" "<<a[j][k]<<" "<<k<<endl;
        }
       
        if(check(xx))c++;

  }

}
cout<<c<<endl;
}

Measured memory_bytes: 256
A,B,K = gets.split.map(&:to_i)

if B-A+1 < 2*K
	for num in A..B
		print num.to_s + "\n"
	end
else
	for num in A..A+K-1
		print num.to_s + "\n"
	end
	
	for num in B-K+1..B
		print num.to_s + "\n"
	end
end

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

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

    int k1 = S%10;
    int k2 = S%100 / 10;
    int k3 = S%1000 /100;
    int k4 = S/1000;
    int deg1 = k4*10 + k3;
    int deg2 = k2*10 + k1;

    /*cout << k1 << endl;
    cout << k2 << endl;
    cout << k3 << endl;
    cout << k4 << endl;*/
    if(deg1 <= 12 && deg1 > 0){
        if(deg2 <= 12 && deg2 > 0){
            cout << "AMBIGUOUS";
        }
        else cout << "MMYY";
        return 0;
    }
    else if(deg2 <= 12 && deg2 > 0){
        cout << "YYMM";
        return 0;
    }
    cout << "NA";
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
S = input()
cnt = Counter(S)

ans = cnt['R']*cnt['G']*cnt['B']
#まずansに要請１を満たす(i, j, k)の組の数を入れておき，ここから，要請２を満たさないものを除いていく。

for i in range(N-2):
    for j in range(i+1, N-1):
        k = j + (j - i)
        #kは　j - i = k - j を満たす。ただし，（i, j, k）が要請１を満たしているとは限らない。
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

print(ans)

Measured memory_bytes: 73688
// https://atcoder.jp/contests/abc175/tasks/abc175_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

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

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  string S;
  cin >> S;
  ll N = S.size();

  ll res = 0;
  ll cur = 0;

  rep(i, N) {
    if (S[i] == 'R') {
      cur++;
      chmax(res, cur);
    } else {
      cur = 0;
    }
  }

  cout << res << "\n";
}


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

int gcd(int s,int t){
    while(t!=0){
        int u;
        u=s%t;
        s=t;
        t=u;
    }
    return s;
}

int main(){
    int K;
    long int ans=0;
    cin >> K;
    for(int a=1;a<=K;a++){
        for(int b=1;b<=K;b++){
            for(int c=1;c<=K;c++){
                int gc=gcd(a,gcd(b,c));
                ans=ans+gc;
            }
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
int f[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(n);
    FOR(i,1,n) r(f[i]);
    sort(f+1,f+n+1);
    int nn=unique(f+1,f+n+1)-f-1;
    if(n==nn) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}

Measured memory_bytes: 1024
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  string s = readln.chomp;
  bool ok = s.length%2 == 0;
  foreach(i; 0..s.length/2) {
    if (!ok) break;
    ok &= s[i*2..i*2+2] == "hi";
  }
  writeln(ok ? "Yes" : "No");
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	// your code goes here
	int x,y;
	scanf("%d%d",&x,&y);
	if(y%2==0&&y<=x*4&&x*2<=y){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}


Measured memory_bytes: 1728
#include<stdio.h>
int main(){
  int A[100],N,i,j,v,k;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=N;i++){
    for(k=0;k<N;k++){
      if(k==N-1)printf("%d",A[k]);
      else printf("%d ",A[k]);
    }
    printf("\n");
    if(i==N)break;
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
  }
  return 0;
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
const int N=100000;

int a,b,c,s;
int main ()
{
cin >> a >> b>> c ;
s=b*10+c;
if (s %4==0)
{
	cout << "YES";
	return 0;
}
cout << "NO";
return 0;
}




Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main { 
    public static void main(String[] args) {
        FastScanner sc=new FastScanner();
        long o=0;
        int n=sc.nextInt();
      	int[] list=new int[100001];
      	for(int j=0;j<n;j++){
          	int a=sc.nextInt();
          	list[a]++;
          	o+=a;
    	}
      	
      	int q=sc.nextInt();
      	for(int i=0;i<q;i++){
        	int a=sc.nextInt();
          	int b=sc.nextInt();
            int num=list[a];
          	list[b]+=list[a];
          	list[a]=0;
          	o+=num*(b-a);
          	System.out.println(o);
        }
        
      
    }
    
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 53316
#include <stdio.h>

int main(void) {
  int ans = 0, i;
  char s[20], t[20] = "CODEFESTIVAL2016";
  scanf("%s", s);
  for(i = 0; i < 16; ++i) if(s[i] != t[i]) ++ans;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let (a,b,k) = {
        let xs = read_vec_i64();
        (xs[0], xs[1], xs[2])
    };
    for i in 0..k {
        if a + i <= b {
            println!("{}", a + i);
        }
    }
    for i in (0..k).rev() {
        if a + k <= b - i && a <= b - i {
            println!("{}", b - i);
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
typedef vector<bool> vb;
const ll INF=1LL << 60;
const ll MOD=1e9+7;

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

  int n, m;
  cin >> n >> m;
  vb t(n+1, true);
  rep(i ,m){
    int a;
    cin >> a;
    t[a]=false;
  }

  vl dp(100010, 0);
  dp[0]=1;
  rep(i, n)for(int j=i+1; j<=min(n, i+2); j++){
    if(t[j]){
      dp[j]+=dp[i];
      dp[j]%=MOD;
    }
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 3984
#create date: 2020-07-01 11:19

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, k = na()
    r, s, p = na()
    t = ns()
    ans = 0
    for j in range(k):
        m = (n-j-1)//k+1
        dp = [[0]*m for _ in range(3)]
        o = t[j]
        if o=="s":
            dp[0][0] = r
        if o=="r":
            dp[1][0] = p
        if o=="p":
            dp[2][0] = s
        for i in range(1, m):
            o = t[k*i+j]
            premax = max(dp[0][i-1], dp[1][i-1], dp[2][i-1])
            if o == "s":
                dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + r
                dp[1][i] = premax
                dp[2][i] = premax
            if o == "r":
                dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + p
                dp[0][i] = premax
                dp[2][i] = premax
            if o == "p":
                dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + s
                dp[0][i] = premax
                dp[1][i] = premax
        ans += max([dp[0][-1], dp[1][-1], dp[2][-1]])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14520
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		int[] dp = new int[n];
		dp[0] = 0;
		for(int i = 1; i < n; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		for(int i = 1; i < n; i++) {
			for(int j = 1; j <= k; j++) {
				if(i - j >= 0) {
					dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
				}
			}
		}
		System.out.println(dp[n - 1]);
	}

}


Measured memory_bytes: 51456
#include <iostream>
#include <string>
#include <vector>
#include <set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

bool Floyd_Warshall(std::set<std::pair<int, int>>& m, int a, int b, int N) {
  vector<vector<int>> dist(N);
  rep(i, N) {
    dist[i].resize(N, N);
  }

  for (const auto& e : m) {
    if (e.first == a && e.second == b) continue;
    if (e.first == b && e.second == a) continue;
    dist[e.first][e.second] = 1;
    dist[e.second][e.first] = 1;
  }

  rep(i, N) {
    dist[i][i] = 0;
  }

  rep(k, N) {
    rep(i, N) {
      rep(j, N){
        if (dist[i][j] > dist[i][k] + dist[k][j]) dist[i][j] = dist[i][k] + dist[k][j];
      }
    }
  }

  rep(i, N) {
    rep(j, N) {
      if (dist[i][j] == N) {
        return false;
      }
    }
  }

  return true;
}

int main() {
  int N, M;
  cin >> N >> M;

  std::set<std::pair<int, int>> m;
  int a, b;
  rep(i, M) {
    cin >> a >> b;
    a--;
    b--;

    m.insert(std::make_pair(a, b));
  }

  int bridge = 0;
  for (const auto& e : m) {
    if (!Floyd_Warshall(m, e.first, e.second, N)) bridge++;
  }

  cout << bridge << endl;

  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map( int, input().split())
y = ty - sy
x = tx - sx
ans = "U"*y + "R"*x + "D"*y + "L"*x + "L" +  "U"*(y+1) + "R"*(x+1) + "D" + "R" + "D"*(y+1) + "L"*(x+1)+"U"
print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c);
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000
#define PI           acos(-1.0)

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

#define scan(x)      do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;
ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    //scan(n);
    cin>>k>>s;
    k++;
    f0(i,k)
    {
        f0(j,k)
        {
            x = s-i-j;
            if(x>=0 && x<k)
            {
                cnt++;
            }
        }
    }

    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef std::vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef long long ll;
const int inf = 1e9 + 5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

void build(int a, int b, string &ans, string &s, string &t, vvi &dp){
    if(!a || !b) return;

    if(s[a-1]==t[b-1]){
        ans.push_back(s[a-1]);
        build(a-1, b-1, ans, s, t, dp);
        return;
    }
    
    if(dp[a-1][b] > dp[a][b-1]) build(a-1,b, ans, s, t, dp);
    else build(a, b-1, ans,s,t,dp);

}


int main(){
    string s,t;
    while(cin>>s>>t){
        int n = s.size();
        int m = t.size();

        vvi dp(n+1, vi(m+1));

        // string ans[n+1][m+1];
        // for(int i=0; i<=n; i++)
        //     for(int j=0; j<=m; j++)
        //         ans[i][j] = "";

        for(int i=1; i<=n; i++){
            for(int j=1; j<=m; j++){
                if(s[i-1]==t[j-1]){
                    dp[i][j] = 1 + dp[i-1][j-1];
                    // ans[i][j] = ans[i-1][j-1] + s[i-1];
                }
                else{
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                    // if(dp[i-1][j] >= dp[i][j-1]){
                    //     dp[i][j] = dp[i-1][j];
                    //     ans[i][j] = ans[i-1][j];
                    // }else{
                    //     dp[i][j] = dp[i][j-1];
                    //     ans[i][j] = ans[i][j-1];
                    // }
                }
            }
        }


        string ans;
        build(n,m, ans, s,t,dp);
        reverse(all(ans));
        cout<<ans<<endl;

        // deb(dp[n][m]);
        // cout<<ans[n][m]<<endl;
        // s = " " + s; t = "  " + t;
        // for(auto x: t) cout<<x<<" ";
        // cout<<endl;
        // for(int i=0; i<=n; i++){
        //     cout<<s[i]<<" ";
        //     for(int j=0; j<=m; j++)
        //         cout<<dp[i][j]<<" \n"[j==m];
        // }


    }
}


Measured memory_bytes: 35712
#include <iostream>
#define sl "\n"
using namespace std ;
const int N = 1e5+5 ;
int a,b,c;
int r,s;
int main()
{
  cin >> a >> b >> c >> r ;
  while ( a >= b) {
    b *= 2 ; s ++;
  }
  while (b >= c) {
    c *= 2 ; s++;
  }
  if ( s > r ) 
    cout << "No";
  else 
    cout << "Yes";
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using Cost = int;

const Cost INF = 2e9;
using P = pair<Cost, int>;

struct Edge {
	int from, to;
	Cost cost;
	Edge() {}
	Edge(int f, int t, Cost c) : from(f), to(t), cost(c) {}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

vector<Cost> Dijkstra(const Graph& G, int s) {
	int n = G.size();
	vector<Cost> d(n, INF);
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.emplace(0, s);
	d[s] = 0;
	while (!pq.empty()) {
		auto p = pq.top(); pq.pop();
		if (p.first > d[p.second]) continue;
		for (const auto& e : G[p.second]) if (d[e.to] > p.first + e.cost) {
			pq.emplace(p.first + e.cost, e.to);
			d[e.to] = p.first + e.cost;
		}
	}
	return d;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int V, E, r;
	cin >> V >> E >> r;
	Graph G(V);
	for (int i = 0, s, t, d; i < E; i++) {
		cin >> s >> t >> d;
		G[s].emplace_back(s, t, d);
	}
	auto res = Dijkstra(G, r);
	for (auto ans : res) {
		if (ans == INF) puts("INF");
		else printf("%d\n", (int)ans);
	}
	return 0;
}

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

int main(){
    bool clear=false;
    int x, ans;
    cin >> x;
    while(true){
        rep(2,x+1){
            if(x%i == 0 && x!=i){
                clear = false;
                break;
            }
            clear = true;
        }
        if(clear) break;
        x++;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,x=map(int,input().split())
    A=list(map(int,input().split()))
    res=0
    for i in range(1,n):
        c=A[i]+A[i-1]-x
        if c>0:
            res+=c
            A[i]=max(A[i]-c,0)
    print(res)
resolve()

Measured memory_bytes: 63856
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n;
	cin>>n;
	int t[n],x[n],y[n];
	t[0]=0;x[0]=0;y[0]=0;
	for(int i=1;i<n+1;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	for(int i=1;i<=n;i++){
		int p,q;
		p=t[i]-t[i-1];
		q=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if(q <= p && p%2 == q%2) ;
		else{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

#define ll long long
#define T int t, q=0; cin>>t; while(q++<t)

int main()
{
    int l, n;
    cin>>l>>n;
    int a[n], ans=0;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a, a+n);

    for(int i=0;i<n-1;i++)
        ans=max(a[i+1]-a[i], ans);
    ans=max(ans, l-a[n-1]+a[0]);
    cout<<l-ans;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

#define is_uruu leapyear
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,a) for(int i=0;i<(a);++i)

int A[50], n;

int solve(int i, int m){
	if(m == 0) return 1;
	if(i >= n) return 0;
	
	int ans;
	ans = (solve(i+1, m) || solve(i+1, m-A[i]));
	return ans;
}

int main() {

	int q, m;
	cin >> n;
	FOR(i, 0, n) cin >> A[i];
	cin >> q;
	
	FOR(i, 0, q){
		cin >> m;
		if(solve(0, m)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
    return 0;
}


Measured memory_bytes: 3112
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RDA;

	long ans;
	foreach (i; 0..N)
	{
		ans = gcd(ans, A[i]);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 4532