akhauriyash/Code-Regression huggingface dataset:
function main()
	N = parse.(Int, readline())
	arr = parse.(Int, split(readline()))
	cnt=0
	while(true)
		flg = true
		for i = 1:N
			flg = arr[i]%2==0
			if flg
				arr[i]/=2
			else
				break
			end
		end

		if flg
			cnt+=1
		else
			println(cnt)
			break
		end
	end
end

main()

Measured memory_bytes: 174528
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MAXN 100
//---------------------

ll sum[MAXN];
string s;
ll sz=0;
ll fd=0,bd=0;
int main(){
  	cin>>sz;
	cin>>s;
	sz=s.size();
	sum[0] = s[0]=='('?1:-1;
	bool lastisplus=sum[0]==1;
	bool isplus=false;
	//cout<<0<<" : "<<sum[0]<<endl;
	REP1(i,sz-1){
	  	isplus=s[i]=='(';
		sum[i]=sum[i-1]+(isplus?1:-1);
		if(!lastisplus && sum[i-1]<0 && isplus){ fd+=(-sum[i-1]);sum[i]=1;} 
		lastisplus = isplus;
		//cout<<i<<" : "<<sum[i]<<endl;
	}
	ll lastsum=sum[sz-1];
	if(lastsum>0) bd=lastsum;
	else if(lastsum<0) fd+=(-lastsum);
	REP(i,fd) cout<<'(';
	cout<<s;
	REP(i,bd) cout<<')';
	
	return 0;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    C = input()
    r = C.count("R")
    w = C.count("W")
    cnt = 0
    if w != 0:
        for i in range(r, N):
            if C[i] == "R":
                cnt += 1
        print(cnt)
    else:
        print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9404
def mp(a,n,mod):
    if n==1:
        return a%mod
    aq=(mp(a,n//2,mod))**2
    ar=a**(n%2)
    return (((aq)%mod)*ar)%mod


def s_comb(n,k):
    s=1
    r=min(k,n-k)
    p=10**9+7
    for c in range(r):
        s=(s*(n-c)*mp(c+1,p-2,p))%p
    return s

x,y=map(int,input().split())
if (x+y)%3!=0 or 2*y<x or 2*x<y:
    print(0)
else:
    r=int(min(2*y-x,2*x-y)/3)
    print(s_comb(int((x+y)/3),r))

Measured memory_bytes: 46172
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
double ruijo(double x, int n) {
    double res = 1;
    rep(i, 0, n) { res *= x; }
    return res;
}
int intruijo(int x, int n) {
    int res = 1;
    rep(i, 0, n) { res *= x; }
    return res;
}
int main() {
    int N, M;
    cin >> N >> M;
    int k[11];
    int s[11][11];
    int p[11];
    rep(i, 0, M) {
        cin >> k[i];
        rep(r, 0, k[i]) { cin >> s[i][r]; }
    }

    rep(i, 0, M) { cin >> p[i]; }

    int res = 0;
    // {0, 1, ..., n-1} の部分集合の全探索
    for(int bit = 0; bit < (1 << N); ++bit) {
        int onR = 0;
        // cout << "bit" << bit << endl;
        rep(i, 0, M) {
            int on = 0;
            rep(r, 0, k[i]) {
                // cout << "s:" << s[i][r] << endl;
                if(bit & (1 << s[i][r] - 1)) {
                    on++;
                    // cout << i << "," << r << "," << bit << endl;
                }
            }
            // cout << "on" << on << endl;
            if(on % 2 == p[i]) {
                onR++;
            }
        }
        if(onR == M) {
            res++;
        }
    }
    cout << res << endl;
}

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

using namespace std;

int main() {
  int W, H, N; cin>>W>>H>>N;
  int x1 = 0, x2 = W;
  int y1 = 0, y2 = H;
  for(int i = 0; i < N; i++) {
    int x, y, a; cin>>x>>y>>a;
    switch (a) {
    case 1: x1 = max(x,x1); break;
    case 2: x2 = min(x,x2); break;
    case 3: y1 = max(y,y1); break;
    case 4: y2 = min(y,y2); break;
    }

  }
  int area = max(0, (y2-y1))*max(0, (x2-x1));
  cout << area << endl;
  return 0;
}


Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    ss=readline().rstrip()
    for s in ss:
        if s=="7":
            print("Yes")
            return
    print("No")
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16164
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&b==c) printf("1\n");
	else if(a==b||b==c||a==c) printf("2\n");
	else printf("3\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();
        m.solve();
        m.out();
    }
    
    boolean ac,bc,cc;
    public void input(){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String[] asp = a.split("");
        
        ac = bc = cc = false;

        for(int i = 0; i < 3; i++){
            if(asp[i].equals("a")){
                ac = true;
            }else if(asp[i].equals("b")){
                bc = true;
            }else if(asp[i].equals("c")){
                cc = true;
            }
        }
        
        sc.close();
    }
    
    public void solve(){
        
    }
    
    public void out(){
        if(ac && bc && cc){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
N,P=map(int,input().split())
A=list(map(int,input().split()))
Am=[]

for a in A:
    Am.append(a%2)
if max(Am)==0:
    if P==0:
        print(2**N)
    else:
        print(0)
else:
    print(2**(N-1))

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

int main(){
    string S;
    cin >> S;
    long long ans = 0;
    int bits = S.length() - 1;
    if(bits == 0){cout << stoll(S) << endl; return 0;}
    for(int i=0;i<(1 << bits);i++){
        int left = 0;
        for(int b=0;b<bits;b++){
            if(i & (1 << b)){
                ans += stoll(S.substr(left, b-left+1));
                left = b+1;
            }
        }
        ans += stoll(S.substr(left, bits-left+1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N =0 , count=0;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<vec.size();i++){
    cin >> vec.at(i);
  }
   bool exist_odd = false;
  while(true){
    
   
    for(int i=0; i<vec.size(); i++){
      if(vec.at(i)%2!=0){
        exist_odd=true;
      }
    }
    
    if(exist_odd){
      break;
    }
    
    for(int i=0;i<vec.size();i++){
      vec.at(i)/=2;
    }
    
    count++;
    
  }
  
  cout << count << endl;
  
}

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


int main() {
  int N;
  cin >> N;
  int A;
  A = 1000 - N % 1000;
  if(A == 1000){
    cout << 0 << endl;
  }
  else{
    cout << A << endl;
  }
}

Measured memory_bytes: 3616
#include <stdio.h>
#define N 10000

int main() {

  int i,n;
  unsigned short a[2000001],b[2000001];
  int c[N+1];
  scanf("%d",&n);
  for(i=0;i<=10000;i++) c[i] = 0;

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

  for(i=1;i<=N;i++){
    c[i] = c[i] + c[i-1];
  }
  
  for(i=n;1<=i;i--){
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", b[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8456
#include<iostream>
#include<cmath>
using namespace std;
 
int main(){
 
    int n, x, y;
    cin >> n >> x >> y;
 
    int distance[n]={0};
 
    for(int i=1; i<=n-1; i++){
        int count=0;
        for(int j=i+1; j<=n; j++){
            int dist = min(abs(j-i),abs(x-i)+abs(y-j)+1);
            dist=min(dist, abs(y-i)+abs(x-j)+1);
            distance[dist]++;
        }
    }
    for(int i=1; i<n; i++) cout << distance[i] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace  std;
const int N=1e9+7;
const int M=2e5+100;
typedef long long ll;
ll qian[M];
ll multi(ll a, ll b, ll m){

    // a * b % m

    ll ret = 0;

    while(b > 0){

        if(b & 1){

            ret = (ret + a) % m;

        }

        b >>= 1;

        a = (a << 1) % m;

    }

    return ret%m;

}


int main()
{
     ll n;
     cin>>n;
     ll a[n];
     for(ll i=0;i<n;i++)
        {cin>>a[i];
         qian[i+1]=a[i]+qian[i];
        }
    ll sum=0;
    for(ll i=1;i<n;i++)
    {
        sum+=multi(a[i],qian[i],N);

    }
    cout<<sum%N<<endl;

}


Measured memory_bytes: 6692
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int x = ri();
    int a = ri();
    int b = ri();
    cout << (x-a)%b << endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>
#include <boost/graph/graph_utility.hpp>
 
using namespace std;
using namespace boost;
 
template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}
 
// 隣接リスト表現による重み付き有向グラフ
using Graph = adjacency_list<vecS, vecS, directedS, no_property, property<edge_weight_t, int64_t>>;
using Vertex = graph_traits<Graph>::vertex_descriptor;
using Edge = std::pair<int, int>;
 
int main()
{
    const int nVert = read<int>();
    const int nEdge = read<int>();
 
    vector<Edge> edges;
    vector<int64_t> weights;
 
    edges.reserve(nEdge);
    weights.reserve(nEdge);

    // 1からnの経路に無関係な閉路を無視するため、逆(nから1)に探索する。
    times_do(nEdge, [&](){
        const auto a = read<int>() - 1;
        const auto b = read<int>() - 1;
        edges.emplace_back(b, a);
        weights.push_back(-read<int64_t>());
    });
 
    const Graph graph(edges.begin(), edges.end(), weights.begin(), nVert);
 
    vector<int64_t> distances(nVert, INT64_MAX);
    distances.back() = 0;

    if(bellman_ford_shortest_paths(graph, nVert, distance_map(distances.data()))){
        cout << -distances.front() << endl;
    }else{
        cout << "inf" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
def main():
    n = int(input())
    S = [int(a) for a in input().split()]

    q = int(input())
    T = [int(a) for a in input().split()]

    count = 0

    for t in T:
        l = 0
        r = n

        while l < r:
            m = int((l + r) / 2)

            if S[m] == t:
                count += 1
                break
            elif S[m] < t:
                l = m + 1
            elif S[m] > t:
                r = m

    print(count)    

main()


Measured memory_bytes: 16900
A,B,C = map(int, input().split())
K = int(input())
bc = 0
cc = 0

if A < B:
    for i in range(7):
        C = C * 2
        cc += 1
        if B < C:
            break

    if bc + cc <= K:
        print("Yes")
    else:
        print("No")
    exit()
for i in range(7):

    B = B * 2
    bc += 1
    if A < B:
        break
# print(bc)
# print(cc)
if bc > K:
    print("No")
    exit()
elif bc == K:
    if B < C:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
for j in range(7):
  
      
    C = C * 2
    cc += 1
    if B < C:
        break  

# print(bc)
# print(cc)

if bc + cc <= K:
    print("Yes")
else:
    print("No")

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


int main() {
  int a , b ;
  cin >> a >> b ;
  
  int sum = 0 ;
  for(int i=1; i<b-a ; i++ ){
    sum+=i;
  }
  
  cout << sum - a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string S;cin>>S;
    int index=S.size()-1;
    for(;;){
        if(index%2==1&&index!=S.size()-1){
            if(S.substr(0,index/2+1)==S.substr(index/2+1,index/2+1)){
                cout<<index+1<<endl;
                return 0;
            }
        }
        index--;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
	
	int a,b,c;
	cin>>a>>b>>c;
	a=abs(a);
	int m=a/c;
	if(m>=b)
	{
		cout<<(a-(b*c))<<endl;
	}
	else
	{
		int left=b-m;
		m+=(b-m)%2;
		cout<<abs(a-(m*c))<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3648
A, B, C = map(int, input().strip().split())
ans = 0
while (A != B or B != C) and (A % 2) + (B % 2) + (C % 2) == 0:
  A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2
  ans += 1
if (A % 2) + (B % 2) + (C % 2) == 0 and A == B == C:
  ans = -1
print(ans)

Measured memory_bytes: 3060
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define in freopen("in.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
 
const ll INF = 1e18;
const int mod = 1e9 + 7;
const ll N = 1e3 + 7;
typedef vector < vector < ll > > matrix;

int main()
{
    speed;
    ll n, mn = INF;
    cin >> n;
    fore( i, 1, sqrt(n) + 1 ) {
    	if ( n % i == 0 ) {
    		mn = min( mn, i - 1 + n / i - 1 );
    	}
    }
    cout << mn;
    time;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y,r,g,c;
    cin>>x>>y>>r>>g>>c;
    vector<P> v;
    FOR(i,0,r){
        ll in; cin>>in;
        v.push_back(P(in,(ll)0));
    }
    FOR(i,0,g){
        ll in; cin>>in;
        v.push_back(P(in,(ll)1));
    }
    FOR(i,0,c){
        ll in; cin>>in;
        v.push_back(P(in,(ll)2));
    }
    sortAlr(v);
    ll ans=0;
    ll ra = 0;
    ll ga=0;
    ll ca=0;
    FOR(i,0,v.size()){
        ll a = v[i].first;
        ll k = v[i].second;
        if(k==0 && ra<x){
            ra++;
            ans+=a;
        }
        if(k==1 && ga<y){
            ga++;
            ans+=a;
        }
        if(k==2){
            ca++;
            ans+=a;
        }
        
        if(ra+ga+ca==x+y)break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10604
#include <iostream>

using namespace std;

int N, remind1,remind2, tmp;

int main(void) {
	cin >> N;
	tmp = N;
	//1の位
	remind1 = tmp % 10;
	//100の位
	remind2 = tmp / 100;

	if (remind1 == remind2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
static long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
static List<long> numsThree = new List<long>();
static List<long> numsThreeR = new List<long>();
static long[] sum = new long[n+1];
static long[] sumR = new long[n+1];
static long answer = 0;
static long check = 0;

	static void Main()
	{
      
    for(int i=0; i<n; i++)
    {
    sum[0] += nums[i];
    numsThree.Add(nums[i]);
    
    sumR[n] += nums[3*n-1-i];
    numsThreeR.Add(nums[3*n-1-i]);
    }
    
    

    numsThree.Sort();//昇順にソート
    numsThreeR.Sort();//降順にソート
    numsThreeR.Reverse();

      
    for(int i=0; i<n; i++)
    {
      numsThree = PushHeap(numsThree,nums[n+i]);
      sum[i+1] = sum[i] + nums[n+i];
      numsThree = PopHeap(numsThree);
      sum[i+1] -= check;

      numsThreeR = PushHeapR(numsThreeR,nums[2*n-1-i]);
      sumR[n-1-i] = sumR[n-i] + nums[2*n-1-i];
      numsThreeR = PopHeapR(numsThreeR);
      sumR[n-1-i] -= check;
    }
    
    answer = sum[0] - sumR[0];
    //Console.WriteLine(sum[0] +" "+ sumR[0]);//デバッグ
    for(int i=1; i<=n; i++)
    {
      long ans = sum[i] - sumR[i];
      //Console.WriteLine(sum[i] +" "+ sumR[i]);//デバッグ
      if(ans > answer) answer = ans;
    }
    
	Console.WriteLine(answer);
	}

  static List<long> PushHeap(List<long> nums, long addNum)//現在のヒープnumsにaddNumを追加
{
  int n = nums.Count;
  nums.Add(addNum);

  while (n > 0)
  {
    int i = (n-1)/2;
    if (nums[n] < nums[i])//親のほうが大きいなら入れ替え。
    {
      long tmp = nums[n];
      nums[n] = nums[i];
      nums[i] = tmp;
    }
    n = i;
  }
  return nums;
}

static List<long> PopHeap(List<long> nums)//ヒープnumsからポップ
{
  int n = nums.Count - 1;
  check = nums[0];
  nums[0] = nums[n];//最大値である根を削除して配列の最後を持ってくる
  nums.RemoveAt(n);

  for (int i = 0, j; (j = 2*i+1) < n; )
  {
    if ((j != n-1) && (nums[j] > nums[j+1]))// ２つの子のうち、値の小さい方を選ぶ
      j++;
    if (nums[i] > nums[j])//子が親より小さいなら入れ替え
    {
      long tmp = nums[j];
      nums[j] = nums[i];
      nums[i] = tmp;
    }
    i = j;
  }
  return nums;
}

static List<long> PushHeapR(List<long> nums, long addNum)//現在のヒープnumsにaddNumを追加
{
  int n = nums.Count;
  nums.Add(addNum);

  while (n > 0)
  {
    int i = (n-1)/2;
    if (nums[n] > nums[i])//親のほうが小さいなら入れ替え。
    {
      long tmp = nums[n];
      nums[n] = nums[i];
      nums[i] = tmp;
    }
    n = i;
  }
  return nums;
}

static List<long> PopHeapR(List<long> nums)//ヒープnumsからポップ
{
  int n = nums.Count - 1;
  check = nums[0];
  nums[0] = nums[n];//最大値である根を削除して配列の最後を持ってくる
  nums.RemoveAt(n);

  for (int i = 0, j; (j = 2*i+1) < n; )
  {
    if ((j != n-1) && (nums[j] < nums[j+1]))// ２つの子のうち、値の大きい方を選ぶ
      j++;
    if (nums[i] < nums[j])//子が親より大きいなら入れ替え
    {
      long tmp = nums[j];
      nums[j] = nums[i];
      nums[i] = tmp;
    }
    i = j;
  }
  return nums;
}




  
}


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

using namespace std;
int main()
{
	int a, b;
	string op;
	cin >> a >> op >> b;

	int ret;
	if (op == "+") {
		ret = a + b;
	}

	if (op == "-") {
		ret = a - b;
	}

   cout << ret; 

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define W 100

vector<string> sv;

void draw(int n, char a, char b)
{
    string aline(W, a);
    string bline(W, b);
    string abline = "";
    string baline = "";

    for (int i = 0; i < W;i++)
    {
        abline += i % 2 == 0 ? a : b;
        baline += i % 2 == 0 ? b : a;
    }

    int h = (n - 1) / (W / 2);
    int w = (n - 1) % (W / 2);

    for (int i = 0; i < h;i++)
    {
        sv.push_back(abline);
        sv.push_back(bline);
    }

    if(w != 0)
    {
        string s = "";
        for (int i = 0; i < w;i++)
        {
            s += b;
            s += a;
        }
        for (int i = w * 2; i < W;i++)
        {
            s += a;
        }
        sv.push_back(s);
        sv.push_back(bline);
    }
}

int main()
{
    int A, B;

    cin >> A >> B;

    if(A == 1 && B == 1)
    {
        cout << "1 2" << endl;
        cout << ".#" << endl;
        return 0;
    }

    string bline(W, '#');
    string wline(W, '.');

    draw(A, '.', '#');


    if (A == 1)
    {
        sv.push_back(bline);
        sv.push_back(wline);
    }
    else
    {
        sv.push_back(wline);
    }

    draw(B, '#', '.');

    sv.push_back(wline);
    
    int H = sv.size();
    cout << H << ' ' << W << endl;

    for (int i = 0; i < H;i++)
    {
        cout << sv[i] << endl;
    }
    return 0;
}

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

int main(){
  int N; cin >> N;
  long long res=0;
  for(int A=1; A<=N; A++){
    if(N%A==0){
      res+=N/A-1;
    }else{
      res+=N/A;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int N, K;
int ans = 0;

int main(void) {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; ++i) {
		if (i == 0) { ans += K; }
		else { ans = ans*(K - 1); }
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

  a=n;

  while(n>0) {
    b += n%10;
    n /= 10;
  }

  if(a%b==0)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j;
	
	for (i=1; i<=9; i++)
	{
		for (j=1; j<=9; j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 520
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] a = new String[n];
    for(int i = 0;i<n;i++){
      a[i] = sc.next();
    }
    int m = sc.nextInt();
    String[] b = new String[m];
    for(int i = 0;i<m;i++){
      b[i] = sc.next();
    }

    int max = -1000;
    for(int i = 0;i<n;i++){
      if(a[i].equals("")){
        continue;
      }
      int point = 0;
      for(int j = 0;j<n;j++){
        if(a[i].equals(a[j])){
          point++;
        }
      }
      for(int j = 0;j<m;j++){
        if(a[i].equals(b[j])){
          point--;
        }
      }
      max = Math.max(max,point);
    }
    if(max<0){
      max=0;
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 23764
N, M = map(int, input().split())

bulbs = []
for m in range(M):
    ks = map(int, input().split())
    bulbs.append(list(ks)[1:])

P = list(map(int, input().split()))

result = 0
for m in range(2**N):

    flag = True
    for idx, bulb in enumerate(bulbs):
        count = 0
        for switch in bulb:
            count += (m >> (switch-1)) & 1
        if count % 2 != P[idx]:
            flag = False
            break
    if flag:
        result += 1
print(result)


Measured memory_bytes: 39668
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;



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

	cin >> N >> L >> R;
	int ans = 0;
	auto ret=[&](int a, int b, int c) {
		return ans=min(a*b, c);
	};
	ret(N, L, R);
	cout << ans << endl;
}

Measured memory_bytes: 384
k = int(input())

flag = False
a = []
a.append(7%k)
for i in range(1,k):
    a.append((a[i-1]*10+7)%k)
for i in range(k):
    if a[i]==0:
        print(i+1)
        flag = True
        break
if flag == False:
    print(-1)

Measured memory_bytes: 48636
#include <stdio.h>

#define M 8
#define free 0
#define nfree 1

void print(void);
void arrange(int);

int bs[M][M];
int gyo[M];
int retsu[M];
int mnnm[2*M-1];
int hnnm[2*M-1];
int in;

int main(){
  int i,j,r,c;

  for(i=0;i<M;i++) gyo[i]=retsu[i]=mnnm[i]=hnnm[i]=free;
  for(i=0;i<2*M-1;i++) hnnm[i]=mnnm[i]=free;
  for(i=0;i<M;i++){
    for(j=0;j<M;j++) bs[i][j]=free;
  }
  
  scanf("%d",&in);
  for(i=0;i<in;i++){
    scanf("%d%d",&r,&c);
    bs[r][c]=nfree;
  }

  arrange(0);
  
  return 0;
}

void arrange(int i){
  int j;

  if(i==M){
    print();
    return;
  }

  for(j=0;j<M;j++){
    if(retsu[j]==nfree||mnnm[i-j+M-1]==nfree||hnnm[j+i]==nfree) continue;
    gyo[i]=j;
    retsu[j]=hnnm[i+j]=mnnm[i-j+M-1]=nfree;
    arrange(i+1);
    gyo[i]=retsu[j]=hnnm[i+j]=mnnm[i-j+M-1]=free;
  }
}

void print(){
  int i,j;

  for(i=0;i<M;i++){
    for(j=0;j<M;j++){
      if(bs[i][j]==nfree&&gyo[i]!=j) return;
    }
  }
  for(i=0;i<M;i++){
    for(j=0;j<M;j++){
      if(gyo[i]==j) printf("Q");
      else printf(".");
    }
   printf("\n");
  }
}



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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a > b) {
    for (int i = 0; i < a; i++)
      cout << b;
  }
  
  else {
    for (int i = 0; i < b; i++)
      cout << a;
  }
  
  cout << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back
using namespace std;
typedef unsigned long long int ll;
#define MOD 1000000007
long modPow(long a, long x, long p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

long modInverse(long a, long p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
long modBinomial(long n, long k, long p) {
// calculates C(n,k) mod p (assuming p is prime).

    long numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    long denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
int  main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=modPow(2,n,MOD);
	ans=(ans-1+MOD)%MOD;
	// cout<<ans<<endl;
	// cout<<fun(n,a,MOD)<<endl;
	// ll a=1ll,b=1ll,c=1ll,d=1ll,e=1ll;
 //  	for(ll i=1;i<=n;i++){
 //  		a=(a*i)%MOD;
 //  		if(i==aa){
 //  			b=a;
 //  		}
 //  		if(i==n-aa){
	// 		c=a;
	// 	}
	// 	if(i==bb){
	// 		d=a;
	// 	}
	// 	if(i==n-bb){
	// 		e=a;
	// 	}
 //  	}
	cout<<((ans-modBinomial(n,a,MOD)+MOD)-modBinomial(n,b,MOD)+MOD)%MOD<<endl;
}

Measured memory_bytes: 256
using System;

namespace ALDS1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = getint();
            int[] a = new int[n];
            string[] input = getsplit();
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(input[i]);
            }
            int count = 0;
            for (int i = 0; i < n; i++)
            {
                int minj = i;
                for (int j = i; j < n; j++)
                {
                    if (a[j] < a[minj])
                    {
                        minj = j;
                    }
                }

                if (a[i] != a[minj])
                {
                    int k = a[i];
                    a[i] = a[minj];
                    a[minj] = k;
                    count++;
                }

            }
            for (int i = 0; i < n-1; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.WriteLine(a[n-1]);
            Console.WriteLine(count);
        }
        static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
        static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
    }
}

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

N=int(input())
s=[]
for _ in range(N):
	s.append(input())

M=int(input())
t=[]
for _ in range(M):
	t.append(input())

for i in t:
	if(i in s):
		s.pop(s.index(i))




max=0
for i in s:
	if(s.count(i)>max):
		max=s.count(i)

print(max)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N, M;
	cin >> N >> M;
	priority_queue<ll, vector<ll>, greater<ll> > Q;

	rep(i, N) {
		ll a;
		cin >> a;
		Q.push(a);
	}

	vector<pair<ll, ll> > CB(M);
	rep(i, M) {
		cin >> CB[i].second >> CB[i].first;
	}

	sort(CB.rbegin(), CB.rend());


	rep(i, M) {
		rep(j, CB[i].second) {
			if(Q.top() < CB[i].first) {
				ll tmp = Q.top();
				Q.pop();
				Q.push(CB[i].first);
			} else {
				break;
			}
		}
	}

	ll ans = 0;
	while(!Q.empty()) {
		ans += Q.top();
		Q.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
ll k, dp[105][4][2];
string in;
ll solve(int idx, int curK, bool allValid)
{
    if(curK > k)
        return 0;
    if(idx == in.size())
        return curK == k;
    if(dp[idx][curK][allValid] != -1)
        return dp[idx][curK][allValid];
    ll ans = 0;
    for(char c = '0'; c <= '9'; c++)
    {
        if(c < in[idx])
            ans += solve(idx + 1, curK + (c != '0'), 1);
        else
        {
            if(c == in[idx] || allValid)
                ans += solve(idx + 1, curK + (c != '0'), allValid);
        }
    }
    dp[idx][curK][allValid] = ans;
    return ans;
}
int main()
{
    memset(dp, -1, sizeof dp);
    cin >> in >> k;
    cout << solve(0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
n,k=(int(x) for x in input().split())
lst=[int(x) for x in input().split()]
sum_lst=[sum(lst[0:k])]
for i in range(n-k):
  next_element=sum_lst[-1]-lst[i]+lst[i+k]
  sum_lst.append(next_element)
print((max(sum_lst)+k)/2.0)

Measured memory_bytes: 24676
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(int i=1 ; i<=sqrt(n) ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
// 出典
// http://jajagacchi.jugem.jp/?eid=531

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a = enum_div(n);
    a.push_back(n);
    ll result = 0;
    for (auto e : a) {
        if(e-1 > n/e){
            result+= e-1;
        }
    }
    std::cout << result << std::endl;

}

Measured memory_bytes: 384
# import math
# import numpy as np
import sys
def input():
    return sys.stdin.readline()[:-1]
# input
N, K, Q = map(int, input().split())
As = [int(input()) for i in range(Q)]

points = [K - Q] * N

for a in As:
    # points = [0 if point == 0 for point in points else point - 1]
    # points -= 1
    # points[a - 1] += 1
    points[a-1] += 1
survive = ['Yes' if point >= 1 else 'No' for point in points]

print(*survive, sep="\n")

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	int p = 0;
	for(int i = 0; i < (int)s.size(); i++)
		if(s[i] == 'p')
			p++;

	cout << (int)s.size()/2 - p << endl;

	return 0;
}

Measured memory_bytes: 512
<?php
foreach (['a', 'b', 'c'] as $v) {
    list($s[$v]) = strs();
    $n[$v] = strlen($s[$v]);
    $i[$v] = 0;
}
$next = 'a';
while (true) {
    if ($i[$next] === $n[$next]) break;
    ++$i[$next];
    $next = $s[$next][$i[$next] - 1];
}
echo strtoupper($next);
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 4856
import java.util.Scanner;

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

        if (A.equals("SUN")) {
            System.out.print(7);
        } else if (A.equals("MON")) {
            System.out.print(6);
        } else if (A.equals("TUE")) {
            System.out.print(5);
        } else if (A.equals("WED")) {
            System.out.print(4);
        } else if (A.equals("THU")) {
            System.out.print(3);
        } else if (A.equals("FRI")) {
            System.out.print(2);
        } else {
            System.out.print(1);
        }
    }
}


Measured memory_bytes: 21972
/**
 * Martin Leshko (leshko.martin@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define for1n(i, n) for (int i = 1; i <= (int)(n); i++)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define psb push_back
template<class T> T read() { T x; cin >> x; return x; }
typedef long long ll;
#define wyzi() read<int>()
#define wyzs() read<string>()

//#define err(...) fprintf(stderr, __VA_ARGS__)

const int N = 200001;

int main() {
  string s = wyzs(), t = wyzs();
  int ans = 0;
  forn(i, 3)
    if (s[i] == t[i])
      ans++;
  cout << ans << endl;
}


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

using namespace std;

int n, m;
int a[10];
int all, bll;
int gl;

int main(void)
{
	scanf("%d %d", &n, &m);
	
	if(n == 1 && m == 0)
	{
		printf("0");
		return 0;
	}
	
	a[3] = -1;
	a[1] = -1;
	a[2] = -1;
	
	for(int i = 0 ; i < m ; i++)
	{
		scanf("%d %d", &all, &bll);
		
		if(a[all] == -1)
		{
			a[all] = bll;
		}
		
		else if(a[all] != -1 && a[all] != bll)
		{
			printf("-1");
			return 0;
		}
	}
	
	if(a[1] == -1)
		a[1] = 1;
	
	if(a[1] == 0 && n >= 2)
	{
		printf("-1");
		return 0;
	}
	
	for(int i = 1 ; i <= n ; i++)
	{
		if(a[i] == -1)
			printf("0");
		else
			printf("%d", a[i]);
	}
	
	return 0;
}

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

struct edge{
  int to,len,id;
  edge(int x, int d, int i){
    to=x;
    len=d;
    id=i;
  }
};

vector<int> used(200005,0);
vector<int> v(100005,-INF);
vector<edge> g[100005];

bool check=true;

int dfs(int t, int n){
  //cout<<t<<'t'<<n<<'n'<<endl;
  for(edge e:g[t]){
    //cout<<e.id<<"id"<<used[e.id]<<"used"<<endl;
    if (used[e.id])continue;
    int now=e.len+n;
    used[e.id]=1;
  //  cout<<e.to<<"to"<<v[e.to]<<'v'<<now<<"now"<<endl;
    if (v[e.to]==-INF){
      v[e.to]=now;
      dfs(e.to,now);
    }
    else{
      if (v[e.to]!=now)check=false;
    }
  }
  return 0;
}
int main() {
  int n,m;
  cin>>n>>m;

  rep(i,m){
    int l1,r1,d1;
    cin>>l1>>r1>>d1;
    l1--;r1--;
    g[l1].push_back(edge(r1,d1,i));
    g[r1].push_back(edge(l1,-d1,i));
  }

  rep(i,n){
    if (v[i]==-INF){
      v[i]=0;
      dfs(i,0);
    }
  }
  if (check==true){
    cout<<"Yes"<<endl;
    return 0;
  }
  else {
    cout<<"No"<<endl;
    return 0;
  }


}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N, S, T;
  	cin >> N;
 
  	S = N/1000;
  	T = (S+1)*1000 - N;
  
  	if(T==1000){
    	cout << "0"<<endl;
    }
  	else{
    	cout << T <<endl;
    }
  	
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  set<int> s;
  rep(i, n) {
    if(s.count(a[i])) {
      cout << "NO" << endl;
      return 0;
    }
    s.insert(a[i]);
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
char s[100007];
int a,b,c;
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for (int i=0;i<len;i++)
	{
		if (s[i]=='a') ++a;
		if (s[i]=='b') ++b;
		if (s[i]=='c') ++c;
	}
	if (abs(a-b)<=1&&abs(b-c)<=1&&abs(c-a)<=1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int i,n,a,ans=0,tmp,num[100010]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    num[a]++;
  }
  for(i=1;i<=100000;i++){
    tmp=num[i-1]+num[i]+num[i+1];
    if(ans<tmp)ans=tmp;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }

    ull operator"" _64u(unsigned long long x){ return ull(x); }

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll L, R;
    is >> L >> R;
    if(!is) return;
    ll minim = INF;
    if(R >= L + 2019){
        minim = 0;
    }
    else{
        for (ll i = L; i < R; ++i) {
            for (ll j = i + 1; j < R + 1; ++j) {
                minim = min(minim, (i*j) % 2019);
            } // end j
        } // end i
    }
    cout << minim << endl;


}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_C.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <functional>

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

std::vector<int> bfs(const Graph<>& graph, int s) {
    std::vector<int> dist(graph.size(), -1);
    std::queue<int> que;

    dist[s] = 0;
    que.push(s);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto e : graph[v]) {
            int u = e.dst;
            if (dist[u] != -1) continue;
            dist[u] = dist[v] + 1;
            que.push(u);
        }
    }

    return dist;
}

void solve() {
    int n;
    std::cin >> n;

    std::vector<std::set<int>> gs(3);
    {
        std::vector<int> ms(3);
        for (auto& m : ms) std::cin >> m;
        for (int i = 0; i < 3; ++i) {
            while (ms[i]--) {
                int v;
                std::cin >> v;
                gs[i].insert(--v);
            }
        }
    }

    auto trans = [&](int v) {
        for (int i = 0; i < 3; ++i) {
            if (gs[i].count(v)) return n + i;
        }
        return v;
    };

    Graph<> graph(n + 3);
    int m;
    std::cin >> m;
    while (m--) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;

        u = trans(u), v = trans(v);
        graph[u].emplace_back(u, v);
        graph[v].emplace_back(v, u);
    }

    std::vector<std::vector<int>> dss(3);
    for (int i = 0; i < 3; ++i) {
        dss[i] = bfs(graph, n + i);
    }

    int ans = n;
    std::vector<int> rs;

    for (int v = 0; v < n; ++v) {
        int u = trans(v);
        int dsum = dss[0][u] + dss[1][u] + dss[2][u];

        if (dsum < ans) {
            rs.clear();
            ans = dsum;
        }
        if (dsum == ans) rs.push_back(u);
    }

    std::vector<std::set<int>> ids(3);
    std::function<void(int, int)>
        dfs = [&](int v, int i) {
            if (ids[i].count(v)) return;

            ids[i].insert(v);
            for (auto e : graph[v]) {
                int u = e.dst;
                if (dss[i][u] >= dss[i][v]) continue;
                dfs(u, i);
            }
        };

    for (auto r : rs) {
        for (int i = 0; i < 3; ++i) {
            dfs(r, i);
        }
    }

    std::set<int> col;
    for (int i = 0; i < 3; ++i) {
        col.insert(gs[i].begin(), gs[i].end());
        col.insert(ids[i].begin(), ids[i].end());
    }

    std::cout << ans << " " << *col.begin() + 1 << std::endl;
}

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

    solve();

    return 0;
}



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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w;;
	cin >> h >>w;
	vector<string> ba(h);
	rep(i, h) cin >>ba[i];
	vector<VI> dp(h+2, VI(w+2, MD));
	dp[0][0] = (ba[0][0]=='#');
	rep(i, h) rep(j, w){
		if(i+1 < h)
			dp[i+1][j] = min(dp[i+1][j], dp[i][j] +(ba[i][j] != ba[i+1][j]));
		if(j+1 < w)
			dp[i][j+1] = min(dp[i][j+1], dp[i][j] +(ba[i][j] != ba[i][j+1]));
	}
	for(auto xl: dp){for(auto x :xl) cerr<<x<<" ";dbg();}
	int ans = (dp[h-1][w-1] + 1) /2;
	cout << ans <<"\n";
	return 0;


}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		long N = scn.nextLong();
		long n = N;
		scn.close();
		int sum = 0;
		while(n!=0) {
			sum += n%10;
			n /=10;
		}
		System.out.println(N%sum == 0?"Yes":"No");
	}
}


Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
# from bisect import *
# from collections import *
# from heapq import *
# import functools
# import itertools
# import math
INF = 500000
MOD = 10**9+7

gcd = lambda a, b: a if b == 0 else gcd(b, a%b)
a, b = map(int, input().split())
print(a*b//gcd(a, b))


Measured memory_bytes: 38452
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,M,a[100],o;
int main(){
	cin>>N>>M;
	rep(i,M){
		cin>>a[i];
		if(a[i]%2==1) o++;
	}
	if(o>=3){
		puts("Impossible");
		return 0;
	}
	vector<int> ans;
	if(o==0){
		rep(i,M) cout<<a[i]<<" ";
		puts("");
		if(a[0]-2>0) ans.pb(a[0]-2);
		ans.pb(1);
		rep1(i,M-1) ans.pb(a[i]);
		ans.pb(1);
	}else if(o==1){
		rep(i,M) if(a[i]%2==1) swap(a[0],a[i]);
		rep(i,M) cout<<a[i]<<" ";
		puts("");
		rep(i,a[0]/2) ans.pb(2);
		rep1(i,M-1) ans.pb(a[i]);
		ans.pb(1);
	}else{
		rep(i,M){
			if(a[i]%2==1){
				swap(a[0],a[i]);
				break;
			}
		}
		rep1(i,M-1){
			if(a[i]%2==1){
				swap(a[M-1],a[i]);
				break;
			}
		}
		rep(i,M) cout<<a[i]<<" ";
		puts("");
		rep(i,a[0]/2) ans.pb(2);
		rep1(i,M-2) ans.pb(a[i]);
		rep(i,a[M-1]/2+1) ans.pb(2);
	}
	cout<<ans.size()<<endl;
	for(int x:ans) cout<<x<<" ";
	puts("");
}


Measured memory_bytes: 640
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
/*#define fast ios_base::sync_with_stdio(0); cin.tie(0)*/
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const double pi = acos(-1);
typedef long long ll;
int main()
{
	//fast;
	
	ll a,b,c,d;
	cin>>a>>b;
	 cout<<max(a*b,max(a+b,a-b));
}

Measured memory_bytes: 3564