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

int main() {
    ll n, k, a[200000], mib, mab, c, b, co, mi, ma, i, mm;
    cin >> n >> k;
    for (i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    mib = -2000000000000000000LL;
    mab = 2000000000000000000LL;
    c = 0;
    while (mib != mab) {
        b = (mab + mib - abs((mab + mib) % 2)) / 2;
        co = 0;
        for (int j = 0; j < n;j++) {
            i = a[j];
            mi = 0;
            ma = n - 1;
            if (i >= 0) {
                if (i * a[0] > b) {
                    continue;
                }
                while (mi != ma) {
                    mm = (mi + ma) / 2 + 1;
                    if (i * a[mm] <= b) {
                        mi = mm;
                    } else {
                        ma = mm - 1;
                    }
                }
                co += mi + 1;
                if (i * i <= b) {
                    co -= 1;
                }
            } else {
                if (i * a[n - 1] > b) {
                    continue;
                }
                while (mi != ma) {
                    mm = (mi + ma) / 2;
                    if (i * a[mm] <= b) {
                        ma = mm;
                    } else {
                        mi = mm + 1;
                    }
                }
                co += n - mi;
                if (i * i <= b) {
                    co -= 1;
                }
            }
        }
        //cout << co << endl;
        if (co / 2 >= k) {
            mab = b;
        } else {
            mib = b + 1;
        }

    }
    cout << mib << endl;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] s = new int[m];
        int[] c = new int[m];

        for (int i = 0; i < m; i++) {
            s[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        int[] num = new int[n + 1];
        Arrays.fill(num, -1);
        for (int i = 0; i < m; i++) {
            if (num[s[i]] != -1 && num[s[i]] != c[i]) {
                System.out.println(-1);
                return;
            }
            num[s[i]] = c[i];
        }
        for (int i = 1; i < num.length; i++) {
            if (i == 1 && num[i] == 0 && i + 1 < num.length) {
                System.out.println(-1);
                return;
            }
            if (num[i] == -1) {
                if (i == 1 && i + 1 < num.length) {
                    num[i] = 1;
                    continue;
                }
                num[i] = 0;
            }
        }
        int ans = 0;
        for (int i = 1; i < num.length; i++) {
            ans += num[i] * Math.pow(10, num.length - i - 1);
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int cnt[N];
  fill(cnt, cnt + N, 0);
  for (int i = 2; i <= N; i++) {
    int A;
    cin >> A;
    A--;
    cnt[A]++;
  }
  for (int i = 0; i < N; i++) cout << cnt[i] << endl;
  return 0;
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
 
int main() {
	int H, N;
	cin >> H >> N;

	vector<int> A(N);
	for (int i = 0; i < N; i++){
		cin >> A.at(i);
	}

	sort(A.begin(), A.end());

	for (int i = N - 1; i >= 0; i--)
	{
		H -= A.at(i);
		if (H <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    int h, w;
    cin >> h >> w;

    ll cost[10][10] = {};
    for(int i=0;i<10;++i) {
        for(int j=0;j<10;++j) {
            cin >> cost[i][j];
        }
    }

    for(int k=0;k<10;++k) {
        for(int i=0;i<10;++i) {
            for(int j=0;j<10;++j) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    ll ans = 0;
    int a[h][w];
    for(int i=0;i<h;++i) {
        for(int j=0;j<w;++j) {
            cin >> a[i][j];
            if(a[i][j] == -1) continue;
            ans += cost[a[i][j]][1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3780
#include <iostream>
using namespace std ;
int main()
{
	int n , b , f , r , v , a[5][4][11] , y , c = 1 , l , o , i , h , w ;
  for ( i = 1 ; i < 5 ; i ++ ){
   for ( h = 1 ; h < 4 ; h ++ ){
   	for ( w = 1 ; w < 11 ; w ++ ){
   		a[i][h][w] = 0 ;
   	}
  }
}
 cin >> n ;
 while ( c <= n ){
 	cin >> b >> f >> r >> v ;
 	b <= 4 ;
 	f <= 3 ;
 	r <= 10 ;
 	v <= 9 ; 
 	a[b][f][r] = a[b][f][r] + v ;
 	a[b][f][r] >= 0 ;
 	c ++ ;
}
   for ( i = 1 ; i < 5 ; i ++ ){
  	for ( h = 1 ; h < 4 ; h ++ ){
  		for ( w = 1 ; w < 11 ; w ++ ){
  			cout << " " << a[i][h][w] ;
  		}
  		cout << endl ;
  	}
  if ( i < 4 )
  	cout << "####################" << endl ;
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000;

//main関数
int main() {
    //入力
    long N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    string S;
    cin>>S;
    A--;
    B--;
    C--;
    D--;
    
    //計算
    bool flag;
    
    //A->C
    flag=false;
    for(int i=A;i<=C;i++){
        if(flag && S.at(i)=='#'){
            
            cout<<"No"<<endl;
            return 0;
        }
        
        flag=(S.at(i)=='#');
    }
    
    
    //B->D
    flag=false;
    for(int i=B;i<=D;i++){
        if(flag && S.at(i)=='#'){
            cout<<"No"<<endl;
            return 0;
        }
        
        flag=(S.at(i)=='#');
    }
    
    
    
    if(D<C){
        long count=(S.at(B-1)=='.');
        long length=count;
        for(int i=B;i<=D+1;i++){
            if(S.at(i)=='.') count++;
            else count=0;
            
            //cout<<i<<"番目"<<count<<endl;
            length=max(length,count);
        }
        
        if(length<3){
            //cout<<"dfghj"<<endl;
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    
    
    //出力
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import sys
import re

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
N = len(S)

if re.match(r'^(hi)+$', S):
    Yes()
else:
    No()


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

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  int count = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    for (int j = 0; j < i; j++) {
      if (s.at(n-1 - (i-1) + j) == t.at(j)) {
        tmp++;
      }
    }
    if (tmp == i) {
      count = i;
    }
  }
  cout << 2*n - count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define eb push_back
#define mp make_pair
#define hello cout<<"hello"<<"\n"
#define forr(i,a,b) for(int i=a;i<b;i++)
#define it(s)	for(auto itr:s)
#define dvg(s) 	for(auto itr:s)	cout<<itr<<" ";cout<<endl;
#define dbg(s)	cout<<#s<<"= "<<s<<endl;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF=(lli)1e18+5;
const ulli MOD=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::cout<< std::fixed;
    std::cout.precision(6);
   
	lli a;
	cin>>a;
	cout<<a+a*a+a*a*a<<"\n";
	
		
			
	return 0;
}









Measured memory_bytes: 3600
aa=[]
a=int(input())
for i in range(0,a):
  aa.append(input())

bb=[]
b=int(input())
for j in range(0,b):
  bb.append(input())

score=0
max=0
for m in aa:
  score=(aa.count(m)-bb.count(m))
  if max<=score:
    max=score
      
print (str(max))


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

#define debug(x) cout << #x << ": " << x << endl;

#define mod 998244353
#define ll long long

ll inv[2<<20]; // ith index will store (1/i)%mod
ll finv[2<<20]; // ith index will store (1/i!)%mod
ll fact[2<<20]; // ith index will store (i!)%mod

void populate(ll n) {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for(ll i = 2;i <= n;i++) {
        fact[i] = (i*fact[i-1])%mod;
        inv[i] = mod-((inv[mod%i]*(mod/i))%mod);
        finv[i] = (finv[i-1]*inv[i])%mod;
    }
}

ll nCr(ll n, ll r) {
  //debug(n);debug(r);
  //cout << (fact[n]*(finv[n-r]*finv[r])%mod)%mod << endl;
  return (fact[n]*((finv[n-r]*finv[r])%mod))%mod;
}

ll N, M;

ll distinct_sequences(ll n, ll sum, ll max_odds_cnt) {
  ll ans = 0;
  for(ll i = 0;i <= min(n, max_odds_cnt);i++) {
    if((sum - i) % 2 != 0) continue;

    //debug(i);
    ll a = nCr(n, i); //debug(a);
    ll b = nCr(((sum-i) / 2) + n - 1, n-1); //debug(b);

    ans = ans + ((a * b)%mod);
    ans %= mod;
  }

  return ans;
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> M;
  populate(2000000);

  ll x = distinct_sequences(N, 3*M, M); //debug(x);
  ll y = distinct_sequences(N, M, M); //debug(y);
  ll z = distinct_sequences(N-1, M, M); //debug(z);

  cout << (mod + x - (((y - z)*N)%mod))%mod << endl;

  /*for(int i =0;i <=5;i++) {
    cout<<fact[i] << " " << finv[i] << " :" << i << endl;
  }*/
  //cout << nCr(5, 2);

  return 0;
}


Measured memory_bytes: 49408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <complex>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

int main(){
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    ll x; cin>>x;
    ll ans=0;
    ans=(x/11)*2;
    x%=11;
    if(1<=x&&x<=6)ans++;
    else if(6<x)ans+=2;
    cout<<ans<<endl;
}


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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
vector<ll> aa(n);
rep(i, n){
  cin >> a[i];
}
vector<ll> comp=a;//全部突っ込む
sort(comp.begin(), comp.end());
comp.erase(unique(comp.begin(), comp.end()), comp.end());//隣接要素を削除した後の末尾イテレータからvの末尾まで削除
rep(i,a.size()){
  ll compnum=lower_bound(comp.begin(), comp.end(), a[i]) - comp.begin();//圧縮後の値
  aa[i]=compnum;
}
rep(i,n){
  if(i%2==0)continue;
  if(aa[i]%2==0)ans++;
}
cout << ans << endl;
return 0;
}

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

int main() {
  string s; cin >> s;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3608
#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 rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(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); }

int main() {
    init();

    int n;
    cin >> n;
    vector<pair<ll, ll>> ab(n);
    FOR(i, 0, n)cin >> ab[i].first;
    FOR(i, 0, n)cin >> ab[i].second;

    rSORT(ab, [](auto x, auto y) {return x.first - x.second < y.first - y.second; });
    int ans = 0; ll sum = 0;
    for (int i = 0; i < n && ab[i].second > ab[i].first; i++) {
        sum -= ab[i].second - ab[i].first;
        ans++;
    }
    for (int i = n - 1; i >= 0 && sum < 0 && ab[i].first > ab[i].second; i--) {
        sum += ab[i].first - ab[i].second;
        ans++;
    }
    cout << (sum < 0 ? -1 : ans) << "\n";
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;


int h,w;
vector<string> A;

void solve(){
    cin >> h >> w;
    string b="";
    rep(i,w+2){
        b+=".";
    }
    A.push_back(b);
    rep(i,h){
        string a;
        cin >> a;
        A.push_back("."+a+".");
    }
    A.push_back(b);
    int num=0;
    rep(i,h+2){
        rep(j,w+2) {
            if (A[i][j]=='#') num+=1;
        }
    }
    //rep(i,h+2) cout << A[i] << endl;
    int pos_x=1,pos_y=1;
    int cnt=0;
    while (pos_x!=w || pos_y!=h) {
        if (A[pos_y][pos_x+1]=='#' && A[pos_y+1][pos_x]=='#') {
            cout << "Impossible" << endl;
            return;
        }
        else if (A[pos_y][pos_x+1]=='#') {
            pos_x+=1;
        }
        else if (A[pos_y+1][pos_x]=='#') {
            pos_y+=1;
        }
        else {
            cout << "Impossible" << endl;
            return;
        }
        //cout << pos_x << " " << pos_y << endl;
        cnt+=1;
    }
    if (cnt==num-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

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

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::string S;
int64_t D[1000001];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> S;

	D[0] = 0;
	for (size_t i = 0; i < N; i++)
	{
		D[i + 1] = D[i];
		if (S[i] == 'D') {
			D[i + 1] += 1;
		}
	}


	int32_t Q;
	in >> Q;
	while (Q--)
	{
		int k;
		in >> k;

		int64_t res = 0;
		int64_t M_num = 0;
		int64_t M_add = 0;
		for (int32_t i = 0; i < N; i++)
		{
			if (S[i] == 'M') {
				M_add += D[i];
				++M_num;
			}
			else if (S[i] == 'C') {
				res += M_add - M_num * D[std::max<int32_t>(0, i - k + 1)];
			}
			if (i - k >= 0 && S[i - k] == 'M') {
				M_add -= D[i - k];
				--M_num;
			}
		}
		out << res << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 9836
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt(), c = sc.nextInt(),x;    
        int[] lst=new int[r+c];
        for(int i=0;i<r;i++){
            for(int j=0;j<c;j++){
                x = sc.nextInt();
                lst[i]+=x;lst[r+j]+=x;
                if(j!=0)System.out.print(" ");
                System.out.print(x);
            }
            System.out.printf(" %d\n",lst[i]);
        }
        
        int sum=0;
        for(int i=0;i<c;i++){
            sum+=lst[r+i];
            if(i!=0)System.out.print(" ");
            System.out.print(lst[r+i]);
        }
        System.out.printf(" %d\n",sum);
    }
}


Measured memory_bytes: 42168
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var result = new int[N];
            for (int i = 0; i < N; i++)
            {
                result[A[i] - 1] = i + 1;
            }
            Console.WriteLine(string.Join(" ", result));
        }
    }
}

Measured memory_bytes: 26588
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
using namespace std;
const int num = 100002;
int partition(int A[], int p, int r) {
	int base = A[r];
	int q = p - 1;
	int i;
	for (i = 0; i < r; i++) {
		if (A[i] <= base)
			swap(A[i], A[++q]);
	}
	swap(A[r], A[++q]);
	return q;
}
int main() {
	int n, a[num];
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d",&a[i]);
	int v = partition(a, 0, n - 1);
	for (int i = 0; i < v; i++) {
		printf("%d", a[i]);
		printf(" ");
	}
	printf("[%d] ", a[v]);
	for (int i = v + 1; i < n; i++) {
		printf("%d", a[i]);
		if(i != n-1)printf(" ");

	}
	printf("\n");
	return 0;
}

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

int main(){
  int n;cin>>n;
  bool flag=true;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2!=0)flag=false;
  }
  cout<<(flag?"second":"first")<<endl;
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int D=365,A=26;

int d;
int c[A],s[D][A],last[A];

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

    cin>>d;
    for(int j=0;j<A;j++)
        cin>>c[j],
        last[j]=-1;
    for(int i=0;i<d;i++)
        for(int j=0;j<A;j++)
            cin>>s[i][j];
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]+c[j]*(i-last[j])*A>
               s[i][best]+c[best]*(i-last[best])*A)
                best=j;
        last[best]=i;
        cout<<best+1<<"\n";
    }
}


Measured memory_bytes: 3724
N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
 A.append(int(input()))
P = []
P = [0] * N
i = 0
while Q>i:
    P[A[i]-1] += 1
    i += 1
for j in P:
    if (K - Q + j) > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 8632
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, a, b;
    cin >> n >> a >> b;
    int p = a + b - n;
    cout << min(a, b) << " " << max(0, p) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    cout << (6 - (a + b)) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      boolean is9x9multiplication = false;

      for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
          if (i * j == N) {
            is9x9multiplication = true;
          }
        }
      }

      if (is9x9multiplication) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created 2017/06/01.
 */
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<String>> ary = new ArrayList<>();

    while (true) {
      ArrayList<String> ary1 = new ArrayList<>();
      String input1 = sc.next();
      String input2 = sc.next();
      String input3 = sc.next();
      if (input2.equals("?")) break;
      ary1.add(input1);
      ary1.add(input2);
      ary1.add(input3);
      ary.add(ary1);
    }
    
    for (ArrayList<String> ary2 : ary) {
      int a = Integer.parseInt(ary2.get(0));
      String op = ary2.get(1);
      int b = Integer.parseInt(ary2.get(2));
      switch (op) {
        case "+":
          System.out.println(a + b);
          break;
        case "-":
          System.out.println(a - b);
          break;
        case "/":
          System.out.println(a / b);
          break;
        case "*":
          System.out.println(a * b);
          break;
      }
    }
  }
}

Measured memory_bytes: 26076
#include <bits/stdc++.h> 
using namespace std;
 
int main(){
    int H, W, count;
    cin >> H >> W;
    vector<vector<char>> vec(H, vector<char>(W,NULL)); //マス情報
    vector<bool> vech(H,false); //縦
    vector<bool> vecw(W,false); //横
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> vec[i][j];
        }
    }
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(vec[i][j]=='#'){
                vecw[i]=true;
                vech[j]=true;
            }
        }
    }
    
    /*
    for(int j = 0; j < W; j++){
        for(int i = 0; i < H; i++){
            if(vec[i][j]=='#'){
                vech[j]=1;
            }
        }
    }
    */
    
    for(int i = 0; i < H; i++){
        if(vecw[i]==true){
          for(int j = 0; j < W; j++){
                if(vech[j] == true){
                    cout << vec[i][j];
                }
            }
            cout << endl;
        }
    }
    
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		long a = 1;
		long b = n;
		ArrayList<Integer> list = new ArrayList<>();
		int min = String.valueOf(n).length();
		if(Math.sqrt(n) - (int)(Math.sqrt(n)) == 0) {
		    min = String.valueOf((int)Math.sqrt(n)).length();
		}else {
    		for(int i=2; i<=Math.sqrt(n); i++) {
    		    if(b % i == 0) {
    		        list.add(i);
    		        a *= i;
    		        b /= i;
    		        i--;
    		    }
    		}

    		
    		for(int i=0; i<Math.pow(2, list.size()); i++) {
    		    a = 1;
    		    b = n;
    		    for(int j=0; j<list.size(); j++) {
    		        if((1&i>>j) == 1) {a*=list.get(j); b /= list.get(j);}
    		    }
    		    if(min > Math.max(String.valueOf(a).length(), String.valueOf(b).length())) min = Math.max(String.valueOf(a).length(), String.valueOf(b).length());
    		}
		}
		
		System.out.println(min);
	}
}

