akhauriyash/Code-Regression huggingface dataset:
def main():
    from math import gcd
    n, *a = map(int, open(0).read().split())
    m = max(a)

    c = [0] * (m + 1)
    g = a[0]
    for i in a:
        g = gcd(g, i)
        c[i] = 1

    if g > 1:
        pre = "not"
    else:
        for i in range(2, 10 ** 6 + 1):
            if sum(c[i::i]) > 1:
                pre = "setwise"
                break
        else:
            pre = "pairwise"

    print(pre + " coprime")


if __name__ == '__main__':
    main()


Measured memory_bytes: 223260
void main()
{
    long n, p;
    rdVals(n, p);
    string s = rdStr;

    long result;

    if (p == 2 || p == 5)
    {
        foreach (i, x; s)
        {
            if ((x - '0') % p) continue;
            result += i + 1;
        }
        result.writeln;
        return;
    }

    long[] exp = new long[n];
    exp[n-1] = 1;
    foreach_reverse (i; 0 .. n-1)
    {
        exp[i] = 10 * exp[i+1] % p;
    }
    long[] list = new long[p];
    long num = 0;
    foreach_reverse (i, x; s)
    {
        num = (num + (x - '0') * exp[i]) % p;
        ++list[num];
    }

    result += list[0];
    foreach (l; list)
    {
        result += (l * (l - 1)) >> 1;
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 3836
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    //Read(a);
    Readln(s);
    count:=0;
    max  :=0;

    if s[1]='+' then
      inc(count)
    else
      count:=count-1;
    if s[2]='+' then
      inc(count)
    else
      count:=count-1;
    if s[3]='+' then
      inc(count)
    else
      count:=count-1;
    if s[4]='+' then
      inc(count)
    else
      count:=count-1;

    Writeln(count);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
struct song{
	char name[101];
	int time;
}str[50];
int main()
{
	int k;scanf("%d",&k);
	for(int i=0;i<k;i++)
	{
		scanf("%s %d",str[i].name,&str[i].time);
	}
	char s[101];int sum=0;
	scanf("%s",s);
	for(int i=0;i<k;i++)
		if(strcmp(str[i].name,s)==0)
		{
			for(int j=i+1;j<k;j++)
			sum=sum+str[j].time;
		}
		printf("%d",sum);
		return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

string s;
int K;
map<string, int> mp;

int main(void){
    
    cin >> s;
    scanf("%d", &K);
    
    vector<P> v(s.size());
    for(int i = 0; i < s.size(); ++i) v[i].first = s[i] - 'a', v[i].second = i;
    sort(v.begin(), v.end());
    
    priority_queue<string, vector<string>, greater<string>> que;
    int cnt = 0, num = 0;
    for(auto p : v){
        if(cnt >= K && num != p.first) break;
        num = p.first;
        int idx = p.second;
        string temp;
        for(int i = idx; i < s.size() && i < idx + K; ++i){
            temp = temp + s[i];
            if(mp.find(temp) == mp.end()) ++cnt, que.push(temp);
            ++mp[temp];
        }
    }
    
    for(int i = 0; i < K - 1; ++i) que.pop();
    printf("%s\n", que.top().c_str());
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <fstream>

using namespace std;

long long mod = 1000000007;

void dfs(int p, int prev, vector<int> &a, vector<int> &dp, int dpl, vector<vector<int>> &v, vector<int> &res)
{
    int l = -1, r = dpl, mid;
    while (r - l > 1)
    {
        mid = (l + r) / 2;
        if (dp[mid] >= a[p])
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    int temp = dp[r];
    dp[r] = a[p];
    if (temp == -1)
    {
        dpl++;
    }
    res[p] = dpl;
    for (int i = 0; i < v[p].size(); i++)
    {
        if (v[p][i] == prev)
        {
            continue;
        }
        dfs(v[p][i], p, a, dp, dpl, v, res);
    }
    dp[r] = temp;
}

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    // ifstream cin("in.txt");
    // ofstream cout("out.txt");
    
    
    // int t;
    // cin >> t;
    // for (int qwe = 0; qwe < t; qwe++)
    // {
    //     cout << "Case #" << qwe + 1 << ": ";
    // }


    string s;
    cin >> s;
    cout << ((s == "ABC") ? "ARC" : "ABC") << '\n';



    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
template< typename T = long long >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}
template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}
int main(){
    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000<<endl;
}

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

long long n, h, a[100], p[10010];
int main(){
        cin >> n;
        for(int i = 0; i < n; i++) cin >> a[i];
        sort(a, a+n);
        p[0] = 1;
        for(int i = 0; i < n; i++){
                for(int j = 10009; j >= a[i]; j--){
                        if(p[j-a[i]]) p[j] = 1;
                }
        }
        for(int i = 0; i < 10010; i++){
                if(i % 10 != 0 && p[i]){
                        h = i;
                }
        }
        cout << h;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int A[10];
int N, M, Q;
int a[50], b[50], c[50], d[50];
int ans;

void calc(int index, int prev) {
    if (index == N) {
        int sum = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i])
                sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }
    for (int i = prev; i <= M; i++) {
        A[index] = i;
        calc(index + 1, i);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    calc(0, 1);
    cout << ans << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) throws Exception{	
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int x = sc.nextInt();
		
		int[] a = new int[n];
		
		long c=0;
		
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
			if(a[i] > x){
				c += a[i] - x;
				a[i] = x;
			}
		}
		
		for(int i=1; i<n; i++){
			if(a[i-1] + a[i] > x){
				c +=   a[i-1] + a[i] - x;
				a[i] -= (a[i-1] + a[i]) - x;
			}
		}
		
		System.out.println(c);
		
		sc.close();
	}
}

Measured memory_bytes: 33112
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		String s1 = replace(s);
		String t1 = replace(t);
		if (s1.equals(t1)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	public static String replace(String str) {
		char count = 0;
		StringBuilder sb = new StringBuilder();
		HashMap<Character, Character> map = new HashMap<Character, Character>();
		for (int i = 0; i < str.length(); i++) {
			Character ct = map.get(str.charAt(i));
			if (ct == null) {
				map.put(str.charAt(i), (char) ('A' + count));
				ct = (char) ('A' + count);
				count++;
			}
			sb.append(ct);
		}
		return sb.toString();		
		
	}
}

Measured memory_bytes: 46476
<?php
$n = trim(fgets(STDIN));
$aArray = explode(" ", trim(fgets(STDIN)));
$aArray[] = -1;

$pa = -1;
$c = 0;
$sum = 0;
foreach($aArray as $a){
    if($pa == $a){
        $c++;
    }else{
        $sum += floor(($c+1) / 2);
        $c = 0;
    }
    $pa = $a;
}
echo $sum;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n){
        if(i%2==0&&a[i]%2==1) ++ ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Edge{
	Edge(int arg_to,int arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
	int to,dist;
};

struct Info{
	Info(int arg_node_id,int arg_sum_dist){
		node_id = arg_node_id;
		sum_dist = arg_sum_dist;
	}
	bool operator<(const struct Info &arg) const{

		return sum_dist > arg.sum_dist; //総距離の昇順(PQ)
	}

	int node_id,sum_dist;
};

int V;
int min_dist[SIZE];
vector<Edge> G[SIZE];

int main(){

	scanf("%d",&V);

	int node_id,num_node,to,dist;

	for(int i = 0; i < V; i++){

		scanf("%d %d",&node_id,&num_node);
		for(int k = 0; k < num_node; k++){

			scanf("%d %d",&to,&dist);
			G[node_id].push_back(Edge(to,dist));
		}
	}

	for(int i = 0; i < V; i++){

		min_dist[i] = BIG_NUM;
	}

	priority_queue<Info> Q;
	min_dist[0] = 0;

	Q.push(Info(0,0));

	while(!Q.empty()){

		if(Q.top().sum_dist > min_dist[Q.top().node_id]){

			Q.pop();

		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){

				int next_node = G[Q.top().node_id][i].to;
				int next_dist = Q.top().sum_dist+G[Q.top().node_id][i].dist;

				if(min_dist[next_node] > next_dist){
					min_dist[next_node] = next_dist;
					Q.push(Info(next_node,next_dist));
				}
			}
			Q.pop();
		}
	}

	for(int i = 0; i < V; i++){

		printf("%d %d\n",i,min_dist[i]);
	}

	return 0;
}



Measured memory_bytes: 10164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		char acceptStr = 'o';
		Scanner sc = new Scanner(System.in);
		String orderStr = sc.next();
		sc.close();
		int amount = 700;
		for(int i=0;i<orderStr.length();i++) {
			if(orderStr.charAt(i) == acceptStr) {
				amount += 100;
			}
		}
		System.out.print(amount);
	}
}

