akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int X,Y;cin>>X>>Y;
    int ans=0;
    if(X==1){
        ans+=300000;
    }
    if(X==2){
        ans+=200000;
    }
    if(X==3){
        ans+=100000;
    }
    if(Y==1){
        ans+=300000;
    }
    if(Y==2){
        ans+=200000;
    }
    if(Y==3){
        ans+=100000;
    }
    if(X==1 && Y==1){
        ans+=400000;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque
import sys
#input = sys.stdin.readline

N = int(input().strip("\n"))
A = [list(map(lambda x :int(x)-1, input().split())) for _ in range(N)]

# 対戦カード (インデックス0>インデックス[1]だけ使う)
all_patterns = [[[] for _ in range(N)] for _ in range(N)]
lines_to_here = [[0 for _ in range(N)] for _ in range(N)]

for i in range(len(A)):
    for j in range(len(A[i])-1):
        playerA = i
        playerB = A[i][j]
        if playerA < playerB:
            playerA, playerB = playerB, playerA
        next_playerA = i
        next_playerB = A[i][j+1]
        if next_playerA < next_playerB:
            next_playerA, next_playerB = next_playerB, next_playerA
        
        all_patterns[playerA][playerB].append((next_playerA,next_playerB))
        lines_to_here[next_playerA][next_playerB] += 1

next_out = deque()
for i in range(1,N):
    for j in range(i):
        if lines_to_here[i][j] == 0:
            next_out.append([i,j])

if len(next_out) == 0:
    print(-1)
    sys.exit()
    

indexin_topological_sorted = [[0 for _ in range(N)] for _ in range(N)]

# topological sort
topological_sorted = []
while len(next_out) > 0:
    added = next_out.pop()
    topological_sorted.append(added)
    indexin_topological_sorted[added[0]][added[1]] = len(topological_sorted)-1
    for direction in all_patterns[added[0]][added[1]]:
        lines_to_here[direction[0]][direction[1]]-=1
        if lines_to_here[direction[0]][direction[1]] == 0:
            next_out.append(direction)

# if there is closed circuit, number remain(not 0 exists)
for i in range(1,N):
    for j in range(i):
        if lines_to_here[i][j] > 0:
            print(-1)
            sys.exit()

costs = [0 for _ in range(len(topological_sorted))]

max_cost = 0
for i in range(len(topological_sorted)):
    processing = topological_sorted[i]
    now_cost = costs[i]
    for direction in all_patterns[processing[0]][processing[1]]:
        direction_in_topological_sorted = indexin_topological_sorted[direction[0]][direction[1]]        
        costs[direction_in_topological_sorted] = max(1+now_cost,costs[direction_in_topological_sorted])
        max_cost = max(max_cost,costs[direction_in_topological_sorted])
print(max_cost+1)


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

#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"#" <<endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 2e5+23;
const ll inf = 1e18+7;
map<ll,ll> primos;

void primeFactors(ll n)  
{  
    set<ll> st;
    while (n % 2 == 0)  
    {  
        st.insert(2);
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            st.insert(i); 
            n = n/i;  
        }  
    }  
    if (n > 2) st.insert(n);
    for(auto it : st){
        primos[it]++;
    }
}  

int main(){
  fastio;
  ll n;
  cin>>n;
  ll gx,a;
  f(i,0,n){
    cin>>a;
    primeFactors(a);
    if(i==0) gx = a;
    gx = __gcd(gx,a);
  }
  bool go = true;
  for(auto it : primos){
    if(it.sc>1){
        go = false;
        break;
    }
  }
  if(go) cout<<"pairwise coprime\n";
  else if(gx==1) cout<<"setwise coprime\n";
  else cout<<"not coprime\n";
  return 0; 
}

Measured memory_bytes: 8524
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

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

def main():
  n,x=LI()
  l=LI()

  a=0
  c=1
  for b in l:
    a+=b
    if a<=x:
      c+=1
    else:
      break

  return c

print(main())