Measured memory_bytes: 26628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const ll M = 1000000007;
 
int main(void){
   ll L,R,i;
   cin >> L >> R;
   ll ans=2018;
   if(L%2019>R%2019){ans=0;}
   else if((R-L)>2018){ans=0;}
   else {int n=L%2019,k=R%2019;
         for(i=n;i<=k-1;i++){
             for(int j=i+1;j<=k;j++){
                 if((i*j)%2019<ans%2019)ans=(i*j)%2019;
                }
            }
        }
    std::cout << ans << std::endl;
}

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

int ans[110][110];

int main () {
    int H, W, N;
    cin >> H >> W;
    cin >> N;

    vector<int> colors;
    for (int i=0; i<N; i++) {
        int c; cin >> c;
        for (int j=0; j<c; j++) {
            colors.push_back(i + 1);
        }
    }

    auto it = colors.begin();
    for (int i=0; i<H; i++) {
        if (i % 2 == 0) {
            for (int j=0; j<W; j++) {
                ans[i][j] = *it;
                it++;
            }
        } else {
            for (int j=W-1; j>=0; j--) {
                ans[i][j] = *it;
                it++;
            }
        }
    }

    if (it != colors.end()) return 1;
    
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            printf("%d%c", ans[i][j], (j == W-1 ? '\n' : ' '));
        }
    }

    return 0;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  string s;
  cin>>s;
  s[3]='8';
  cout<<s<<endl;
}


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

