akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    int A[100] = {};
    for(int i = 1; i <= n; i++)
    {
        cin >> A[i];
    }
    int Count = 0;
    int index1 = 1;
    int index2 = 1;

    for(int i = 1; i <= n; i++)
    {
        if(Count == 0 && A[i] != i)
        {
            index1 = A[i];
            Count++;
            //cout << "1" << index1 << endl;
        }
        else if(Count == 1 && A[i] != i)
        {
            index2 = A[i];
            Count++;
            //cout << "2" << index2 << endl;
            break;
        }
    }
    //cout << endl;
    //cout << index1 << " " << index2 << endl;
    A[index1] = index1;
    A[index2] = index2;
    for(int i = 1; i <= n; i++)
    {
        if(A[i] != i)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
typedef long long ll;
typedef unsigned long long ull;
/*
id: sadykhzadeh -> @Azer_Sadykhzadeh
Programming Language: (C++)
*/
#define qq2(x,y) cerr << (#x) << " = " << (x) << '\t' << (#y) << " = " << (y) << endl
#define qq(x) cerr << (#x) << " = " << (x) << endl
#define elif else if
#define pb push_back
#define ins insert
#define pow2(x) ((x)*(x))
#define mod(x, m) ((x) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define rus_lang setlocale(LC_ALL , "Russian")
#define F_READ ios_base::sync_with_stdio(false);cin.tie(0)
#define MOD 1000000007
#define line cerr << endl << endl << "========================" << endl
#define COUT(x) return cout << (x) << endl, 0;
#define stop return 0
using namespace std;
#include <bits/stdc++.h>
ll T1 = clock();
void timer(){rus_lang; ll T2(clock());cerr<<"Время: "<<(T2-T1)/1000.<<" секунд."<<endl;
cerr << "Автор: Азер Садыхзаде";}
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

int prime(ll x){
    for(ll i = 2; i <= sqrt(x); i++) if(x % i == 0) return 1;
    return 0;
}

int main(){
    ll n; cin >> n;
    if(prime(n) == false) return cout << n - 1 << endl, 0;
    else{
            ll k = 9999999999999999;
        for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0){
            k = min(k, i+n/i-2);
            qq2(i, n/i);
        }
    cout << k << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    static int lcs[5001][5001];
    
    int ans = 0;
    for (int i = n-1; i >= 0; i--){
        for (int j = i - 1; j >= 0; j--){
            if (s[i] != s[j]){
                lcs[j][i] = 0;
                continue;
            }
            lcs[j][i] = lcs[j+1][i+1] + 1;
            ans = max(ans, min(i - j, lcs[j][i]));
        }
    }
    cout << ans;
    return 0;
}  


Measured memory_bytes: 96768
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mod 1000000007

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; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll n,m;
  cin>>n>>m;
  vector<ll> x(m);
  vector<ll> diff(0);
  rep(i,m){
    cin>>x[i];
  }
  if(n>=m){
    cout << 0 << endl;
    return 0;
  }

  sort(all(x));
  rep(i,m){
    if(i>0){
      diff.pb(x[i]-x[i-1]);
    }
  }
  ll ans=0;
  sort(all(diff));
  rep(i,m-n){
    ans+=diff[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2168
#include<stdio.h>
int main()
{
	int a;
	int b;
    int c;
	while(~scanf("%d%d%d",&a,&b,&c)){
		if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	
	
	return 0;	
 } 

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

int n;
string str[12];
bool zero[10];
int k[10];
char c[10];
int alpha[26];
int num;
bool use[10];

class verval{
public:
  int sum,comb;
  verval(void){};
  verval(int a,int b){sum = a;comb = b;};
  const bool operator<(const verval x)const{return sum<x.sum;};
};

vector<verval> v[2];

void make(int from,int to,int sum,int type){
  if(from==to){
    int tmp = 0;
    for(int i=0;i<10;i++)
      if(use[i])tmp += (1<<i);
    
    v[type].push_back(verval(sum,tmp));
    return;
  }
  for(int i=0;i<10;i++){
    if(!i && zero[from])continue;
    if(!use[i]){
      use[i] = true;
      make(from+1,to,sum+i*k[from],type);
      use[i] = false;
    }
  }
}
int main(){
  for(;;){
    cin >> n;
    if(!n)break;

    for(int i=0;i<26;i++)alpha[i] = -1;

    num = 0;
    for(int i=0;i<n;i++){
      cin >> str[i];
      for(int j=0;j<(int)str[i].size();j++){
	if(alpha[str[i][j]-'A']<0){
	  alpha[str[i][j]-'A'] = num;
	  c[num] = str[i][j];
	  num++;
	}
      }
    }

    for(int i=0;i<num;i++){
      zero[i] = false;
      k[i] = 0;
    }

    for(int i=0;i<n;i++){
      int tmp = 1;
      for(int j=(int)str[i].size()-1;j>=0;j--){
	if(str[i].size()>1 && !j)zero[alpha[str[i][j]-'A']] = true;
	if(i!=n-1)k[alpha[str[i][j]-'A']] += tmp;
	else k[alpha[str[i][j]-'A']] -= tmp;
	tmp *= 10;
      }
    }
    for(int i=0;i<10;i++)use[i] = false;
    v[0].clear();
    make(0,num/2,0,0);
    sort(v[0].begin(),v[0].end());

    for(int i=0;i<10;i++)use[i] = false;
    v[1].clear();
    make(num/2,num,0,1);
    sort(v[1].begin(),v[1].end());

    int ans = 0;
    for(int i=0;i<(int)v[0].size();i++){
      int l=0,r=(int)v[1].size()-1;
      int search = -1*v[0][i].sum;
      while(l+1<r){
	int mid = (l+r)/2;
	if(v[1][mid].sum<search)l=mid;
	else r=mid;
      }
      while(r<(int)v[1].size()){
	if(v[1][r].sum!=search)break;

	if( !(v[0][i].comb & v[1][r].comb) )ans++;
	r++;
      }
    }
    cout << ans << endl;
  }

}

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

int main() {
  int n,k,x,y,ans=0;
  cin >> n >> k >> x >> y;
  for(int i=0; i<n; i++) {
    if(i < k) ans += x;
    else ans += y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        
        while(true){
            int a = scanner.nextInt();
            String str = scanner.next();
            int b = scanner.nextInt();
            if  ("?".equals(str)) break;
            
            switch(str){
                case "+":
                    System.out.println(a+b);
                    break;
                case "-":
                    System.out.println(a-b);
                    break;
                case "*":
                    System.out.println(a*b);
                    break;
                case "/":
                    System.out.println(a/b);
                    break;
            }
        }
        
    }
}


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

int main(){
  char s;
  cin >> s;
  if(s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.io.*;

public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  }
 }
}


Measured memory_bytes: 27156
def cut(list1,k):
    return list1[k:]+list1[:k]
def riffle(list1):
    tmplist=[]
    n=int(len(list1)/2)
    for k in range(n):
        tmplist+=[list1[k],list1[n+k]]
    return tmplist
N=int(input())
list2=list(range(1,2*N+1))
M=int(input())
for _ in range(M):
    j=int(input())
    if j==0:
        list2=riffle(list2)
    else:
        list2=cut(list2,j)
for k in list2:
    print(k)


Measured memory_bytes: 5628
from bisect import bisect_left
import sys

name = ["pre-meiji", "meiji", "taisho", "showa", "heisei"]
period = [(1868,9,7), (1912,7,29), (1926,12,24), (1989,1,7)]

for t in (tuple(map(int, l.split())) for l in sys.stdin):
    index = bisect_left(period, t)
    if index:
        date = "{} {} {}".format(t[0]-period[index-1][0]+1, t[1], t[2])
        print(name[index], date)
    else:
        print(name[index])


Measured memory_bytes: 5640
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>
#include <vector>
#include <iomanip>
#include <set>

using namespace std;

int main()
{
  string S;
  cin >> S;
  vector<int16_t> X;

  for (int idx=S.size()-1; idx>=0; --idx) {
    X.push_back(S[idx]-'0');
  }

  vector<int> DP = {0};

  DP.push_back(X[0]);

  vector<int> tens;
  tens.push_back(1);
  for (int idx=1; idx<X.size(); ++idx) {
    tens.push_back((tens[idx-1]*10)%2019);
  }

  for (int ii=1; ii<X.size(); ++ii) {
    int temp = X[ii]*tens[ii];
    DP.push_back((DP.back() + temp)%2019);
  }

  vector<int> mods(2019,0);

  for (auto dp : DP) {
    ++mods[dp];
  }

  uint64_t ans = 0;
  for (auto mod : mods) {
    if (mod>1)
      ans += mod*(mod-1)/2;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

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

    int ans = 0;
    int tmp, cnt;
    rep2(i, 1, n + 1)
    {
        cnt = 0;
        tmp = i;
        while (tmp)
        {
            cnt += tmp % 10;
            tmp /= 10;
        }
        if (a <= cnt && cnt <= b)
        {
            ans += i;
        }
    }

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


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10100000
#define INF 1e15
#define MAP 110
#define initial_value -1
#define LINF 1LL << 60
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,A,B,C;
int L[10];
int dfs(int cnt, int a, int b, int c){
    if(cnt == N){
        if(a == 0 || b == 0 || c == 0) return MM;
        else return abs(a-A)+abs(b-B)+abs(c-C);
    }
    int ans = MM;
    ans = min(ans, dfs(cnt+1, a, b, c));
    ans = min(ans, dfs(cnt+1, a + L[cnt], b, c) + (a>0 ? 10:0));
    ans = min(ans, dfs(cnt+1, a, b + L[cnt], c) + (b>0 ? 10:0));
    ans = min(ans, dfs(cnt+1, a, b, c + L[cnt]) + (c>0 ? 10:0));
    return ans;
}
int main(){
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++) cin >> L[i];
    cout << dfs(0,0,0,0) << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int T;
    cin >> T;

    vector<ll> res(T);
    for (int i=0; i<T; ++i) {
        int N;
        cin >> N;
        vector<pair<int, int>> plus, minus;
        for (int j=0; j<N; ++j) {
            int k, r, l;
            cin >> k >> l >> r;
            res[i] += min(l, r);
            if (l - r >= 0) plus.push_back({k, l-r});
            else minus.push_back({k, r-l});
        }
        sort(plus.begin(), plus.end());
        sort(minus.rbegin(), minus.rend());
        priority_queue<int, vector<int>, greater<int>> que;
        for (auto p : plus) {
            int k = p.first, diff = p.second;
            que.push(diff);
            while ((int)que.size() > k) que.pop();
        }
        while (!que.empty()) {
            res[i] += que.top();
            que.pop();
        }
        for (auto p : minus) {
            int k = p.first, diff = p.second;
            que.push(diff);
            while ((int)que.size() > N-k) que.pop();
        }
        while (!que.empty()) {
            res[i] += que.top();
            que.pop();
        }
    }
    for (ll x : res) cout << x << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 5704
import heapq
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, M = list(map(int, sys.stdin.readline().split()))
UV = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
S, T = list(map(int, sys.stdin.readline().split()))

U = []
V = []
for u, v in UV:
    U.extend([u, u + N, u + N * 2])
    V.extend([v + N, v + N * 2, v])

# graph = csr_matrix(([1] * (M * 3), (U, V)), shape=(N * 3 + 1, N * 3 + 1))
# dist = dijkstra(graph, indices=S)[T]
# if dist < np.inf:
#     print(int(dist // 3))
# else:
#     print(-1)

#: :type: list of (list of int)
graph = [[] for _ in range(N * 3 + 1)]
for u, v in zip(U, V):
    graph[u].append(v)

# S から T までの距離
heap = [(0, S)]
dist = [IINF] * (N * 3 + 1)
while heap:
    d, v = heapq.heappop(heap)
    if v == T:
        print(int(d // 3))
        exit()
    for u in graph[v]:
        if d + 1 < dist[u]:
            dist[u] = d + 1
            heapq.heappush(heap, (d + 1, u))
print(-1)


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

#define printLn(X) cout << X << endl
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(){
	string S;
	cin >> S;
	S[3] = '8';
	printLn(S);
	return 0;
}


Measured memory_bytes: 764
S = input()

# S = 'SAT'

if S == 'SUN':
    ans = 7
if S == 'MON':
    ans = 6
if S == 'TUE':
    ans = 5
if S == 'WED':
    ans = 4
if S == 'THU':
    ans = 3
if S == 'FRI':
    ans = 2
if S == 'SAT':
    ans = 1

print(ans)


Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	k := nextInt()
	ans := k
	for i := 1; i < n; i++ {
		ans *= k - 1
	}

	fmt.Println(ans)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
N, M = map(int,input().split())
num_li = [input().split() for n in range(N)]
num_li = sorted(num_li)
#print(num_li)
#minin = []
#for i in range(len(num_li)):
#  minin.append(num_li[i][0])
#idx = minin.index(min(minin))
flag = False
count = 0

if len(num_li) ==  1:
  print(len(num_li[0][1:]))
  exit()

for i in range(1, int(num_li[0][0])+1):
  for j in range(1, len(num_li)):
    if num_li[0][i] in num_li[j][1:]:
#      print(num_li[0][i])
#      print(num_li[j])
      flag = True
    else:
      flag = False
      break
  if flag == True:
    count += 1
print(count)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

int count[3][101];
int data[200][3];

int main() {
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			int k;
			scanf("%d", &k);
			data[i][j] = k;
			count[j][k]++;
		}
	}
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < 3; j++) {
			if (count[j][data[i][j]] == 1) sum += data[i][j];
		}
		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 2700
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() { // 日本語文字列のテスト
    int w = readint;
    int n = readint;

    auto xs = new int[w + 1];
    for (int i = 0; i < xs.length; i++)
        xs[i] = i;

    for (int i = 0; i < n; i++) {
        auto ab = readln.chomp.split(",").to!(int[]);
        int a = ab[0], b = ab[1];
        swap(xs[a], xs[b]);
    }

    foreach (x; xs[1 .. $])
        writeln(x);
}

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

int n, x, l, d=0;

int main(void) {
	cin >> n >> x;
	bool ret = true;
	int i;
	for (i = 0; i < n; i++) {
		cin >> l;
		d = d + l;
		if (d > x) {
			ret = false;
			break;
		}
	}
	cout << i+1 << endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
AB=sorted(AB)
cost=0
x=0
for ab in AB:
    if x+ab[1]<M:
        cost+=ab[0]*ab[1]
        x+=ab[1]
    else:
        cost+=ab[0]*(M-x)
        break
print(cost)


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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int jdg = (a * b) % 2;

	if (jdg == 1) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}
}

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

int main(){
  int N,M;
  cin >>N>>M;
  if(N==M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
// Problem : B - Common Raccoon vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int H, N; cin >> H >> N;
	int tot = 0; while(N--) { int v; cin >> v; tot += v; }
	if(tot >= H) cout << "Yes" << endl;
	else cout << "No" << endl;
}



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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            long count = 0;

            Dictionary<string, long> dic = new Dictionary<string, long>();
            for (int i = 0; i < n; i++)
            {
                // 文字列の入力
                string s = Console.ReadLine();

                if (dic.ContainsKey(s))
                {
                    dic[s]++;
                }
                else
                {
                    dic.Add(s, 1);
                }

                if (dic[s] > count)
                {
                    count = dic[s];
                }
            }

            List<string> results = new List<string>();
            foreach (var kv in dic)
            {
                if (kv.Value == count)
                {
                    results.Add(kv.Key);
                }
            }

            var array = results.ToArray();
            Array.Sort(array, StringComparer.OrdinalIgnoreCase);

            foreach (var result in array)
            {
                Console.WriteLine(result);
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 42844
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$N = $key->A[0];
$sum = 0;
foreach($key->X as $a) {
  $S[]=$a[0];
  $sum += $a[0];
}
if (($sum % 10) != 0) {
  printf("%d\n",$sum);
  exit;
}
asort($S);
foreach($S as $v) {
  if (($v % 10) == 0) continue;
  $sum -= $v;
  if (($sum % 10) != 0) {
    printf("%d\n",$sum);
    exit;
  }
}
printf("0\n");


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <utility>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    std::string N;
    std::cin >> N;
    int len = N.length();

    switch(N[len-1])
    {
        case '3':
            print("bon");
            break;
        case '2':
        case '4':
        case '5':
        case '7':
        case '9':
            print("hon");
            break;
        case '0':
        case '1':
        case '6':
        case '8':
            print("pon");
            break;
    }

    return 0;
}

Measured memory_bytes: 3628
from itertools import product
h, w, k = map(int, input().split())
c = [[1 if j == '#' else 0 for j in input()] for i in range(h)]
print(sum(sum(c[i][j]*br[i]*bc[j] for i, j in product(range(h), range(w))) == k for br in product([0, 1], repeat=h) for bc in product([0, 1], repeat=w)))

Measured memory_bytes: 9116
n = int(input())
s = input()
a = list('abcdefghijklmnopqrstuvwxyz')
cnt = [0]*26
for i,a_ in enumerate(a):
    cnt[i] += s.count(a_)+1
ans = 1
for cnt_ in cnt:
    ans *= cnt_
print(ans%int(1e9+7)-1)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	ll n, W;
	cin >> n >> W;
	vector<ll> w(n), v(n);
	rep(i, n) cin >> w[i] >> v[i];

	ll vsum = accumulate(allof(v), 0);
	// dp[i][j]:= i番目までの商品を見たときの価値jでの重さの最小値
	vector<vector<ll>> dp(n + 1, vector<ll>(vsum + 1, infll));

	rep(i, n + 1) {
		dp[i][0] = 0;
	}
	Rep(i, 1, n + 1) {
		rep(j, vsum + 1) {
			if(j - v[i - 1] >= 0)
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
		}
	}

	ll ans = 0;
	for (int j = vsum; j >= 0; j--) {
		//cout << j << " " << dp[n][j] << endl;
		if (dp[n][j] <= W) {
			ans = j;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(int argc, char* argv[])
{
    int w, h, x, y, r;
    //Junsang****if( w<0 || h<0 || r<0) return -1;
    cin >> w >> h >> x >> y >> r;

    if( (x<=(w-r)) && (x>=r) && (y<=(h-r)) && (y>=r))
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3104
#include<stdio.h>
int main(){

  int i;
  int n,k;
  int count=0,sum=0,P=0;
  
  scanf("%d%d",&n,&k);
  int N[n];
  for(i=0;i<n;i++){
    scanf("%d",&N[i]);
    sum+=N[i];
  } 
  P=sum/k;
  sum=0;
  while(1){
    for(i=0;i<n;i++){
      sum+=N[i];
      if(P<sum){
	sum=0;
	i--;
	count++;
	if(count>=k){
	  count=0;
	  P++;
	  i++;
	  break;
	}
      }
    }
    if(i==n) break;
  }
  printf("%d\n",P);
  return 0;
}



Measured memory_bytes: 2132
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;
using ll = long long;

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

	int size = str.size();

	ll ans = 0;

	for (int i = 0; i < (1 << (size  - 1)); i++) {
		int l = 0;
		int r;
		string tmp;
		for (int r = 0; r < size - 1; r++) {
			if((i & 1<<r) == 1<<r) {
				tmp = str.substr(l,r - l + 1);

//				cout << "tmp=" << tmp << endl;
				ans += std::stoll(tmp);
				l = r + 1;
			}
		}
//		cout << "nokori=" << str.substr(l,size)<<endl;
		ans += stoll(str.substr(l,size));

	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
    int a, b, c, d; cin>>a>>b>>c>>d;
    int x=1;
    while (a>0 and c>0) {
        if (x) {
            c-=b;
        }
        else {
            a-=d;
        }
        x=!x;
    }
    cout<<(a>0 ? "Yes" : "No")<<endl;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10;
int n,m,a[N];
ll L[N],R[N],newL[N],newR[N];

int pre[N],nxt[N];
inline void Del(int x){
	pre[nxt[x]]=pre[x],nxt[pre[x]]=nxt[x];
}

int main(){
	n=read(),m=read();
	For(i,1,n) a[i]=read();
	set<pa>s;
	For(i,1,n) s.insert(mp(a[i],i)),pre[i]=i-1,nxt[i]=i+1,L[i]=R[i]=1;
	ll ans=n;
	while (!s.empty()){
		//for (int i=1;i!=n+1;i=nxt[i]) printf("%d ",a[i]);puts("");
		int u=(*s.begin()).se;s.erase(s.begin());
		int l=u,r=u;
		while (a[pre[l]]==a[l]) l=pre[l];
		while (a[nxt[r]]==a[r]) r=nxt[r];
		poly v;
		for (int i=l;i!=r;i=nxt[i]) v.pb(i); 
		v.pb(r);
		if (siz(v)<m){
			for (auto i:v) s.erase(mp(a[i],i)),a[i]=0;
			continue;
		}
		ll S=0;
		FOR(i,m-1,siz(v)) S+=L[v[i-m+1]],ans+=S*R[v[i]];
		l=m-1,r=l+m-1;
		int cnt=siz(v)/m;
		For(i,1,cnt){
			newR[i]=0;
			For(j,l,min(r,siz(v)-1)) newR[i]+=R[v[j]];
			l+=m,r+=m; 
		}
		r=siz(v)-m,l=r-m+1;
		Dow(i,cnt,1){
			newL[i]=0;
			For(j,max(l,0),r) newL[i]+=L[v[j]];
			l-=m,r-=m;
		}
		for (auto i:v) s.erase(mp(a[i],i));
		FOR(i,0,cnt){
			a[v[i]]++,L[v[i]]=newL[i+1],R[v[i]]=newR[i+1];
			s.insert(mp(a[v[i]],v[i]));
		}
		FOR(i,cnt,siz(v)) Del(v[i]);
		S=0;
		FOR(i,m-1,cnt) S+=L[v[i-m+1]],ans-=S*R[v[i]];
		s.insert(mp(a[v[0]],v[0]));
	}
	printf("%lld\n",ans);
}
/*
10 2
1 2 4 1 4 2 1 1 4 2 
*/

Measured memory_bytes: 18908
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Triangles solver = new Triangles();
        solver.solve(1, in, out);
        out.close();
    }

    static class Triangles {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] array = new int[n];

            for (int i = 0; i < n; i++) {
                array[i] = in.nextInt();
            }
            Arrays.sort(array);

            long result = 0;
            for (int i = 0; i < n - 2; i++) {
                int a = array[i];
                for (int j = i + 1; j < n - 1; j++) {
                    int b = array[j];
                    for (int k = j + 1; k < n; k++) {
                        int c = array[k];
                        if (b - a < c && c < a + b) {
                            result++;
                        }
                        if (c >= a + b) {
                            break;
                        }
                    }
                }
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 40220
#include <iostream>
 
using namespace std;
 
void call(int n) {
    for (int i = 1; i <= n; ++i) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        }
        else {
            while (x!=0) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}
 
int main(void) {
    int n;
    cin >> n;
    call(n);
 
    //system("pause");
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int H,W;
    cin >> H >> W;
    
    string S[H];
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
    
    int ans[52][52];
    for(int i=0;i<52;i++){
        for(int k=0;k<52;k++){
            ans[i][k] = 0;
        }
    }
    
    for(int i=0;i<H;i++){
        for(int k=0;k<W;k++){
            if(S[i][k]=='#'){
                ans[i+1][k+1] = MOD;
                ans[i][k]++;
                ans[i][k+1]++;
                ans[i][k+2]++;
                ans[i+1][k]++;
                ans[i+1][k+2]++;
                ans[i+2][k]++;
                ans[i+2][k+1]++;
                ans[i+2][k+2]++;
            }
        }
    }
    
    for(int i=1;i<=H;i++){
        for(int k=1;k<=W;k++){
            if(ans[i][k]<MOD){
                cout << ans[i][k];
            }else{
                cout << "#";
            }
        }
        cout << endl;
    }
    return 0;
}


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

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

    bool res = true;
    rep(i, int(S.size())) {
        if((i+1)%2) {
            if(S[i] != 'L') continue;
            else {
                res = false;
                break;
            }
        } else {
            if(S[i] != 'R') continue;
            else {
                res = false;
                break;
            }
        }
    }

    if(res) cout << "Yes" << endl;
    else cout<< "No" << endl;

    return 0;
}

Measured memory_bytes: 256
def m_pow(x, n) -> int:
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return (K * x)


ans = 1
x = int(input())
for i in range(2, 1001):
    for j in range(2, 1001):
        n = m_pow(i, j)
        if n <= x:
            ans = max(n, ans)
        else:
            break

print(ans)


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

using namespace std;
using ll = long long;

int main()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	char c = s.at(k - 1);

	if (c == 'A')
		s.at(k - 1) = 'a';
	else if (c == 'B')
		s.at(k - 1) = 'b';
	else
		s.at(k - 1) = 'c';

	cout << s << endl;


	return 0;
}


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 int;

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

  vector<int> a(N + 1, 0);
  rep(i, N) cin >> a[i + 1];

  int ans = 0;
  for (int i = 1; i <= N; i++)
  {
    if (i % 2 == 1 && a[i] % 2 == 1) ans++;
  }
  cout << ans;
}

Measured memory_bytes: 3624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d;
    for(int i=0;i<n;++i)
    {
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }

    sort(d.begin(), d.end());
    int mid = (n-1) / 2;

    if (d[mid] == d[mid + 1]) {
        cout << 0 << endl;
    }
    else 
    {
        cout << d[mid + 1] - d[mid] << endl;
    }
}

Measured memory_bytes: 892
import java.util.Scanner;

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

			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < N.length; i += 2) {
				sb.append(N[i]);
			}

			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 22760
import sys
from itertools import accumulate

readline=sys.stdin.readline
read=sys.stdin.read

def main():
  q,*lr=map(int,read().split())
  n=10**5
  ansl=[]
  sieve=[1]*(n+1)
  sieve[0],sieve[1]=0,0
  for i in range(2,n):
    if sieve[i]:
      sieve[2*i::i]=[0 for _ in range(2*i,n+1,i)]
  ans=[0]*(n+1)
  for i in range(3,n):
    if sieve[i]==1 and sieve[(i+1)//2]==1:
      #ans[i]=1
      ans[i]=ans[i-1]+1
    else:
      ans[i]=ans[i-1]
  
  #ans=list(accumulate(ans))
  for l,r in zip(*[iter(lr)]*2):
    print(ans[r]-ans[l-1])

if __name__=='__main__':
  main()


Measured memory_bytes: 32968
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,ans=0,tmp,v;
  cin >> n >> k;
  ll a[n],s[n+1];
  s[0] = 0;
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    s[i+1] = s[i]+a[i];
  }
  mp[0]++;
  for(int i=1;i<=n;i++){
    tmp = i-k;
    if(tmp>=0){
      mp[(s[tmp]-tmp)%k]--;
    }
    v = (s[i]-i)%k;
    ans += mp[v];
    mp[v]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define  maxn 20
using namespace std;
struct Node{
    int d[maxn];
}q[maxn];
int main()
{
    int n,d;
    scanf("%d%d",&n,&d);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=d;j++){
            scanf("%d",&q[i].d[j]);
        }
    }
    int res=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(i==j) continue;
            long long tmp=0;
            for(int k=1;k<=d;k++){
                tmp+=(q[i].d[k]-q[j].d[k])*(q[i].d[k]-q[j].d[k]);
            }
            long long sqrtmp=sqrt(tmp);
            if(sqrtmp*sqrtmp==tmp) res++;
        }
    }
    printf("%d\n",res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    int d=max(a,b);
    int e=a+b+c;
    d=max(d,c);
    cout << e-d<<endl;
    return 0;
}



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


int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >>d;
  if (max(a, c)<=min(b, d)){
    cout << min(b,d)-max(a, c) << endl;
  }
  else{
    cout << 0 << endl;
  }
}
  
    
  
    
                       
       

        


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]

