akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input()

ans = 0

for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = S.find(str(j),a+1)
        for k in range(10):
            if b == -1:
                continue
            c = S.find(str(k),b+1)
            if c > b :
                ans +=1
print(ans)


Measured memory_bytes: 38384
#include <cstdio>

int main() {
	int n, ans = 0x3f3f3f3f;
	scanf("%d", &n);
	for (int i = 1; i <= n / 2; ++i) {
		int a = i, b = n - i, t = 0;
		while (a) t += a % 10, a /= 10;
		while (b) t += b % 10, b /= 10;
		if (t < ans) ans = t;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		// input
		int k = scan.nextInt();
		int pos = scan.nextInt();


		// check
		int len = (k - 1) * 2 + 1;
		for(int i = pos - (k - 1); i <= pos + (k - 1); i++){
			System.out.print(i + " ");
		}
		System.out.println("");

	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<bool> f;
vector<vector<int> > g;
bool dfs(int v,int s){
  f[v] = true;
  //cout<<v<<" g:"<<g[v][0]<<" s:"<<s<<endl;
  //cout<<g[v].size()<<endl;
  for(auto i : g[v]){
    //cout<<v<<" i:"<<i<<" s:"<<s<<endl;
    if(s==i) return 1;
    //cout<<v<<" i:"<<i<<" s:"<<s<<"....2"<<endl;
    if(f[i])continue;
    if(dfs(i,s))return 1;
  }

  return 0;
}
int main(){
  int v,e,s,t;
  cin>>v>>e;
  g.resize(v);
  f.resize(v);
  bool flag =0;
  for(int i=0;i<e;i++){
    cin>>s>>t;
    g[s].push_back(t);
  }
  for(int i=0; i<v;i++){
    if(g[i].empty())continue;
    flag=dfs(i,i);
    //cout<<flag<<endl;
    if(flag)break;
    for(int i=0;i<v;i++)f[i]=false;
  }
  cout<<flag<<endl;

  return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
char g3[3][4]={
    "aa.",
    "..b",
    "..b"
};
char g4[4][5]={
    "abcc",
    "abdd",
    "eefg",
    "hhfg"
};
char g5[5][6]={
    "aabcc",
    "deb..",
    "de..f",
    "g.hhf",
    "giijj"
};
char g6[6][7]={
    "aabb.c",
    "d..eec",
    "dfg...",
    ".fg.hh",
    "..ijjl",
    "kki..l"
};
char g7[7][8]={
    "aa.bbcc",
    "ddeff..",
    "..ehi..",
    "..ghi..",
    "..g..lm",
    "..k..lm",
    "jjk..nn",
};
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    if(N==2) dame;
    if(N==3){
        rep(i,3){
            rep(j,3){
                cout<< g3[i][j];
            }
            cout<<"\n";
        }
        return;
    }
    if(N==7){
        rep(i,7){
            rep(j,7){
                cout<< g7[i][j];
            }
            cout<<"\n";
        }
        return;
    }
    ll num4,num5,num6;
    rep(i,251){
        rep(j,251){
            rep(k,251){
                if(i*4+j*5+k*6==N){
                    num4=i,num5=j,num6=k;
                }
            }
        }
    }
    ll x=0;
    char ans[N][N];
    rep(i,N){
        rep(j,N){
            ans[i][j]='.';
        }
    }
    while(--num4>=0){
        rep(i,4){
            rep(j,4){
                ans[x+i][x+j]=g4[i][j];
            }
        }
        x+=4;
    }
    while(--num5>=0){
        rep(i,5){
            rep(j,5){
                ans[x+i][x+j]=g5[i][j];
            }
        }
        x+=5;
    }
    while(--num6>=0){
        rep(i,6){
            rep(j,6){
                ans[x+i][x+j]=g6[i][j];
            }
        }
        x+=6;
    }
    rep(i,N){
        rep(j,N){
            cout<< ans[i][j];
        }
        cout<<"\n";
    }
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;

class G
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];
		// 多重辺および自己ループを除去。
		var es = new int[h[1]].Select(_ => Read()).Select(e => (v0: e[0], v1: e[1])).Where(e => e.v0 != e.v1).Distinct().ToArray();

		var map = Array.ConvertAll(new int[n], _ => new List<int>());
		var map_r = Array.ConvertAll(new int[n], _ => new List<int>());
		foreach (var (v0, v1) in es)
		{
			map[v0].Add(v1);
			map_r[v1].Add(v0);
		}

		var u = new bool[n];
		var order = new List<int>();
		var gs = new List<List<int>>();
		List<int> lg = null;

		void Dfs(int v)
		{
			u[v] = true;
			foreach (var nv in map[v]) if (!u[nv]) Dfs(nv);
			order.Add(v);
		}
		for (int v = 0; v < n; v++) if (!u[v]) Dfs(v);

		void Dfs_r(int v)
		{
			u[v] = true;
			foreach (var nv in map_r[v]) if (!u[nv]) Dfs_r(nv);
			lg.Add(v);
		}
		Array.Clear(u, 0, n);
		order.Reverse();
		foreach (var v in order) if (!u[v]) { gs.Add(lg = new List<int>()); Dfs_r(v); }

		Console.WriteLine(gs.Count);
		Console.WriteLine(string.Join("\n", gs.Select(g => string.Join(" ", g.Prepend(g.Count)))));
	}
}


