akhauriyash/Code-Regression huggingface dataset:
from collections import deque

N, M = map(int, input().split())

edges = [[] for _ in range(N)]
edgesR = [[] for _ in range(N)]

for _ in range(M):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edgesR[to].append(fr)

for start in range(N):
    st = deque([(start, True)])
    L = deque()
    V = set()

    while st:
        now, isFirst = st.pop()
        if isFirst:
            L.append(now)

            if now in V:
                break

            V.add(now)

            st.append((now, False))

            for to in edges[now]:
                st.append((to, True))
        else:
            L.pop()
            V.remove(now)
    else:
        continue

    loopStart = L.pop()
    while L[0] != loopStart:
        L.popleft()
    V = set(L)
    dist = [float('inf')] * N
    que = deque([(loopStart, 0)])

    while que:
        now, d = que.popleft()

        if dist[now] <= d:
            if now == loopStart:
                dist[loopStart] = d
                break
            continue
        dist[now] = d

        for to in edges[now]:
            if to in V:
                que.append((to, d + 1))

    ans = [loopStart]
    now = loopStart
    while dist[now] > 1:
        for back in edgesR[now]:
            if dist[now] - 1 == dist[back]:
                ans.append(back)
                now = back
                break

    ans = set([a + 1 for a in ans])
    print(len(ans))
    print(*ans, sep='\n')
    exit()

print(-1)

Measured memory_bytes: 4076
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->parent = y;

  if(y==NIL)root=z;
  else if(z->key < y->key) y->left =z;
  else y->right = z;
  
}

void inorder(Node u){
  if(u->left!=NIL)inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)inorder(u->right);
			
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL)preorder(u->left);
  if(u->right!=NIL)preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    if( i <= 0 )break;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,P;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>P;
	P+=A*3;
	cout<<P/2<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
	cin >> n;
  long long s = 0;
  for(int i = 1; i <= n; ++i) {
    if(i % 3 != 0 && i % 5 != 0) {
      s += i;
    }
  }
  cout << s << "\n";
	return 0;
}

Measured memory_bytes: 3636
def main():
    weight = 8,4,2,1

    q,h,s,d = map(int,input().split() )
    n = int(input())

    
#    print(q,h,s,d,n)
    s = min(4*q, h*2, s)

#    print(q,h,s,d,n)
#    print(n%2,n//2 )

    div = n//2
    mod = n%2
#    print(d,m)
    sum = 0
    if mod == 1:
        sum = sum + s

#    print( s*2, d)
    sum = sum + div * min(s*2 , d)

    print(sum)
main()

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

const int INF = 999999999;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> vW(N+1,0), vE(N+1,0); //std::vector<型名> 変数名(要素数,値)　A[0] = 0
    for(int i=0; i<N; i++){
        vW[i+1] += vW[i];  // 累積和
        if(S[i] == 'W') vW[i+1]++;
        vE[i+1] += vE[i];
        if(S[i] == 'E') vE[i+1]++;
    }
    int ans = INF;
    for(int i=0;i<N; i++){
        int now = vW[i] + (vE[N]-vE[i+1]);
        if(ans > now) ans = now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
from collections import deque
import sys
def input():
  return sys.stdin.readline()[:-1]

H, W=map(int, input().split())
S=['#'*(W+2)]+['#'+input()+'#' for i in range(H)]+['#'*(W+2)]

def f(data):
  m[data[0]][data[1]]=data[2]
  if m[data[0]-1][data[1]]==-2 and S[data[0]-1][data[1]]=='.':
    m[data[0]-1][data[1]]=-1
    q.append([data[0]-1, data[1], data[2]+1])
  if m[data[0]+1][data[1]]==-2 and S[data[0]+1][data[1]]=='.':
    m[data[0]+1][data[1]]=-1
    q.append([data[0]+1, data[1], data[2]+1])
  if m[data[0]][data[1]-1]==-2 and S[data[0]][data[1]-1]=='.':
    m[data[0]][data[1]-1]=-1
    q.append([data[0], data[1]-1, data[2]+1])
  if m[data[0]][data[1]+1]==-2 and S[data[0]][data[1]+1]=='.':
    m[data[0]][data[1]+1]=-1
    q.append([data[0], data[1]+1, data[2]+1])

out=0
for x in range(1, H+1):
  for y in range(1, W+1):
    if S[x][y]=='#':
      continue
    q=deque()
    q.append([x, y, 0])
    m=[[-2]*(W+2) for i in range(H+2)]
    while len(q)>0:
      data=q.popleft()
      f(data)
      if data[2]>out:
        out=data[2]
      
print(out)

Measured memory_bytes: 3316
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e18;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long, long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1)%mod;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////