Measured memory_bytes: 22484
import collections
s = input()
sli = list(s)
c = collections.Counter(sli)
d = c.most_common()
if len(d) == 2:
    if d[0][1] == d[1][1]:
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"

print(ans)            


Measured memory_bytes: 3316
import sys

def insertionSort(x_list,y):
  for i in range(1, y):
    v = x_list[i]
    j = i - 1
    while j >= 0 and x_list[j] > v:
      x_list[j + 1] = x_list[j]
      j -= 1
    x_list[j+1] = v
    for k in range(0, y):
      print x_list[k],
    print

y = sys.stdin.readline()
y = int(y)

x = sys.stdin.readline()

x_list = x.split(" ")

for i in range(y):
  x_list[i] = int(x_list[i])

for k in range(0, y):
  print x_list[k],
print

insertionSort(x_list, y)

Measured memory_bytes: 6360
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

i_i f(int n){
  int b=n%10;
  int a=0;
  while(n){
    a=n;
    n/=10;
  }
  return i_i(a,b);
}
int main(){
  map<i_i,int> mp;
  int N; cin >> N;
  for(int i=1;i<=N;i++){
    mp[f(i)]++;
  }
  ll ans=0;
  for(auto c:mp){
    ans+=c.second*mp[i_i(c.first.second,c.first.first)];
  }
  cout << ans << endl;
  /*
  for(auto c:mp){
    cout << c.first.first << " " << c.first.second << " " << c.second << endl;
  }
  */
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n; cin>>n;
    vector<int> vec;
    rep(i,n) {
        int a; cin >> a;
        vec.push_back(a);
    }
    sort(all(vec));
    cout << vec[n-1] - vec[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int x;
    cin >> x;
    if(x>=30) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3636
N=int(input())

import math
X=math.ceil(math.sqrt(N))

FACT=[]
for i in range(1,X+1):
    if N%i==0:
        FACT.append(i)

ANS=10**10

for f in FACT:
    x=N//f
    ANS=min(ANS,max(len(str(x)),len(str(f))))

print(ANS)



Measured memory_bytes: 3060
n, m = map(int, input().split(' '))
a = map(int, input().split(' '))

d = {0: 1}
asum = 0
for aa in a:
    asum = (asum + aa) % m
    if asum in d:
        d[asum] += 1
    else:
        d[asum] = 1


ans = 0
for v in d.values():
    ans += int(v * (v - 1) / 2)

print(ans)

Measured memory_bytes: 16100
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}
void min_self(ll& a, ll b) {
    a = min(a, b);
}

const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

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

int main(){
    string str;
    getline(cin, str);
    for(int i = 0; i < str.size(); i++){
        if('a' <= str.at(i) && str.at(i) <= 'z'){
            str.at(i) += 'A' - 'a';
        }
        else if('A' <= str.at(i) && str.at(i) <= 'Z'){
            str.at(i) += 'a' - 'A';
        }
    }
    cout << str << endl;
}


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

int main() {
  int N;
  int K;
  cin >> N >> K;
  
  int d = 0;
  for (int i = 0; i < N; i++) { 
    int x;
    cin >> x;
    
    if (2 * (x - 0) < 2 * (K - x)) {
      d += 2 * (x - 0);
    }
    else {
      d += 2 * (K - x);
    }
  }
  
  cout << d << endl;
}

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

using i64 = long long;
using u64 = unsigned long long;

const int mod = (int) 1e9+7;

void __print() {cerr << "]\n";}

template<typename T, typename... V>
void __print(T t, V... v)
{ cerr << t; if(sizeof...(v)) cerr << ", "; __print(v...);}

#define dbg(x...) cerr << "[" << #x << "] = [", __print(x)
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(NULL)

int main()
{
    i64 n;
    cin >> n;
    i64 cnt = 0;
    for(i64 i = 1; i <= n; i++) {
        for(i64 j = 1; j <= n; j++) {
            if(i*j >= n) break;
            if(i*j < n) cnt++;
        }
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 3672
#include<iostream>
using namespace std;
int main(){
  int a[3]={1}; 
  char ch[3]={'A','B','C'};
  char d,e,f;
  while(cin>>d>>e>>f)
    for(int i=0;i<3;i++)
      for(int j=0;j<3;j++){
	if(i!=j)
	  if(d==ch[i]&&f==ch[j])
	    swap(a[i],a[j]);
      }

  for(int i=0;i<3;i++)
    if(a[i]==1)
	cout<<ch[i]<<endl;
  return 0;
}

Measured memory_bytes: 1132
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
#include <utility>
#include <vector>
#include <math.h>

#define rep(i, n) for (auto i = 0; i < (n); i++)
#define MOD 1e9 + 7
typedef long long ll;

using namespace std;

int main() {
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;

  return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
	cin >> s;

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

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

using namespace std;

const int INF = 1e8;

int hopscotch(int s, int t, vector<vector<int>>& graph){
  int n = (int)graph.size();
  vector<vector<int>> dist(n, vector<int>(3, -3));
  
  queue<pair<int, int>> q;
  q.push({s, 0});
  dist[s][0] = 0;
  while(!q.empty()){
    int u = q.front().first;
    int d = q.front().second;
    q.pop();
    d++;
    for(int v : graph[u]){
      if(dist[v][d % 3] == -3){
        dist[v][d % 3] = d;
        q.push({v, d});
      }
    }
  }
  
  return dist[t][0] / 3;
}

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> graph(N);
  for(int i = 0; i < M; i++){
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(v);
  }
  
  int S, T;
  cin >> S >> T;
  S--;
  T--;
  
  cout << hopscotch(S, T, graph) << endl;
  
  return 0;
}

Measured memory_bytes: 11136
def main():
    D = int(input())
    fuman = list(map(int, input().split()))
    manzoku = [[0]*26 for _ in range(D)]
    for i in range(D): manzoku[i] = list(map(int, input().split()))
    # できるだけ点数が下がらないように、満足度の高いものを選んでいく
    # d日目にテストiを受けた時、score += manzoku[d][i]-sigma[i以外25個](fuman[k]*それを受けてない日数)
    # >テストiをd日目に受ける
    # manzoku[d][i]-sigma[i以外25個](fuman[k]*それを受けてない日数)が一番大きいもの(i)を受けるそれだけ
    timepass = [0]*26
    # 最初の1日のみ指定
    x,t = 0,0
    for j in range(26):
        tmp = manzoku[i][j]
        if tmp>x:
            x = tmp
            t = j
    for j in range(26):
        if not j==t: timepass[j] += 1
        else: timepass[j] = 0
    print(t+1)
    for i in range(1,D):
        # greedy
        x1 = 0
        t1 = 0
        for j in range(26):
            tmp = manzoku[i][j]
            for k in range(26):
                if not j==k: tmp -= fuman[k]*timepass[k]
            if tmp>x1:
                x1 = tmp
                t1 = j

        # update timepass
        for j in range(26):
            if not j==t1: timepass[j] += 1
            else: timepass[j] = 0
        print(t1+1)



main()


Measured memory_bytes: 9516
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }

int main(){
    // in;
    // out;
	ll n;
	cin>>n;
	map<string,ll> s;
	map<string,ll>::iterator it;
	ll maxx=1;
	while(n--){
		string a;
		cin>>a;
		it=s.find(a);
		if(it!=s.end()){
			it->second++;
			maxx=max(maxx,it->second);
		}
		else
			s.insert(pair<string,ll>(a,1)); 
	}
	for(it=s.begin();it!=s.end();it++)
		if(it->second==maxx)
			cout<<it->first<<endl;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    int base = 1; 
  
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

int main()
{
    ll n;
    cin >> n;

    ll ans = 3*n*n;
    cout << ans << "\n";
}




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

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

    int n;
    cin >> n;
    if (n % 2 == 0)
    {
        cout << n / 2 << endl;
    }
    else
    {
        cout << n / 2 + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  deque<int> A;
  for(int i=0;i<N;i++){
    int j;cin >> j;
    if(i % 2 == N % 2) A.push_back(j);
    else A.push_front(j);
  }
  for(auto&& x:A)cout << x << " ";
  cout << endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  ll N, M; cin >> N >> M;
  vector<ll> A(N), B(M), C(M);
  REP(i, N) cin >> A[i];
  REP(i, M) cin >> B[i] >> C[i];

  map<ll, ll> cnt;
  REP(i, N) {
    cnt[A[i]]++;
  }

  REP(i, M) {
    cnt[C[i]] += B[i];
  }

  ll ans = 0, num = N;
  for (auto i = cnt.rbegin(); i != cnt.rend(); ++i) {
    ans += i->first * min(i->second, num);
    num -= i->second;

    if (num <= 0) {
      break;
    }
  }

  cout << ans << endl;
}

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

int64_t N;
vector<vector<int64_t>> connect;

vector<int64_t> dijkstra(int64_t s) {
    constexpr int64_t INF = INT_MAX;
    vector<int64_t> cost(N, INF);
    struct Element {
        int64_t node, cost;
        bool operator<(const Element& rhs) const {
            return cost < rhs.cost;
        }
        bool operator>(const Element& rhs) const {
            return cost > rhs.cost;
        }
    };
    priority_queue<Element, vector<Element>, greater<Element>> pq;

    cost[s] = 0;
    pq.push({ s, 0 });
    while (!pq.empty()) {
        Element t = pq.top();
        pq.pop();
        if (t.cost > cost[t.node]) {
            continue;
        }

        for (const int64_t & next_node : connect[t.node]) {
            int64_t new_cost = t.cost + 1;
            if (new_cost < cost[next_node]) {
                pq.push({ next_node, cost[next_node] = new_cost });
            }
        }
    }

    return cost;
}

int main() {
    int64_t X, Y;
    cin >> N >> X >> Y;
    X--; Y--;
    connect.resize(N);
    connect[X].push_back(Y);
    connect[Y].push_back(X);
    for (int64_t i = 0; i < N - 1; i++) {
        connect[i].push_back(i + 1);
        connect[i + 1].push_back(i);
    }

    vector<int64_t> ans(N);
    for (int64_t i = 0; i < N; i++) {
        vector<int64_t> cost = dijkstra(i);
        for (int64_t j = 0; j < N; j++) {
            ans[cost[j]]++;
        }
    }

    for (int64_t i = 1; i < N; i++) {
        cout << ans[i] / 2 << endl;
    }
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }

  int ans = 0, i = 0;
  while (ans < n) {
    i = a[i];
    ans++;
    if (i == 1) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    p = LI()
    t = LI()
    ans = float("inf")
    for i in range(n+1):
        x0 = t[0]*i
        m0 = p[0]*i
        for j in range(n+1):
            x1 = x0+t[1]*j
            m1 = m0+p[1]*j
            for k in range(n+1):
                x2 = x1+t[2]*k
                m2 = m1+p[2]*k
                rest = max(0,math.ceil((n-x2)/t[3]))
                m3 = m2+p[3]*rest
                if m3 < ans:
                    ans = m3
    print(ans)
    return

#B
def B():
    def f(n):
        if n < 4:
            return 1
        m = n
        res = 1
        i = 2
        while i**2 <= n:
            if m%i == 0:
                if m//i != i:
                    res *= m//i
                res *= i
            i += 1
        return res
    MA = 100000
    d = [0]*(MA+1)
    for i in range(12,MA+1):
        if not d[i]:
            if f(i) >= (i<<1):
                j = i
                while j <= MA:
                    d[j] = 1
                    j += i
    for i in range(MA):
        d[i+1] += d[i]
    q = I()
    for i in range(q):
        print(d[I()])
    return

#C
def C():
    n = I()

    return

#D
def D():
    a,b = LI()
    for i in range(b+1,b+a):
        x = i//b
        j = i%b
        x += j//a
        j = j%a
        x += j
        y = i//a+i%a
        if y < x:
            print(i)
            break
    else:
        print(-1)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#G
def G():
    n = I()

    return

#Solve
if __name__ == "__main__":
    D()



Measured memory_bytes: 8240
#include <stdio.h>

int main(){
  long long int X,K,D;
  scanf("%lld %lld %lld",&X,&K,&D);
  if(X<0LL) X=-X;
  if(X/D>=K) X-=K*D;
  else{
    long long int Y=X/D;
    K-=Y;
    X-=Y*D;
    if(K%2LL==1LL) X=D-X;
  }
  printf("%lld\n",X);
  return 0;
}


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


void solve(long long N, std::vector<long long> P, std::vector<long long> Q){
    vector<long long> numbers(N, 0);
    for(int i = 0; i < N; ++i) numbers[i] = i+1;
    int cnt = 1;
    int a = 0; int b = 0;
    do{
        vector<bool> flag(2, true);
        for(int i = 0; i < N; ++i){
            //cout << numbers[i] << " " << P[i] << " " << Q[i] << endl;
            if(numbers[i] != P[i]) flag[0] = false;
            if(numbers[i] != Q[i]) flag[1] = false;
        }
        if(flag[0]) a = cnt;
        if(flag[1]) b = cnt;
        cnt++;
    }while(next_permutation(numbers.begin(), numbers.end()));
    //cout << a << " " << b << endl;
    cout << abs(a - b) << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    solve(N, std::move(P), std::move(Q));
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vvll vecror<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
 
 
 

void solve()
{
	string s;
	
	cin>>s;
	
	if(s[2] == s[3] && s[5] == s[4])
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No";
	}
}
 
int main()
{
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
ll inf = 1e18+7;
//LLONG_MIN

/*

*/

string to_6(ll n){
	string ans="";
	rep(i,6){
		if(pow(10,i)>n){
			ans+="0";
		}
	}
	return ans+to_string(n);
}

int main(void){
	ll n,m;
	vector<mp> a[100010];
	string ans[100010];
	cin>>n>>m;
	rep(i,m){
		ll p,y;
		cin>>p>>y;
		a[p].push_back(make_pair(y,i));//通し番号で管理
	}
	reg(i,1,n){
		sort(a[i].begin(),a[i].end());
		rep(j,a[i].size()){
			ans[a[i][j].second]=to_6(i)+to_6(j+1);
		}
	}
	rep(i,m){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class MagicNumberThree
{

    public:
int countSubsequences(string s)
{

}

};


int f[5005][5005]={};
int sum[5005][5005]={};
int main()
{
   int a,b;
   while(cin>>a>>b){
        int ans=0;
        int t=2*b;
    for(int i=0;i<a;i++){
        int x,y;
        char z;
        cin>>x>>y>>z;
        if(z=='W')
        x+=b;
   x%=t;
   y%=t;

   f[x][y]++;
   f[x][y+b]--;
   f[x+b][y]--;
   f[x+b][y+b]++;

    f[x+b][y+b]++;
   f[x+2*b][y+b]--;
      f[x+b][y+2*b]--;
      f[x+2*b][y+2*b]++;

    }
    for(int i=1;i<4*b;i++){
    for(int j=0;j<4*b;j++){
        f[i][j]+=f[i-1][j];
    }
    }
       for(int i=0;i<4*b;i++){
    for(int j=1;j<4*b;j++){
        f[i][j]+=f[i][j-1];
    }
    }
    for(int i=0;i<4*b;i++){
        for(int j=0;j<4*b;j++){
            sum[i%t][j%t]+=f[i][j];
        }
    }
    for(int i=0;i<t;i++){
        for(int j=0;j<t;j++){
            ans=max(ans,sum[i][j]);
        }
    }
    cout<<ans<<endl;



   }
    return 0;
}


Measured memory_bytes: 120320
num = list(map(int, input().split()))
num.sort()
first_num = num[:]

count = 0
while num[0]%2==0 and num[1]%2==0 and num[2]%2==0:
    a = num[0]//2
    b = num[1]//2
    c = num[2]//2

    num[0] = b + c
    num[1] = c + a
    num[2] = a + b
    num.sort()

    if num == first_num:
        count = -1
        break
    else:
        count += 1

print(count)


Measured memory_bytes: 3064
#include<cstdio>
#include<string>

using namespace std;

int main(){
	char ch[100];
	scanf("%s", ch);
	string str = ch;
	str = str.substr(0, 4);
	if(str == "YAKI") printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

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

    string ss;
    cin >> ss;
    if (ss.size() % 2) {
        cout << "No" << endl;
        return 0;
    } else {
        for (i = 0; i < ss.size(); ++i) {
            if (i % 2 && ss[i] != 'i') {
                cout << "No" << endl;
                return 0;
            } else if (i % 2 == 0 && ss[i] != 'h') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
//#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>

using namespace std;

#define PI 3.1415926535897932384626433


int main(void) {
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	int minit = H * 60 + M;
	int maxminit = 60 * 12;

	double Ax = sin(2 * PI * (double)(minit) / maxminit) * A;
	double Ay = sin(2 * PI * ((double)(minit) / maxminit - 0.25)) * A;	

	double Bx = sin(2 * PI * (double)(M) / 60) * B;
	double By = sin(2 * PI * ((double)(M) / 60 - 0.25)) * B;

#ifdef _DBG_
	cout << Ax << "," << Ay << endl;
	cout << Bx << "," << By << endl;
#endif

	double dist = sqrt(pow((Ax - Bx), 2.0) + pow((Ay - By), 2.0));
	cout << std::setprecision(20) << dist << endl;

#ifdef _DBG_
	int CC;
	cin >> CC;
#endif

	return 0;
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vi a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    rep(i, n) {
        int ans = -1;
        int mn = 1001001001;
        rep(j, m) {
            if (chmin(mn, abs(a[i] - c[j]) + abs(b[i] - d[j]))) {
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
n=int(input(""))
liss=[]
for i in range(n):
    liss+=[input("")]
liss.sort()
lisk=[]
maxt=1
t=0
s=liss[0]
for i in liss:
    if(s==i):
        t+=1
        if(t==maxt):
            lisk+=[i]
        elif(t>=maxt):
            lisk=[i]
            maxt=t
    else:
        s=i
        t=1
        if(t==maxt):
            lisk+=[i]
for i in lisk:
    print(i)
        
    
    
    
    

Measured memory_bytes: 25160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const int INF = 1001001001;


int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    int h_cnt = 0;
    for(int i=0;i<N-1;i++){
        if(S[i] == S[i+1]) h_cnt++;
    }

    int uh_cnt = 0;
    for(int i=0;i<N-1;i++){
        if(S[i] != S[i+1]) uh_cnt++;
    }

    h_cnt += min(2*K,uh_cnt);
    cout << h_cnt << endl;

}


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

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

int MOD=1e9+7;
ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int d[110][110];

void warshall_floyd(int n){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int n, m; cin>>n>>m;

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i == j) d[i][j]=0;
            else d[i][j]=MOD;
        }
    }

    vector<int> a(m+10), b(m+10), c(m+10);
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--, b[i]--;
        d[a[i]][b[i]]=c[i];
        d[b[i]][a[i]]=c[i];
    }

    warshall_floyd(n);

    int ans=0;
    for(int i=0; i<m; i++){
        if(d[a[i]][b[i]] < c[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
dic = {}

for i in range(N):
    S = input()
    if S not in dic:
        dic[S] = 1
    else:
        dic[S] += 1

sortDic = sorted(dic.items(), key=lambda x:x[1],reverse=True)

list = []
list.append(sortDic[0][0])
j = 0

if len(sortDic) != 1:
    while j < len(sortDic)-1 and sortDic[j][1] == sortDic[j+1][1]:
        list.append(sortDic[j+1][0])
        j += 1

list = sorted(list)

for i in range(len(list)):
    print(list[i])


Measured memory_bytes: 47324
import numpy as np 
import math

N,K = map(int,input().split())
d = []
A = []
for i in range(K):
    temp = int(input())
    d.append(temp)
    a = list(map(int,input().split()))
    for j in range(temp):
        A.append(a[j])

counter = 0
for i in range(N):
    if i+1 in A:
        counter == 0
    else:
        counter += 1

print(counter)

Measured memory_bytes: 27120
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); scanf().tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair

int a[2*100001];

int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n-1;i++){
    int x;
    cin>>x;
    a[x]++;
  }
  for(int i=1;i<=n;i++)
  {
    cout<<a[i]<<endl;
  }
}


Measured memory_bytes: 4376
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

 int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    string s;
    cin >> n >> k >> s;
    if(s[k-1]=='A') s[k-1]='a';
    if(s[k-1]=='B') s[k-1]='b';
    if(s[k-1]=='C') s[k-1]='c';
    cout << s << endl;
 }

Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc134/tasks/abc134_c"

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    sort_a = sorted(a, reverse=True)
    for v in a:
        if sort_a[0] == v:
            print(sort_a[1])
        else:
            print(sort_a[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 91128
#!/usr/bin/env python3


def add(bound, r, c, x, y, i):
    if x == 0:
        bound.append((0, y, i))
    elif y == c:
        bound.append((1, x, i))
    elif x == r:
        bound.append((2, c - y, i))
    else:
        bound.append((3, r - x, i))


def solve(bound):

    if not bound:
        return True

    bound.sort()
    st = [0] * len(bound)
    p = -1

    for _, _, i in bound:
        if 0 <= p and st[p] == i:
            p -= 1
        else:
            p += 1
            st[p] = i

    return p == -1


def main():
    r, c, n = input().split()
    r = int(r)
    c = int(c)
    n = int(n)
    bound = []
    for i in range(n):
        x1, y1, x2, y2 = input().split()
        x1 = int(x1)
        y1 = int(y1)
        x2 = int(x2)
        y2 = int(y2)
        if (x1 % r == 0 or y1 % c == 0) and (x2 % r == 0 or y2 % c == 0):
            add(bound, r, c, x1, y1, i)
            add(bound, r, c, x2, y2, i)


    print('YES' if solve(bound) else 'NO')


if __name__ == '__main__':
    main()



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


int main(){
	LL X, Y;
	cin >> X >> Y;
	LL ans = 1;
	LL tmp = X;
	while(1){
		tmp *= 2;
		if(tmp<=Y) ans++;
		else break;
	}
	cout << ans << endl;
		

}














Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		do {
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" " + i);
			} else {
				do {
					if (x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
				} while (x != 0);
			}
		} while (++i <= n);
		System.out.print("\n");
	}
}

Measured memory_bytes: 28748
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int l = s.length();
    int num1 = 0, num2 = 0;
    for (int i = 0; i < l;i++)
    {
        if(s[i]=='0')
            num1++;
        else
            num2++;
    }
    cout <<min(num1,num2)*2;
    return 0;
}

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

const int N = 100 * 1000 + 5;

map <long long, int> mp;
vector <pair <int, int> > e;
pair <long long, int> d[N];
int c[N];
long long sum[N];


int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> d[i].first;
		d[i].second = i;
		c[i] = 1;
	}
	sort(d + 1, d + n + 1);
	for (int i = 1; i <= n; i++) {
		mp[d[i].first] = i;
	}
	for (int i = n; i > 1; i--) {
		int u = mp[d[i].first - n + 2 * c[i]];
	//	cout << "73 " << d[i].second << " " << d[u].second << endl;
		if (u == 0 || u == i) {
			cout << -1;
			return 0;
		} 
		c[u] += c[i];
		sum[u] += c[i] + sum[i];
		e.push_back({d[i].second, d[u].second});
	}
	if (sum[1] != d[1].first) {
		cout << -1;
		return 0;
	} 
	for (auto p : e) {
		cout << p.first << " " << p.second << endl;
	}
}


Measured memory_bytes: 13276
#include<iostream>
#include<string>
#define MAX 30000
using namespace std;

int main(){
    int N, first[10], second[10], count=0, third[10];
    char lucky[MAX];
    int ans = 0;
    for(int i= 0; i<10; i++){
        first[i] = 0;
        second[i] = 0;
        third[i] = 0;
    }
    cin >> N >> lucky;
    int num[N][2];
    for(int i = N-1; i>=0; i--){
        int number = lucky[i]-'0';
        num[i][0] = number;
        if(third[number] == 0){
            third[number] = 1;
            count++;
        }
        num[i][1] = count;
    }
    /*
    for(int i=0; i<N; i++){
        cout << num[i][0] << " ";
        }
        cout << endl;
    for(int i=0; i<N; i++){
        cout << num[i][1] << " ";
        }
        cout << endl;
    */
    for(int f=0; f<N-2; f++){
        if(first[num[f][0]] == 0){
            first[num[f][0]] = 1;
            for(int s=f+1; s<N-1; s++){
                if(second[num[s][0]] == 0){
                    second[num[s][0]] = 1;
                    ans += num[s+1][1];
                    //cout << num[f][0] << num[s][0] << num[s+1][1] << endl;
                }else{
                    //cout << "break because num[s][0] = " << num[s][0] << endl;
                }
            }
            for(int i=0; i<10; i++) second[i] = 0;
        }else{
            //cout << "break because num[f][0] = " << num[f][0] << endl;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512