int main(){
	double r,menseki,ensyu;
    cin>>r;
	menseki=r*r*M_PI;
    ensyu=2*r*M_PI;
	cout << fixed << setprecision(5);
	cout <<menseki<<" "<<ensyu<<endl;
   }




Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll n;
  cin>>n;
  ll a;
  map<ll,ll> mp;
 ll sum=0;
  for(ll i=0;i<n;i++)
  {
   cin>>a;
    sum+=a;
    mp[a]++;
  }
  ll q;
  cin>>q;
  ll x,y;
  while(q--)
  {
   cin>>x>>y;
    sum-=mp[x]*x;
    sum+=mp[x]*y;
    mp[y]+=mp[x];
    mp[x]=0;
    cout<<sum<<endl;
  }
  

}


Measured memory_bytes: 9516
import sys
input = sys.stdin.readline

N, M, K = map(int, input().split())
friends_table = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    friends_table[a-1] += [b-1]
    friends_table[b-1] += [a-1]

group_list = [i for i in range(N)]
friends_candidate = [[] for i in range(N)]

for i in range(N):
    # すでにDFS済み
    if i != group_list[i]:
        continue
    next_stack = [i]
    friend = [i]
    while next_stack:
        u = next_stack.pop(-1)
        for v in friends_table[u]:
            # 訪問済み
            if i == group_list[v]:
                continue
            friend += [v]
            group_list[v] = i
            next_stack += [v]
    for f in friend:
        friends_candidate[f] = friend