//メイン関数
int main(){
  //doubleの桁数
  
  string s;
  cin >> s;
  string t;
  if(s[s.size() - 1] == 's'){
    t = s +  "es";
  }
  else{
    t = s + "s";
  }

  cout << t << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>

#define ll long long
#define INF 100000000000000

using namespace std;

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

  int ans = 0;

  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - 1 - i])
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import math

def is_prime_sqrt(q): #合成数xはp<=sqrt(x)を満たす素因子pを持つ
    if q == 1: #1は素数ではない
        return False
    if q == 2: #2は素数
        return True
    elif q % 2 == 0: #2以外の偶数は合成数
        return False
    for divisor in range(3, math.floor(math.sqrt(q))+1, 2): #繰り返しの上限は平方根
        if q % divisor == 0: #平方根までに約数があれば合成数
            return False
    return True

def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def sieve(n): #nまでの素数をエラトステネスの篩で列挙＝戻り値は各要素が素数のリスト
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

def sieveyn(n): #nまでの素数をエラトステネスの篩で列挙＝戻り値は各要素が素数のリスト
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return s


Q = int(input())
A = [0] * 100001 #A[0]からA[100000]までのリスト
A[3] = 1
S = sieveyn(100000)

for i in range(5,100001,4):
    if S[i] and S[int((i+1)/2)]:
        A[i] = 1
for i in range(4,100001):
    A[i] += A[i-1]

#print(A[:100])

for i in range(Q):
    l, r = map(int, input().split())
    print(A[r]-A[l-1])


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll h, n;

    cin >> h >> n;

    ll total = 0, tmp = 0;
    REP(i, n){
        cin >> tmp;
        total += tmp;
    }

    if (h <= total){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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




int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	long long s = 0;
	for (int i = 1; i <= n; ++i){
		for (int j = 1; j <= n; ++j){
			int g1 = __gcd(i,j);
			for (int k = 1; k <= n; ++k){
				int g2 = __gcd(g1,k);
				s += g2;
			}
		}
	}
	cout << s << "\n";
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
    int N, x, count=0 ;
    double probability ;

    scanf("%d", &N) ;
    for(x=1; x<=N; x=x+2)
    {
        count++ ;

    }
    probability = (double)count/N ;

    printf("%.10lf\n", probability) ;

    return 0 ;
}

Measured memory_bytes: 1728
#include <iostream>
#include <cstdio>
#include <algorithm>

#define INF (1e9)

#define MAX_N 2000
#define GENRE 10

using namespace std;

int field[GENRE + 1][MAX_N + 1];
int genre_num[GENRE + 1];
int dp[GENRE + 1][MAX_N + 1];	//dp[genre][sold num];

int N;
int K;

int ans;


void solve(){

	for(int i = 0;i <= genre_num[1];i++){
		dp[1][i] = field[1][i];
	}
	
	for(int i = 1;i < GENRE;i++){
		for(int j = 0;j <= K;j++){
			if(j != 0 && dp[i][j] == 0)break;
			for(int k = 0;k <= genre_num[i + 1];k++){
				if(j + k > K)break;
				dp[i + 1][j + k] = max(dp[i + 1][j + k],dp[i][j] + field[i + 1][k]);
			}
		}
	}

	/*for(int i = 1;i <= GENRE;i++){
		puts("###");
		for(int j = 0;j <= K;j++){
			printf(" %d",dp[i][j]);
		}
		puts("");
	}*/

	ans = 0;
	for(int i = 1;i <= GENRE;i++){
		ans = max(ans,dp[i][K]);
	}

	return ;
}


int main(){

	scanf("%d%d",&N,&K);
	int v,g;
	for(int i = 0;i < N;i++){
		scanf("%d%d",&v,&g);
		field[g][genre_num[g]] = v;
		genre_num[g]++;
	}
	for(int i = 1;i <= GENRE;i++){
		field[i][genre_num[i]] = INF;
		//genre_num[i]++;
	}
	for(int i = 1;i <= GENRE;i++){
		sort(field[i],field[i] + genre_num[i] + 1,greater<int >());
		field[i][0] = 0;
		for(int j = 0;j < genre_num[i];j++){
			field[i][j + 1] += field[i][j];
		}
		//printf("###genre = %d\n",i);
		for(int j = 1;j <= genre_num[i];j++){
			field[i][j] += j * (j - 1);
			//printf("###%d: %d ",j,field[i][j]);
		}
		//puts("");
	}

	solve();

	printf("%d\n",ans);


	return 0;
}

