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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string str;
  getline(cin,str);
  
  for(char &ch: str){
      if('a'<=ch && ch<='z') ch += 'A'-'a';
      else if( 'A'<=ch && ch <='Z') ch -= 'A'-'a';
      cout << ch;
  }
  cout << endl;
 
  return 0;
}


Measured memory_bytes: 3156
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

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



int main()
{
    
    long long n,t=0;
    string s;
    cin >> n >> s;
    for (int a=0; a<n-2 ; a++){
        if (s[a]== 'A'&&s[a+1]=='B'&&s[a+2]=='C'){
            t++;
        }
    }
    cout << t ;
        return 0;
}



Measured memory_bytes: 256
fn main() {
    let (n, k) = {
        let s = {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            s.trim_right().to_owned()
        };
        let mut integers = s.split_whitespace();
        let p: i32 = integers.next().unwrap().parse().unwrap();
        let q: i32 = integers.next().unwrap().parse().unwrap();
        (p, q)
    };
    
    let mut answer = 1;
    let mut x = k;
    while n >= x {
        x*=k;
        answer += 1;
    }

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


Measured memory_bytes: 4352
s = input()
q = int(input())
r = False
top = ""
end = ""

for i in range(q):
    t = input().split()
    if t[0] == "1":
        r = not r
    else:
        if t[1] == "1":
            if r == False:
                top += t[2]
            else:
                end += t[2]
        else:
            if r == True:
                top += t[2]
            else:
                end += t[2]
if r == False:
    print(top[::-1] + s + end)
else:
    print(end[::-1] + s[::-1] + top)

Measured memory_bytes: 4468
#include <iostream>
#include <cstdio>
#include <vector>

int cnt;
std::vector<int> G;

void insertion_sort(int* array, int n, int g)
{
    for(int i = g; i < n; i++)
    {
        int v = array[i];
        int j = i - g;
        while(j >= 0 && array[j] > v)
        {
            array[j+g] = array[j];
            j = j - g;
            cnt++;
        }
        array[j+g] = v;
    }
}

int shell_sort(int* array, int n)
{
    int gi = 1;
    while(gi <= n)
    {
        G.push_back(gi);
        gi = 3 * gi + 1;
    }

    int m = G.size();

    for(int i = m - 1; i >= 0; i--)
        insertion_sort(array, n, G[i]);
    return m;
}

int main()
{
    int n;
    scanf("%d", &n);
    int* array = new int[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &array[i]);

    cnt = 0;

    int m = shell_sort(array, n);
    std::cout << m << std::endl;
    for(int i = m - 1; i >= 0; i--)
    {
        std::cout << G[i];
        if(i != 0)
            std::cout << " ";
        else
            std::cout << std::endl;
    }
    std::cout << cnt << std::endl;
    for(int i = 0; i < n; i++)
    {
        std::cout << array[i] << std::endl;
    }
}


Measured memory_bytes: 7060
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 998244353, mxn = 1e5 + 1;

struct fenwick{
	int n;
	vi dat;
	void init(int x){
		n = x;
		dat.resize(n + 1, 0); 
	}
	void update(int ind, int val){
		ind++;
		while(ind <= n){
			dat[ind] += val;
			dat[ind] %= mod;
			ind += ind & (-ind);
		}
	}
	int sum(int ind){
		int sum = 0;
		ind++;
		while(ind > 0){
			sum += dat[ind];
			sum %= mod;
			ind -= ind & (-ind);
		}
		return sum;
	}
};

int solve(){
	struct fenwick bit;
	bit.init(1e6 + 77);
	int n, k;
	cin>> n>> k;
	vi l(k), r(k);
	rep(i, 0, k)
		cin>> l[i]>> r[i];
	vi dp(n + 1, 0);
	dp[1] = 1;
	bit.update(1, 1);
	rep(i, 2, n + 1){
		rep(j, 0, k){
			if(l[j] >= i)
				continue;
			int a = l[j], b = r[j];
			b = min(i - 1, b);
			a = min(i + 1, a);
			if(a > b)
				continue;
			int add = (bit.sum(i - a) - bit.sum(i - b - 1) + mod) % mod;
			dp[i] += add;
			dp[i] %= mod;
			bit.update(i, add);
		}
	}
	cout<< dp[n]<< "\n";
	return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


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

//Cosmic Market
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		boolean[] r = new boolean[50000], c = new boolean[50000];
		int[] a = new int[50000], b = new int[50000], o = new int[50000];
		for(;;){
			int R = sc.nextInt(), C = sc.nextInt(), Q = sc.nextInt();
			if((R|C|Q)==0)break;
			Arrays.fill(r, false);
			Arrays.fill(c, false);
			long res = 0;
			for(int i=0;i<Q;i++){
				a[i] = sc.nextInt(); b[i] = sc.nextInt(); o[i] = sc.nextInt();
			}
			for(int i=Q-1;i>=0;i--){
				if(o[i]==0){
					if(a[i]==0){
						if(r[b[i]])continue;
						r[b[i]] = true;
						R--;
					}
					else{
						if(c[b[i]])continue;
						c[b[i]] = true;
						C--;
					}
				}
				else{
					if(a[i]==0){
						if(r[b[i]])continue;
						r[b[i]] = true;
						res+=C;
						R--;
					}
					else{
						if(c[b[i]])continue;
						c[b[i]] = true;
						res+=R;
						C--;
					}
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1000000000000000000;
typedef pair<int,int> pii;
typedef pair<int,pii> pr;
ll dp[405][405];
ll minCost(vector<ll> &prefix,int i,int j){
	if(i >= j){
		return 0;
	}
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	ll ans = inf;
	for(int k=i;k<j;k++){
		ans = min(ans,prefix[j+1] - prefix[i] + minCost(prefix,i,k) + minCost(prefix,k+1,j));
	}
	return dp[i][j] = ans;
}
int main(int argc,char const* argv[]){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<ll> arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	vector<ll> prefix(n+1,0);
	for(int i=1;i<=n;i++){
		prefix[i] = prefix[i-1] + arr[i-1];
	}
	memset(dp,-1,sizeof(dp));
	cout<<minCost(prefix,0,n-1)<<endl;
	return 0;
}

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

#define INF 1e9+5
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define pushf push_front
#define pushb push_back
#define popf pop_front
#define popb pop_back

ll n, sum;

int main(){
        scanf("%lld", &n);
        for(ll i=1; i<=n; ++i) if(i%3 && i%5) sum+=i;

        printf("%lld", sum);

        return 0;
}

Measured memory_bytes: 3812
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			while (sc.hasNext()) {
				String s = sc.nextLine();
				s = s.replaceAll("apple", "XXXXX");
				s = s.replaceAll("peach", "apple");
				s = s.replaceAll("XXXXX", "peach");
				System.out.println(s);
			}
		}
	}
}

Measured memory_bytes: 26076
#include<stdio.h>
int F[44];
int fibonacci(int n){
  if(n==0 || n==1)return F[n]=1;
  if(F[n]!=-1)return F[n];
  return F[n]=fibonacci(n-2)+fibonacci(n-1);
}
int main(){
  int n,i;
  scanf("%d",&n);
  for(i=0;i<=n;i++)F[i]=-1;
  printf("%d\n",fibonacci(n));
  return 0;
}



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

using namespace std;

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

    vector<int> a(n), num(n,0);
    for (int i = 0; i < n; i++){
            cin >> a.at(i);
            num.at(a.at(i)-1)++;//番号＝数字
    }
    sort(num.begin(), num.end(), greater<int>());

    int temp = k;
    int ans_log = 0;
    for (int i = 0; i < n; i++)
    {
        if (num.at(i) >= 1&&temp>0)
        {
            temp--;
            }
            else if (temp <= 0)
            {
                ans_log += num.at(i);
            }
        }

        cout << ans_log << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n,u,i,j;cin>>n>>u;ll s[n],t[n],c[n];
  vvll r(u,vll(100010,0));
  for(i=0;i<n;i++){
    cin>>s[i]>>t[i]>>c[i];c[i]--;
    r[c[i]][s[i]]++;r[c[i]][t[i]+1]--;
  }
  //caricurate
  vll tv(100010,0);
  for(i=0;i<u;i++){
    for(j=1;j<100011;j++){
      r[i][j]+=r[i][j-1];
      if(r[i][j]){tv[j]++;}
    }
  }        
  //output
  cout<<*max_element(tv.begin(),tv.end())<<endl;
}

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

int main() {
    int n;
    cin >> n;
    for(int i = 1;;i ++) {
        if(i * 1000 >= n) {
            cout << i * 1000 - n << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <unordered_map>

const int MOD = pow(10,9)+7;
typedef long long ll;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



ll solve(vector<ll> csum, ll N, ll sig){
    
    ll cumOper = 0;
    
    ll sign = sig;
    ll count = 0;
    
    
    ll signi;
    
    for(auto i = 0; i < N; i++){
        
        
        if( (csum[i]+cumOper) == 0){
            count++;
            cumOper -= sign;
        }
        
        signi = (csum[i]+cumOper)/abs(csum[i]+cumOper);
        
        if (signi!= sign) {
            sign = signi;
            continue;
        }
        
        ///  csum[i]+cumOperを (-sign)にする。
        
        
        /// sign = 1のとき、csum[i]+cumOper > 0なので、 -1になるまで減らす。
        /// sign = -1のとき、csum[i]+cumOper < 0なので、+1になるまで増やす
        
        if (sign == 1){
            count +=(csum[i] + cumOper + 1);
            cumOper += (-1) * (csum[i] + cumOper + 1);
        }else{
            count +=  (-(csum[i] + cumOper) + 1);
            cumOper += (1) * (-(csum[i] + cumOper) + 1);
        }
        
        sign = -sign;
    }
    
    return count;
}




int main() {

    ll N  = lin();

    vector<ll> vec;
    vector<ll> csum;

    vec.push_back(in());
    csum.push_back(vec.back());
    
    for(auto i = 1; i < N; i++){
        vec.push_back(in());
        
        csum.push_back(csum.back() + vec.back());
        
    }
    
    
    ll tempp;
    ll tempn;


    tempp = solve(csum,N,1);
    
    tempn = solve(csum,N,-1);
    
    ll out = (tempn<tempp)?tempn:tempp;
    
    cout << out << endl;
    
    return 0;
    
    
}







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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, H, W; cin >> N >> H >> W;
        cout << (N - H + 1) * (N - W + 1) << endl;
        return 0;
    }
};

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


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val userCount = readLine()!!.toInt()
    val scoreList = readLine()!!.split(" ").map { if(it.toInt() >= 3200) 8 else it.toInt() / 400 }
    val min = Math.max(scoreList.toSet().count { it < 8 }, 1)
    val max = scoreList.toSet().count{ it < 8} + scoreList.count { it == 8 }

    println("%s %s".format(min, max))
}




Measured memory_bytes: 37876
#include<stdio.h>

#define FREE -1
#define NOTFREE 1
#define QUEEN 12
#define NOQUE 2

int A[8][8];
int tate[8],yoko[8],nanalef[8*2-1],nanarig[8*2-1];

void reset(void);
void print(void);
void recursive(int);

void reset(void)
{
  int i;

  for(i=0;i<8;i++) {
    tate[i] = FREE;
    yoko[i] = FREE;
  }

  for(i=0;i<8*2-1;i++) {
    nanalef[i] = FREE;
    nanarig[i] = FREE;
  }
}

void print(void)
{
  int i,j;
  
  for(i=0;i<8;i++) {
    for(j=0;j<8;j++) {
      if(A[i][j] == QUEEN) {
	if(tate[i] != j)
	  return;
      }
    }
  }
  
  for(i=0;i<8;i++) {
    for(j=0;j<8;j++) {
      if(tate[i] == j) {
	printf("Q");
      }else{
	printf(".");
      }
    }
    printf("\n");
  }
}

void recursive(int a)
{
  int i;
    
  if(a == 8) {
    print();
    return;
  }

  for(i=0;i<8;i++) {
    if(yoko[i] == NOTFREE ||
       nanalef[a+i] ==  NOTFREE ||
       nanarig[a-i+8-1] == NOTFREE)
      continue;
    tate[a] = i;
    yoko[i] = nanalef[a+i] = nanarig[a-i+8-1] = NOTFREE;
    recursive(a+1);
    tate[a] = yoko[i] = nanalef[a+i] = nanarig[a-i+8-1] = FREE;
  }
}
    
  
int main()
{
  int k,r,c,i,j;

  reset();
  
  scanf("%d",&k);

  for(i=0;i<8;i++) {
    for(j=0;j<8;j++) {
      A[i][j] = NOQUE;
    }
  }

  for(i=0;i<k;i++) {
    scanf("%d%d",&r,&c);
    A[r][c] = QUEEN;
  }

  recursive(0);

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
/* snukeくんの解説動画最後10分弱くらい */

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    int a, b;
    cin >> a >> b;
    if(1 <= a && a <= 9 && 1 <= b && b <= 9) {
        cout << a* b << endl;
    } else {
        cout << "-1" << endl;
    }
    

    return 0;
}


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

int main()
{
	string s;
	cin >> s;
	ll sn = s.size();
	ll n = sn+1;
	vector<ll> v (n);
	
	for(ll i =0;i<n-1;i++)
	{
		if(s[i]=='<')v[i+1] = v[i]+1; 
	}
	for(ll i =sn;i>=0;i--)
	{
		if(s[i]=='>')v[i] = max(v[i+1]+1,v[i]);
	}
	ll sum = 0;
	for(ll i = 0;i<n;i++)sum+= v[i];
	//for(int i =0;i<n;i++)cout<<v[i]<<endl;
	cout<<sum<<endl;
	return 0;
}


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

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

int main(){
  while(1){
    int N,i; cin >> N;
    if( N == 0 ) break;
    int x[201],y[201];
   
    int xMax = 0,xMin = 0,yMax = 0,yMin = 0;
    x[0] = 0,y[0] = 0;
    int n,d;
    for( i = 1; i < N; i++ ){
      cin >> n >> d;
     
	x[i] = x[n] + dx[d];
	y[i] = y[n] + dy[d];

      
      xMax = max( x[i],xMax );
      yMax = max( y[i],yMax );
      xMin = min( x[i],xMin );
      yMin = min( y[i],yMin );
  }

    cout << xMax - xMin + 1 << " " << yMax - yMin + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if (a == 2 || b == 2) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 35604
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int c=0;
		string i = Console.ReadLine();
		string output="AC";
        if(i.Substring(0, 1)!="A")output="WA";
        else{
            int nagasa=i.Length;
            string a=i.Substring(2,nagasa-3);
            if(CountChar(a, 'C')!=1)output="WA";
            else{
                
                char po='a';
                //Console.WriteLine(po);
                for(int f=0;f<26;f++){
                    //Console.WriteLine(po);
                    c+=CountChar(i, po);
                    po++;
                }
                if(c!=nagasa-2)output="WA";
            }
        }
        
		//出力
		Console.WriteLine(output);
	}
	public static int CountChar(string s, char c) 
  {
    return s.Length - s.Replace(c.ToString(), "").Length;
  }
}

Measured memory_bytes: 13140
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


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

  vector<long> b(n);
  cin >> b;

  vector<long> ans(n);

  vector<long> num(101, 0);

  for (int i = 0; i < n; ++i) {
    num[b[i]]++;
  }

  bool an = true;


  for (int i = 0; i < n; ++i){
    bool iserase = false;
    int num = 0;
    for (int j = 0; j < b.size(); ++j){
      if (b[j] == j+1){
        iserase = true;
        num = j;
      }
    }

    if (iserase){
      ans.push_back(num + 1);
      b.erase(b.begin() + num);
    }else{
      an = false;
    }
  }

  reverse(ans.begin(),ans.end());


  if (an) {
    for (int i = 0; i < n; ++i) {
      cout << ans[i] << endl;
    }
  } else {
    cout << -1 << endl;
  }


}




