blocks_table = [[] for i in range(N)]
for _ in range(K):
    a, b = map(int, input().split())
    if group_list[a-1] == group_list[b-1]:
        blocks_table[a-1] += [b-1]
        blocks_table[b-1] += [a-1]

for i in range(N):
    print(len(friends_candidate[i]) - len(friends_table[i]) - len(blocks_table[i])-1)


Measured memory_bytes: 87856
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x , ans;
    cin>>x;
    
    ans = x/500;
    ans *= 1000;
    
    x=x%500;
    
    ans+=(x/5) * 5;
    
    cout<<ans<<endl;
    return(0);
}


Measured memory_bytes: 256
import math
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    A, B, H, M = [int(i) for i in input().strip().split()]
    rad_h = math.radians(H * (360/12) + (360/12) * M/60)
    rad_m = math.radians(360 * M / 60)
    rad = abs(rad_h - rad_m)
    if rad > math.pi:
        rad = 2 * math.pi - rad

    return (A**2 + B**2 - 2 * A * B * math.cos(rad)) ** (1/2)


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9584
import sys
#N 単語数を登録。そのあと、wordをいんぷｔ（）
c=[]
N=int(input())
word = [input() for l in range(N)]
#ようやく文字を区切れた。。。同じことやったと思うけどな。。。
#print(word[0])
#print(word[1])