Measured memory_bytes: 177368
def distance_between_houses(d1, d2=0):
    """
    2点の基準値からの距離を引数に2点間の距離を求める。
    引数：d1 : 家１の基準値からの距離
    　　　d2 : 家２の基準値からの距離
    戻り値：2点間の距離
    """
    return d2 - d1

def traveling_salesman_around_lake():
    # 入力
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    # 家と家との距離
    distances = list()
    for i in range(N):
        if i < N-1 :
            distances.append(distance_between_houses(A[i], A[i+1]))
        # 基準値から最も遠い家と最も近い家の距離
        else:
            distances.append(distance_between_houses(A[i], A[0]+K))
    # 最も遠い距離をリストから除外
    max_value_ind = distances.index(max(distances))
    distances.pop(max_value_ind)
    # リストを全合計
    return sum(distances)

result = traveling_salesman_around_lake()
print(result)

Measured memory_bytes: 30960
let () =
    let main () =
        let n, k = Scanf.sscanf (read_line ()) "%d %d" (fun n k -> n, k) in
        let s = read_line () in
        let rec loop i prev acc =
            if i = n then acc else
                if prev = s.[i] then loop (i + 1) s.[i] acc else
                        loop (i + 1) s.[i] (acc + 1)
        in
        let a = loop 1 s.[0] 0 in
        let rest_k = k - min (a / 2) k in
        let rest_a = a - 2 * (k - rest_k) in
        let rest_a = if rest_a = 1 && rest_k > 0 then rest_a - 1 else rest_a in

        let r = n - (rest_a + 1) in
        Printf.printf "%d\n" r
    in
    main ()

Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	cout << (h - a)*(w - b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    string s;
    cin >> s;
    int ans = 0, n = s.size();
    for(int i = 0; i<n; i++){
        if(i % 2 !=s.at(i) - '0'){
            ans++;
        }
    }
    cout << min(ans, n- ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
//rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
//if(y==0) return x;
//return gcd(y, x%y);
//}
//sort小さい順(昇順)
//g++ code.cpp   ./a.out 
int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(), l.end());
  int ans=0;
  rep(i,n){
    for(int j=i+1; j<n; j++){
      int it=lower_bound(l.begin(), l.end(), l[i]+l[j])-l.begin();
      ans += max(it-j-1, 0);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  int a[n];
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    v[i] = x;
    a[i] = x;
  }
  sort(v.begin(), v.end());
  int mid = v[n/2];
  int mid2 = v[n/2-1];
  for(int i = 0; i < n; i++){
    if(a[i] < mid) cout << mid << endl;
    else cout << mid2 << endl;
  }
  return 0;
}

Measured memory_bytes: 3840
// 偶数なら全部変えられるし奇数ならabs(x)の最小に-を押し付けることができそう
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	sum := 0
	minn := int(1e10)
	minc := 0
	for i := 0; i < N; i++ {
		var A int
		fmt.Scan(&A)
		if A < 0 {
			minc++
		}
		if minn > abs(A) {
			minn = abs(A)
		}
		sum += abs(A)
	}
	if minc%2 == 0 {
		fmt.Println(sum)
	} else {
		fmt.Println(sum - 2*minn)
	}
}
func abs(x int) int {
	if x < 0 {
		x *= -1
	}
	return x
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 5504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int x = 1; x <= 9; x++)
            {
                for (int y = 1; y <= 9; y++)
                {
                    Console.WriteLine("{0}x{1}={2}", x, y, x * y);
                }
            }
        }
    }
}