Measured memory_bytes: 1332
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int N, M;
	cin >> N >> M;
	LL time = (N - M) * 100 + M * 1900;
	time *= (1 << M);
	cout << time << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
import numpy as np
h,w=map(int,input().split())
a=np.array([list(input()) for _ in range(h)])
for i in range(h):
    for j in range(w):
        if a[i,j]!='#':
            a[i,j]=np.count_nonzero(a[max(i-1,0):min(i+2,h),max(j-1,0):min(j+2,w)]=='#')
for i in range(h):
    print(''.join(a[i,:]))

Measured memory_bytes: 13628
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	int K;
	int X;
	int Y;

	cin >> N;
	cin >> K;
	cin >> X;
	cin >> Y;

	if (N <= K)
	{
		cout << X * N;
	}
	else
	{
		cout << X * K + Y * (N - K);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    ll mod = 1e9 + 7;
    vector<ll> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    // Ai == 9 && Aj == 0
    // Ai not exist 9 || Aj not exist 0
    ll total = 1;
    ll use9 = 1;
    ll use8 = 1;
    for(int i = 0; i < n; i++) {
        total *= 10;
        total %= mod;
        use9 *= 9;
        use9 %= mod;
        use8 *= 8;
        use8 %= mod;
    }
    ll invalid = (use9 * 2 - use8 + mod*10) % mod;
    cout << (total - invalid + mod*10) % mod << endl;
    return 0;
}


Measured memory_bytes: 11020
N = int(input())
ls = list(map(int, input().split()))
mod = 10**9+7
total = sum(ls)
sq_power = sum(map(lambda x:x*x%mod, ls))
ans = (total**2 - sq_power)%mod
ans2 = 2
for _ in range(9):
    ans2 = (ans2**10)%mod
ans2 *= 2**5 % mod
print(ans*ans2%mod)

Measured memory_bytes: 31544
import sys
n, m = map(int, input().split())
a=set(int(input()) for i in range(m))
ans = [0 for _ in range(n)]

for i in range(n):
    if i+1 in a:
        ans[i] = 0
    else:
        if i == 0:
            ans[i] = 1
        elif i == 1:
            ans[i] = 1+ans[i-1]
        else:
            ans[i] = (ans[i-1]+ans[i-2])%(10**9+7)
print(ans[-1])


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

int main() { 
  int N;
  string S;
  cin >> N >> S;
  string ans="Yes";
  if (S.size()%2==1) {
    ans="No";
  }
  for (int i=0; i<S.size()/2; i++) {
    if (S.at(i)!=S.at(i+S.size()/2)) {
      ans ="No";
      break;
    }
  }
  cout << ans << endl;
} 

Measured memory_bytes: 3608
#include <bits/stdc++.h>
/**
 *    author:  dattrinh
 *    created:    Codeforces Round #635
**/
#define pb push_back
#define fi first
#define ss second
#define tp(x) fixed<<setprecision(x)
using namespace std;
using ll = int64_t;
const int N = 1000003;
ll t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n;cin>>n;
    long long t=0;
    for(int i=1;i<=n;++i){
        t+=((i%3==0||i%5==0)?0:i);
    }
    cout<<t;
    return 0;
}






Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,count1=0,count2=0,count3=0,count4=0;
  while(cin>>a>>b>>c ){
      int ia,ib,ic,max,z;
      ia=a*a;
      ib=b*b;
      ic=c*c;
      if(ia>=ib && ia>=ic) {
	if(a<b+c) {
	  max=ia;
	  ia=ic;
	}
	else break;
      }
      
      else if(ib>=ia && ib>=ic) {
	if(b<a+c) {
	  max=ib;
	  ib=ic;
	}
	else break;
      }
      else if(ic>=ia && ic>=ib) {
	if(c<a+b) {
	  max=ic;
	}
	else break;
      }
      else break;
      count1++;
      if(max==ia+ib) count2++;
      else if(max<ia+ib) count3++;
      else count4++;
  }
  cout<<count1<<" "<<count2<<" "<<count3<<" "<<count4<<endl;
  return 0;
  
}



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