#最初のリストの最後文字と次の文字の最初文字が同じかチェック
for i in range(0,N-1):
    letter1=list(word[i])
#    print(letter1)
    letter2=list(word[i+1])
#    print(letter2)
#    print(i)
    if letter1[-1]==letter2[0]:
#        print("OK")
        continue
    else:
        print("No")
        sys.exit()
#文字が同じものがないかチェック
for i in range(N):
    for j in range(N):
#        print(word[i],word[j])
        if i==j:
            continue
        elif word[i]==word[j]:
            print("No")
            sys.exit()
print("Yes")    


Measured memory_bytes: 3064
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < sz(s); ++i) {
        if (s[i] == s[i+1]) {
            ans += 2;
            if (i+2 >= sz(s))
                ans--;
            i += 2;        
        } else {
            ans++;
        }
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.
const int N=200010;
bool cmp(int a, int b)
{
    return a>b;
}
int a[N],t[N];
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,x,i;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&x);
        a[i]=t[i]=x;
    }
    sort(t+1,t+n+1,cmp);
    for(i=1; i<=n; i++)
    {
        if(a[i]<t[n/2]) printf("%d\n",t[n/2]);
        else printf("%d\n",t[n/2+1]);
    }
    return 0;
}


Measured memory_bytes: 3712
import math


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


