akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.NoSuchElementException;
public class Main {
	private static final PrintStream ps = System.out;
	private static final InputStream IS = System.in;
	private static final byte[] BUFFER = new byte[1024];
	private static int ptr = 0;
	private static int buflen = 0;

	public static void main(String[] args) {
		int n = ni();
		int[] a = new int[n+2];
		
		for (int i = 1; i <= n; i++) {
			a[i] = ni();
		}
		
		int change = 0;
		int i = 1;
		while (i <= n) {
			if (a[i] == i) {
				change++;
				a[i] = 0;
				if (a[i+1] == i+1) {
					a[i+1] = 0;
				}
			}
			i++;
		}
		ps.println(change);
	}

	private static boolean hasNextByte() {
		if (ptr < buflen)
			return true;
		else {
			ptr = 0;
			try {
				buflen = IS.read(BUFFER);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0)
				return false;
		}
		return true;
	}

	private static int readByte() {
		if (hasNextByte())
			return BUFFER[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public static boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(BUFFER[ptr]))
			ptr++;
		return hasNextByte();
	}

	public static String n() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public static long nl() {
		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 static int ni() {
		long nl = nl();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public static double nextDouble() {
		return Double.parseDouble(n());
	}

	private static int[] nia(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
int n,i,j,l,k,s,x,y,z,c;
long long b[200];
int main(){
  for(cin>>n;i<n;i++)cin>>b[i];
  while(true){
    for(i=0;i<n;i++){
      if(b[i]%2==1)return cout<<j,0;
      b[i]/=2;
    }
    j++;
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    ll ans = A.back();

    for (int i = 0; i < N; ++i) {
        if (A[i] > i) goto END;
    }

    for (int i = N - 1; i > 0; --i) {
        if (A[i] - 1 > A[i-1]) {
            goto END;
        } else if (A[i] - 1 < A[i-1]) {
            ans += A[i-1];
        }
    }
    cout << ans << "\n";
    return 0;
    END:
    cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstring>
using namespace std;
const int M = 2e3 + 10;
int dprow[M][M] , dpcow[M][M] , a[M][M] , sum[M][M];
char mmp[M][M];
int main() {
    int n , m , q;
    cin >> n >> m >> q;
    memset(dprow , 0 , sizeof(dprow));
    memset(dpcow , 0 , sizeof(dpcow));
    memset(a , 0 , sizeof(a));
    memset(sum , 0 , sizeof(sum));
    for(int i = 1 ; i <= n ; i++) {
        cin >> mmp[i];
    }
    for(int i = 1 ; i <= n ; i++) {
        for(int j = 1 ; j <= m ; j++) {
            a[i][j] = mmp[i][j - 1] - '0';
        }
    }
    for(int i = 1 ; i <= n ; i++) {
        for(int j = 1 ; j <= m ; j++) {
            sum[i][j] = a[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
            dpcow[i][j] = dpcow[i - 1][j] + dpcow[i][j - 1] - dpcow[i - 1][j - 1];
            dprow[i][j] = dprow[i - 1][j] + dprow[i][j - 1] - dprow[i - 1][j - 1];
            if(a[i][j] == 1) {
                if(a[i - 1][j] == 1) dpcow[i][j]++;
                if(a[i][j - 1] == 1) dprow[i][j]++;
            }
        }
    }
    while(q--) {
        int x1 , y1 , x2 , y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int ans = sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
        ans -= (dpcow[x2][y2] - dpcow[x1][y2] - dpcow[x2][y1 - 1] + dpcow[x1][y1 - 1]);
        ans -= (dprow[x2][y2] - dprow[x2][y1] - dprow[x1 - 1][y2] + dprow[x1 - 1][y1]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 68864
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, sum, a[3100], b[3100];
string str;
bool f[1100];
char c;
int main() {
	cin >> str;
	rep(i, str.size() - 1) {
		if (str[i] == 'B'&&str[i + 1] == 'C') {
			ans += cnt;
			i = i + 1;
		}
		else if (str[i] == 'A')cnt++;
		else cnt = 0;
	}
	cout << ans << endl;
	return 0;
}


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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }


int main()
{
int N, K;
cin >> N >> K;
int R, S, P; //　グー、チョキ、パー
cin >> R >> S >> P;
string T; // r: グー　s:チョキ p:パー
cin >> T;

ll dp[N + 1][3];
dp[0][0] = dp[0][1] = dp[0][2] = 0;
vector<bool>flag(N + 1, true);

for(int i = 1; i <= N; i++){
  ll m = max(dp[i - 1][0], max(dp[i - 1][1], dp[i - 1][2]));
  dp[i][0] = dp[i][1] = dp[i][2] = m;
  // print(m);
  if(K < i){
  
  if(T[i - 1] == 's') {
    if(T[i - K - 1] != 's' || flag[i - K]) {
      dp[i][0] += R;
      flag[i] = false;
    }
  }
  
  if(T[i - 1] == 'p') {
    if(T[i - K - 1] != 'p' || flag[i - K]) {
      dp[i][1] += S;
      flag[i] = false;
    }
  }
  if(T[i - 1] == 'r') {
    if(T[i - K - 1] != 'r' || flag[i - K]) {
      dp[i][2] += P;
      flag[i] = false;
    }
  }

  

  }else{

  if(T[i - 1] == 's') {
    dp[i][0] += R;
    flag[i] = false;
  }
  
  if(T[i - 1] == 'p') {
    dp[i][1] += S;
    flag[i] = false;
  }
  
  if(T[i - 1] == 'r') {
    dp[i][2] += P;
    flag[i] = false;
  }
  
  
  }
}

ll ans = max(dp[N][0],max(dp[N][1], dp[N][2]));
print(ans);
}

Measured memory_bytes: 2816
import bisect

INF = 1000000000000
A, B, Q = [int(x) for x in input().split()]
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]

def solve(x):
    sr = s[bisect.bisect_left(s, x)]
    sl = s[bisect.bisect_right(s, x) - 1]
    tr = t[bisect.bisect_left(t, x)]
    tl = t[bisect.bisect_right(t, x) - 1]
    
    a = max(abs(x - sl), abs(x - tl))
    b = max(abs(x - sr), abs(x - tr))
    c = min(abs(x - sl) + abs(sl - tr), abs(x - tl) + abs(tl - sr));
    d = min(abs(x - sr) + abs(sr - tl), abs(x - tr) + abs(tr - sl));
    return min(a, b, c, d)

for _ in range(Q):
    x = int(input())
    ans = solve(x)
    print(ans)



Measured memory_bytes: 12824
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,count=0;
	cin >> n;
	map <string, int> db;
	string s;
	while (n--) {
		cin>>s;
		if (db.count(s) == 0)
		{
			count++;
			db[s] += 1;
		}
	}
	cout<<count<<endl;
	return 0;
}

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

int main()
{

        int h,n;
        cin >> h>> n;
        int total = 0;
        for(int i = 0; i < n;i++)
        {       
                int a;
                cin >> a;
                total += a;
        }
        if(h <= total)
        {
                cout << "Yes" << endl;
        }
        else if(h>total)
        {
                cout << "No" << endl;
        }

}


Measured memory_bytes: 256
//https://beta.atcoder.jp/contests/abc105/tasks/abc105_b
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    bool can_buy = false;
    for(int i=0;i<=N/4;i++){
        for(int j=0;j<=N/7;j++){
            if(N == 4*i + 7*j) can_buy = true;
        }
    }
    if(can_buy) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

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

	long long n, a, b;
	cin >> n >> a >> b;

	if(n == 1) {
		if(a == b) {
			cout << 1 << '\n';
		}
		else {
			cout << 0 << '\n';
		}
		return 0;
	}

	if(b < a) {
		cout << 0 << '\n';
		return 0;
	}

	long long ans = b * (n - 2) - a * (n - 2) + 1;
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll x; cin>>x;
	ll p[401];
	for(ll i=0; i<=400; i++){
		ll a=i-200;
		p[i]=a*a*a*a*a;
	}
	for(int i=0; i<=400; i++){
		for(int j=0; j<=400; j++){
			if(p[j]-p[i]==x){
				cout<<j-200<<" "<<i-200<<endl;
				return 0;
			}
		}
	}
	return 0;
}


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

using namespace std;


int main(void)
{
	int r;

	cin >> r;

	if (r < 1200)
		cout << "ABC" << endl;
	else if (r < 2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(){
  int bun,index = 65,n,i,alp[26] = {0};
  scanf("%d",&bun);
  while((bun = getchar()) != EOF){
    if(isalpha(bun)){
    bun = tolower(bun);
      i = bun - 97;
      alp[i] ++;
    }else if(isspace){
    }else{
      break;
    }
  }
  for(n = 0;n < 26;n++){
    printf("%c : %d\n",index+n+32,alp[n]);
  }
  return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

char s[1005][1005];
int dp[1005][1005];
int dx[] = {-1, 0};
int dy[] = {0, -1};
int h, w;

bool check(int x, int y) {
    if (x >= 1 && x <= h && y >= 1 && y <= w) return true;
    return false;
}

int main() {
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++) scanf("%s", s[i] + 1);

    dp[1][1] = 1;
    int x, y;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            for (int k = 0; k < 2; k++) {
                x = i + dx[k];
                y = j + dy[k];
                if (check(x, y) && s[x][y] == '.') dp[i][j] = (dp[i][j] + dp[x][y]) % MOD;
            }
        }
    }

    printf("%d\n", dp[h][w]);
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pair pair<int,int>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	vector<vector<int>> a(510,vector<int>(510));
	rep(i,h){
		rep(j,w){
			cin >> a[i][j];
		}
	}
	int n=0;
	vector<pair> b;
	vector<pair> f;
	rep(i,h){
		rep(j,w){
			if(a[i][j]%2==1){
				if(j==w-1 && i==h-1){
					break;
				}
				else if(j==w-1){
					f.pb(mp(i+1,j+1));
					b.pb(mp(i+2,j+1));
					a[i+1][j]++;
					n++;
				}
				else{
					f.pb(mp(i+1,j+1));
					b.pb(mp(i+1,j+2));
					a[i][j+1]++;
					n++;
				}
			}
		}
	}
	cout << n << endl;
	rep(i,n) cout << f.at(i).first << " " << f.at(i).second << " " << b.at(i).first << " " << b.at(i).second << endl;
}

Measured memory_bytes: 5276
#include<iostream>
#include<vector>
#include<set>
using namespace std;

#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;

void bfs(int current, int prev) {
    //ノードcurrentを訪問した直後の処理
    prenum[current] = lowest[current] = timer;
    timer++;
    
    visited[current] = true;
    
    int next;
    
    for(int i = 0; i < G[current].size(); i++) {
        next = G[current][i];
        if(!visited[next]) {
            //ノードcurrentからノードnextへ訪問する直前の処理
            parent[next] = current;
            bfs(next, current);
            
            //ノードnextの探索が終了した直後の処理
            lowest[current] = min(lowest[current], lowest[next]);
        }else if(next != prev) {
            //エッジcurrent-->nextがBack-edgeの場合の処理
            lowest[current] = min(lowest[current], prenum[next]);
        }
    }
    //ノードcurrentの探索が終了した直後の処理
}

void art_points() {
    for(int i = 0; i < N; i++) visited[i] = false;
    timer = 1;
    //lowestの計算
    bfs(0, -1); //0 == root
    
    set<int> ap;
    int np = 0;
    for(int i = 1; i < N; i++) {
        int p = parent[i];
        if(p == 0) np++;
        else if(prenum[p] <= lowest[i]) ap.insert(p);
    }
    
    if(np > 1) ap.insert(0);
    for(set<int>::iterator it = ap.begin(); it != ap.end(); it++)
        cout << *it << endl;
}

int main() {
    int m;
    cin >> N >> m;
    
    for(int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    art_points();
    
    return 0;
}


Measured memory_bytes: 6828
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mt make_tuple
#define eb emplace_back
#define INF 1e9
#define PI 3.141592653589793238
#define EPS 1e-9
ll modexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b&1) res = (res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
int ck(string str)
{
	if(str.size()&1) return 0;
	int n = str.size();
	int i;
	string str1,str2;
	str1 = str.substr(0,n/2);
	str2 = str.substr(n/2);
	return str1 == str2;
}
int main()
{
	string str;
	cin>>str;
	while(1)
	{
		str = str.substr(0,str.size()-1);
		if(ck(str))
		{
			cout<<str.size()<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
loop do
  h, w = gets.chomp.split.map(&:to_i)
  break if [h, w].all?(&:zero?)

  tile_map = Array.new
  tile_already_arrived = Array.new

  h.times do
    tile_map << gets.chomp.split('')
    tile_already_arrived << Array.new(w, false)
  end

  x = y = 0

  while true
    if tile_already_arrived[y][x] == true
      goal = "LOOP"
      break
    else
      tile_already_arrived[y][x] = true
      case tile_map[y][x]
      when '>' 
        x += 1
      when '<'
        x -= 1
      when 'v'
        y += 1
      when '^'
        y -= 1
      when '.'
        goal = "#{x} #{y}"
        break
      end
    end
  end

  puts goal
end

Measured memory_bytes: 6896
#include<stdio.h>
int main(void){
    int i,a,b,x;
    for(i=0;i<10000;i++){
        scanf("%d%d",&a,&b);
        if(a>b){
            x=a;
            a=b;
            b=x;
        }
        if(a==0&&b==0)
        break;
        printf("%d %d\n",a,b);
    }
    return 0;
}


Measured memory_bytes: 2012
def isRect(data,dic):
  for d in dic.items():
    isValid=True
    for i in xrange(d[1][0],d[1][2]+1):
      for j in xrange(d[1][1],d[1][3]+1):
        if not (data[i][j]==d[0] or data[i][j]=="*") :
          isValid=False
    if isValid: return d[0]
  return "-"

def checker(data,dic):
  while len(dic)>0:
    r=isRect(data,dic)
    if r=="-":
      print "SUSPICIOUS"
      return
    else:
      for i in xrange(dic[r][0],dic[r][2]+1):
        for j in xrange(dic[r][1],dic[r][3]+1):
          data[i][j]="*"
      del dic[r]
  print "SAFE"


T=int(raw_input())
for _ in xrange(T):
  H,W=map(int,raw_input().split())
  data=[["-"]*W for _ in xrange(H)]
  dic={}
  for i in xrange(H):
    s=raw_input()
    for j in xrange(W):
      data[i][j]=s[j]
      if s[j] not in dic:
        dic[s[j]]=(i,j,i,j)
      else:
        dic[s[j]]=(min(dic[s[j]][0],i),min(dic[s[j]][1],j),max(dic[s[j]][2],i),max(dic[s[j]][3],j))
  checker(data, dic)

Measured memory_bytes: 6404
n=int(input())
M=0
m=0
a_list=[]
for i in range(n):
    a=int(input())
    a_list.append(a)
    if a>M:
        temp=M
        M=a
        m=temp
    else:
        if a>m:
            m=a
for i in range(n):
    if a_list[i]==M:
        print(m)
    else:
        print(M)


Measured memory_bytes: 68952
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n,m;
    cin>>n>>m;
    (n<=m)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

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

typedef long long ll;
typedef pair <int , int> pii;

const int N = 2e5+10 , mod = 1e9+7 , M = 1e6 + 10;

int cnt[M];
bool mark[M];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   for(int i = 0 ; i < n ; i++){
      int x;
      cin >> x;
      cnt[x]++;
   }
   int ans = 0;
   for(int i = 1 ; i < M ; i++){
      if(cnt[i]){
         int st = 2 * i;
         if(cnt[i] > 1)
            st = i;
         for(int j = st ; j < M ; j += i)
            mark[j] = true;
      }
      if(!mark[i])
         ans += cnt[i];
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 8520
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int MOD=1000000007;

ll fac[5005];
long long qexp(long long b,long long p,int m){
    long long res=1;
    while (p){
        if (p&1) res=(res*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return res;
}

ll fix(ll i){
	while (i<0) i+=MOD;
	while (MOD<=i) i-=MOD;
	
	return i;
}

int n;
vector<int> al[5005];
bool vis[5005];

int idx=0;
int w[5005];
ll memo[5005][5005];

int dfs(int i,int p){
	int res=1;
	
	vis[i]=true;
	
	for (auto &it:al[i]){
		if (it==p) continue;
		
		if (vis[it]) res=-1;
		else{
			int temp=dfs(it,i);
			
			if (temp==-1) res=-1;
			else if (res!=-1) res+=temp;
		}
	}
	
	return res;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	fac[0]=1;
	rep(x,1,5005) fac[x]=fac[x-1]*x%MOD;
	
	cin>>n;
	
	int keychain=0;
	rep(x,1,n+1){
		int t;
		cin>>t;
		
		if (t!=-1){
			al[x].push_back(t);
			al[t].push_back(x);
		}
	}
	
	rep(x,1,n+1){
		if (!vis[x]){
			int temp=dfs(x,-1);
			//cout<<temp<<endl;
			if (temp!=-1) w[idx++]=temp;
			else keychain++;
		}
	}
	
	ll comps=keychain*qexp(n-1,idx,MOD)%MOD;
	
	rep(x,0,idx+1) memo[x][0]=1;
	rep(x,0,idx){
		rep(y,1,idx+1){
			memo[x+1][y]=(memo[x][y]+memo[x][y-1]*w[x])%MOD;
		}
	}
	
	rep(x,0,idx){
		comps=(comps+(w[x]-1)*qexp(n-1,idx-1,MOD))%MOD;
	}
	
	if (idx) rep(x,2,idx+1){
		comps=(comps+memo[idx][x]*fac[x-1]%MOD*qexp(n-1,idx-x,MOD))%MOD;
	}
	
	//cout<<comps<<endl;
	cout<<fix(n*qexp(n-1,idx,MOD)%MOD-comps)<<endl;
}


Measured memory_bytes: 199348
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

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

    int q;
    cin >> q;
    bool prime[100001] = {false};
    int sum[100002] = {0};
    repi(i, 100000 + 1, 2)
    {
        if (!prime[i])
        {
            for (int j = i + i; j <= 100000; j += i)
            {
                prime[j] = true;
            }
        }
    }
    for (int i = 3; i <= 100000; i += 2)
    {
        if (!prime[i] && !prime[(i + 1) / 2])
            sum[i]++;
    }
    repi(i, 100000 + 1, 3)
    {
        sum[i + 1] += sum[i];
    }
    repi(ri, q, 0)
    {
        int r, l;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 1152
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
    const numbers = line.split(' ').map(Number);

    // Edit from here
    let a = numbers[0];
    let b = numbers[1];

    if ( a === 0 && b === 0 ) { break; }

    if ( a > b ) {
        const tmp = a;
        a = b;
        b = tmp;
    } 

    const output = a + ' ' + b;
    // to here
    
    console.log(output);
    
}


Measured memory_bytes: 19100
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int s, w;
  cin >> s >> w;
  if(s > w) cout << "safe" << endl;
  if(s <= w) cout << "unsafe" << endl;
  return 0;
}
//templete by private_yusuke

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

using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

const int MAX = 100005;

bool is_prime[MAX];
int similar_count[MAX];

/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  REPS(i,2,MAX) is_prime[i] = true;
  for(int i = 2; i < MAX; ++i) {
    if(is_prime[i]) {
      for(int j = i+i; j <= MAX; j+= i) is_prime[j] = false;
    }
  }
  for(int i = 3; i < MAX; i+=2) {
    if(is_prime[i] && is_prime[(i+1)/2]) ++similar_count[i];
  }
  for(int i = 4; i < MAX; ++i) similar_count[i] += similar_count[i-1];
  int ans[n];
  REP(i,n) {
    int l,r;
    cin >> l >> r;
    ans[i] = similar_count[r] - similar_count[l-1];
  }
  REP(i,n) {
    cout << ans[i] << endl;
  }
  return 0;
}
/***** MAIN *****/


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

int n,k,a=1;

int main () {
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        if(a+k<2*a){
            a+=k;
        }
        else{
             a=a*2;
        }
        }
    cout<<a<<endl;
}


Measured memory_bytes: 3656
N, M = map(int,input().split())
check_lis = [-1 for _ in range(N)]
for _ in range(M):
    s,c = map(int,input().split())
    if check_lis[s-1] == -1:
        check_lis[s-1] = c
    else:
        if check_lis[s-1] != c:
            print('-1')
            break
    if check_lis[0] == 0 and N != 1:
        print('-1')
        break
else:
    min_range = 10 ** (N-1)
    max_range = 10 * min_range
    if min_range == 1:
        min_range = 0
    for i in range(min_range, max_range):
        for idx, check in enumerate(check_lis):
            if check == -1:
                continue
            if (i // 10 ** (N - idx - 1)) % 10 != check:
                break
        else:
            print(i)
            break

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

typedef long long ll;

void make_sum(vector<ll>& v, vector<ll>& s){
    s.push_back(0);
    for(int i = 0; i < v.size(); ++i){
        s.push_back(s[i] + v[i]);
    }
    
    return;
}

void debug(vector<ll>& s){
    for(int i = 0; i < s.size(); ++i){
        cerr << s[i] << " ";
    }
    cerr << "\n";
    
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    for(int i = 0; i < n; ++i){
        cin >> w[i] >> v[i];
    }
    if(W < w[0]){
        cout << 0 << endl;
        return 0;
    }
    
    vector<ll> w0, w1, w2, w3;
    for(int i = 0; i < n; ++i){
        if(w[i] == w[0]){
            w0.push_back(v[i]);
        }
        else if(w[i] == w[0] + 1){
            w1.push_back(v[i]);
        }
        else if(w[i] == w[0] + 2){
            w2.push_back(v[i]);
        }
        else{
            w3.push_back(v[i]);
        }
    }
    sort(w0.begin(), w0.end(), greater<ll>());
    sort(w1.begin(), w1.end(), greater<ll>());
    sort(w2.begin(), w2.end(), greater<ll>());
    sort(w3.begin(), w3.end(), greater<ll>());
    
    vector<ll> sum0, sum1, sum2, sum3;      // 累積和用
    make_sum(w0, sum0);
    make_sum(w1, sum1);
    make_sum(w2, sum2);
    make_sum(w3, sum3);

    ll res = 0;
    for(int a = 0; a < sum0.size(); ++a){
        ll weight0 = w[0] * a;
        if(weight0 > W)      continue;
        
        for(int b = 0; b < sum1.size(); ++b){
            ll weight1 = weight0 + (w[0] + 1) * b;
            if(weight1 > W)     continue;
            
            for(int c = 0; c < sum2.size(); ++c){
                ll weight2 = weight1 + (w[0] + 2) * c;
                if(weight2 > W)     continue;
                
                for(int d = 0; d < sum3.size(); ++d){
                    ll weight3 = weight2 + (w[0] + 3) * d;
                    if(weight3 > W)     continue;
                    
                    res = max(res, sum0[a] + sum1[b] + sum2[c] + sum3[d]);
                }
            }
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector <long long int, long long int> 
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int MAX = 1e5 + 5;
ll fact[MAX], invf[MAX], f[MAX], pre[MAX];
ll n, k;
ll modmul(ll x, ll y)
{
	x = (x + MOD) % MOD;
	y = (y + MOD) % MOD;
	ll res = x * y;
	return(res >= MOD ? res % MOD: res);
}
ll power(ll x, ll y)
{
	ll res = 1;
	x = x % MOD;
	while(y){
		if(y & 1)
		res = modmul(res, x);
		y >>= 1;
		x = modmul(x, x);
	}
	return res;
}
void preprocess()
{
	ll i;
	fact[0] = 1;
	invf[0] = 1;
	for(i = 1; i < MAX; i++){
		fact[i] = (fact[i - 1] * i) % MOD;
		invf[i] = power(fact[i], MOD - 2);
	}
	fo(i, 0, MAX)
	f[i] = (i - k + 2 >= 0 && k >= 2 ? modmul(fact[i], modmul(invf[k - 2], invf[i - k + 2])) : 0);
}
int main()
{
	boost;
	ll i;
	cin >> n >> k;
	preprocess();
	ll arr[n + 1];
	foe(i, 1, n)
	cin >> arr[i];
	sort(arr + 1, arr + n + 1, greater <int>());
	pre[0] = f[0];
	foe(i, 1, n)
	pre[i] = (pre[i - 1] + f[i]) % MOD;
	ll ans = 0, strt, en;
	foe(i, 1, n){
		strt = n - i - 1;
		ll x = (strt >= 0 ? modmul(pre[strt], arr[i]) : 0);
		ans = (ans + x) % MOD;
		en = i - 2;
		x = (en >= 0 ? modmul(pre[en], arr[i]) : 0); 
		ans = (ans - x + MOD) % MOD;
	}
	cout << ans;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define all(x) (x).begin(),(x).end()

int main() {
    int N, Q, K;
    cin >> N >> K >> Q;

    vector<int> answer(Q, 0);
    rep(i, Q) {
        cin >> answer.at(i);
    }

    vector<int> res(N, 0);
    rep(i, answer.size()) {
        res.at(answer.at(i) - 1)++;
    }

    rep(i, res.size()) {
        if (K + (res.at(i) - Q) < 1) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
}



Measured memory_bytes: 1408
import java.io.*;

class Main{
    public static void main (String[ ] args) throws Exception{
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        StringBuffer sb = new StringBuffer();
        
        while(true){
            String[] strAry = (br.readLine()).split(" ");
            int h = Integer.parseInt(strAry[0]);
            int w = Integer.parseInt(strAry[1]);
            
            if(0 == h & 0 == w){
                break;
            }
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    sb.append("#");
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25632
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
if R - L >= 673:
  print(0)
elif l > r:
  print(0)
elif l <= 672 and r >= 673:
  print(0)
elif l == 673 and r >= 675:
  print(0)
elif l <= 1344 and r >= 1346:
  print(0)
elif l <= 1346 and r >= 1347:
  print(0)
else:
  m = 2019
  for i in range(l, r):
    for j in range(i + 1, r + 1):
      m = min(i * j % 2019, m)
  print(m)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    string s;cin>>s;
    int cnt=0,cnt_left=0,cnt_right=0;
    REP(i,N){
        if(s[i]=='(')cnt--;
        if(s[i]==')')cnt++;
        if(cnt>0){cnt_left++;cnt--;}
    }
    cnt=0;
    for(int i=N-1;i>=0;i--){
        if(s[i]=='(')cnt--;
        if(s[i]==')')cnt++;
        if(cnt<0){cnt_right++;cnt++;}
    }
    REP(i,cnt_left){
        s='('+s;
    }
    REP(i,cnt_right){
        s=s+')';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
vector<int> vec[200010];

pair<int,int> bfs(int x) {
	int d[200010];
	fill(d, d + n + 5, INF);
	queue<P> que;
	que.push({ x,0 });
	int mi = -INF, k = 0;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		d[p.first] = p.second;
		if (mi < p.second) {
			mi = p.second;
			k = p.first;
		}
		for (int i = 0; i < (int)vec[p.first].size(); i++) {
			if (d[vec[p.first][i]] == INF) {
				que.push({ vec[p.first][i],p.second + 1 });
			}
		}
	}
	return { k,mi };
}

signed main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	int s = bfs(1).first;
	int t = bfs(s).second;
	if (t % 3 == 1)cout << "Second" << endl;
	else cout << "First" << endl;
}

Measured memory_bytes: 17568
#include "bits/stdc++.h"
using namespace std;

const int MAX_N=2001;

vector<int> G[MAX_N];
vector<int> used(MAX_N,-1);
int tans;
int deep;
int k;

void dfs(int p){
  for(int i=0;i<G[p].size();i++){
    if(used[G[p][i]]==-1){
      used[G[p][i]]=used[p]+1;
      if(used[G[p][i]]>(k/2))tans++;
      dfs(G[p][i]);
    }
  }
}

void dfsx(int p){
  for(int i=0;i<G[p].size();i++){
    if(used[G[p][i]]==-1){
      used[G[p][i]]=used[p]+1;
      if(used[G[p][i]]>((k-1)/2))tans++;
      dfsx(G[p][i]);
    }
  }
}

int main(){
  int n;
  cin>>n>>k;
  vector<int> a(n);
  vector<int> b(n);

  for(int i=0;i<n-1;i++){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }

  int ans=1e9;

  if(k%2==0){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)used[j]=-1;
      tans=0;
      deep=0;
      used[i]=0;
      dfs(i);
      ans=min(ans,tans);
    }
  }else{
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)used[j]=-1;
      tans=0;
      deep=0;
      used[a[i]]=0;
      used[b[i]]=0;
      dfsx(a[i]);
      dfsx(b[i]);
      ans=min(ans,tans);
    }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n+1],c[n+1] ;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i] ;
	int dp1[n+1],dp2[n+1],dp3[n+1] ;
	dp1[1]=a[1];
	dp2[1] = b[1] ;
	dp3[1] = c[1] ;
	for(int i=2;i<=n;i++)
	{
		dp1[i]=a[i] + max(dp2[i-1],dp3[i-1]) ;
		dp2[i]=b[i] + max(dp1[i-1],dp3[i-1]) ;
		dp3[i]=c[i] + max(dp2[i-1],dp1[i-1]) ;
	}
	cout<<max(dp1[n],max(dp2[n],dp3[n])) ;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
    int n, a[3];
    cin >> n >> a[0] >> a[1] >> a[2];
    int l[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    int g[n+1];
    memset(g, 0, sizeof(g));

    int ans = 1e4;
    while (g[n] == 0) {
        int t[3] = {0};
        int c[3] = {0};
        for (int i = 0; i < n; i++) {
            if (g[i] < 3) {
                t[g[i]] += l[i];
                c[g[i]]++;
            }
        }

        int m = 0;
        for (int i = 0; i < 3; i++) {
            if (c[i] == 0 || c[i] > a[i]) {
                m = 1e4;
                break;
            }
            m += (c[i] - 1) * 10 + abs(t[i] - a[i]);
        }

        if (m < ans) {
            ans = m;
        }

        g[0]++;
        for (int i = 0; i < 8; i++) {
            if (g[i] == 4) {
                g[i] = 0;
                g[i+1]++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	string c1, c2;
	cin >> c1;
	cin >> c2;

	if(c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    Integer a[]=new Integer[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    Set s=new HashSet();
    for(int i=0;i<n;i++){
      s.add(a[i]);
    }
    if(s.size()==n){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 70072
S = input()
T = input()

#ad_list = [[] for i in range(26)]
#ad_list2 = [[] for i in range(26)]
num = 97
al_dict = {}
al_dict2 = {}
new = ''
new2 = ''
for i, moji in enumerate(S):
    if moji not in al_dict:
        al_dict[moji] = i
        new += chr(num)
        num += 1
    else:
        new += new[al_dict[moji]]

num = 97

for i, moji in enumerate(T):
    if moji not in al_dict2:
        al_dict2[moji] = i
        new2 += chr(num)
        num += 1
    else:
        new2 += new2[al_dict2[moji]]

if new==new2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3760
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int max1 = 0;
    int max2 = 0;
    int[] num = new int[N];
    for(int i = 0; i < N; i++){
      num[i] = Integer.parseInt(sc.nextLine());
      if(num[i] > max1){
        max1 = num[i];
      }else if(num[i] > max2){
        max2 = num[i];
      }
    }
    
    int ans = 0;
    for(int i = 0; i < N; i++){
      if(max1 == max2){
        ans = max1;
      }else{
        if(num[i] == max1){
          ans = max2;
        }else{
          ans = max1;
        }
      }
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 157432
#inport
import sys
import numpy as np
import itertools as itlt
from collections import deque

#input 

s = [[0,0,0]
    ,[0,0,0]
    ,[0,0,0]]    
s[0] = [int(x) for x in sys.stdin.readline().split()]
s[1] = [int(x) for x in sys.stdin.readline().split()]
s[2] = [int(x) for x in sys.stdin.readline().split()]
g = [[0,0,0]
    ,[0,0,0]
    ,[0,0,0]]
N = int(sys.stdin.readline())
p = list([0]*N)
s = np.array(s)
for _ in range(N):
    a = int(sys.stdin.readline())
    b = np.where(s == a)
    for i in range(np.size(b[0])):
        g[b[0][i]][b[1][i]] = 1

#print("debug")


flg_win = 0

for i in range(3):
    if (g[i][0] + g[i][1] + g[i][2]) == 3:
        flg_win = 1
    if (g[0][i] + g[1][i] + g[2][i]) == 3:
        flg_win = 1

if (g[0][0]+g[1][1]+g[2][2]) == 3:
    flg_win = 1

if (g[0][2]+g[1][1]+g[2][0]) == 3:
    flg_win = 1

if flg_win == 1:
    print("Yes")
else:
    print("No")
#print(g)


Measured memory_bytes: 27268
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  int k; cin>>k;
  set<string> se;
  rep(i,s.size()){
    for(int j=i;j<s.size();j++){
      if((j+1)-i>5) continue;
      string c=s.substr(i,(j+1)-i);
      se.insert(c);
    }
  }

  // vector<string> vs;
  int C=0;
  for(auto itr=se.begin();itr!=se.end();itr++){
    C++;
    if(C==k)
    cout<<*itr<<endl;
  }

  // sort(vs.begin(),vs.end());
  // cout<<vs[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

int w, h;
ll d[110][110];
char c[110][110];

int bfs(int h, int w) {
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			d[i][j] = INF;
		}
	}
	d[0][0] = 1;
	queue<P>q;
	q.push(P(0, 0));
	while (!q.empty()) {
		P p = q.front();
		q.pop();
		int a = p.fr, b = p.sc;
		for (int i = 0; i < 4; i++) {
			int nx = a + dx[i], ny = b + dy[i];
			if (nx<0 || nx>h - 1 || ny<0 || ny>w - 1 || c[nx][ny] == '#')continue;
			if (d[nx][ny] == INF) {
				q.push(P(nx, ny));
				d[nx][ny] = d[a][b] + 1;
			}
		}
	}
	return d[h - 1][w - 1];
}

int main() {
	int cnt = 0;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
			if (c[i][j] == '.')cnt++;
		}
	}
	if (bfs(h, w)==INF) {
		cout << -1 << endl;
	}
	else cout << cnt - d[h - 1][w - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):a,b,c=I();R+=[((a,b),c)];Y+=[c];X+=[a,b]
for i in r(m):a,b,c=I();H+=[(a,(b,c))];X+=[a];Y+=[b,c]
def g(X):s=dict(enumerate(sorted(set(X))));return{s[i]:i for i in s},s,len(s)
h,s,K=g(X);w,t,L=g(Y);j=lambda:[[0]*(K+2)for i in r(L+2)];V=j();U=j();v=j()
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for i in r(L+1):
 for j in r(K+1):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0:
   if U[(f>0)+y][x]|e==0 or V[y][(e>0)+x]|f==0:q+=[(c,d)];v[d][c]=1
if a>F:a='INF'
print(a)

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

int main() {
  long int N, count, i, j;
  cin >> N;
    vector<int> a(N);
  for(i = 0;i < N;i++){
    cin >> a.at(i);
  }
  
  count = 0;
  i = 0;
  j = 1;
  while(i < N){
    while(a.at(i) != j){
      //cout << "a: " << a.at(i) << "j: " << j << endl;
      count++;
      i++;
      if(i == N){
        if(j == 1){
          count = -1;
        }
        break;
      }
    }
    j++;
    i++;
  }
  
 cout << count << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
map<string,int> mp;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	cin>>t;
	int mmax=0;
	for(int i=1;i<=t;i++){
		string s;
		cin>>s;
		mp[s]++;
		if(mp[s]>mmax) mmax=mp[s];
	}
	for(auto i:mp) if(i.second==mmax) cout<<i.first<<endl;
    return 0;
}


Measured memory_bytes: 23808