b = [0 for i in range(n+1)]

for mi in range(m):
    b[int(input())] = 1
cnt = 0
s = [0 for i in range(n+1)]
s[0] = 1
if b[1] == 0:
    s[1] = 1
else:
    s[1] = 0
for ni in range(2,n+1):
    if b[ni] == 0:
        s[ni] = (s[ni-1] + s[ni-2]) % 1000000007
    else:
        s[ni] = 0
print(s[n])

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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int64_t M = 0;
  int64_t A = 0;
  int64_t R = 0;
  int64_t C = 0;
  int64_t H = 0;
  
  for(int j=0; j<N; j++){
    string S = vec.at(j);
    if(S.at(0) == 'M'){
      M++;
    }
    if(S.at(0) == 'A'){
      A++;
    }
    if(S.at(0) == 'R'){
      R++;
    }
    if(S.at(0) == 'C'){
      C++;
    }
    if(S.at(0) == 'H'){
      H++;
    }
  }
  
  vector<int64_t> MARCH(5);
  MARCH.at(0) = M;
  MARCH.at(1) = A; 
  MARCH.at(2) = R;
  MARCH.at(3) = C; 
  MARCH.at(4) = H;
  
  int64_t ans = 0;
    ans += MARCH.at(2) * MARCH.at(3) * MARCH.at(4);
    ans += MARCH.at(1) * MARCH.at(3) * MARCH.at(4);
    ans += MARCH.at(1) * MARCH.at(2) * MARCH.at(4);
    ans += MARCH.at(2) * MARCH.at(3) * MARCH.at(1); 
    ans += MARCH.at(0) * MARCH.at(1) * MARCH.at(2);
    ans += MARCH.at(0) * MARCH.at(3) * MARCH.at(1);
    ans += MARCH.at(0) * MARCH.at(1) * MARCH.at(4);
    ans += MARCH.at(0) * MARCH.at(3) * MARCH.at(2);
    ans += MARCH.at(0) * MARCH.at(2) * MARCH.at(4);
    ans += MARCH.at(0) * MARCH.at(3) * MARCH.at(4);
  cout << ans << endl;
}