Measured memory_bytes: 256
gets.to_i
S = gets.chomp.chars
T = gets.chomp.chars
MOD = 10 ** 9 + 7

ans = 3
v = S[0] == T[0] ? false : true
until S.empty? do
  if S[0] == T[0] then
    if v then
      ans *= 2
    end
    S.shift; T.shift
    v = true
  else
    if v then
      ans *= 2
    else
      ans *= 3
    end
    S.shift; S.shift; T.shift; T.shift
    v = false
  end
  ans %= MOD
end

puts ans


Measured memory_bytes: 1788
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7')
        cout<<"Yes";
    else cout<<"No";
	return 0;
}

Measured memory_bytes: 3608
import sys

#fin = open("test.txt", "r")
fin = sys.stdin

sentence = fin.read()
sentence = sentence.lower()

num_alphabet_list = [0 for i in range(26)]

for c in sentence:
	if ord(c) < ord('a') or ord(c) > ord('z'):
		continue

	num_alphabet_list[ord(c) - ord('a')] += 1

for i in range(0, 26):
	print(chr(i + ord('a')), end="")
	print(" : ", end="")
	print(num_alphabet_list[i])

Measured memory_bytes: 7456
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define N 5010
using namespace std;

ll l,last,ans,a,b,n;

int main()
{
	ll i,j,p,q;
	cin>>n;
	cin>>a>>b;
	for(i=2;i<=n;i++)
	{
		scanf("%lld%lld",&p,&q);
		a=(a/p+(a%p!=0))*p;
		if(b<=a/p*q) b=a/p*q;
		else
		{
			b=(b/q+(b%q!=0))*q;
			a=b/q*p;
		}
	}
	cout<<a+b;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long int64;
static const int MAXN = 1e5 + 3;

int n, a, b;
int h[MAXN];

inline bool check(int att)
{
    int64 acc = 0;
    for (int i = 0; i < n; ++i)
        if (h[i] > (int64)att * b) acc += (h[i] - att * b + a - 1) / a;
    return (acc <= att);
}

int main()
{
    scanf("%d%d%d", &n, &a, &b);
    a -= b;
    for (int i = 0; i < n; ++i) scanf("%d", &h[i]);

    int lo = -1, hi = 1e9 + 2, mid;
    while (lo < hi - 1) {
        mid = (lo + hi) >> 1;
        if (check(mid)) hi = mid; else lo = mid;
    }
    printf("%d\n", hi);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t A, B, K;
    cin >> A >> B >> K;
    if (A < K) {
        cout << 0 << " " << max(B - (K - A), int64_t(0)) << endl;
    }
    else {
        cout << A - K << " " << B << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,r;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&r);
	if(0<=(c-r) && (c+r)<=a && 0 <=(d-r) && (d+r)<=b) 
	{
		printf("Yes\n");
	}
	else 
	{
		printf("No\n");
	}
}


Measured memory_bytes: 2112
import sys
from collections import defaultdict

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    c = defaultdict(int)
    for i in range(n):
        c["".join(sorted(S()))] += 1
    ans = 0
    for k, v in c.items():
        ans += int(v * (v - 1) /2)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 18188
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((LL)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin, (X).rend()
// #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define readV(X) for(int &ele : (X)) cin >> ele
#define readVI(X) for(int idx = 1; idx < SZ((X)); ++idx) cin >> (X)[idx]
#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a, b) ((b) - (a))
#define length(a) (hypot((a).imag(), (a).real()))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) * (b)).imag())
#define lengthSqr(p) dot(p, p)
#define rotateO(p, ang) ((p) * exp(point(0, ang)))
#define rotateA(p, ang, about) (rotateO(vec(about, p), ang) + about)
#define reflectO(v, m) (conj((v) / (m)) * (m))
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define X real()
#define Y imag()
 
using namespace std;
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
// void err(istream_iterator<string> it) {}
// template<typename T, typename... Args>
// void err(istream_iterator<string> it, T a, Args... args) {
//     cerr << *it << " = " << a << endl;
//     err(++it, args...);
// }
// template<typename... Args>
// void read(Args&... args)
// {
//     ((cin >> args), ...);
// }
 
// template<typename... Args>
// void write(Args... args)
// {
//     ((cout << args), ...);
// }
typedef long long LL;
typedef complex<double> point;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);


int main(){
    FAST_IO
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    int x, y, z; cin >> x >> y >> z;
    cout << (int) (x - z) / (y + z) << "\n";

}  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long N, X;
    cin >> N >> X;

    long long ans = N;

    long long res = X<N-X ? X : N-X ;
    N-=res;
    while (res!=0){
        ans+=res*(N/res)*2;
        long long tmp = N%res;
        N=res;
        res=tmp;
    }
    ans-=N;
    cout << ans << '\n';
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    a1, b1 = map(int, input().split())
    a.append([a1, b1])
for _ in range(m):
    c, d = map(int, input().split())
    b.append([c, d])
for a_ in a:
    e = []
    for b_ in b:
        ans = abs(a_[0] - b_[0]) + abs(a_[1] - b_[1])
        e.append(ans)
    print(e.index(min(e))+1)

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

N, M, Q = map(int, input().split())
cum = [[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
    l, r = map(int, input().split())
    cum[l][r] += 1
for i in range(1, N+1):
    for j in range(i+1, N+1):
        cum[i][j] = cum[i][j] + cum[i][j-1]
ans = []
for _ in range(Q):
    p, q = map(int, input().split())
    tot = 0
    for i in range(p, q+1):
        tot += cum[i][q]
    ans.append(tot)
print(*ans, sep="\n")


Measured memory_bytes: 82776
#include<cstdio>

long long S,x1,x2,x3,y1,y2,y3;

int main(){
	scanf("%lld",&S);
	if (S<=1e9){
		x1=0,y1=0;
		x2=S,y2=0;
		x3=0,y3=1;
		printf("%lld %lld %lld %lld %lld %lld",x1,y1,x2,y2,x3,y3);
		return 0;
	}
	x1=0,y1=0;	//S=x3y2-y3x2;
	x3=1e9;
	y2=S/x3+(S%x3?1:0);
	y3=1;
	x2=x3*y2-S;
	printf("%lld %lld %lld %lld %lld %lld",x1,y1,x2,y2,x3,y3);
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  if(a >= k) {
    a -= k;
    cout << a << ' ' << b << endl;
    return 0;
  }else {
    k -= a;
    a = 0;
  }
  if(b >= k) {
    b -= k;
    cout << a << ' ' << b << endl;
    return 0;
  }else {
    a = 0;
    b = 0;
  }
  cout << a << ' ' << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    ld a,b,x;cin >>a>>b>>x;
    ld ans;
    ld pi=3.14159265358979323;
    if(2*x>a*a*b){
        ld k=(2*a*a*b-2*x)/(a*a*a);
        ans=atan(k);
    }
    else {
        ans=atan(a*b*b/(2*x));
    }
    cout <<setprecision(15)<<ans*180/pi<<endl;
}


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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans = w * h / 2.0;
    bool mul = false;
    if (w / 2.0 == x && h / 2.0 == y) mul = true;

    printf("%f %d\n", ans, mul);
    return 0;
}


Measured memory_bytes: 256
n, p = map(int, input().split())
if n == 1:
  print(p)
  exit()
ans = 1
for i in range(2, 1+int(p**(1/n))):
  count = 0
  while True:
    if p % i ==0:
      count += 1
      p = p / i
    else:
      ans*= i**(count//n)
      break
print(ans)

Measured memory_bytes: 3060
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 1e5 + 10;
string s;
int n;

void solve() {
	cin >> n;
	ll ans = 0LL;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			for (int k = 1; k <= n; ++k) {
				ans += __gcd(__gcd(i, j), k);
			}
		}
	}
	cout << ans;
}
int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

Measured memory_bytes: 3640
#include<iostream>
int main(){
  int a, b, c;
  std::cin >> a >> b >> c;
  int cnt=0;
  for(int i=0;i < (b/a); i++){
    if(cnt == c){
      break;
    }else{
      cnt++;
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}


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

char a, b;

int main(void){
    
    scanf("%c %c", &a, &b);
    
    if(a == 'H') printf("%c\n", (b == 'H') ? 'H' : 'D');
    else printf("%c\n", (b == 'H') ? 'D' : 'H');
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;

const int N = 1e5 + 10; 

int n, k, zcnt;
long long a[N];
long long ans = 2147483640;

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; ++i){
		scanf("%lld", &a[i]);
		if(a[i] == 0){
			i--;
			n--;
			k--;
		}
		if(a[i] > 0 && a[i - 1] < 0)
			zcnt = i - 1; 
	}
	if(a[n] < 0)
		zcnt = n;
	if(a[1] > 0)
		zcnt = 0;
	if(k == 0){
		printf("0");
		return 0;
	}
	for(int i = max(zcnt - k + 1, 1); i + k - 1 <= min(zcnt + k, n); ++i){

		if(i == zcnt - k + 1)
			ans = min(ans, abs(a[i]));
		else if(i == zcnt + 1)
			ans = min(ans, abs(a[i + k - 1]));
		else if(abs(a[i]) > abs(a[i + k - 1])){
			ans = min(ans, abs(a[i]) + 2 * abs(a[i + k - 1]));
		}
		else if(abs(a[i]) <= abs(a[i + k - 1])){
			ans = min(ans, 2 * abs(a[i]) + abs(a[i + k - 1]));
		}
	}
	printf("%lld", ans);
	
    return 0;
}

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

int main()
{
	int n,T,a,h;
	float t1,t2;
	scanf("%d",&n);
	scanf("%d %d",&T,&a);
	int i,same;
	for( i = 0; i < n; i ++ ){
		scanf("%d",&h);
		t2 = T - h * 0.006;
		if( i == 0 ){
			t1 = T - h * 0.006;
		}
		if(fabs(t2-a) <= fabs(t1-a)){
			t1 = t2;
			same = i;
		}
	}
	printf("%d",same+1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

const int MAX = 25;

struct node{
    int id = -1;
    int parent = -1;
    int degree = 0;
    int left = -1;
    int right = -1;
    int sibling = -1;
};

node nodes[MAX];

string label(node no) {
    if (no.parent == -1) return "root";
    else if (no.degree < 1) return "leaf";
    else return "internal node";
}

int getHeight(node no, int height) {
    if (no.left < 0 && no.right < 0) {
        return height;
    }
    int leftH = no.left < 0 ? height : getHeight(nodes[no.left], height + 1);
    int rightH = no.right < 0 ? height : getHeight(nodes[no.right], height + 1);
    return max(leftH, rightH);
}

int getDepth(node no, int depth) {
    if (no.parent == -1) {
        return depth;
    }
    
    return getDepth(nodes[no.parent], depth + 1);
}

int getDegree(int left, int right) {
    if (left == -1 && right == -1) {
        return 0;
    }
    if (left != -1 && right != -1) {
        return 2;
    }
    return 1;
}

int main() {
    int N;

    scanf("%d", &N);
    
    for (int i = 0; i < N; i++) {
        int id, left, right;
        scanf("%d", &id);
        scanf("%d", &left);
        scanf("%d", &right);
        nodes[id].id = id;
        nodes[id].left = left;
        nodes[id].right = right;
        nodes[id].degree = getDegree(left, right);
        
        if (left != -1) {
            nodes[left].parent = id;
            nodes[left].id = left;
            nodes[left].sibling = right;   
        }
        
        if (right != -1) {
            nodes[right].parent = id;
            nodes[right].id = right;
            nodes[right].sibling = left;   
        }
    }
    
    for (int i = 0; i < N; i++) {
        string l = label(nodes[i]);

        int dep = getDepth(nodes[i], 0);
        int height = getHeight(nodes[i], 0);

        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s",
            nodes[i].id,
            nodes[i].parent,
            nodes[i].sibling,
            nodes[i].degree,
            dep,
            height,
            l.c_str()
        );
        
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3328
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        cout<<(n*(n-1)/2+m*(m-1)/2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int keta(long long n) {
  if (n < 10) return 1;
  return keta(n / 10) + 1;
}

int main() {
  long long N;
  int ans = 11;
  cin >> N;

  for (long long i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      int k = keta(N / i);
      if (k < ans) ans = k;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e6+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n,k;
    cin>>n>>k;
    n++;
    ll ans=0;
    ll mod=(ll)1e9+7;
    while(k<=n)
    {
        ans+=(n-k)*k%mod+1;
        ans%=mod;
        k++;
    }
    cout<<ans;
}


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

using namespace std;

struct UnionFind {
  UnionFind(int32_t n)
      : parent(vector<int32_t>(n, 0)), size(vector<int32_t>(n, 0)) {
    for (int i = 0; i < n; i++) {
      parent[i] = i;
      size[i] = 1;
    }
  }

  int32_t Root(int32_t a) {
    if (parent[a] == a) {
      return a;
    } else {
      return parent[a] = Root(parent[a]);
    }
  }

  bool IsSame(int32_t a, int32_t b) { return Root(a) == Root(b); }

  void Unite(int32_t a, int32_t b) {
    a = Root(a);
    b = Root(b);

    if (a == b) return;

    if (size[a] > size[b]) {
      parent[b] = a;
      size[a] += size[b];
      size[b] = 0;
    } else {
      parent[a] = b;
      size[b] += size[a];
      size[a] = 0;
    }
  }

  int32_t Size(int a) { return size[Root(a)]; }

  vector<int32_t> parent;
  vector<int32_t> size;
};  // struct UnionFind

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    P[i]--;
  }

  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    uf.Unite(x, y);
  }

  int result = 0;
  for (int i = 0; i < N; i++) {
    if (uf.IsSame(P[i], i)) {
      result++;
    }
  }

  printf("%d\n", result);

  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
 
int calc(int x,int y){
    if(y == 0){
        return x;
    }else{
        return calc(y,x%y);
    }
}
 
int main(){
    int x,y;
    scanf("%d %d",&x,&y);
    if(x >= y)
        printf("%d\n",calc(x,y));
    else{
        printf("%d\n",calc(y,x));
    }
}


Measured memory_bytes: 2764
#include <iostream>

using namespace std;

long long int N, ans[87] = {};

int main() {
	cin >> N;
	ans[0] = 2;
	ans[1] = 1;
	for (int i = 2; i <= N; i++)ans[i] = ans[i - 1] + ans[i - 2];
	cout << ans[N] << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
index = [0]*(N+1)
ans = -2
for k in range(10000):
    today = set()
    flag = 0
    for j in range(N):
        if j+1 in today:
            continue
        if index[j+1] >= N-1:
            continue
        #print(j, index[j+1])
        opponent = A[j][index[j+1]]
        if A[opponent-1][index[opponent]] == j+1:
            if opponent not in today:
                index[opponent] += 1
                index[j+1] += 1
                today.add(opponent)
                today.add(j+1)
                flag = 1
    if flag == 0:
        if sum(index) == N*(N-1):
            ans = k
            break
        else:
            ans = -1
            break
    #print(index)

if ans == -2:
    print(N*(N-1)//2)
else:
    print(ans)


Measured memory_bytes: 53852
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{w:f64,h:f64,x:f64,y:f64};

    print!("{} ", (w*h)/2.0);

    if w/2.0 == x && h/2.0 == y {
        println!("1");
    } else {
        println!("0");
    }

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long

using namespace std;


int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int a,b,s=0;
    cin>>a>>b;
    vector<int>vec(b);
    map<int,int>ma;
    for(int &x:vec) {
        cin >> x;
        ma[x]++;
    }
    string x=to_string(a);
    while(true){
        bool p=true;
        for(int i=0;i<x.length();i++){
            if(ma.find(x[i]-'0')!=ma.end()){
                p=false;
                a++;
                x=to_string(a);
                break;
            }
        }
        if(p){
            cout<<a;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int counter[26] = {};
    char ch;
    while(cin >> ch){
        int num;
        if(isupper(ch)){
            num = ch -'A';
        }
        else{
            num = ch - 'a';
        }
        // if((num < 0) || (num > 26)) break;
        counter[num]++;
    }

    ch = 'a';
    for(int i = 0; i < 26; i++){
        cout << ch << " : " << counter[i] <<endl;
        ch++;
    }

    return 0;
    
}


Measured memory_bytes: 3072
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110000;
int N, K;
string S;
int value[Max];
vector<pair<char, int>> chunks;

int happiness(string& s) {
    int happ = 0;
    repd(i, 1, s.length()-1) {
        if (s[i] == 'L' && s[i-1] == 'L') {
            happ++;
        } else if (s[i] == 'R' && s[i+1] == 'R') {
            happ++;
        }
    }
    return happ;
}

void to_chunks() {
    chunks.reserve(Max);
    char last = S[0];
    int cnt = 1;
    repd(i, 1, S.length()) {
        if (S[i] != last) {
            chunks.push_back(make_pair(last, cnt));
            last = S[i];
            cnt = 1;
        } else {
            cnt++;
        }
    }
    chunks.push_back(make_pair(last, cnt));
}

int main(int argc, const char * argv[]) {
    cin >> N >> K >> S;
    to_chunks();
    int chunknum = chunks.size();
    // for(auto& chunk : chunks) {
    //     printf("%c,%d\n", chunk.first, chunk.second);
    // }

    S = 'x' + S + 'x';
    int score = happiness(S);
    // printf("%d, %d\n", chunknum, score);
    if (chunknum % 2 == 0) {
        if (chunknum / 2 > K) {
            score += 2 * K;
        } else {
            score += (chunknum / 2 - 1) * 2 + 1;
        }
    } else {
        score += min(chunknum / 2, K) * 2;
    }

    output(score);

    return 0;
}

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

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

  int w, h, n;
  cin >> w >> h >> n;
  int rx = w, lx = 0, ry = h, ly = 0;

  rep(i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    switch(a) {
      case 1:
        lx = max(lx, x);
        break;
      case 2:
        rx = min(rx, x);
        break;
      case 3:
        ly = max(ly, y);
        break;
      case 4:
        ry = min(ry, y);
        break;
    }
  }
  cout << max(0, rx-lx) * max(0, ry-ly) << endl;
}

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

int main(){
    string s,t;
    int ctr = 0;
    cin >> s>>t;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]){
            ctr++;
        }
       
    }
     cout << ctr <<endl;
}


Measured memory_bytes: 256