akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef tuple<ll, ll, ll> mytuple;
const ll INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589793238;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) { if (b == 0) {return a;} else {return GCD(b, a % b);} }
// a と b の最小公倍数を返す関数
long long LCM(long long a, long long b) { return a/GCD(a,b)*b; }

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

int sunuke[100] = {0};

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

  for(int i = 0; i < K; i++) {
    int d; cin >> d;
    for(int j = 0; j < d; j++) {
      int a; cin >> a;
      sunuke[a]++;
    }
  }

  int64_t cnt = 0;
  for(int i = 1; i <= N; i++) {
    if(sunuke[i] == 0) {
      cnt++;
    }
  }

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  string s;
  cin>>s;
  int count=0;
  int c=0;
  rep(i,10){
    if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){
      c++;
    }
    else{
      c=0;
    }
    if(c>count)
      count=c;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<utility>

typedef std::pair<int, int> P;

P gcd( int s, int a, int b )
{
	if( b == 0 )
		return P( a, s );

	return gcd( s + 1, b, a % b );
}

int main()
{
	int a, b;
	while( std::cin >> a >> b, a | b )
	{
		P p = gcd( 0, std::max( a, b ), std::min( a, b ) );
		std::cout << p.first << ' ' << p.second << std::endl;
	}

	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int a[3][3];
	for (auto &i : a) for (auto &j : i) j = ri();
	int n = ri();
	for (int i = 0; i < n; i++) {
		int x = ri();
		for (auto &i : a) for (auto &j : i) if (j == x) j = 0;
	}
	bool res = false;
	for (int i = 0; i < 3; i++)
		if (!std::accumulate(a[i], a[i] + 3, 0)) res = true;
	for (int i = 0; i < 3; i++) {
		int sum = 0;
		for (int j = 0; j < 3; j++) sum += a[j][i];
		if (!sum) res = true;
	}
	int sum = 0, sum1 = 0;
	for (int i = 0; i < 3; i++) sum += a[i][i], sum1 += a[i][2 - i];
	if (!sum || !sum1) res = true;
	puts(res ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ios;
	int n,k;cin>>n>>k;
	int a[n+1],dp[n+1];
	for(int i=1;i<n+1;i++)cin>>a[i];
	for(int i=1;i<=n;i++)dp[i]=hell;
	dp[2]=abs(a[2]-a[1]);
	dp[1]=0;
	for(int i=3;i<=n;i++){
		for(int j=1;j<=k and (i-j)>0;j++){
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
int a[100001],n;

int Partition(int a[], int p, int r);

int main()
{

     int i,m;

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

   m = Partition(a,0,n-1);

   for(i=0;i<m;i++){
          printf("%d ",a[i]);
   }
   printf("[%d] ",a[m]);

   for(i=m+1;i<n-1;i++){
          printf("%d ",a[i]);
   }

   printf("%d\n",a[n-1]);

   return 0;
}


int Partition(int a[], int p,int r){
     int x,i,j,temp,temp2;

     x = a[r];
     i = p-1;

     for(j=p;j<=r-1;j++){
          if(a[j] <= x){

               i += 1;
               temp = a[i];
               a[i] = a[j];
               a[j] = temp;
        }
 }

 temp2 = a[i+1];
 a[i+1] = a[r]; 
 a[r]= temp2;  

 return i+1;
}

Measured memory_bytes: 988
#include <stdio.h>

int main(void){
    int N,K;
    double ans=0;
    double buf;
    scanf("%d %d",&N,&K);
    int i,tmp;
    for(i=1;i<=N;i++){
        buf = 1.0;
        tmp = i;
        while(tmp<K){
            tmp *= 2;
            buf *= 0.5;
        }
        ans += buf;
    }
    ans *= 1.0/N;
    printf("%.12f",ans);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
S = list(input())

s = list(S)
x = 0
res = 0
for j in range(len(s)):
    if s[j] == 'I':
        x+=1
    elif s[j] == 'D':
            x-=1
    res = max(res, x)       
print (res)


Measured memory_bytes: 2940
import math
import sys
import itertools
from collections import deque
# import numpy as np

def main():
  n = int(input())

  d = deque()
  for _ in range(n):
    order = input().split()

    if order[0] == 'insert':
      d.appendleft(order[1])
    elif order[0] == 'delete':
      try:
        d.remove(order[1])
      except ValueError:
        pass
    elif order[0] == 'deleteFirst':
      d.popleft()
    elif order[0] == 'deleteLast':
      d.pop()

  print(*d)

if __name__ == '__main__':
  main()


Measured memory_bytes: 69928
import datetime

H1, M1, H2, M2, K = map(int, input().split())

a = datetime.datetime(2020, 5, 30, H2, M2)
b = datetime.datetime(2020, 5, 30, H1, M1)
delta = a - b
minute = delta.seconds // 60
print(minute - K)


Measured memory_bytes: 9308
#define MAX 500000
#define SENTINEL 2000000000
#include<stdio.h>
#include<math.h>

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int left, int mid, int right) {
	int n1, n2;
	int i, j, k;

	n1 = mid - left;
	n2 = right - mid;

	for (i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = SENTINEL;

	i = 0;
	j = 0;
	for (k = left; k < right; k++) {
	    cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[], int left, int right) {
	int mid;

	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main() {
	int n, S[500000], i;

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

	mergeSort(S, 0, n);
	for (i = 0; i < n; i++) {
		printf("%d", S[i]);
		if (i < n - 1) {
			printf(" ");
		}
	}
	printf("\n");
	printf("%d\n",cnt);
	
	return 0;
}


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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	string s; cin >> s;


	int n = s.size();

	int ans = 10000;
	for(int i = 0; i < n - 2; i++){
		int t = stoi(s.substr(i, 3));
		ans = min(ans, abs(t - 753));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt() - 1;
    }
    int num = 0;
    for (int i = 0; i < N; i++) {
      if (a[a[i]] == i) num++;
    }
    System.out.println(num / 2);
  }
}


Measured memory_bytes: 49548
import math
a,b,angle=map(int,input().split(" "))
rad=angle/180*math.pi
h=b*math.sin(rad)
#print(h)
S=a*h*1/2

c=math.sqrt(a**2+b**2-2*a*b*math.cos(rad))
L=a+b+c

print("{:.8f}".format(S))
print("{:.8f}".format(L))
print("{:.8f}".format(h))



Measured memory_bytes: 5712
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    Queue<Long> pq = new PriorityQueue<Long> (Collections.reverseOrder());
    for(long i=1;i<=(long)Math.floor(Math.sqrt(N));i++){
      if(N%i==0){
        pq.add(i);
      }
    }
    long dmax = pq.poll();
    long dmaxb = N/dmax;
    System.out.println(dmax+dmaxb-2);
      
  }
  

  
}

Measured memory_bytes: 23860
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
   X, Y, Z = MAP()
   print(Z, X, Y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n;
  cin>>n;
  cout<<180*(n-2)<<endl;
  
}


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

int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=0; i<N; i++){
    char S;
    cin >> S;
    if(S=='Y') ans++;
  }
  if(ans==0) cout << "Three" << endl;
  else cout << "Four" << endl;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()
As = list(mi())

oddans = 1
for a in As:
  if a % 2 == 1:
    #自身が奇数なら、自身を選ぶしかない
    continue
  else:
    #自身が偶数なら、両側の奇数を選ぶことができる
    oddans *= 2

print(pow(3, N) - oddans)










Measured memory_bytes: 38640
#include<stdio.h>


void output(int A[], int n){
  int i;
  for(i =0;i<n;i++){
    if(i > 0){
      printf(" ");
    }
      printf("%d",A[i]);
  }
  printf("\n");
}


void insertionSort(int A[], int n){
  int j,i,v;
  for(i = 1;i < n;i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;

    }
    A[j + 1] = v;
    output(A, n);
    }
  }

int main(){

  int i,n,j;
  int A[100];

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








Measured memory_bytes: 2136
# AGC014B - Unplanned Queries
def main():
    N, _, *A = map(int, open(0).read().split())
    T = [0] * (N + 1)
    for i in A:
        T[i] += 1
    flg = all(i % 2 == 0 for i in T)
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 25076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

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

    void solve() throws IOException {

    	int a = ni();
    	String op = ns();
    	int b = ni();

    	int ans;

    	if(op.equals("+")){
    		ans = a + b;
    	}else{
    		ans = a - b;
    	}

    	out.println(ans);

    }

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

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

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

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

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

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

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

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

Measured memory_bytes: 8276
#include <cstdio>
#include <cstdint>

int main() {
    int n;
    scanf("%d", &n);

    int* a = new int[n];
    scanf("%d", &a[0]);
    int min = a[0];
    int max = a[0];
    int64_t sum = a[0];
    for (int i=1; i<n; i++) {
        scanf(" %d", &a[i]);
        if (min > a[i]) { min = a[i]; }
        if (max < a[i]) { max = a[i]; }
        sum += a[i];
    }
    printf("%d %d %lld\n", min, max, sum);

    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 2e5 + 5;

const int inf = 1e15;

int dp[N], n, h[N], c, pter = 0;

vector<ii> vec;

int mul(int x, int y) {
    return (1ll * x * 1ll * y) % mod;
}

int del(int x, int y) {
    return ((1ll * x - 1ll * y) % mod + mod) % mod;
}

long double findx(ii x, ii y) {
    return ((long double)(y.se) - (long double)(x.se)) / ((long double)(x.fi) - (long double)(y.fi));
}

bool compare(ii x, ii y, ii z) {
    return(findx(x, y) > findx(x, z));
}

void add(int a, int b) {
    vec.pb({a, b});
    while(vec.size() >= 3 && compare(vec[vec.size() - 3], vec[vec.size() - 2], vec[vec.size() - 1])) {
        vec.pop_back();
        vec.pop_back();
        vec.pb({a, b});
    }
}

int query(int x) {
    pter = min(pter, (long long)(vec.size()) - 1);
    while(pter + 1 < vec.size() && vec[pter].fi * x + vec[pter].se >= vec[pter + 1].fi * x + vec[pter + 1].se)
        pter++;
    return vec[pter].fi * x + vec[pter].se;
}

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> c;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    dp[1] = 0;
    add(-2 * h[1], h[1] * h[1] + dp[1] + c);
    for(int i = 2; i <= n; i++) {
        dp[i] = query(h[i]) + h[i] * h[i];
        add(-2 * h[i], h[i] * h[i] + dp[i] + c);
    }
    cout << dp[n];
}



Measured memory_bytes: 8816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N;
  cin >> N;
  ll a[N];
  rep(i, N){
    cin >> a[i];
  }
  ll ans = 0;
  rep(i, N){
    rep(j, N){
      ans += a[i]*a[j];
    }
  }
  rep(i, N){
    ans -= a[i]*a[i];
  }
  ans/= 2;
  cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    for(int i = 1; i < 10; ++i) {
        for(int j = 1; j < 10; ++j) {
            if(i*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

using namespace std;

#define REPEAT(i, N) for (int i = 0; i < (N); i++)

int main() {
  int N;
  
  vector<int> p;
  
  cin >> N;
  
  REPEAT(i, N) {
    int _in;
    
    cin >> _in;
    
    p.push_back(_in);
  }
  
  int cnt = 0;
  
  for (int i = 1; i < N - 1; i++) {
    if ((p[i - 1] <= p[i] && p[i] < p[i + 1]) || (p[i - 1] >= p[i] && p[i] > p[i + 1])) {
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,N);
  IN(ll,X);
  AIN(ll,L,N);
  ll sum = 0;
  ll count = 0;
  while(X >= sum){
    if(count == N){
      count++;
      break;
    }
    sum += L.at(count);
    count++;
  }
  OUT(count);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	char x;
	cin >> x;
	if(x>=97)
	cout << "a";
	else
	cout << "A";
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll l = 0, r = INF;
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    while (l + 1 < r) {
        ll m = l + (r - l) / 2;
        ll cnt = 0;
        for (i = 0; i < n; i++) {
            cnt += (a[i] - 1) / m;
        }
        if (cnt > k)
            l = m;
        else
            r = m;
    }
    cout << r << endl;
}

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

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

    int ans = 0;
    while (N > 0)
    {
        ans += N - 1;
        N--;
    }
    while (M > 0)
    {
        ans += M - 1;
        M--;
    }
    cout << ans << endl;

    return (0);
}

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

int n;
queue<int> q;
vector<int> depth;

void dfs(int start, vector<vector<int>> a) {
    depth[start] = 0;
    q.push(start);

    while (!q.empty()) {
        int current = q.front();
        q.pop();
        rep(adj, n) {
            if (a[current][adj] == 1 && depth[adj] == -1) {
                depth[adj] = depth[current] + 1;
                q.push(adj);
            }
        }
    }
}

int main() {
    scanf("%d", &n);
    depth.resize(n+1, -1);
    vector<vector<int>> a(n+1, vector<int>(n+1, 0));
    rep(i, n) {
        int u;
        scanf("%d", &u);
        int k;
        scanf("%d", &k);
        rep(j, k) {
            int adj;
            scanf("%d", &adj);
            a[u][adj] = 1;
        }
    }
    dfs(1, a);
    rep(i, n) {
        printf("%d %d\n", i, depth[i]);
    }
}


Measured memory_bytes: 3268
N, W = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

w0 = X[0][0]
ctr = [[] for _ in range(4)]
for w, v in X:
    ctr[w - w0].append(v)

for n in range(4):
    values = sorted(ctr[n], reverse=True)
    s = [0] * (len(values) + 1)
    for i in range(len(values)):
        s[i + 1] = s[i] + values[i]
    ctr[n] = s

ans = 0
for i in range(len(ctr[0])):
    for j in range(len(ctr[1])):
        for k in range(len(ctr[2])):
            for l in range(len(ctr[3])):
                tmp = ctr[0][i] + ctr[1][j] + ctr[2][k] + ctr[3][l]
                w = w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l
                if w <= W:
                    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 42092
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll a, b;
	cin >> a >> b;
	if (a != b)cout << 2 * max(a, b) - 1 << endl;
	else cout << 2 * a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

template<int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt& operator+=(const ModInt& p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(const ModInt& p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator*=(const ModInt& p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt& operator/=(const ModInt& p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt& p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt& p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt& p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt& p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt& p) const { return x == p.x; }
    bool operator!=(const ModInt& p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e) {
        long long a = 1, p = x;
        while (e > 0) {
            if (e % 2 == 0) { p = (p * p) % mod; e /= 2; }
            else { a = (a * p) % mod; e--; }
        }
        return ModInt(a);
    }

    friend ostream& operator<<(ostream& os, const ModInt<mod>& p) {
        return os << p.x;
    }
    friend istream& operator>>(istream& is, ModInt<mod>& a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};
using modint = ModInt<mod>;

int main() {
    init();

    int n;
    cin >> n;
    string S, T, s = "", t = "";
    cin >> S >> T;
    s += S[0], t += T[0];
    FOR(i, 0, n - 1)if (S[i] != S[i + 1]) {
            s += S[i + 1];
            t += T[i + 1];
    }
    
    modint ans = (s[0] == t[0] ? 3 : 6), br[2][2] = { {3,1},{2,2} };
    FOR(i, 0, s.length() - 1)ans *= br[s[i] == t[i]][s[i + 1] == t[i + 1]];
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;


constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N;
  ll K, Q;
  cin >> N >> K >> Q;

  vll scores(N, K-Q);
  for (int i=0; i<Q; i++) {
    int A;
    cin >> A;
    A--; // 0-indexe
    scores[A]++;
  }

  for (auto x : scores) {
    if (x <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main(){
  string s,t;
  cin >> s >> t;
  int count=0;
  for(int i=0;i<s.length();i++){
    if(s[i]!=t[i]){
      count++;
    }
  }
  cout<<count;
}


Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
#include <algorithm>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100000;
int l[5 + nmax], r[5 + nmax];
ll sum[5 + nmax], sum2[5 + nmax];

int main() {
  int n;
  std::cin >> n;
  for(int i = 1;i <= n; i++)
    std::cin >> l[i] >> r[i];
  std::sort(l + 1, l + n + 1);
  std::sort(r + 1, r + n + 1);
  std::reverse(l + 1, l + n + 1);
  for(int i = 1;i <= n; i++)
    sum[i] = sum[i - 1] + l[i];
  for(int i = 1; i <= n; i++)
    sum2[i] = sum2[i - 1] + r[i];
  ll result = 0;
  for(int i = 1;i <= n; i++) {
    result = std::max(result, sum[i - 1] - sum2[i]);
    result = std::max(result, sum[i] - sum2[i]);
    result = std::max(result, sum[i] - sum2[i - 1]);
  }
  std::cout << 2 * result;
  return 0;
}


Measured memory_bytes: 5952
//52
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n;){
    int ans=0;
    for(int a=0;a<=9;a++){
      for(int b=0;b<=9;b++){
	for(int c=0;c<=9;c++){
	  for(int d=0;d<=9;d++){
	    ans+=a+b+c+d==n;
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long n,m,i,s,a,res;
map<long,long>mp;
int main(void){
  cin>>n>>m;
  mp[0]=1;
  for(i=0;i<n;i++){
    cin>>a;
    s+=a;
    res+=mp[s%m];
    mp[s%m]++;
  }
  cout<<res<<endl;
  return 0;
}


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

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


int main(){
  int k;
  long long tmp,cnt=0;
  cin >> k;
  
  for(int i=1;i<=k;i++){
      for(int j=1;j<=k;j++){
          tmp = gcd(i,j);
          for(int l=1;l<=k;l++){
              cnt += gcd(tmp,l);
          }
      }
  }
  cout << cnt << endl;
}


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

int main() {


    int a, b;
    cin>>a>>b;
    if (a > 0 & a < 10 & b >0 & b < 10){
    	cout<<(a*b)<< endl;
    } 
    else{
    	cout<<-1<< endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,k,i,d,a,r[101],j,l,sum=0;
    scanf("%d%d",&n,&k);
    for(l=0;l<=n;l++)
    {
        r[l]=0;
    }
    for(i=0;i<k;i++)
    {
        scanf("%d",&d);
        for(j=0;j<d;j++)
        {
            scanf("%d",&a);
            r[a]=r[a]+1;
        }
    }
    for(l=1;l<=n;l++)
    {
        if(r[l]==0)
        {
            sum=sum+1;
        }
    }
    printf("%d",sum);
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int mod = 1e9+7;
int dp[101][4][4][4];
int main(){
    int n; cin >> n;
    dp[0][3][3][3] = 1;
    
    rep(len,n){
        rep(c1,4){
            rep(c2,4){
                rep(c3,4){
                    if(dp[len][c3][c2][c1] == 0) continue;

                    rep(add,4){
                        if(c3 == 0 && c1 == 1 && add == 2) continue;
                        if(c2 == 0 && c1 == 1 && add == 2) continue;
                        if(c2 == 1 && c1 == 0 && add == 2) continue;
                        if(c2 == 0 && c1 == 2 && add == 1) continue;
                        if(c3 == 0 && c2 == 1 && add == 2) continue;

                        dp[len+1][c2][c1][add] += dp[len][c3][c2][c1];
                        dp[len+1][c2][c1][add] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;

    rep(c3,4){
        rep(c2,4){
            rep(c1,4){
                ans += dp[n][c3][c2][c1];
                ans %= mod;
            }
        }
    }

    cout << ans << endl;
}


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

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;

	priority_queue<ll> que;
	for (ll i = 0; i < N; ++i)
	{
		ll a; cin >> a;
		que.push(a);
	}

	for (ll i = 0; i < M; ++i)
	{
		ll p = que.top(); que.pop();
		que.push(p/2);
	}

	ll res{0};
	while (!que.empty())
	{
		ll p = que.top(); que.pop();
		res += p;
	}

	std::cout << res << std::endl;
}

Measured memory_bytes: 1400
program main
  implicit none

  character(len=17) :: num
  integer, allocatable :: n(:)
  integer :: k, i, ans, end

  read(*,*) num
  k = len_trim(num)
  allocate(n(k))

  do i = 1, k
     read(num(i:i),*) n(i)
  end do

  end = 0
  ans = 0
  if(k == 1) then
     ans = n(1)
  else if(n(2) /= 9) then
     ans = 9 * (k-1) + (n(1) - 1)
  else if(k == 2) then
     ans = n(1) + n(2)
  else
     ans = n(1)
     do i = 3, k
        if(n(i) == 9) then
           ans = ans + 9
           end = 1
        else
           ans = ans + 17 + 9 * (k - i)
           end = 0
           exit
        end if
     end do
     if(end == 1) then
        ans = ans + 9
     end if
     
  end if

  write(*,*) ans
           

  deallocate(n)

end program main

  


Measured memory_bytes: 2832
import java.io.*;
import java.util.*;

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private void solve(Scanner sc, PrintWriter out) {
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if (a == 7 && b == 5 && c == 5
    || a == 5 && b == 7 && c == 5
    || a == 5 && b == 5 && c == 7) {
      out.println("YES");
    } else {
      out.println("NO");
    }
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  private long ceil2pow(long n) {
    if (n == 0) {
      return 1;
    }
    n--;
    n |= (n >>> 1);
    n |= (n >>> 2);
    n |= (n >>> 4);
    n |= (n >>> 8);
    n |= (n >>> 16);
    n++;
    return n;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 9812
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

def match(ofs_x, ofs_y):
    for i in range(M):
        if A[i+ofs_y][ofs_x:ofs_x+M] != B[i]:
            return False
    return True

for i in range(N-M+1):
    for j in range(N-M+1):
        if match(j,i):
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(S: str):
    d1 = int(S[:2])
    d2 = int(S[2:])
    print({
        (False, False): "NA",
        (False, True): "YYMM",
        (True, False): "MMYY",
        (True, True): "AMBIGUOUS",
    }[1 <= d1 <= 12, 1 <= d2 <= 12])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


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



int MOD=1000000007;
int main(void){
	long long K,X;
	cin >> K >> X;
	if(500*K>=X) cout << "Yes" << endl;
	else cout << "No" << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
int n, maks=-1;
string s;

int main(){
	IOS
	cin >> n >> s;
	for(int i=0;i<n-1;i++){
		int ans=0;
		set<int>s1, s2;
		for(int j=0;j<=i;j++) s1.insert(s[j]);
		for(int j=i+1;j<n;j++) s2.insert(s[j]);
		for(auto x:s1){
			if(s2.count(x)) ans++;
		}
		maks=max(maks, ans);
	}
	cout << maks << '\n';	
}


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

vector<int> solve(int st,int en,int lev){
	if(lev == 0)	return {st,en};
	int idx = __builtin_ctz(st^en);
	int base = 1<<idx;
	int nxtst = st%base + st/base/2*base;
	int nxten = en%base + en/base/2*base;
	auto ls = solve(nxtst,nxtst^1,lev-1);
	auto rs = solve(nxtst^1,nxten,lev-1);
	vector<int> res;
	for(int it:ls)
		res.emplace_back(it%base+it/base*2*base);
	for(int it:rs)
		res.emplace_back(it%base+it/base*2*base);
	if(st&base)
		for(int i=0;i<(1<<lev);i++)
			res[i] ^= base;
	else
		for(int i=(1<<lev);i<res.size();i++)
			res[i] ^= base;
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	if(__builtin_parity(a) == __builtin_parity(b))
		return cout<<"NO"<<endl, 0;
	cout<<"YES"<<endl;
	auto res = solve(a,b,n-1);
	for(int it:res)
		cout<<it<<' ';
	cout<<endl;
}


Measured memory_bytes: 1756
#include <iostream>
#include <vector>
#include <map>
int main()
{
	int N;
	int64_t K;
	std::cin >> N >> K;
	std::vector<int> A;
	for (int i = 0; i < N; ++i) {
		int a;
		std::cin >> a;
		A.push_back(a);
	}
	int pos = 1;
	std::map<int, int64_t> hist;
	hist.insert(std::map<int, int64_t>::value_type(1,-1));
	int64_t count = K;
	for (int64_t i = 0; i < count; ++i) {
		pos = A[pos - 1];
		auto itr = hist.find(pos);
		if (itr == hist.end()) {
			hist.insert(std::map<int, int64_t>::value_type(pos, i));
		}
		else {
			int64_t interval = (i - itr->second);
			i += (count - 1 - i) / interval * interval;
		}
	}
	std::cout << pos << std::endl;
	return 0;
}

Measured memory_bytes: 13960
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec;
//use std::vec::Vec;
//use std::collections::HashSet;


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: usize = sc.read();
    let b: usize = sc.read(); // unused
    let s: String = sc.read();
    let s = to_chars(s);
    let mut ok = true;
    for i in 0..s.len() {
        ok &= i == a && s[i] == '-' || i != a && s[i] != '-';
    }
    match ok {
        true => println!("Yes"),
        false => println!("No"),
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
int main()
{
    int num;
    int sum = 0;
    int temp;
    scanf("%d",&num);
    temp = num;
    while(temp > 0)
    {
        sum+=temp%10;
        temp/=10;
    }
    if(num%sum==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

int main()
{
	int a, b, c, s;
	cin >> a >> b >> c;

	s = a + b + c;
	if( s == 2*( a + b ) or s == 2*( b + c ) or s == 2*( c + a )) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No"  << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    ll ans=0;
    vector<ll>num;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            num.push_back(i);
        }
    }
    ll sum=1;
    if(num.size()==0){
        cout << 0 << endl;
        return 0;
    }
    for(ll i=0;i<num.size()-1;i++){
        if(num[i]==num[i+1]-1){
            sum++;
        }
        else {
            ans=max(ans,sum);
            sum=1;
        }
    }
    ans=max(ans,sum);
    cout << ans << endl;
}

Measured memory_bytes: 3520
mod = 10**9+7
K = int(input())
S = input()

M = 2*10**6
fact = [1]*(M+1)
factinv = [1]*(M+1)
for n in range(1,M+1):
    fact[n] = n*fact[n-1]%mod
    factinv[n] = pow(fact[n],mod-2,mod)

def comb(n,k):
    return fact[n]*factinv[k]*factinv[n-k]%mod
n = len(S)
ans = 0

for k in range(K+1):
    ans += comb(n+k-1,k)*pow(25,k,mod)*pow(26,K-k,mod)
    ans %= mod
print(ans)

Measured memory_bytes: 102056
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	int a = 753;
	int diff = 100000;
	for (int i = 0; i < s.size() - 2; i++) {
		int three = stoi(s.substr(i, 3));
		diff = min(abs(three - a), abs(diff));
	}
	cout << diff;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    if(l==6)
    {
        if(s[2]==s[3] && s[4]==s[5])
        {
            cout<<"Yes\n";
        }
        else cout<<"No\n";
    }
    else cout<<"No\n";

}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll a,b,k; cin >> a >> b >> k;
  if(a+b<=k) cout << 0 << " "<< 0 << endl;
  else if(a<=k) cout << 0 <<" "<< b+a-k << endl;
  else cout << a-k << " "<< b << endl;
  return 0;
}


Measured memory_bytes: 256
import heapq

N, K = map(int, raw_input().split())
pq = []
for a, b in [map(int, raw_input().split()) for _ in range(N)]:
  heapq.heappush(pq, (a, (a, b)))
res = -1
while K > 0:
  res, (_, num) = heapq.heappop(pq)
  K -= num
print res

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

from collections import Counter
counter=Counter(A)

LIST=sorted(list(counter.keys()),reverse=True)

L=len(LIST)

i=0
ANS=0
while i<L:
    #print(i,counter,ANS)
    if counter[LIST[i]]==0:
        i+=1
    else:
        for k in range(1,33):
            if 2**k<=LIST[i]:
                continue
            if 2**k>LIST[i]*2:
                i+=1
                break
            if counter.get(2**k-LIST[i],0)>0:
                if LIST[i]!=2**k-LIST[i]:
                    x=min(counter[LIST[i]],counter[2**k-LIST[i]])
                    counter[LIST[i]]-=x
                    counter[2**k-LIST[i]]-=x
                    ANS+=x
                else:
                    if counter[LIST[i]]>=2:
                        x=counter[LIST[i]]//2
                        counter[LIST[i]]-=x*2
                        ANS+=x
                    

print(ANS)

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

int main(){
  
    int n;
    cin >> n;
    string s;
    cin >> s;
 
    int ans = 0;
 
    for(int i = 0; i < n - 1; i++){
        string x = s.substr(0, i + 1);
        string y = s.substr(i + 1, n - i - 1);
 
        int c[2][26] = {};
 
        for(int j = 0; j < x.size(); j++){
            c[0][x[j] - 'a']++;
        }
 
        for(int j = 0; j < y.size(); j++){
            c[1][y[j] - 'a']++;
        }
 
        int tmpans = 0;
 
        for(int j = 0; j < 26; j++){
            if(c[0][j] > 0 && c[1][j] > 0) tmpans++;
        }
 
        ans = max(ans,tmpans);
    }
 
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384