a, b, x = LI()
if x == (a**2*b)/2:
    ans = 45
elif x > (a**2*b)/2:
    ans = math.degrees(math.atan((2*(b-x/(a**2)))/a))
else:
    ans = math.degrees(math.atan(a*b**2/(2*x)))
print(ans)


Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
int num[101];
int main()
{
    int cnt=0,n,m;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&num[i]);
    for(int i=0;i<n;i++)
    {
        m=i;
        for(int j=i;j<n;j++)
            if(num[j]<num[m]) m=j;
       if(m!=i)
       {
           swap(num[i],num[m]);
           cnt++;
       }
    }
    for(int i=0;i<n;i++)
        if(i==0) printf("%d",num[i]);
    else printf(" %d",num[i]);
    printf("\n");
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

signed main(){
  int a,b; cin>>a>>b;
  reps(i,3){
    if(i!=a && i!=b) return cout<<i<<endl,0;
  }


  return 0;
}


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

//const int mod = 998244353;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint fact(int n){
    if(n==0) return 1;
    mint ans = n;
    ans *= fact(n-1);
    return ans;
}


mint combi(int n, int k){
    if(n<k) return 0;
    return fact(n)/(fact(k)*fact(n-k));
}

int main(void){
    int n,k;
    cin >> n >> k;

    for(int i=1;i<=k;i++){
        mint ans = combi(n-k+1,i);
        ans *= combi(k-1,i-1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#C問題
N = int(input())
S = list(str(input()))

A = []
for i in range(N):
    if i == 0:
        A.append(S[0])
    else:
        if A[-1] == S[i]:
            pass
        else:
            A.append(S[i])
            
print(len(A))


Measured memory_bytes: 4652
'''
in
-----
7
2
9
4
5
1
6
10
'''
'''
out
-----
8
'''
from collections import defaultdict
dp = defaultdict(lambda:int(0))

N = int(input())
L = [0] * (N +2)
for i in range(0, N):
    L[i] = list(map(int, input().split()))

for i in range(0, N):
    for j in range(0, 3):
        for k in range(0, 3):
            if j == k:
                continue
            dp[(i+1,k)] = max(dp[i+1,k], dp[(i,j)] + L[i][k])

print(max(dp.values()))


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

int main(){
    double n,t,a;
    cin>>n>>t>>a;
    vector<double> h(n);
    rep(i,n)cin>>h[i];
    //t:気温
    //a:aに近い平均気温が欲しい
    //h:標高
    double ans=20021003;
    int num=0;
    rep(i,n){
        double save=t-h[i]*0.006;
        double ab = a - save;
        if(ab<0) ab = -ab;
        if(ans>ab){
        ans = ab;
        num = i+1;
        }
    }
    cout<<num<<endl;
}

Measured memory_bytes: 256
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
    
def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)

    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	std::string s;
	std::cin >> s;
	if(s[s.size()-1]=='s') std::cout << s << "es" << EL;
	else std::cout << s << 's' << EL;
}


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

using namespace std;


const int maxi=2e6+6;


int t[2][maxi];
int a[maxi],b[maxi];
int len,n;
int p[maxi];
int rez[maxi];
set<int> st;
set<int>st1;

void build(int *a, int n, int tip)
{
    len=1<< int (ceil(log2(n)));

    //cout<<len<<"\n";
    for (int i=len;i<2*len;i++)
        t[tip][i]=1e9;

    for (int i=len;i<2*len;i++)
        if (i>len+n-1) t[tip][i]=1e9; else
        if (i%2==0 && tip==1) t[1][i]=a[i-len+1]; else
        if (i%2==1 && tip==0)
        t[0][i]=a[i-len+1];

    for (int i=len-1;i>0;i--)
        t[tip][i]=min(t[tip][i<<1],t[tip][i<<1|1]);
}


int get(int l, int r,int tip)
{
    int ans=a[l];

    l+=len-1;
    r+=len;

    for (;l<r;l>>=1,r>>=1){
        if (l&1) ans=min(ans,t[tip][l++]);
        if (r&1) ans=min(ans,t[tip][--r]);
    }
    return ans;
}


int main()
{

    cin>>n;

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

     build(a,n,0);
     build(a,n,1);

    st1.insert(0);
    st1.insert(n+1);

    st.insert(get(1,n,1));

    for (int i=1;i<=n;i+=2)
    {
        int cur=*st.begin();
        rez[i]=cur;
        int tip=(1-p[cur]%2);
        int idx=*st1.lower_bound(p[cur]);
        rez[i+1]=get(p[cur]+1,idx-1,tip);
        st.erase(cur);

        set<int>::iterator it=st1.lower_bound(p[cur]);
        it--;

        int ispod=*it;
        st1.insert(p[cur]);
        st1.insert(p[rez[i+1]]);

        if (p[cur]-ispod>1)
            st.insert(get(ispod+1,p[cur]-1,(ispod+1)%2));

         if (p[rez[i+1]]-p[cur]>1)
            st.insert(get(p[cur]+1,p[rez[i+1]]-1,(p[cur]+1)%2));

           if (idx-p[rez[i+1]]>1)
                st.insert(get(p[rez[i+1]]+1,idx-1,(p[rez[i+1]]+1)%2));

    }

  for (int i=1;i<=n;i++)
    printf("%d ",rez[i]);
  printf("\n");
   return 0;
}

//RINGISPIL SE PLACA


Measured memory_bytes: 28160
L, R = map(int, input().split())
temp = 2019

for i in range(L, R):
    for j in range(i+1, R+1):
        temp = min(temp, (i*j) % 2019)
        if (i*j) % 2019 == 0:
            print(temp)
            exit(0)
print(temp)

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <algorithm>

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

using namespace std;

int n;
map<char, char> c;

int main(){
	while(1){
		cin >> n;
		if(!n){
			break;
		}
		rep(i, n){
			char a, b;
			cin >> a >> b;
			c[a] = b;
		}
		int q;
		cin >> q;
		rep(i, q){
			char p;
			cin >> p;
			cout << (c[p] ? c[p] : p);
		}
		cout << endl;
		c.clear();
	}
	return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  string s; cin >> s;
  if (s == "SUN") cout << 7 << endl;
  if (s == "MON") cout << 6 << endl;
  if (s == "TUE") cout << 5 << endl;
  if (s == "WED") cout << 4 << endl;
  if (s == "THU") cout << 3 << endl;
  if (s == "FRI") cout << 2 << endl;
  if (s == "SAT") cout << 1 << endl;
  return 0;
}

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

int n, q;
int t, u, v;

int main() {
	cin >> n >> q;
	dsu uf(n);
	
	for (int i = 0; i < q; i++) {
		cin >> t >> u >> v;
		if (t == 0) {
			uf.merge(u, v);
		}
		else {
			if (uf.same(u, v)) {
				cout << 1 << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4072
public class Main {

  private static void solve() {
    char[] s = ns();
    int n = s.length;

    int mod = (int) 1e9 + 7;

    long[][] dp = new long[n + 1][13];
    dp[0][0] = 1;
    int f = 1;
    for (int i = 0; i < n; i++) {
      char c = s[n - i - 1];
      if (c == '?') {
        for (int j = 0; j < 13; j++) {
          for (int d = 0; d < 10; d++) {
            dp[i + 1][(j + f * d) % 13] += dp[i][j];
            dp[i + 1][(j + f * d) % 13] %= mod;
          }
        }

      } else {
        int d = c - '0';
        for (int j = 0; j < 13; j++) {
          dp[i + 1][(j + f * d) % 13] += dp[i][j];
          dp[i + 1][(j + f * d) % 13] %= mod;
        }
      }
      f *= 10;
      f %= 13;
    }

    System.out.println(dp[n][5]);


  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

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

  private static char[] ns() {
    return next().toCharArray();
  }

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

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h,a;
    cin>>h>>a;
    int ans = 0;
    while(h > 0){
        h = (h-a);
        ans++;
    }
    cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <functional>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;

int n;
string s[10];

int main() {
    cin >> n;
    for (int i = 0; i < 3; i++) cin >> s[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        static int c[26];
        memset(c, 0, sizeof c);
        for (int j = 0; j < 3; j++) c[s[j][i] - 'a']++;
        int mx = 0;
        for (int j = 0; j < 26; j++) mx = max(mx, c[j]);
        if (mx == 1) ans += 2;
        else if (mx == 2) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256