Measured memory_bytes: 7320
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    vvint ans(h, vint(w));
    int num = 1;
    rep(i, h) rep(j, w) {
        if (a[num-1] == 0) num++;
        ans[i][j] = num;
        a[num-1]--;
    }

    rep(i, h) {
        if (i%2==1) reverse(all(ans[i]));
        out_ary(ans[i]);
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
int x1, x2, x3, x4, x5;
scanf("%d %d %d %d %d", &x1 ,&x2, &x3, &x4, &x5);

if(x1 == 0){
    printf("%d\n", 1);
}else if(x2 == 0){
    printf("%d\n", 2);
}else if(x3 == 0){
    printf("%d\n", 3);
}else if(x4 == 0){
    printf("%d\n", 4);
}else if(x5 == 0){
    printf("%d\n", 5);
}
return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a==b) cout << "Draw";
  else if (a==1) cout << "Alice";
  else if (b==1) cout << "Bob";
  else if (a>b) cout << " Alice";
  else cout << "Bob";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int arr[n];
    double arr2[n], sum=0.0;
    for(int i=0; i<n; i++)
        cin >> arr[i];
    sort(arr, arr+n);
    for(int i=0; i<n; i++)
        arr2[i]=(double)arr[i];
    for(int i=0; i<n; i++)
        sum=sum+(1.0/arr2[i]);
    cout << fixed << showpoint;
    cout << setprecision(10);
    cout << (1.0/sum) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "YES" << endl;
  exit(0);
}

void no(){
  cout << "NO" << endl;
  exit(0);
}