#define int long long


signed main()
{
    string o, e;
    cin >> o >> e;
    for(int i=0; i<o.size(); ++i) {
        if(i<e.size())
            cout << o[i] << e[i];
        else cout << o[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void);

int main(void){

    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a < b && b < c){
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}



Measured memory_bytes: 2044
n, m = map(int, input().split())
a, b, num = [0]*m, [0]*m, [0]*n
if n!=1:
  num[0]=1
for i in range(m):
  a[i], b[i] = map(int, input().split())
  num[a[i]-1]=b[i]
for i in range(m):
  if num[a[i]-1]!=b[i]:
    print(-1)
    exit()

ans=''
for i in num:
  ans+=str(i)
ans = int(ans)
ans = str(ans)
if len(ans)==n:
  print(ans)
else:
  print(-1)

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


int main()
{
	int count_1, count_2, count_3, count_4;
	count_1=0;
	count_2=0;
	count_3=0;
	count_4=0;
	vector <int> a(6);
	for (int i=0; i<6; i++){
		cin >> a.at(i); //数字の読み込み
	}
	for (int i=0; i<6; i++){
		if (a.at(i)==1)count_1++;
		if (a.at(i)==2)count_2++;
		if (a.at(i)==3)count_3++;
		if (a.at(i)==4)count_4++;
	}
	if (max(max(count_1, count_2),max(count_3,count_4))==3)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>


int main(int argc, char const *argv[])
{
    int R, G, B, N;
    std::cin >> R >> G >> B >> N;
    // max_num
    int n_r = N / R;
    int n_g = N / G;
    int n_b = N / B;
    int ans = 0;

    for (int i = 0; i <= n_r; i++) {
        for (int j = 0; j <= n_g; j++) {
            int num = N - R * i - G * j;
            if (num >= 0 && num % B == 0) {
                ans += 1;
                // std::cout << i << " " << j << " " << num / B << std::endl;
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    VEC(int) V(5);
    READVEC(V);
    int s = accumulate(ALL(V), 0);
    cout << 15 - s << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b) * c / 2 << endl;
}

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

int main() {
  // ここにプログラムを追記
  double rate_now = 0;
  double rate_next = 0;
  double performance = 0;
  
  cin >> rate_now;
  cin >> rate_next;
  
  performance = 2*rate_next - rate_now;
  
  cout << performance << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
    double n;
    double x[100], y[100];
    
    cin >> n;
    
    double p1 = 0.0; 
    double p21 = 0.0;
    double p2 = 0.0;
    double p31 = 0.0;
    double p3 = 0.0;
    double p0 = 0.0;
   
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < n; i++) cin >> y[i];
        
    for (int i = 0; i < n; i++) p1 += fabs(x[i] - y[i]);
    for (int i = 0; i < n; i++) p21 += (fabs(x[i] - y[i])) * (fabs(x[i] - y[i]));
    p2 = sqrt(p21);
        
    for (int i = 0; i < n; i++) p31 += (fabs(x[i] - y[i])) * (fabs(x[i] - y[i])) * (fabs(x[i] - y[i]));
    p3 = cbrt(p31);
        
    for (int i = 0; i < n; i++) {
        if (fabs(x[i] - y[i]) > p0) p0 = fabs(x[i] - y[i]);
    }
    
    printf("%lf\n", p1);
    printf("%lf\n", p2);
    printf("%lf\n", p3);
    printf("%lf\n", p0);
    
    return 0;
}


Measured memory_bytes: 3392
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll r;
  cin >> r;
  ll ans = 3 * pow(r, 2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
bool cmp(pi & a,pi &b)
{
  if(a.ss==b.ss)return a.ff<b.ff;
  else return a.ss<b.ss;
}
int32_t main()
{
   fastio
   int n;
   cin>>n;
   vector<pi >v;
   rep(i,n)
   {
     int t,d;
     cin>>t>>d;
     v.pb(mkp(t,d));
   }
   sort(v.begin(),v.end(),cmp);
   int ans=0;
   int flag=0;
   rep(i,n)
   {
     int t=v[i].ff;
     if(ans+t<=v[i].ss){ans+=t;}
     else {flag=1;break;}
   }
   if(flag==0)cout<<"Yes\n";
   else cout<<"No\n";
   return 0;
}


Measured memory_bytes: 6384
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

#define read(x) scanf("%d",&x)
#define MOD 998244353

int n,m,k;
int jc[200005];
int ans=0;

int quickpow(int a,int b)
{
	int ans=1,base=a;
	while(b)
	{
		if(b&1) ans=1ll*base*ans%MOD;
		b>>=1;
		base=1ll*base*base%MOD;
	}
	return ans%MOD;
}

void gjc(int n)
{
	jc[0]=1;
	for(int i=1;i<=n;i++) jc[i]=1ll*jc[i-1]*i%MOD;
	return;
}

int inv(int a){return quickpow(a,MOD-2);}

int C(int n,int m){return 1ll*jc[n]*inv(1ll*jc[m]*jc[n-m]%MOD)%MOD;}

int main()
{
	read(n),read(m),read(k);
	gjc(n);
	for(int i=0;i<=k;i++)
	{
		ans=(ans+1ll*m*C(n-1,i)%MOD*quickpow(m-1,n-i-1)%MOD)%MOD;
	}
	printf("%d\n",ans%MOD);
	return 0;
}

Measured memory_bytes: 4604
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    n = int(sys.stdin.readline().rstrip())
    c, s, f = [], [], []
    for i in range(n-1):
        ci, si, fi = (int(x) for x in sys.stdin.readline().split())
        c.append(ci); s.append(si); f.append(fi)
    
    x = []
    for i in range(n-1):
        xi = 0
        for j in range(i, n-1):
            if s[j] >= xi: 
                xi = s[j]
                xi += c[j]
            else:
                if (xi - s[j]) % f[j] == 0:
                    xi += c[j]
                else:
                    xi += c[j] + f[j] - (xi - s[j]) % f[j]
        x.append(xi)
    x.append(0)
    for xi in x:
        print(xi)

if __name__ == "__main__":
    # execute only if run as a script
    main()

# 乗り換え時間がなく、一方通行の電車!


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

using namespace std;

using int64 = long long;
const int mod = 998244353;


int main() {
  int N, M;
  bitset< 300 > X[300];
  cin >> N >> M;
  int rank = 0;
  for(int i = 0; i < N; i++) {
    bitset< 300 > tap;
    for(int j = 0; j < M; j++) {
      int p;
      cin >> p;
      tap[j] = p;
    }
    for(int j = 0; j < M; j++) {
      if(tap[j]) {
        tap ^= X[j];
        if(tap[j]) {
          X[j] = tap;
          ++rank;
          break;
        }
      }
    }
  }
  int64 all = 1, sub = 1;
  for(int i = 0; i < N + M - 1; i++) (all *= 2) %= mod;
  for(int i = 0; i < N + M - rank - 1; i++) (sub *= 2) %= mod;
  cout << (all + mod - sub) % mod << endl;
}


Measured memory_bytes: 256
import Control.Applicative

qsort :: [Int]->[Int]

qsort [] = []

qsort (p:xs) = qsort x_smaller ++ [p] ++ qsort x_larger
  where x_smaller = [x | x <- xs, x < p]
        x_larger = [x | x <- xs, x >= p]

main = do
  [s0, s1, s2] <- words <$> getLine
  let x = read s0 :: Int
  let y = read s1 :: Int
  let z = read s2 :: Int

  let dst_list = qsort [x, y, z]

  putStr $ show $ dst_list !! 0
  putChar ' '
  putStr $ show $ dst_list !! 1
  putChar ' '
  putStr $ show $ dst_list !! 2
  putChar '\n'

Measured memory_bytes: 3508
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n=as.nextInt();
		long[] a;
		int[] b;
		a = new long[n];
		b = new int[n];
		for(int i=0;i<n;i++){
			a[i] = Long.parseLong(as.next());
			b[i] = Integer.parseInt(as.next()); 
		}
		long l = 0;
		try{
			for(int i=n-1;i>=0;i--){
				if(a[i]%b[i]!=0){
					l+=((a[i]/b[i])+1)*b[i]-a[i];
					a[i-1]+=l;
				}else{
					a[i-1]+=l;
				}
			}
		}catch(Exception e){
			
		}
		System.out.println(l);
	}
}

Measured memory_bytes: 47856
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    (v).begin(), (v).end()
#define in        ([]{int n; cin>>n; return n;}())
using namespace std;
using lint = int64_t;

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    int ans = 0;
    vector<int> V(N); rep( i, N ) V[i] = in;
    vector<int> C(N); rep( i, N ) C[i] = in;
    rep( i, N ) {
        int v = V[i], c = C[i];
        ans += v-c > 0 ? v-c : 0;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int a, p;
    cin >> a >> p;
    cout << (3*a+p)/2 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())


int main() {
  ll X,K,D;
  cin >> X >> K >> D;
  X = abs(X);
  ll a = X/D;
  if (a <= K) {
    K -= a;
    X -= a*D;
    if (K%2)
      X -= D;
  } else {
    X -= K*D;
  }
  print(abs(X));
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int si=s.size();
    for(int i=0;i<si;i++){
        cout<<'x';
    }
    cout<<'\n';
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    int n;
    cin >> n;
    string s1,s2;
    cin >> s1 >> s2;
    mint ans = 1;
    int ind;
    if(s1[0]==s2[0]){
        ind = 1;
        ans *= 3;
    }else{
        ind = 2;
        ans *= 6;
    }
    for(int i=ind;i<n;i++){
        if(s1[i]==s2[i]){
            if(s1[i-1]==s2[i-1]) ans *= 2;
            else continue;
        }else{
            if(s1[i-1]==s2[i-1]) ans *= 2;
            else ans *= 3;
            ++i;
        }
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;

int gcd(int a, int b , int c){
    if(b < c) swap(b,c);
    if(a < b) swap(a,b);
    if(b < c) swap(b,c);

    while(1) {
    if(a < c) swap(a, c);
    if(!c) break;
    a %= c;
  }
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }

  return a;

}

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

    int k;
    cin >> k;
    ll sum = 0;
    for(ll i = 1; i < k+1;i++){
        for(ll l = 1; l < k+1;l++){
            for(ll m = 1; m < k+1;m++){
              sum+=gcd(i,l,m);
            }
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
	int a,b,c,count=0;
	cin >> a >> b >> c;
	do {
		count++;
	} while ((count <= c) && (b >= (a*count)));
	cout << count - 1 << endl;
	return(0);
}

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

using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define REP(i,n) FOR(i,0,n)
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;

const int MAX_N = 575;

int T;
ll A[MAX_N], B[MAX_N], C[MAX_N], D[MAX_N];

ll getGcd(ll a, ll b) {
  if (a % b == 0) return b;
  return getGcd(b, a % b);
}

bool solve(ll tmp, int i) {
  ll gcdNum = getGcd(B[i], D[i]);
  ll res = B[i] - gcdNum + A[i] % gcdNum;
  return (res <= C[i]);  
}

int main() {
  cin >> T;
  REP(i, T) {
    cin >> A[i] >> B[i] >> C[i] >> D[i];
  }

  REP(i, T) {
    if (A[i] < B[i]) {
      OK(false);
      continue;
    }
    if (B[i] > D[i]) {
      OK(false);
      continue;
    }
    if (C[i] >= B[i]) {
      OK(true);
      continue;
    }
    OK(solve(A[i], i));
  }
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
use std::str::FromStr;
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut v: Vec<String> = s.trim().
        split_whitespace().map(|c| c.parse().ok().unwrap()).collect();
    v.sort_by_key(|s| s.len());
    let mut mp: HashMap<String, usize> = HashMap::new();

    let mut ans1= String::new();
    let mut m = 0;
    for x in v.iter() {
        let key = x.clone();
        let count = mp.entry(key).or_insert(0);
        *count += 1;
        if m < *count{
            m = *count;
            ans1 = x.clone();
        }
    }

    let ans2 = v.last().unwrap();
    println!("{} {}",ans1,ans2);
}


Measured memory_bytes: 5052
#include "bits/stdc++.h" // 提出時こちらで問題なし
//#include <iostream>
//#include <string>
//#include <typeinfo>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define REP2(i, s, n) for (int i=(int)(s); i<(int)(n); i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
#define SORT(c) sort((c).begin(),(c).end())
#define R_SORT(c) sort((c).begin(),(c).end(),greater<>())
using G = vector<vector<int>>;
using M = map<int, int>;
using P = pair<int, int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

// C - Repsept

// B - Distance 
int main() {
	double n, d;
	cin >> n >> d;
	double x, y = 0;
	int ans = 0;
	/*vector<int> v_x(n);
	vector<int> v_y(n);*/
	/*REP(i, n) { cin >> v_x.at(i) >> v_y.at(i); }*/
	REP(i, n) {
		cin >> x >> y;
		if (sqrt(pow(x,2) + pow(y, 2)) <= d) { ans++; }
		/*cout << sqrt(pow(x, 2) + pow(y, 2)) << endl;*/
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 3776
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll li
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000000000000
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 401030
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
 
 
// #define INTMAX 200000000 
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;             
typedef priority_queue<pii, vector<pii> ,greater < pii > > min_pq;
// typedef priority_queue<pii, vector<pii> , greater<pii >  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
// using namespace __gnu_pbds;         
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005

string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    cin >> s;
    for ( ll i = 0; i < s.size(); i ++)
    {
        if ( s[i]=='1')
            cout << '9';
        else if ( s[i] == '9')
            cout <<'1';
        else
            cout << s[i];
    }

}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
char s[maxn];
int n;
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	int cnt=0;
	ll ans=0;
	for(int i=n;i;i--)
		if(s[i]=='A')ans+=cnt;
		else if(s[i]=='C'&&s[i-1]=='B')++cnt,--i;
		else cnt=0;
	writeln(ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   // your code goes here

    int n,k,s=0;
    int a[1005];
    cin>>n>>k;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for (int i=0;i<k;i++)
    {
        s+=a[i];
    }
cout<<s;



}


Measured memory_bytes: 3604
#include<iostream>
#include<bitset>

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int h,w,m; std::cin >> h >> w >> m;
  int br[300000];
  int bc[300000];
  int cntr[300000] = {};
  int cntc[300000] = {};
  int maxr=0,maxc=0;
  for(int i = 0; i < m; ++i){
    std::cin >> br[i] >> bc[i];br[i]--;bc[i]--;
    cntr[br[i]]++;
    cntc[bc[i]]++;
    if(maxr < cntr[br[i]])maxr = cntr[br[i]];
    if(maxc < cntc[bc[i]])maxc = cntc[bc[i]];
  }
  std::bitset<300000>r,c;
  int cr=0,cc=0,cntd=0;
  for(int i = (h<w?w:h)-1; i >= 0; --i){
    cr+=r[i] = maxr == cntr[i];
    cc+=c[i] = maxc == cntc[i];
  }
  cntd = cr*cc;
  for(int i = 0; i < m; ++i)
    cntd -= c[bc[i]]&r[br[i]];
  std::cout << maxr + maxc - (!cntd) << '\n';
}


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

int N;
int a[110];

int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int ans=99999999;
    for(int i=-100;i<=100;i++){
        int sum=0;
        for(int j=0;j<N;j++){
            sum+=(a[j]-i)*(a[j]-i);
        }
        if(sum<ans)ans=sum;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
//typedef long long LL;
using namespace std;

struct shop{
    string s;
    int p;
    int num;

    shop(string s_i, int p_i, int num_i){
        s = s_i;
        p = p_i;
        num = num_i;
    }
};

bool cmp(const shop &a, const shop &b){
    if(a.s!=b.s){
        return a.s < b.s;
    }else{
        return a.p > b.p;
    }
}

int main(){
    int n;
    string tmp_s;
    int tmp_p;
    vector<shop> sp;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_s >> tmp_p;
        sp.push_back(shop(tmp_s, tmp_p, i+1));
    }

    sort(sp.begin(), sp.end(), cmp);

    for(int i=0; i<n; i++){
        cout << sp[i].num << endl;
    }
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void){
    string S;
    string T="";
    string Tr="";
    int ans=0;

    cin >> S;
    int len = S.length();

    for(int i=0;i<len;i++){
        if(S[i] != 'x'){
            T += S[i];
            Tr += S[i];
        }
    }
    reverse(T.begin(), T.end());
    if(T != Tr){
        ans = -1;
        cout << ans << endl;
        return 0;
    }
    int i = 0, j = len - 1;
    while (i < j) {
      if (S[i] == S[j]) {
        i++;
        j--;
        continue;
      }
      ans++;
      if (S[i] == 'x') {
        i++;
      } else {
        j--;
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
K, N = map(int, input().split())
A = list(map(int, input().split()))

B = [None] * (N - 1)
for i in range(N - 1):
    B[i] = A[i + 1] - A[i]

shuu = K
tmp = shuu - sum(B)
print(shuu - max(max(B), tmp))


Measured memory_bytes: 26436