akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  int x, n, flg, ans = -1, tmp = 100;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  sort(p.begin(), p.end());
  for(int i = -1; i <= 101; i++) {
    flg = 1;
    rep(j, n) {
      if(p[j] == i) {
        flg = 0;
        break;
      }
    }
    if(flg == 1) {
      if(tmp > abs(x - i)) {
        tmp = abs(x - i);
        ans = i;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#A
"""
a,b,c = LI()
print(min(b//a,c))
"""

#B
"""
a,b,k = LI()
i = 1
ans = [1]
while i <= min(a,b):
    i += 1
    if a%i == 0 and b%i == 0:
        ans.append(i)
print(ans[-k])
"""

#C
"""
s = list(map(int,S()))
print(2*min(sum(s),len(s)-sum(s)))
"""

#D
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]
def unite(x,y):
    x = root(x)
    y = root(y)
    if x == y:
        ans.append(ans[-1])
        return
    sx = s[x]
    sy = s[y]
    if rank[x] < rank[y]:
        par[x] = y
        s[y] += sx
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
        s[x] += sy
    ans.append(ans[-1]+sx*sy)
n,m  = LI()
v = LIR(m)
v = v[::-1]
par = [i for i in range(n)]
rank = [0 for i in range(n)]
s = [1 for i in range(n)]
ans = [0]
k = n*(n-1)//2
v.pop(-1)
for a,b in v:
    if ans[0] == k:
        ans.append(k)
        continue
    a -= 1
    b -= 1
    unite(a,b)
for i in ans[::-1]:
    print(k-i)
#E
"""
n,a,b = LI()
s = input()
ans = 0
i = 0
while i < n:
    j = i+1
    if s[i:j] in s[:i]:
        while s[i:j] in s[:i]:
            j += 1
            if j >= n-1:break
        j -= 1
        print(s[i:j],s[:i])
        ans += min(b,a*(j-i+1))
    else:
        ans += a*(j-i)
    i = j
print(ans)
"""
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 91480
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	ll i, n, m, most = 1;
	cin >> n >> m;
	for (i = 1; i*i <= m; i++) {
		if (m%i == 0) {
			if (i*n <= m) most = max(most, i);
			if (m/i*n <= m) most = max(most, m/i);
		}
	}
	cout << most << endl;
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		for (int i = 0; i < s.length(); i++) {
			s = s.replaceAll(",", " ");
		}
		System.out.println(s);
		sc.close();
	}
}


Measured memory_bytes: 10064
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] S = new int[13];
		int[] H = new int[13];
		int[] C = new int[13];
		int[] D = new int[13];
		for (int i=0; i<n; i++) {
			String temp_s = sc.next();
			int temp_i = sc.nextInt()-1;
			if (temp_s.equals("S")) {S[temp_i]++;}
			else if (temp_s.equals("H")) {H[temp_i]++;}
			else if (temp_s.equals("C")) {C[temp_i]++;}
			else if (temp_s.equals("D")) {D[temp_i]++;}
		}
		
		for (int i=0; i<13; i++) {
			if (S[i]==0) {System.out.println("S"+" "+(i+1));}
		}
		for (int i=0; i<13; i++) {
			if (H[i]==0) {System.out.println("H"+" "+(i+1));}
		}
		for (int i=0; i<13; i++) {
			if (C[i]==0) {System.out.println("C"+" "+(i+1));}
		}
		for (int i=0; i<13; i++) {
			if (D[i]==0) {System.out.println("D"+" "+(i+1));}
		}
	}
}


Measured memory_bytes: 26364
use std::io;
use std::cmp::min;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let m = v[1];
	let x = v[2];
	let mut a = vec![0; (n+1) as usize];
	/*for i in &a {
		println!("{}", i);
	}*/
	let v:Vec<i32> = procon_read();
	for i in v {
		a[i as usize] = 1;
	}
	let mut left = 0;
	let mut right = 0;
	for i in 0..x {
		left += a[i as usize];
	}
	for i in (x+1)..(n+1) {
		right += a[i as usize];
	}
	println!("{}", min(left, right));
}