Measured memory_bytes: 6144
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)
*/

main :-
    get_number(N, A, B),
    X is N div (A + B) * A + min(A, N mod (A + B)),
    writeln(X).

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8180
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  string s ;
  cin >> s ;
  int n = s.size() ;
  
  for(int i =0;i<n;i+=2){
    cout << s.at(i) ;
  }
  
  cout << endl ;

  return 0 ;
}




Measured memory_bytes: 512
while True:
    inputs = input().split(' ')
    a = int(inputs[0])
    op = inputs[1]
    b = int(inputs[2])
    if op == "?":
        break
    elif op == "+":  # (和)
        print(a + b)
    elif op == "-":  # (差)
        print(a - b)
    elif op == "*":  #(積)
        print(a * b)
    else:  # "/"(商)
        print(a // b)


Measured memory_bytes: 5596
#include<stdio.h>
int main(void) {
	int t = 0, n = 0, a[100] = { 0 }, b[100] = { 0 }, i,c=100000;
	scanf("%d %d", &n,&t);
	for (i = 0; i < n; i++)
	{
		scanf("%d %d", &a[i], &b[i]);
		if (t >= b[i]) {
			if (c >= a[i])
				c = a[i];
		}
	}
	if (c == 100000)
		printf("TLE\n");
	else
		printf("%d\n", c);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#include<cmath>
#include<string>
#define pb push_back
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern

const int nax = 2e5+2;
int n,m;
vector<int> adj[nax];
vector<bool> vis;

int dfs(int next){
	vis[next] = true;
	int no =0;
	for(auto it : adj[next]){
		if(vis[it] == false){
			no += dfs(it);
		}
	}
	return no + 1;
}

signed main() {    
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	
	cin >> n >> m;
	for(int i =0 ; i < m; i++){
		int u,v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	
	vis.assign(n+1 , false);
	
	
	int ans= 0;
	for(int i = 1; i <= n;i++){
		if(vis[i] == false){
			int val = dfs(i);
			ans = max(val , ans);
		}
	}
	cout<<ans;
	 
	return 0;
}


Measured memory_bytes: 23956
import math
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
lis = [[0,0] for i in range(h * w)]
num = [[0] * math.ceil((h * w) // d + 1) for i in range(d)]
for i in range(h):
    for j in range(w):
        lis[a[i][j]-1] = [i,j]
for i in range(h * w-d):
    num[i%d][i//d+1] = num[i%d][i//d]+abs(lis[i][0]-lis[i+d][0])+abs(lis[i][1]-lis[i+d][1])
q = int(input())
for _ in range(q):
    now,goal = map(int,input().split())
    if now % d == 0:
        print(num[now%d-1][(goal-now%d)//d-1]-num[now%d-1][(now-now%d)//d-1])
    else:
        print(num[now%d-1][(goal-now%d)//d]-num[now%d-1][(now-now%d)//d])


Measured memory_bytes: 25712
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a1,b1,a2,b2;
	cin>>a1>>a2>>b1>>b2;
	if(a1+a2>b1+b2)
        cout<<"Left"<<endl;
	else if(a1+a2<b1+b2) 
        cout<<"Right"<<endl;
    else
    	cout<<"Balanced"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
button = []
for i in range(n):
  button.append(int(input()))
times = 0
next_button = 1
while times < n:
  times += 1
  next_button = button[next_button-1]
  if next_button == 2:
    print(times)
    exit()
print(-1)


Measured memory_bytes: 7340
// problem: "https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_b"

#include<iostream>
#include<string>

using namespace std;

int main()
{
    string s;
    int n,k;

    cin>>n>>s>>k;

    int i;
    for(i=0;i!=s.size();i++)
    {
        if(s[i]!=s[k-1])
            s[i] = '*';
    }

    cout<<s;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                int N;
                int[] A;
                try (Scanner sc = new Scanner(System.in)) {
                        N = sc.nextInt();
                        A = new int[N];
                        for (int i = 0; i < N; i++) {
                                A[i] = sc.nextInt();
                        }
                } catch (Exception e) {
                        return;
                }
                long ans  = 1L << 60;
                for (int j = -100; j <= 100; j++) {
                        int memo = 0;
                        for (int i = 0; i < N; i++) {
                                memo += (A[i] - j) * (A[i] - j);
                        }
                        ans = Math.min(memo, ans);
                }
                System.out.println(ans);
        }
}

Measured memory_bytes: 9684