Measured memory_bytes: 5592
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
int N;
cin>>N;
int A;
ll ans=1;
map<int,int> map;
rep(i,N){
    cin>>A;
    if(A==0){
        if(N%2==0){
            cout<<0<<endl;
            return 0;
        }
        else if(map[N/2]!=0){
            cout<<0<<endl;
            return 0;
        }
        else{
            map[N/2]++;
            
        }

    }
    else{
        if((N+A)%2==0){
            cout<<0<<endl;
            return 0;
        }
        else if(map[(N+A)/2]!=0){
            if(map[(N-A)/2]!=0){
                cout<<0<<endl;
                return 0;
            }
            else{
                map[(N-A)/2]++;
                ans*=2;
                ans%=MOD;
            }
        }
        else{
            map[(N+A)/2]++;
        }
    }

}
cout<<ans<<endl;


return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a) for(int i=0;i<a;i++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main() {
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;
	int count = 0;
	FOR(n) {
		if (a[i] == b[i] && b[i] == c[i]) {
			;
		}
		else if (a[i] == b[i] || a[i] == c[i] || b[i] == c[i]) {
			count++;
		}
		else {
			count += 2;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 3e5, M = N;
//=======================

vi g[N];

void solve() {
	int i, j, n, m;
	cin >> n;
	int a[n];
	fo(i, n) cin >> a[i];
	int ans = 0;
	fo(i, n)
	{
		if (i == 0) continue;
		if (a[i] < a[i - 1]) {
			// deb2(i, ans);
			ans += abs(a[i] - a[i - 1]);
			a[i] = a[i - 1];
		}
	}
	cout << ans << "\n";
}

int32_t main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	solve();
	return 0;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 12264
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using namespace std;

void Main()
{
  int H, W;
  cin >> H >> W;
  int h,w;
  cin >> h >> w;

  cout << (H-h)*(W-w) << endl;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	if ((str.back() == str.front()) ^ (str.length() & 1)) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int d(char c){
    return c-'0';
}

int main(){
    string S;cin>>S;
    int y=d(S[0])*1000+d(S[1])*100+d(S[2])*10+d(S[3]);
    int m=d(S[5])*10+d(S[6]);
    int day=d(S[8])*10+d(S[9]);
    if(y*10000+m*100+day<=20190430){
        cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }
}


Measured memory_bytes: 3536
k = int(input())
if k % 2 == 0:
	print(-1)
elif k % 5 == 0:
	print(-1)
elif k%7 == 0:
	l = 9*k//7
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l 
else:
	l = 9 * k
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l 

Measured memory_bytes: 9184
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    b <- readLn
    c <- readLn
    p <- readLn
    -- 出力
    putStrLn $ show $ length [1 | x <- [0..a], y <- [0..b], z <- [0..c], 500*x+100*y+50*z == p]


Measured memory_bytes: 1020
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>

using namespace std;


/*
 *
 *
 *   ~~~~Below My Answer~~~~
 *
 *
 **/

int main() {

    while (true) {
        string str;
        getline(cin, str);

        if (str.size() == 1 && str[0] == '.') break;

        int countCircle = 0;
        int countRect = 0;

        bool good = true;
        for (int i = 0; i < str.size(); i++) {
            if (str[i] == '(')countCircle++;
            if (str[i] == ')')countCircle--;
            if (countCircle < 0) good = false;
        }
        for (int i = 0; i < str.size(); i++) {
            if (str[i] == '[')countRect++;
            if (str[i] == ']')countRect--;
            if (countRect < 0)good = false;
        }

        if (countCircle != 0) good = false;
        if (countRect != 0)good = false;

        if (good) {
            stack<int> S;
            for (int i = 0; i < str.size(); i++) {
                if (str[i] == '(') S.push(0);
                if (str[i] == '[') S.push(1);
                if (str[i] == ')') {
                    int top = S.top();
                    S.pop();
                    if (top != 0) good = false;
                }
                if (str[i] == ']') {
                    int top = S.top();
                    S.pop();
                    if (top != 1) good = false;
                }
            }
        }

        if (good) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }

    }

    return 0;
}






















































Measured memory_bytes: 3144
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[0] >= '2'  || s[0] == '1' && s[1] >= '3'  || s[0]=='0' && s[1]=='0') {
        if (s[2] >= '2' || s[2] == '1' && s[3] >= '3' || s[2] == '0' && s[3] == '0') cout << "NA" << endl;
        else cout << "YYMM" << endl;
    }
    else {
        if (s[2] >= '2'  || s[2] == '1' && s[3] >='3'  || s[2] == '0' && s[3] == '0') cout << "MMYY" << endl;
        else cout << "AMBIGUOUS" << endl;
    }
}



    

Measured memory_bytes: 256
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; ++i)
    {
        if(i % d == 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){

	double a, b, x, h, w, sita;

	cin>> a >> b >> x;

	if(a*a*b<=2.0*x){
		h=b-(x/a/a);

		sita=atan2(h, a/2)*180.0/3.14159265359;

		cout<< std::setprecision(8) << sita <<endl;

	}else{
		w=2.0*x/a/b;

		sita=atan2(b, w)*180.0/3.14159265359;

		cout<< std::setprecision(8) << sita <<endl;
	}


}


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



int main(){
    int N;
    int size;
    string W[100];
    string ans;
    string tar_word;
    string bef_word;


    cin >> N;
    cin >> W[0];

    ans = "Yes";

    for(int n = 1 ; n < N ; n++ ){

        cin >> W[n];

        tar_word = W[n];
        bef_word  = W[n - 1];
        size      = bef_word.size() - 1;

        if (bef_word[size] != tar_word[0] ){
            ans = "No";
            cout << ans;
            return 0;
        }
        for(int nn = 0 ; nn < n ; nn++){
            bef_word = W[nn];
            if (bef_word == tar_word ){
                ans = "No";
                cout << ans;
                return 0;
            }
        }
    }



    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
	N4RUTO;
	int t;
	t=1;
	// cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		int a[n];
		loop(i,0,n-1) cin>>a[i];
		sort(a,a+n);
		int ans= 0;
		loop(i,0,k-1) ans+=a[i];
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 3664
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

void solve(){
  while(true){
    int n, p;
    cin >> n >> p;
    int all = p;
    if(n == 0 && p == 0) return;
    vector<int> cnt(n, 0);
    rep(i, 1000000){
      int t = i % n;
      if(p){
        p--;
        cnt[t]++;
        if(p == 0 && cnt[t] == all){
          cout << t << endl;
          break;
        }
      }else{
        p += cnt[t];
        cnt[t] = 0;
      }
    }
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}



Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int c0 = 0, c1 = 0;
		String str = null;
		Scanner scan = new Scanner(System.in);
		str = scan.nextLine();
		
		for(int i = 0;i < str.length();i++){
			String s = str.substring(i, i+1);
			if(s.equals("0"))c0++;
			else c1++;
		}
		
		scan.close();
		if(c0 < c1)System.out.println(c0*2);
		else System.out.println(c1*2);
		
	}
	
}

Measured memory_bytes: 32196
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define pb push_back
const int N = 100005 ;
ll n ;
vector<ll> ans ;

void c () {

    for(ll i=1;;i++) {

        for(ll j = 0 ;j<10;j++) {
            if (abs(j-ans[i]%10)<=1)  {ans.pb(ans[i]*10+j) ;}

        }
      //  cout << ans.size() << endl ;
        if (ans.size()>=N) return ;
    }

}


int main() {
    for(ll i=0;i<10;i++)
        ans.pb(i) ;
    c() ;
    sort(ans.begin(),ans.end()) ;
   // cout << "OK" ;


    cin >> n ;

    cout << ans[n] << endl ;

    return 0 ;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

//const int INF = 1e9 + 1;
//const ll LLINF = 1e17 + 1;
//const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
//const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
//const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	


	ll A, B;
	cin >> A >> B;

	cout << lcm(A, B);






}

//---------------------------------------------------------------
//ユークリッドの互除法
//---------------------------------------------------------------
ll gcd(ll a, ll b) {
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

//---------------------------------------------------------------
// 最小公倍数
//---------------------------------------------------------------
ll lcm(ll a, ll b) {
	ll temp = gcd(a, b);
	return temp * (a / temp)*(b / temp);
}

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

int main() {
 string s,t;
 cin >> s >> t;
 long long a = s.size();
 long long change = 0;
 for(int i = 0; i < a; i++){
   if(s.at(i) != t.at(i)) change++;
 }
  cout << change << endl;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}

int main(){
	//ios::sync_with_stdio(0);cin.tie(0);
	int test,n,d;
	cin>>n;
	cout<<((n/100==n%10)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 764
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int H, W, m;
    cin >> H >> W >> m;
    vi h(m), w(m);
    vi row(H), col(W);
    vvi v(H);
    rep(i, m) {
        cin >> h[i] >> w[i];
        h[i]--;
        w[i]--;
        row[h[i]]++;
        col[w[i]]++;
        v[h[i]].pb(w[i]);
    }
    multiset<int> st;
    rep(i, W) st.insert(col[i]);
    int ans = 0;
    rep(i, H) {
        for (int j : v[i]) {
            int ol = col[j];
            st.erase(st.find(ol));
            st.insert(ol - 1);
        }
        auto it = st.end();
        it--;
        chmax(ans, row[i] + *it);
        for (int j : v[i]) {
            int ol = col[j];
            st.erase(st.find(ol - 1));
            st.insert(ol);
        }
    }
    cout << ans << endl;
}

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

int main(){
    string s;
    bool sma;
    int c_pos;
    
    cin >> s;
    if ( s[0] == 'A' ) {    
        c_pos = -1;
        
        for ( int i = 2; i < s.size()-1; i++ ) {
            if ( s[i] == 'C' ) {
                c_pos = i;
            }
        }
        if ( c_pos == -1 ) {
            cout << "WA\n";
        } else {
            sma = 1;
            for ( int i = 1; i < s.size(); i++ ) {
                if ( i != c_pos && (s[i] < 'a' || s[i] > 'z') ) {
                    sma = 0;
                }
            }
            cout << ( sma ? "AC\n" : "WA\n" );
        }
    } else {
        cout << "WA\n";
    }
    
    return (0);
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int d[n];
  for(int i=0;i<n;i++) cin >>d[i];
  int ans = 0;
  for(int i = 0; i<n-1;i++)
    for(int j=i+1; j < n;j++)
      ans += d[i] * d[j];
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n, price, m, sum;
  string item, ingre, wantMake;
  while(cin >> n, n){
    sum = 0;
    map <string,int> itemPrice;
    while(n--){
      cin >> item >> price;
      itemPrice.insert(map<string,int>::value_type(item,price));
    }
    cin >> m;
    while(m--){
      sum = 0;
      cin >> item >> price;
      while(price--){
	cin >> ingre;
	if(itemPrice.find(ingre)!=itemPrice.end()){
          sum += itemPrice[ingre];
	}
      }
      if(itemPrice[item]>sum){
	itemPrice[item] = sum;
      }
    }
    cin >> wantMake;
    cout << itemPrice[wantMake] <<endl;
  }
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;
    ll mod=998244353;
ll pr( ll x , ll y)
{
    ll ans=1;
    if(y==0) return ans;
    while(y>1)
    {
        if(y&1) ans*=x;
        x*=x;
        y/=2;
        x%=mod;
        ans%=mod;
    }
    ans*=x;
    ans%=mod;
    return ans;
}
ll fact( ll n)
{
    ll ans=1,i;
    rep(i,1,n+1)
    {
        ans*=i;
        ans%=mod;
    }
    return ans;
}
ll in(ll x) { return  pr(x,mod-2);}
bool ok(string s)
{
    int i,n=s.size();
    rep(i,1,n)
    {
        if(s[i]-s[i-1]>1) return false;
    }
    return true;
}
void solve()
{
 ll i,j=1,k,n,m=0,f,s1=0,x,c=1,y=0,a=0,b=0,d;
 cin>>n;
 set < ll > st; m=n-1;
 for(i=1;i*i<=m;i++)
 {
     if(m%i==0) st.insert(i);
     if(i*i!=m and m%i==0) st.insert(m/i);
 }
 for(i=2;i*i<=n;i++)
 {
     if(n%i==0)
     {
         m=n;
         while(m%i==0) m/=i;
         if(m%i==1) st.insert(i);
     }
     if(n%i==0 and n!=i*i)
     {
         m=n;
         while(m%i==0) m/=i;
         if(m%i==1) st.insert(i);
     }
 }
 st.insert(n); st.erase(1);
 cout<<st.size();
 //for(auto it:st) cout<<it<<" ";
 /*
 vector < ll > v;
 rep(k,2,n+1)
 {
     m=n;
     while(m>0)
     {
         if(m%k==0) m/=k;
         else m-=k;
         if(m==1) v.pb(k);
     }
 }
 for(auto it:v) cout<<it<<" "; */

}


 //}

    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        // cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	size_t n = s.length();
	int cnt=0, ans=0;
	for (int i = 0;i < n; i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			cnt += 1;
			if (cnt > ans) {
				ans = cnt;
			}
		}
		else cnt = 0;
	}
	cout << ans << endl;;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << max(A * B, C * D) << endl;

	return 0;
}

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

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

using namespace std;
using lint=long long;

template<class T> T gcd(const T& a,const T& b){ return b==0?a:gcd(b,a%b); }

template<class T>
T xgcd(T a,T b,T& x,T& y){
	if(b==0){ x=1; y=0; return a; }
	T g=xgcd(b,a%b,y,x);
	y-=a/b*x;
	return g;
}

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

	int ans=0;
	rep(_,q){
		lint a,k; scanf("%lld%lld",&a,&k);

		while(a%k!=0){
			lint x=a/k+1,y=k,z=a%k;
			lint g=gcd(x,y);

			if(z%g==0){
				// find (m, n) s.t. m*x + n*y = z
				lint m,n;
				xgcd(x,y,m,n);
				m*=z/g;
				n*=z/g;
				assert(m*x+n*y==z);

				// compute the smallest positive m
				if(m>0){
					lint l=m/(y/g);
					m-=l*(y/g);
					n+=l*(x/g);
				}
				else{ // m<0
					lint l=(-m)/(y/g)+1;
					m+=l*(y/g);
					n-=l*(x/g);
				}
				assert(m>0);

				lint a2=a-m*x;
				if(a2>=0 && a2/k+1==x){
					a=a2;
					assert(a%k==0);
					break;
				}
			}

			lint lo=0,hi=2*k;
			while(hi-lo>1){
				lint mi=(lo+hi)/2;
				lint a2=a-mi*x;
				if(a2>=0 && a2/k+1==x) lo=mi;
				else                   hi=mi;
			}
			a-=hi*x;
		}

		ans^=a/k;
	}
	puts(ans>0?"Takahashi":"Aoki");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long A, long long B, long long C, long long D){
    if(A+B == C+D) {
        cout << "Balanced" << endl;
    }
    if(A+B > C+D) {
        cout << "Left" << endl;
    }
    if(A+B < C+D) {
        cout << "Right" << endl;
    }

}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}



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

#define vd vector<double>
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    int n;
    cin >> n;
    ll result = 0;
    if(n==1){
        result = 0;
    }
    else{
        rep1(i,n-1){
            result += i;
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 1000000007;


int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll x,a;
  std::cin>>x>>a;
  if(x<a){
    std::cout<<0;
  }else{
    std::cout<<10;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        String a = sc.next();
        String b = sc.next();
        int result = 0;
        for (int i = 0; i < a.length(); i++) {
            result += (a.charAt(i) == b.charAt(i)) ? 0 : 1;
        }
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 41088
#include<bits/stdc++.h>
using namespace std;
const int N = 1003;
int n, m, dis[N], par[N];
vector<int> adj[N], ans;
int main(int argc, char const *argv[])
{
	scanf("%d %d\n", &n, &m);
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		scanf("%d %d\n", &u, &v);
		adj[u].push_back(v);
	}
	for (int s = 1; s <= n; ++s)
	{
		queue<int> q;
		memset(dis, -1, sizeof(dis));
		memset(par, -1, sizeof(par));
		q.push(s);
		dis[s] = 0;
		while (!q.empty())
		{
			int u = q.front();
			q.pop();
			for (int v: adj[u])
			{
				if (dis[v] == -1)
				{
					par[v] = u;
					dis[v] = 1 + dis[u];
					q.push(v);
				}
				else if (v == s)
				{
					int cur = u;
					vector<int> temp;
					while (cur != -1)
					{
						temp.push_back(cur);
						cur = par[cur];
					}
					if (temp.size() < ans.size() || ans.empty())
					{
						ans.clear();
						for (int node: temp)
							ans.push_back(node);
					}
				}
			}
		}
	}
	if (ans.empty())
		printf("%d\n", -1);
	else
	{
		printf("%d\n", (int)ans.size());
		for (int node: ans)
			printf("%d\n", node);
	}
	return 0;
}

Measured memory_bytes: 3832
n = int(input())
A = list(map(int,input().split()))

A.sort()
dp = [True for _ in range(A[-1]+1)]

for i in range(n-1):#同じものがいたらその番号をfalseにする
    if A[i] == A[i+1]:
        dp[A[i]] = False

res = 0
for a in A:
    if dp[a]:
        res += 1
    for b in range(a,len(dp),a):#aの倍数を削除する
        dp[b] = False
print(res)

Measured memory_bytes: 32192
n = int(input())
a = [int(i) for i in input().split()]
table = [0 for i in range(10**5+2)]#末尾は番兵
for i in range(len(a)):
    table[a[i]] += 1
    if a[i] > 0:
        table[a[i]-1] += 1
    table[a[i] + 1] += 1
maxCount = 0
for i in range(len(table)-1):
    maxCount = max(maxCount, table[i])
print(maxCount)

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

struct query { int v, d, c; };
int n, m, q, res[100001];
vector<int> g[100001];
vector<query> b;
bool mark[100001][11];
void color(int u, int par, int c, int depth) { // check par
	mark[u][depth] = true;
	if(!res[u]) res[u] = c;
	if(!depth) return;
	for(int v: g[u]) if(v != par && !mark[v][depth-1]) color(v, u, c, depth-1);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	cin >> q;
	for(int i = 0, v, d, c; i < q; i++) {
		cin >> v >> d >> c;
		b.push_back({v, d, c});
	}
	for(int i = q-1; i >= 0; i--) color(b[i].v, -1, b[i].c, b[i].d);
	for(int i = 1; i <= n; i++) cout << res[i] << '\n';
}


Measured memory_bytes: 9584
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int mod=1e5;
int cnt[100010];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; int m; cin >> n >> m;
	int a,b;
	for(int i=0;i<n-1;i++){
		cin >> a;
		cnt[i+1]=cnt[i]+a;
	}
	int sum=0;
	int now=0;
	for(int i=0;i<m;i++){
		cin >> b;
		sum+=abs(cnt[now]-cnt[now+b]);
		sum%=mod;
		now+=b;
	}
	cout << sum << endl;
}


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

int main()
{
    int n, c = 0, ans = 0;
    int *a, *b;

    // 配列のサイズを取得
    cin >> n;

    a = new int[n];
    b = new int[n];

    // Nの数だけ配列を生成
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    while (1)
    {
        //N回繰り返す
        for (int i = 0; i < n; i++)
        {
            if (a[i] % 2 == 0)
            {
                c++; //2で割り切れた数字の個数をインクリメント
            }
            else
            {
            }
        }
        //全て2で割り切れた場合
        if (c == n)
        {
            for (int i = 0; i < n; i++)
            {
                a[i] /= 2;
            }
            c = 0; //cを初期化
            ans++; //操作回数をインクリメント
        }
        //一つでも2で割り切れなかった場合
        else
        {
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256