Measured memory_bytes: 4352
function Main(input){
    input = input.split("\n");
    var k = 0;
    while(1){
        input[k] = input[k].split(" ");
        var n = parseInt(input[k][0],10);
        var p = parseInt(input[k][1],10);
        if(n == 0 && p == 0)
            break;

        var temoto = [];

        for(var i = 0;i < n;i++){
            temoto[i] = 0;
        }

        aaa = n;
        for(var i = 0;;i = (i + 1) % n){
            if(p > 0){
                if(temoto[i] == 0)
                    aaa--;
                temoto[i]++;p--;
                if(aaa == n - 1 && p == 0){
                    console.log(i);
                    break;
                }
            }else{
                if(temoto[i] > 0)
                    aaa++;
                p += temoto[i];
                temoto[i] = 0;
            }
        }
        k++;
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 16012
// https://atcoder.jp/contests/abc085/tasks/abc085_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << "2018" << s.substr(4) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

int main(void) {
  int abc[4] = {0};
  std::cin >> abc[0] >> abc[1] >> abc[2];

  std::sort(abc, abc + 3);

  int diffsum = 0;
  diffsum += abc[2] - abc[1];  /* max - mid */
  diffsum += abc[2] - abc[0];  /* max - min */

  int result = 0;
  if (diffsum % 2 == 0) {
    result = diffsum / 2;
  } else {
    result = (diffsum + 3) / 2;
  }

  std::cout << result << std::endl;

  return 0;
}


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

int main(){
  string n, res;
  cin >> n;

  for(int i; i<n.size(); i++){
    if(n.at(i) == '1'){
      n.at(i) = '9';
    } else if(n.at(i) == '9'){
      n.at(i) = '1';
    }
  }

  cout << n << endl;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define double long double
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 998244353;
const i64 INF = 2e15;

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

	int a, b;
  	cin >> a >> b;
  
  	if ( ( a + b) % 2 != 0) cout << "IMPOSSIBLE" << endl;
 	else cout << (a + b) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,m,k,i,j,a,b;
  int d[20];
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    int min=1000001;
    for(i=0;i<n;i++){
      scanf("%d",&d[i]);
    }
    //k=1;
    //for(i=0;i<n;i++)k*=2;
    for(i=0;i<(1<<n);i++){
      a=b=0;
      m=i;
      for(j=0;j<n;j++){
	if(m%2)a+=d[j];
	else   b+=d[j];
	m/=2;
      }
      if(min>abs(a-b)){
	min=abs(a-b);
      }
    }
    printf("%d\n",min);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
mt19937_64 mt(1);//seed
uniform_real_distribution<double> rnd(0.00,1.00);


int main(){
	string s;
	cin >> s;
	ll ans=0,N=s.size();
	vector<ll> r(N+1,0),l(N+1,0); 
	FOR(i,0,N){
		if(s[i]=='<'){
			l[i+1] = l[i]+1;
		}
	}
	FORR(i,0,N){
		if(s[i]=='>'){
			r[i] = r[i+1]+1;
		}
	}
	FOR(i,0,N+1){
		ans += max(r[i],l[i]);
	}
	cout << ans << endl;
}


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

int main() {
  int N, K, ans = 1;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    if((ans + K) < (ans * 2))
      ans += K;
    else
      ans *= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s = input().split()
N = int(s[0])
D = int(s[1])
Vector = []
for i in range(N):
    s = input().split()
    Vector.append(list(map(int,s)))

def distance(vec1,vec2,D):
    ans = 0
    for i in range(D):
        ans = ans + abs(vec1[i]- vec2[i]) * abs(vec1[i] - vec2[i])
    return ans
count = 0
for i in range(N):
    for j in range(i,N):
        dis = distance(Vector[i],Vector[j],D)
        dis = dis**0.5
        if i == j:
            continue
        if abs(dis- int(dis)) < 0.000000000001:
            count = count + 1

print(count)


Measured memory_bytes: 3064
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String x,r;int[]a={0,3,6,9,12,15,19,22},b={3,3,3,3,3,4,3,4},k={46,44,33,63,32};for(int t=s.nextInt(),c,i,p;t-->0;System.out.println(r))for(x=s.next(),r="",i=c=0;i<x.length()-1;)if((p=x.charAt(i))==x.charAt(++i))c++;else{if(p>48)r+=(char)(p<50?k[c%5]:97+(a[p-=50]+c%b[p]));c=0;}}}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
using namespace std;

int main() {
	int N,K;
    cin >> N >> K;
  if(N<=K){
    cout << 0 <<endl;
    return 0;
  }
    vector<long long int> H(N);
    for(int i=0;i<N;i++){
    	cin >> H[i];
    }
    sort(H.begin(),H.end());
    long long int ans=0;
  //  ans = accumulate(H.begin(),H.end()-K,0);//これできなかった
    for(int i=0;i<N-K;i++){
    	ans = ans + H[i];
    }

	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 


fast;
ll n,k,d;
cin>>n>>k;

vector<ll> freq(n+1,0);
for(ll i=0;i<k;i++)
{
    cin>>d;
    for(ll j=0;j<d;j++)
    {
        ll x;
        cin>>x;
        freq[x]++;
    }
}
ll ans=0;
for(ll i=1;i<=n;i++)if(!freq[i])ans++;
    cout<<ans<<endl;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  int ans=0;
  for(int &i:v) {cin>>i;if(i>=k) ans++;}
  cout<<ans<<"\n";
  
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define in freopen("input.txt", "r" ,stdin)
#define out freopen("output.txt", "w" , stdout)
#define ll long long
#define inf 200005
#define fr first
#define  sc second
#define pb push_back
#define p_b pop_back
#define mp make_pair
using namespace std;
int n , k;
int h[100005];
int dp[100005];
int main (){
//in;out;
ios_base::sync_with_stdio(0);
cin >> n >> k;
for (int i = 1;i <= n; i++) {
     cin >> h[i];
}

for (int i = 1; i <= k; i++) {
dp[i] = abs(h[i]-h[1]);
}
for (int i=k+1; i <= n; i++) {
     int f = 1e9;
     for (int j = i-1; j >= i-k; j--) {
        f = min (f , dp[j] + abs(h[i] - h[j]));
     }
     dp[i] = f;
}

cout << dp[n];
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;
typedef tuple<ll,ll,ll> tl;
typedef tuple<ll,ll,ll,ll> ql;

#define FOR(i, a, b) for(ll i=(a); i<=(b); i++)
#define ROF(i, a, b) for(ll i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e pb
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 500+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){
    FAST
    ll grid[MAXN][MAXN];
    bool left[MAXN][MAXN];
    ll n;
    cin >> n;
    FOR(i,1,n){
        FOR(j,1,n){
            ll vert = min(i-1,n-i);
            ll horz = min(j-1,n-j);
            ll minimum = min(vert,horz);
            grid[i][j] = minimum;
            left[i][j] = 0;
        }
    }

    deque<ii> bfs;
    ll ans=0;

    ll c1[4] = {-1, 0, 0, 1};
    ll c2[4] = {0, -1, 1, 0};

    FOR(i,1,n*n){
        ll x;
        cin >> x;
        x--;
        
        ll row = x/n + 1;
        ll col = x%n + 1;

        ans += grid[row][col];
        grid[row][col]--;
        left[row][col] = 1;

        bfs.eb(row,col);
        while (!bfs.empty()){
            ll r = bfs.front().f;
            ll c = bfs.front().s;
            bfs.ppf();

            FOR(j,0,3){
                ll newr = r+c1[j];
                ll newc = c+c2[j];

                if (newr == 0 || newc == 0 || newr > n || newc > n) continue;
                if (grid[r][c] + 1 < grid[newr][newc] && !left[newr][newc]){
                    grid[newr][newc] = grid[r][c] + 1;
                    bfs.eb(newr,newc);
                } else if (left[newr][newc] && grid[r][c] < grid[newr][newc]){
                    grid[newr][newc] = grid[r][c];
                    bfs.ef(newr,newc);
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 7872
import Queue

dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
field = []
H, W = 0, 0
q = Queue.Queue()

def solver(x, y, symbol):
  global q, field, H, W
  while True:
    if x < 0 or y < 0 or x >= H or y >= W:
      continue
    for dx, dy in dxy:
      if x+dx < 0 or y+dy < 0 or x+dx >= H or y+dy >= W:
        continue
      if field[x+dx][y+dy] == symbol:
        field[x+dx][y+dy] = '.'
        q.put([x+dx, y+dy])
    if q.empty():
      return
    x, y = q.get()

while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  field = [list(raw_input()) for i in range(H)]

  ans = 0
  for x in xrange(H):
    for y in xrange(W):
      if field[x][y] != '.':
        solver(x, y, field[x][y])
        ans += 1
  print ans

Measured memory_bytes: 7188
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        long N = sc.nextLong();
        if (N < 10) {
            System.out.println(N);
            return;
        }
        int[][] cnt = new int[10][10];
        for (int i = 1; i <= N; i++) {
            int st = Integer.parseInt(String.valueOf(i).substring(0, 1));
            int ft = i % 10;
            cnt[st][ft]++;
        }
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                ans += (long) cnt[i][j] * cnt[j][i];
            }
        }
        /*
         * int grade = String.valueOf(N).length(); if (N < 10) { System.out.println(N);
         * return; } ans += 9;// 1 for (int g = 1; g <= grade - 1; g++) {// 2<= g
         * <=grade-1 ans += 81L * Math.pow(10, g * 2); } int f1 =
         * Integer.parseInt(String.valueOf(N).substring(0, 1)); ans += f1 * f1 *
         * Math.pow(10, (grade - 2) * 2);
         */
        System.out.println(ans);
    }
}


Measured memory_bytes: 38048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector< vector<int> > A(N, vector<int>(M));
    for(int i=0; i<N; i++) {
        cin >> C[i];
        for(int j=0; j<M; j++) {
            cin >> A[i][j];
        }
    }

    int ans = numeric_limits<int>::max();
    for(int bit=0; bit<(1<<N); bit++) {
        int price = 0;
        vector<int> v(M);
        for(int i=0; i<N; i++) {
            if(bit>>i & 1) {
                price += C[i];
                for(int j=0; j<M; j++) {
                    v[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        for(int j=0; j<M; j++) {
            if(v[j] < X) ok = false;
        }
        if(ok) {
            ans = min(ans, price);
        }
    }

    if(ans == numeric_limits<int>::max()) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main(){
    
    int count_01=0,count_10=0,judge_01=0,judge_10=1;
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++){
        //01
        if((s[i]-'0')!=judge_01){
            count_01++;
        }
        
        //10
        if((s[i]-'0')!=judge_10){
            count_10++;
        }
    
        //change!
        if(judge_01 == 0){
            judge_01=1;
            judge_10=0;
        }else{
            judge_01=0;
            judge_10=1;
        }
    }

    if(count_01<count_10){
        cout << count_01 << endl;
    }else{
        cout << count_10 << endl;
    }
    return 0;
}

Measured memory_bytes: 512
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, m = map(int, input().split())
h = readints()
x = [0]*n
for i in range(n):
    x[i] = []*n
for i in range(m):
    a, b = map(int, input().split())
    #print(a, b)
    x[a-1].append(b)
    x[b-1].append(a)
# print(x)
cnt = 0

for i in range(n):
    y = True
    for j in x[i]:
        #print(i, x[i])
        if h[i]-h[j-1] <= 0:
            y = False
    if y:
        cnt += 1
print(cnt)


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



int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  --X; --Y;
  vector<vector<int>> dist(N, vector<int>(N, 99999));
  REP(i, N) {
    queue<pair<int,int>> q;
    q.push(make_pair(i, 0));
    while(!q.empty()) {
      auto t = q.front();
      q.pop();
      int pos = t.first, d = t.second;
      if(dist[i][pos] <= d)
        continue;
      dist[i][pos] = d;
      if(pos-1 >= 0)
        q.push(make_pair(pos-1, d+1));
      if(pos+1 < N)
        q.push(make_pair(pos+1, d+1));
      if(pos ==  X)
        q.push(make_pair(Y, d+1));
      if(pos == Y)
        q.push(make_pair(X, d+1));
    }
  }
  vector<int> ret(N, 0);
  REP(i,N) {
    for(int j=i+1; j<N; ++j) {
      ret[dist[i][j]]++;
    }
  }
  for(int i=1; i<N; ++i) {
    cout << ret[i] << endl;
  }
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int q;
    cin >> q;
    ll a[q], b[q];
    rep(i, q) {
        cin >> a[i] >> b[i];
    }
    rep(i, q) {
        ll c = a[i] * b[i];
        auto isOK = [&](ll n) { return n * (n + 1) < c; };
        ll ng = INF, ok = 0;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (isOK(mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ll ans = ok * 2;
        if ((ok + 1) * (ok + 1) < c){
            ans++;
            ok++;
        }
        if (a[i] <= ok) ans--;
        if (b[i] <= ok) ans--;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 100000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

ll dp[200005][3];

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1;
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
        dp[i][k]=C[k];
    } 
    return dp[n][k]=C[k]; 
} 

int main()
{
    fio;
    ll n;cin>>n;
    vl a(n);
    f(n)cin>>a[i];
    umpl mp;
    f(n)mp[a[i]]++;
    ll ans=0;
    memset(dp, 0, sizeof(dp)); 
    binomialCoeff(n,2);
    for(auto i=mp.begin();i!=mp.end();i++){
        ans=ans + dp[i->second][2];
    }
    for(ll i=0;i<n;i++){
        ll ele=a[i];
        ll temp=ans;
        temp=temp-dp[mp[a[i]]][2];
        temp=temp+dp[mp[a[i]]-1][2];
        cout<<temp<<"\n";
    }
}



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

void sort(int A[],int n){
	int tmp,t;
	int count=0;
	for(int i=0;i<(n);i++){
		t=i;
		for(int j=i;j<(n);j++){
			if(A[j]<A[t]){
				t=j;
			}
		}
		if(A[t]!=A[i]){
			tmp=A[i];
			A[i]=A[t];
			A[t]=tmp;
			count++;
		}
	}
	for(int i=0;i<n;i++){
		printf("%d",A[i]);
		if(i==(n-1)){
			printf("\n");
		}else{
			printf(" ");
		}
	}
	printf("%d\n",count);
}

int main(){
    int n;
	int *A;

	scanf("%d",&n);
	A=(int*)malloc(sizeof(int)*n);

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

	sort(A,n);	
	return 0;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	string S;
	cin >> S;

	if (S == "SUN") cout << 7 << endl;
	else if (S == "MON") cout << 6 << endl;
	else if (S == "TUE") cout << 5 << endl;
	else if (S == "WED") cout << 4 << endl;
	else if (S == "THU") cout << 3 << endl;
	else if (S == "FRI") cout << 2 << endl;
	else if (S == "SAT") cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;



int n;
const int N=83;
ll a[N];
void solve(){
    cin >> n;
    for(int i=0;i<n;++i)
        cin >> a[i];
    ll ans=1000;
    int  s=0;
    if(s==n) {
        cout << ans << "\n";
        return;
    }
    a[n]=0;
    while(s < n) {
        while(a[s]>=a[s+1]&&s<n)s++;
        if(s==n)break;
        int t=s;
        while(a[t]<=a[t+1]&&t<n)t++;
        if(a[s] < ans) {
            ll sh=ans/a[s];
            ans -= sh * a[s];
            ans += sh * a[t];
        }
        s=t+1;
    }
    cout << ans << "\n";
}





int main(){
    fastio 
    int test=1;
    while(test--)
        solve();
    return 0;
}


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

template <typename T>
void print(const T &v);

int n;
vector<string> ans;

void dfs(string str)
{
    if (str.size() == n)
    {
        ans.push_back(str);
        return;
    }
    char maxi = 'a';
    for (char c : str)
    {
        maxi = max(c, maxi);
    }

    for (char i = 'a'; i <= maxi + 1; i++)
    {
        string tmp = str;
        tmp.push_back(i);
        dfs(tmp);
    }
}

int main()
{
    cin >> n;
    if (n == 1)
    {
        cout << 'a' << endl;
        return 0;
    }
    dfs("a");
    sort(ans.begin(), ans.end());
    for (string a : ans)
    {
        cout << a << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
};

Measured memory_bytes: 7336
import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 50740
#include<cstdio>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=200005;
int n,p[N],pmx,q,pos[2],len[2],f[N][2]; bool tp[N];
class Segment_Tree
{
	private:
		int mx[N<<2];
	public:
		#define TN CI now=1,CI l=1,CI r=n
		#define LS now<<1,l,mid
		#define RS now<<1|1,mid+1,r
		inline void modify(CI pos,CI mv,TN)
		{
			if (l==r) return (void)(mx[now]=mv); int mid=l+r>>1;
			if (pos<=mid) modify(pos,mv,LS); else modify(pos,mv,RS);
			mx[now]=max(mx[now<<1],mx[now<<1|1]);
		}
		inline int query(CI beg,CI end,TN)
		{
			if (beg<=l&&r<=end) return mx[now]; int mid=l+r>>1,ret=0;
			if (beg<=mid) ret=max(ret,query(beg,end,LS));
			if (end>mid) ret=max(ret,query(beg,end,RS)); return ret;
		}
		#undef TN
		#undef LS
		#undef RS
}T0,T1;
inline bool check(CI x,CI lim)
{
	if (lim<0) return 0; if (lim&1) return T1.query(x,n)>=lim; else return T0.query(x,n)>=lim;
}
int main()
{
	RI i; for (scanf("%d",&n),i=1;i<=n;++i)
	if (scanf("%d",&p[i]),pmx=max(pmx,p[i]),p[i]==pmx) ++q,tp[i]=1;
	for (i=n;i;--i)
	{
		int c0=T0.query(p[i],n),c1=T1.query(p[i],n);
		f[i][(c0+tp[i]+1)&1]=max(f[i][(c0+tp[i]+1)&1],c0+tp[i]+1);
		f[i][(c1+tp[i]+1)&1]=max(f[i][(c1+tp[i]+1)&1],c1+tp[i]+1);
		T0.modify(p[i],f[i][0]); T1.modify(p[i],f[i][1]);
	}
	if (!check(1,q)) return puts("-1"),0;
	for (i=1;i<=n;++i)
	{
		T0.modify(p[i],0); T1.modify(p[i],0); q-=tp[i];
		int x=p[i]>p[pos[0]]?i:pos[0],y=len[0]+(x==i);
		if (check(p[x],len[1]-y+q)||check(p[pos[1]],y-len[1]+q))
		pos[0]=x,len[0]=y,putchar('0'); else
		pos[1]=(p[i]>p[pos[1]]?i:pos[1]),len[1]+=pos[1]==i,putchar('1');
	}
	return 0;
}

Measured memory_bytes: 10256
#include<stdio.h>


int main()
{
  int N,a,b,c;
  int sum[1000];
    
   
    scanf("%d",&N);
    
    for(a=0;a<N;a++)
    {
      scanf("%d",&sum[a]);
    }
    for(a=0;a<N;a++){
      b=sum[a];
      c=a-1;
      while(c>=0 && sum[c]>b)
	{
	  sum[c+1]=sum[c];
	  c--;
	}
      sum[c+1]=b;
      for(c=0;c<N-1;c++)
	{
	  
	  printf("%d ",sum[c]);
	 
	}
      printf("%d",sum[c]);
      printf("\n");
    }
    
   
    
    return 0;
}


Measured memory_bytes: 2056
MOD = 2019

L, R = map(int, input().split())

if R - L >= 2018 or R % MOD <= L % MOD:
    print(0)
else:
    ans, LM, RM = 2019, L % MOD, R % MOD
    for i in range(LM, RM):
        for j in range(i + 1, RM + 1):
            ans = min(ans, (i * j) % MOD)
    print(ans)


Measured memory_bytes: 2940
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)

	fr := make(map[rune]bool)
	for _, ch := range s {
		fr[ch] = true
	}

	if len(fr) == 1 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    S = Scanner.string()
    ans = S.count('R') * S.count('G') * S.count('B')
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            k = 2 * j - i
            if k >= N:
                continue
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 78868
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int H,W;
	in(H,W);
	auto s = mv<string>(H);
	in(s);
	int ans = 0;
	auto bfs = [&](int sy,int sx)->int{
		auto dist = mv(H,W);
		fill(dist,INF);
		dist[sy][sx]=0;
		queue<pair<int,int>>st;
		st.push({sy,sx});
		int dx[] = {1,0,-1,0};
		int dy[] = {0,1,0,-1};
		while(st.size()){
			int i = st.front().first;
			int j = st.front().second;
			st.pop();
			REP(k,4){
				int ni = i + dy[k];
				int nj = j + dx[k];
				if(!IN(0,ni,H))continue;
				if(!IN(0,nj,W))continue;
				if(s[ni][nj] == '#')continue;
				if(dist[ni][nj]!=INF)continue;
				dist[ni][nj] = dist[i][j] + 1;
				st.push({ni,nj});
			}
		}
		int ret = -INF;
		REP(i,H)REP(j,W)if(dist[i][j]!=INF)CHMAX(ret,dist[i][j]);
		return ret;
	};
	REP(i,H)REP(j,W){
		if(s[i][j] == '#')continue;
		CHMAX(ans,bfs(i,j));
	}
	out(ans);
}

Measured memory_bytes: 256
import math
l1 , l2 ,hour, minute  = map(int,input().split())

minuteAngel = (float(minute)*360)/60
hourAngel = (float(hour)%12)*30 + (float(minute)*30)/60
angel = abs(hourAngel - minuteAngel)

tmp = l1**2 + l2**2 - 2 * l1 * l2 * math.cos(math.radians(angel))

print(math.sqrt(tmp))

Measured memory_bytes: 9448
#include <stdio.h>

int main(void)
{
	int ans=0,a,i,M,D;
	scanf("%d%d",&M,&D);
	
	if(D>21)
	{
		for(i=0;i<M;i++)
		{
			for(a=21;a<D;a++)
			{
				if(((a+1)/10)*((a+1)%10)==i+1 && (a+1)/10 >=2 && (a+1)%10>=2)
				{
					ans++;
				}
			
			}
		}
	}
	
	printf("%d",ans);
	
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int t,n,mx,mn,r,x,m=0;
    scanf("%d%d",&m,&n);
        if(n>m)
            {
                mx=n;
                mn=m;
            }
        else
            {
                mx=m;
                mn=n;
            }
        for( t=0 ; t<mx ; t++ )
            printf("%d",mn);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll S, W; cin >> S >> W;
    string ans = "safe";
    if (S <= W) ans = "unsafe";
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

const int NMAX = 3100;
int dp[NMAX][NMAX] = {};

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

    string s, t; cin >> s >> t;

    for(int i=0; i<(int)s.size(); ++i){
        for(int j=0; j<(int)t.size(); ++j){
            if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
            chmax(dp[i+1][j+1], dp[i][j+1]);
            chmax(dp[i+1][j+1], dp[i+1][j]);
        }
    }

    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while(0<i && 0<j){
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res += s[i-1];; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }

    reverse(res.begin(), res.end());
    cout << res << endl;

	return 0;
}


Measured memory_bytes: 37120
#include<stdio.h>
#include<string.h>
int main()
{
    int l,i,j,cnt=0,arrcnt[1000]={0};
	char str[10000];
	scanf("%s",str);
	l=strlen(str);
	for(i=0;i<l;i++)
    {

        arrcnt[str[i]-97]++;
    }
    	for(i=0;i<26;i++)
    {

       if(arrcnt[i]%2!=0)
       {
           printf("No\n");
           return 0;
       }
    }
    printf("Yes\n");
    return 0;

}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int a[2000];


int main()
{
    int n;scanf("%d",&n);
    for (int i=0;i<n;++i) scanf("%d",&a[i]);
    int ans=0;
    for (int i=0;i<n;++i)
        for (int j=i+1;j<n;++j)
         ans+=a[i]*a[j];
    printf("%d\n",ans);


}


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

int main(){
  int n;
  cin >>n;
  vector<vector<int>> a(2,vector<int>(n));
  rep(i,2) rep(j,n) cin >> a.at(i).at(j);
  
  int ans=0;
  for(int i=0;i<n;i++){
    int cnt=0;
    for(int j=0;j<=i;j++) cnt += a.at(0).at(j);
    for(int j=i;j<n;j++) cnt += a.at(1).at(j);
    ans = max(ans,cnt);
  }
  
  cout << ans << endl;
      
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    string s;
    cin >> s;
    char c_stone = s[0];
    int count = 0;

    for(int i=0; i<s.size()-1; i++) {
        char n_stone = s[i+1];
        if(c_stone != n_stone) {
            c_stone = n_stone;
            count++;
        }
    }
    cout<< count << endl;
}

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

int main() {
  string S;
  cin >> S;
  int ans = S.size();
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '-') ans -= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool b=0;
void dfs(int X){
  if(X==100) {b=1;return;}
  else if(X==101) {b=1;return;}
  else if(X==102) {b=1;return;}
  else if(X==103) {b=1;return;}
  else if(X==104) {b=1;return;}
  else if(X==105) {b=1;return;}
 
  if(X<100) return;
  dfs(X-100);
  dfs(X-101);
  dfs(X-102);
  dfs(X-103);
  dfs(X-104);
  dfs(X-105);
}
int main(){
  int X;
  cin>>X;
  int a[X+1];
  memset(a,0,sizeof a);
  for(int i=100;i<=105;i++) a[i]=1;
  for(int i=200;i<=X;i++){
    if(a[i-100]) a[i]=1;
    else if(a[i-101]) a[i]=1;
    else if(a[i-102]) a[i]=1;
    else if(a[i-103]) a[i]=1;
    else if(a[i-104]) a[i]=1;
    else if(a[i-105]) a[i]=1;
  }
  cout<<a[X];
}

Measured memory_bytes: 640
#include<iostream>
#include<queue>
using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);
int n, M[N][N];
int d[N];
void bfs(int s) {
	queue<int>q;
	q.push(s);
	for (int i = 0; i < n; i++)d[i] = INFTY;
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u = q.front(); q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0)continue;
			if (d[v] != INFTY)continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
	}
}
int main() {
	int u, k, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	bfs(0);
	return 0;
}

Measured memory_bytes: 3108
import java.util.*;
import java.io.*;
public class Main {
    static long mod = (long) Math.pow(10, 9) + 7;
    public static void main(String[] args) {
        FastScanner f = new FastScanner(System.in);
        int a1 = f.nextInt();
        int a2 = f.nextInt();
        int a3 = f.nextInt();
        if((a1 + a2 + a3) >= 22)
            pn("bust");
        else
            pn("win");
    }
        
/******************************END OF MAIN PROGRAM*******************************************/
    // Fast Scanner Alternative of Scanner 
    // Uses Implementation of BufferedReader Class
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new
                    InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
    
    // Print in console
    static void pn(Object o){System.out.println(o);}
    static void p(Object o){System.out.print(o);}
    static void pni(Object o){System.out.println(o);System.out.flush();}

    //GCD of two integers
    static int gcd(int a, int b) {
        if(b == 0) return a;
        else {
            return gcd(b, a % b);
        }
    }

    // GCD of a array of integers
    static int gcdarray(int a[]) {
        int res = a[0];
        for(int i = 1; i < a.length; i++) {
            res = gcd(a[i] , res);
        }
        return res;
    }
    
    // Return boolean sieve of first n prime nos.
    static boolean[] sieve(int n) {
        boolean isprime[] = new boolean[n + 1];
        for(int i = 0; i <= n;++i) {
            isprime[i] = true;
        }
        isprime[0] = false;
        isprime[1] = false;
        for(int i = 2; i * i <= n; ++i) {
             if(isprime[i] == true) {               
                 for(int j = i * i; j <= n;j += i)
                     isprime[j] = false;
            }
        }
        return isprime;
    }

    // Return HashSet of factors of a number
    static HashSet<Long> factors(long n) {
        HashSet<Long> hs = new HashSet<Long>();
        for(long i = 1; i <= (long)Math.sqrt(n); i++) {
            if(n % i == 0) {
                hs.add(i);
                hs.add(n / i);
            }
        }
        return hs;
    }

    //Is n prime ?
    static boolean isPrime(int n) {
        if(n == 1) return false;
        int i = 2;
        while((i * i) <= n) {
            if(n % i == 0) return false;
            i += 1;
        }
        return true;
    }
}

Measured memory_bytes: 20820
let input = require('fs').readFileSync( '/dev/stdin', 'utf8' );
let arr = input.split("\n");
for (let i = 0; i < arr.length; i++) {
    let Arr = arr[i].split(" ").map(Number);
    let H = Arr[0];
    let W = Arr[1];
    if (H === 0 && W === 0) break;
    let str = '';
    for (let i = 0; i < H; i ++) {
        for (let i = 0; i < W; i ++) {
            str += '#';
        }
        str += '\n';
    }
    console.log(str);
}


Measured memory_bytes: 18964