int main() {
  ll n; cin >> n;
  ll cnt = 0;
  REP(i,n){
    ll a; cin >> a;
    if(a%2==1) cnt++;
  }
  if(cnt%2==1) no();
  else yes();
} 

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  vector<long long> c(n);

  for (int i = 0; i < n; i++){
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n; i++) cin >> c[i];

  long long ans = -1000000000000000000;
  for (int i = 0; i < n; i++)
  {
    long long csum = 0;
    int clen = 0;
    int now = i;
    while(true){
      clen++;
      now = p[now];
      csum+=c[now];
      if(now==i) break;
    }

    int cnt = 0;
    long long path = 0;
    while(true){
      // now = p[now];
      // path += c[now];
      // cnt++;

      // if(cnt>k) break;

      // long long sum = path + max(0ll, csum) * (long long)(k-cnt)/clen;
      // ans = max(ans,sum);

      // if(now == i) break;
        cnt++;
        path += c[now];

        if (cnt > k) break;

        int num = (k - cnt) / clen;
        long long score = path + max(0ll, csum) * num;
        ans = max(ans,score);

        now = p[now];
        if (now == i) break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

// const (
// 	initialBufSize = bufio.MaxScanTokenSize //65536
// 	maxBufSize     = 100000
// )
func main() {
	scanner.Split(bufio.ScanWords)
	// buf := make([]byte, initialBufSize)
	// scanner.Buffer(buf, maxBufSize)

	a, b, c := nextInt(), nextInt(), nextInt()
	fmt.Println(min(b/a, c))
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}
func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}

func min(n, m int) int {
	if n < m {
		return n
	}
	return m
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	int sum;
	vint bit(3);
	string A;
	sum = 0;
	cin >> A;
	for (int i = 0; i < 8; i++) {
		sum = A[0] - '0';
		for (int j = 0; j < 3; j++) {
			if (i & (1 << j)) sum += A[j + 1] - '0';
			else sum -= A[j + 1] - '0';
		}

		if (sum == 7) {

			bit[2] = (i / 4) % 2;
			bit[1] = (i / 2) % 2;
			bit[0] = i % 2;
			for (int j = 0; j < 3; j++) {
				cout << A[j];
				if (bit[j] == 0)cout << '-';
				if (bit[j] == 1)cout << '+';
			}
			cout << A[3] << "=7" << endl;
			
			break;
		}


	}
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll H,W,N;
int main(){
    cin>>H>>W>>N;
    cout<<(N-1)/(max(H,W))+1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
 int a,b,c,d;
  
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  
  while(1){
    c-=b;
    if(c<=0){
      cout << "Yes" << endl;
      break;
    }
    a-=d;
    if(a<=0){
      cout << "No" << endl;
      break;
    }
  }
 return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int h,w;
string s[200];
int dp[200][200];
int visited[200][200];
int dfs(int now_h,int now_w){
    if(now_h==h-1&&now_w==w-1){
        return 0;
    }
    if(visited[now_h][now_w])return dp[now_h][now_w];
    int ans=1e9;
    visited[now_h][now_w]=1;
    if(now_w+1<w){
        int f=0;
        if(s[now_h][now_w]!=s[now_h][now_w+1]){
            f=1;
        }
        ans=min(ans,dfs(now_h,now_w+1)+f);
    }
    if(now_h+1<h){
        int f=0;
        if(s[now_h][now_w]!=s[now_h+1][now_w]){
            f=1;
        }
        ans=min(ans,dfs(now_h+1,now_w)+f);
    }
    return dp[now_h][now_w]=ans;
}
int main(){
    cin>>h>>w;
    for(int i=0;i<h;++i){
        cin>>s[i];
    }
    int a=dfs(0,0);
    if(s[0][0]=='.'&&s[h-1][w-1]=='.'){
        cout<<a/2<<endl;
    }else{
        cout<<a/2+1<<endl;
    }
}

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

using namespace std;

int main(void){
    int N;

    cin >> N;

    int C[N+5], S[N+5], F[N+5];
    
    for(int i=0;i<N+5;i++){
        C[i] = 0;
        S[i] = 0;
        F[i] = 0;
    }
    for(int i=0;i<N-1;i++){
        cin >> C[i] >> S[i] >> F[i]; 
    }

    for(int i=0;i<N;i++){
        int t = 0;
        for(int j=i;j<N-1;j++){
            if(t <= S[j]){
                t = S[j];
            }
            else if(t % F[j] != 0){
                t = t + F[j] - t % F[j];
            }
            t = t + C[j];
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split(" ")
    var a = parseInt(input[0]); 
    var b = parseInt(input[1]);
    var c = parseInt(input[2]);
    if (a <= b && b <= c && a <= c) { //123
        console.log(a + " " + b + " " + c);
    }else if (a <= b && c <= b && a <= c) { //132
        console.log(a + " " + c + " " + b);
    }else if (b <= a && b <= c && a <= c) { //213
        console.log(b + " " + a + " " + c);
    }else if (a <= b && c <= b && c <= a) { //231
        console.log(c + " " + a + " " + b);
    }else if (b <= a && b <= c && c <= a) { //312
        console.log(b + " " + c + " " + a);
    }else if (b <= a && c <= b && c <= a) { //321
        console.log(c + " " + b + " " + a);
    }
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug() {
    var input = document.getElementById("input").value;
    Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15136
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    while(true){
        int n, m;
        cin >> n >> m;

        if(n == 0 && m == 0){
            break;
        }

        vector<vector<int>> a(n, vector<int>(m));
        rep(i, n){
            rep(j, m){
                cin >> a[i][j];
            }
        }

        int ans = 0;
        for(int h = 3; h <= n; h++){
            for(int w = 3; w <= m; w++){
                rep(i, n-h+1){
                    rep(j, m-w+1){
                        int min = INF;
                        for(int k = i; k < i + h; k++){
                            for(int l = j; l < j + w; l++){
                                if(i < k && k < i+h-1 && j < l && l < j+w-1){
                                    continue;
                                }
                                if(min > a[k][l]){
                                    min = a[k][l];
                                }
                            }
                        }

                        int tmp = 0;
                        bool ok = true;
                        for(int k = i; k < i + h; k++){
                            for(int l = j; l < j + w; l++){
                                if(i == k || k == i+h-1 || j == l || l == j+w-1){
                                    continue;
                                }
                                if(min <= a[k][l]){
                                    ok = false;
                                }
                                tmp += min - a[k][l];
                            }
                        }

                        if(ok && ans < tmp){
                            ans = tmp;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3148
x = int(input())

ans_list = [1]

for i in range(2,x+1):
    cnt = 2
    while True:
        tmp = i ** cnt
        if tmp > x:
            break
        ans_list += [tmp]
        cnt += 1
        
    
ans_list.sort()

for i in ans_list[::-1]:
    if i <= x:
        print(i)
        break
        

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k,x;
  cin >> k >> x;
  int s=max(-1000000,x-k+1);
  int e=min(1000000,x+k-1);
  while(s<=e){
    cout << s << " ";
    s++;
  }

  
  return 0;
    

}


Measured memory_bytes: 256
from collections import Counter
H, W = map(int, input().split())
C = []
for i in range(H):
  C = C + (list(input()))
  
C = Counter(C)
if len(C) == 1:
  print("Yes")
  exit(0)
  
V = sorted(C.values())

"""
H:odd, W:odd
  H+W-1 が奇数一つと2の倍数で組成
  残りH*W - sakkino が4の倍数で組成
H:even, W:odd
  H が2の倍数で組成
  残りが4の倍数で組成
H:even, W:even
  すべて4の倍数で組成
"""
oddFlg = True if H%2 == 1 and W%2 == 1 else False
res = 1 if H%2 == 1 and W%2 == 1 else 0
res += H if W%2 == 1 else 0
res += W if H%2 == 1 else 0

als = H*W - res

A2 = []
A4 = []
for i in range(len(V)):
  v = V[i]
  if v == 0:
    continue
  elif v % 2 == 1:
    if oddFlg:
      oddFlg = False
      res -= 1
      A2.append(v-1)
    else:
      print("No")
      exit(0)
  elif v%4 == 0:
    A4.append(v)
  else:
    A2.append(v)
  
"""
print(res)
print(A2)
print(A4)
"""

for a in A2:
  res -= 2
  A4.append(a-2)
  if res < 0:
    print("No")
    exit(0)
    
res += als
if res == sum(A4):
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 9576
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<pair<ll,ll> > line;
    rep(i,n){
        ll tmp;cin>>tmp;
        line.push_back(make_pair(tmp,0));
    }
    rep(i,n){
        ll tmp;cin>>tmp;
        line.push_back(make_pair(tmp,1));
    }
    sort(line.begin(),line.end());
    ll cnt=0;
    ll state = line[0].second;
    ll res = 1;
    rep(i,2*n){
        if(cnt==0){state=line[i].second;}
        if(state==line[i].second){
            cnt++;
        }else{
            res *= cnt;
            res %= MOD;
            cnt--;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;
const int N = 2e5+5;
ll a[N],n,k;

bool ok(ll mid)
{
    ll temp = k;
    f(i,0,n)
    {
        temp -= (a[i]+mid-1)/mid - 1;
        if(temp<0) return false;
    }
    return true;
}

int main()
{
    FAST
    cin>>n>>k;
    ll m;
    f(i,0,n) cin>>a[i],m=max(a[i],m);
    ll ans=m;
    ll l=1,r=m;
    ll mid;
    while(l<=r)
    {
        mid = (l+r)/2;
        if(ok(mid))
        {
            ans=min(ans,mid);
            r=mid-1;
        }
        else l = mid+1;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 5144
#include <iostream>

using namespace std;

int main(){
    int x, y, s;
    while(1){
        cin >> x >> y >> s;
        if(x + y + s == 0) break;
        int ans = 0;
        for(int i = 1; i < 1001; ++i){
            for(int j = 1; j < 1001; ++j){
                if((100 + x) * i / 100 + (100 + x) * j / 100 == s){
                    int now = (100 + y) * i / 100 + (100 + y ) * j / 100;
                    if(ans < now){
                        ans = now;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll T,X;
    string S;
    cin >> T>>X;
    double t = (double)T / X;

    cout << setprecision(9) << t << endl;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int m=min({a,b,c}); int M=max({a,b,c});
  int d=a+b+c-m-M;
  cout << m*d/2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        for (int i=x-k+1;i<=x+k-1;i++)System.out.print(i+" ");
        System.out.println();
    }
}


Measured memory_bytes: 38388
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    string s,t;
    while(cin>>s>>t)
    {
        int id=-1;
        for(int i=s.size()-1;i>=0;i--)
        {
            if(s.size()-i>=t.size())
            {
                bool f=true;
                for(int j=i,k=0;k<t.size();j++,k++)
                {
                    if(s[j]!='?' && s[j]!=t[k])
                    {
                        f=false;
                        break;
                    }
                }
                if(f)
                {
                    id=i;
                    break;
                }
            }
        }
        if(id==-1)puts("UNRESTORABLE");
        else
        {
            for(int i=0;i<id;i++)
            {
                if(s[i]=='?')pf("a");
                else pf("%c",s[i]);
            }
            cout<<t;
            for(int i=id+t.size();i<s.size();i++)
            {
                if(s[i]=='?')pf("a");
                else pf("%c",s[i]);   
            }
            nl;
        }
    }
    return 0;
}
 









 




























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

int main() {
	string s,t;
  	cin >> s >> t;
  	int n = s.size();
  	bool ok = true;
  	for(int i = 0; i< n ;i++) {
      	ok = true;
      	for(int j = 0; j < n; j++) {
      		if(s[j] != t[(j+i)%n] ) {
             	ok = false;
              	break;
            }
        }
      	if(ok) {
          	cout << "Yes" << endl;
         	return 0; 
        }
    }
  	cout << "No" << endl;
  	
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
    cout.tie(0);
	int n,a,ans=0,sum=0;
	cin >> n;
	while (n--)
	{
		cin >> a;
		if (a % 2 == 0) {
			ans++;
			if (a % 3 == 0 || a % 5 == 0) sum++;
		}
	}
	if (ans == sum) cout << "APPROVED";
	else cout << "DENIED";
}


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

//答えが合わない場合はlong long型を疑うこと！

int main(){
    string s;
    cin >> s;
    if (s=="Sunny") cout << "Cloudy" << endl;
    else if (s=="Cloudy") cout << "Rainy" << endl;
    else if (s=="Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sqr(a) ((a) * (a))
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define fd(i, a, b) for (int i = a; i >= b; i--)
#define fe(i, a, b) for (int i = a; i < b; i++)
#define ii pair <int, int>
#define fi first
#define se second
#define sz(a) a.size()
#define RESET(a, b) memset((a), (b), sizeof (a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e9 + 7;
const int maxN = 1e9;

int N, L;
vector <string> V;

void enter()
{
   cin >> N >> L;
   string s;
   ff(i, 1, N) {
      cin >> s;
      V.push_back(s);
   }
}

void process()
{
  sort(V.begin(), V.end());
  fe(i, 0, V.size()) cout << V[i];
}

int main()
{
   ios_base::sync_with_stdio(false); cin.tie(NULL);
   //freopen("template.inp", "r", stdin);
   //freopen("template.out", "w", stdout);

   enter();
   process();

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
  int A, B;  cin >> A >> B;

  if (A <= 9 && B <= 9) print(A * B);
  else print(-1);

  return 0;
}

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

int main() {
  long long X,K,D;
  cin >> X >> K >> D;
  X=abs(X);
  long long A=X/D;
  if(K<A){
    cout << X-K*D << endl;
    return 0;
  }
  X-=A*D;
  K-=A;
  if(K%2==0){
    cout << X << endl;
    return 0;
  }
  else{
    cout << abs(X-D) << endl;
    return 0;
  }
}
  
  

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll a,b;
    cin>>a>>b;
    if(abs(a-b)%2!=0) cout<<"IMPOSSIBLE";
    else cout<<(a+b)/2;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#define rng(x, y) (0 <= x && x < W && 0 <= y && y < H)
int H, W, n, gx, gy, x[12][12], d[4] = { 1, 0, -1, 0 };
int solve(int sx, int sy, int depth) {
	if (depth++ == n) return ((sx == gx || sy == gy) ? 1 : 0);
	int ret = 0;
	for (int i = 0; i < 4; i++) {
		int tx = sx + d[i], ty = sy + d[i ^ 1];
		while (rng(tx, ty)) {
			if (x[ty][tx] == 1) {
				x[ty][tx] = 0;
				ret += solve(tx, ty, depth);
				x[ty][tx] = 1;
				break;
			}
			tx += d[i];
			ty += d[i ^ 1];
		}
	}
	return ret;
}
int main() {
	while (scanf("%d%d", &W, &H), W | H) {
		n = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				scanf("%d", &x[i][j]);
				if (x[i][j] == 1) n++;
				if (x[i][j] == 2) gx = j, gy = i;
			}
		}
		printf("%d\n", solve(gx, gy, 0));
	}
	return 0;
}

Measured memory_bytes: 2592
import sys

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

S = input()
T = input()
N = len(S)

ans = 0
for i in range(N):
    if S[i] != T[i]:
        ans += 1
print(ans)


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

int main() {
    int m, n_min, n_max;
    while (cin >> m >> n_min >> n_max, m) {
        vector<int> p(m);
        for (int &pi: p) cin >> pi;
        sort(p.begin(), p.end());
        reverse(p.begin(), p.end());
        vector<pair<int, int>> res;
        for (int n = n_min; n <= n_max; n++) {
            res.emplace_back(p[n - 1] - p[n], n);
        }
        sort(res.begin(), res.end());
        cout << res[res.size() - 1].second << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ll long long
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
#define mod 1000000007ll
using namespace std;
ll dp[105][100005];
int main()
{
    //need to mod
    //handle k=0
    ll n,k;
    scanf("%lld%lld",&n,&k);
    ll a[n+5];
    for(ll i=1;i<=n;++i)
    {
        scanf("%lld",&a[i]);
    }
    if(!k)
    {
        printf("1");
        return 0;
    }
    dp[1][0]=1;
    for(ll i=1;i<=a[1];++i)
    {
        dp[1][i]=dp[1][i-1]+1;
    }
    for(ll i=a[1]+1;i<=k;++i)
    {
        dp[1][i]=dp[1][i-1];
    }
    /*for(int i=0;i<=k;++i)
    {
        printf("%lld ",dp[1][i]);
    }
    printf("\n");*/
    for(ll i=2;i<=n;++i)
    {
        dp[i][0]=dp[i-1][0];
        //watch(dp[i][0])
        for(ll j=1;j<=k;++j)
        {
            ll r=j;
            ll l=j-min(j,(ll)a[i]);
            //watch(r)
            //watch(l)
            if(!l)
            {
                dp[i][j]=(dp[i][j-1]+dp[i-1][r])%mod;
            }
            else
            {
                dp[i][j]=(dp[i][j-1]+dp[i-1][r]-dp[i-1][l-1]+mod)%mod;
            }
            //watch(i)
           // watch(j)
            //watch(dp[i][j])
        }
    }
    printf("%lld",(dp[n][k]-dp[n][k-1]+mod)%mod);
    return 0;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef vector<lo> vl;
typedef vector<vl>vll;
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define REPV(a, b, c) for (lo(a) = b; (a) < (c); (a)++) 
#define REP(a,b) for(lo i =(a) ;i<(b);i++)

template <typename T>

istream &operator>>(istream &in, vector<T> &v)
{
	for (unsigned i = 0; i < v.size(); i++)
		in >> v[i];
	return in;
}

bool ans = false;

void recur(lo A,lo B,lo C,lo K){
	if(ans==true)return;

	if(K==0){
		if(B>A&&C>B)ans = true;
		return;
	}
	recur((A*2),B,C,(K-1));
	recur(A,(B*2),C,(K-1));
	recur(A,B,(C*2),(K-1));


}


void solve(){
		lo A,B,C,K;
		cin>>A>>B>>C>>K;
		recur(A,B,C,K);
		if(ans)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(20);
	solve();
	return 0;
}

Measured memory_bytes: 3576
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif


#ifdef _DEBUG
void init_global_C() { }
#else

#endif


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

    string S; cin >> S;
    int N = S.size();
    vi A(N); REP(i, N) A[i] = S[i] - '0';

    int M = 0x01 << 3;
    vector<char> op(N - 1);
    REP(i, M) {
        int p = i;
        int mask = 0x01;
        int sum = A[0];
        REP(j, N - 1) {
            if (p & mask) {
                op[j] = '+';
                sum += A[1 + j];
            }
            else {
                op[j] = '-';
                sum -= A[1 + j];
            }
            mask <<= 1;
        }
        if (sum == 7) break;
    }

    cout << A[0];
    REP(i, N - 1) cout << op[i] << A[1 + i];
    cout << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

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

    int mx = INF, mn = -1;
    rep(i, m){
        int l, r; cin >> l >> r;
        chmax(mn, l);
        chmin(mx, r);
    }
    cout << max(mx - mn + 1, 0) << ln;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, total) = readLine()!!.split(" ").map(String::toInt)
    for (x in 0..n) {
        for (y in 0..(n - x)) {
            val z = n - x - y
            if (10000 * x + 5000 * y + 1000 * z == total) {
                println("$x $y $z")
                return
            }
        }
    }
    println("-1 -1 -1")
}

Measured memory_bytes: 37948
h,w = map(int, input().split())
a = [input() for i in range(h)]
abc = [0]*26
import heapq

for i in range(h):
  for j in range(w):
    abc[ord(a[i][j])-ord("a")]+=1

heap=[]
heapq.heapify(heap)
for i in range(26):
  if abc[i]!=0:
    heapq.heappush(heap, -1*abc[i])
    
num4 = (h//2)*(w//2)
num2 = 0
if h%2==1:
  num2+=w//2
if w%2==1:
  num2+=h//2
    
while num4>0:
  temp=-1*heapq.heappop(heap)
  if temp>=4:
    if temp > 4:
      heapq.heappush(heap, -1*(temp-4))
    num4-=1
  else:
    print("No")
    quit()
    
while num2>0:
  temp=-1*heapq.heappop(heap)
  if temp>=2:
    if temp > 2:
      heapq.heappush(heap, -1*(temp-2))
    num2-=1
  else:
    print("No")
    quit()  
print("Yes")


Measured memory_bytes: 74648
import java.util.Scanner;

class Main  {

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

        String s=stdIn.next();
        

        if(s.equals("AAA")||s.equals("BBB")){
            System.out.println("No");
            
        }
        else{
            System.out.println("Yes");
            
        }
        
        
    }

}

Measured memory_bytes: 21844
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(std::string S) {
  int result;
  if (sz(S) % 2 == 0) {
    S.erase(sz(S) - 2, 2);
  } else {
    S.erase(sz(S) - 1, 1);
  }

  while (1) {
    string s1 = S.substr(0, sz(S) / 2);
    string s2 = S.substr(sz(S) / 2, sz(S) / 2);
    if (s1 == s2) {
      result = sz(S);
      break;
    }

    S.erase(sz(S) - 2, 2);
  }

  cout << result << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 384
a=list(map(int, input().split()))
n=a[0]
k=a[1]
d=[0]*k
sunuke=[0]*n
t=0
for i in range(k):
    d[i]=int(input())
    a=list(map(int, input().split()))
    for j in range (d[i]):
        x=a[j]-1
        sunuke[x]+=1
for y in range (n):
    if sunuke[y]==0:
        t+=1
print(t)


Measured memory_bytes: 9200
from itertools import groupby
def sum_until_n(n): return (n+1)*n//2

S = groupby(input())
ans = 0
prv_r_val = 0
for key, value in S:
  value = list(value)
  len_value = len(value)
  if key == '<':
    ans += sum_until_n(prv_r_val+len_value) - sum_until_n(prv_r_val)
    prv_r_val += len_value
  else:
    if prv_r_val-len_value < 0:
      ans +=  abs(prv_r_val-len_value)     
      
    ans += sum_until_n(len_value-1)
    prv_r_val = 0      
print(ans)

Measured memory_bytes: 8328
#include<stdio.h>
#include<math.h>

int main(void){

int n,b[100];

while(scanf("%d",&n) != EOF){

for(int i=0; i<=9; i++){
b[i]=pow(2,i);
}

for(int i=0; i<=9; i++){
     if(b[i]==n){
        printf("%d\n",b[i]);
     }
    for(int j=i+1; j<=9; j++){
       if(b[i]+b[j]==n){
         printf("%d %d\n",b[i],b[j]);
       }
       for(int k=j+1; k<=9;k++){
          if(b[i]+b[j]+b[k]==n){
            printf("%d %d %d\n",b[i],b[j],b[k]);
          }
          for(int l=k+1; l<=9;l++){
             if(b[i]+b[j]+b[k]+b[l]==n){
               printf("%d %d %d %d\n",b[i],b[j],b[k],b[l]);
             }
             for(int m=l+1; m<=9; m++){
                if(b[i]+b[j]+b[k]+b[l]+b[m]==n){
                printf("%d %d %d %d %d\n",b[i],b[j],b[k],b[l],b[m]);
                }
                for(int o = m+1; o<=9; o++){
                   if(b[i]+b[j]+b[k]+b[l]+b[m]+b[o]==n){
                   printf("%d %d %d %d %d %d\n",b[i],b[j],b[k],b[l],b[m],b[o]);
                   }
                   for(int p=o+1; p<=9; p++){
                       if(b[i]+b[j]+b[k]+b[l]+b[m]+b[o]+b[p]==n){
                       printf("%d %d %d %d %d %d %d\n",b[i],b[j],b[k],b[l],b[m],b[o],b[p]);
                       }
                       for(int q=p+1; q<=9; q++){
                          if(b[i]+b[j]+b[k]+b[l]+b[m]+b[o]+b[p]+b[q]==n){
                          printf("%d %d %d %d %d %d %d %d\n",b[i],b[j],b[k],b[l],b[m],b[o],b[p],b[q]);
                          }
                          for(int r=q+1; r<=9; r++){
                             if(b[i]+b[j]+b[k]+b[l]+b[m]+b[o]+b[p]+b[q]+b[r]==n){
                              printf("%d %d %d %d %d %d %d %d %d\n",b[i],b[j],b[k],b[l],b[m],b[o],b[p],b[q],b[r]);
                              }
                             for(int s=r+1; s<=9; s++){
                                if(b[i]+b[j]+b[k]+b[l]+b[m]+b[o]+b[p]+b[q]+b[r]+b[s]==n){
                                 printf("%d %d %d %d %d %d %d %d %d %d\n",b[i],b[j],b[k],b[l],b[m],b[o],b[p],b[q],b[r],b[s]);
                                 }
}
}
}
}
}
}
}
}
}
}
}
return 0;
}


Measured memory_bytes: 2032
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool pairsort1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool pairsort2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool pairsort3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool pairsort4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}
int main() {
	int n;
	cin >> n;
	vector<int>odd(n / 2), even(n / 2);
	rep(i, n) {
		int v;
		cin >> v;
		if (i % 2 == 0) {
			odd[i / 2] = v;
		}
		else {
			even[(i - 1) / 2] = v;
		}
	}
	sort(all(odd));
	sort(all(even));
	deque<pair<int,int>> oc,ec;
	int count = 1;
	rep(i, n / 2-1) {
		if (odd[i] == odd[i + 1]) {
			count++;
		}
		else {
			oc.push_back(make_pair(count, odd[i]));
			count = 1;
		}
	}
	oc.push_back(make_pair(count, odd[n/2-1]));
	oc.push_back(make_pair(0, 0));
	count = 1;
	rep(i, n / 2-1) {
		if (even[i] == even[i + 1]) {
			count++;
		}
		else {
			ec.push_back(make_pair(count, even[i]));
			count = 1;
		}
	}
	ec.push_back(make_pair(count, even[n/2-1]));
	ec.push_back(make_pair(0,0));
	sort(all(ec), pairsort2);
	sort(all(oc), pairsort2);
	int same = 0;
	rep(i, 2)rep(j, 2) {
		if (ec[i].S != oc[j].S) {
			//cout << ec[i].S <<" "<<oc[j].S << endl;
			same = max(same, ec[i].F + oc[j].F);
		}
	}
	cout << n - same << endl;

}


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

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;
    vector<int> cnt;

    UnionFind(int N){
        parent = vector<int>(N,-1);
        cnt = vector<int>(N,0);
    }

    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    int size(int A){
        return -parent[root(A)];
    }
    int vcount(int A){
        return cnt[root(A)];
    }

    bool unite(int A, int B) {
        A = root(A), B = root(B);
        if(A == B) return false; 

        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        cnt[A] += cnt[B];
        return true;
    }
    void add(int A){
        A = root(A);
        cnt[A]++;
    }

    bool same(int A, int B){
        return root(A)==root(B);
    } 
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll n,h,w;
    cin>>n>>h>>w;
    array<ll,3> a[n];
    for(int i=0;i<n;i++){
        ll r,c,s;
        cin>>r>>c>>s;
        r--,c--;
        a[i] = {s,w+r,c};
    }
    sort(a,a+n,greater<array<ll,3>>());
    ll ans = 0;
    UnionFind uni(h+w);
    for(int i=0;i<n;i++){
        if(!uni.same(a[i][1],a[i][2])){
            int cnt = uni.vcount(a[i][1]) + uni.vcount(a[i][2]);
            int siz = uni.size(a[i][1]) + uni.size(a[i][2]);
            if(cnt+1 > siz) continue;
            uni.unite(a[i][1],a[i][2]);
            uni.add(a[i][1]);
            ans += a[i][0];
            continue;
        }
        int cnt = uni.vcount(a[i][1]);
        int siz = uni.size(a[i][1]);
        if(cnt < siz){
            ans += a[i][0];
            uni.add(a[i][1]);
        }
    }
    cout << ans << endl;

}

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

int main(void)
{
    string a,b,c;
    bool judge = true;
    cin >> a >> b >> c;
    if(a[a.length() - 1] != b[0] || b[b.length() - 1] != c[0]){judge = false;}
    if(judge){cout << "YES" << endl;}
    else{cout << "NO" << endl;}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,W,w[101],v[101],dp[101][10001]={0};
	cin>>n>>W;
	for(int i=0;i<n;i++)cin>>v[i]>>w[i];
	for(int i=n-1;i>=0;i--)for(int j=0;j<=W;j++)
	{
		if(j<w[i])dp[i][j]=dp[i+1][j];
		else dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
	}
	cout<<dp[0][W]<<endl;
	return 0;
}


Measured memory_bytes: 7068
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        s: Chars,
    }

    let mut max = 0;
    let mut current = 0;
    for i in 0..s.len() {
        if s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T' {
            current = 0;
        } else {
            current += 1;
        }
        if max < current {
            max = current;
        }
    }

    println!("{}", max);
}


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

int H,W;
string ch = "ABCDEFGHIJKLMNOPQRSTUVWXY";
int main(){  
  cin >> H >> W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      string s; cin >> s;
      if( s == "snuke" ){
        cout << ch[j] << i + 1 << endl;
      }
    }
  }
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  if(a%2==0||b%2==0||c%2==0){
    print(0);
  }
  else{
    ll x = a * b;
    ll y = b * c;
    ll z = c * a;
    ll mini = min(x, min(y, z));
    print(mini);
  }
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int ans = INF, n = s.length();
  int cnt = 0;
  REP(i, n) {
    if (i & 1) {
      if (s[i] == '0') ++cnt;
    } else {
      if (s[i] == '1') ++cnt;
    }
  }
  ans = cnt;
  cnt = 0;
  REP(i, n) {
    if (i & 1) {
      if (s[i] == '1') ++cnt;
    } else {
      if (s[i] == '0') ++cnt;
    }
  }
  ans = min(ans, cnt);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512