akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int d[15][15];
int weight[15][105];
int xy[105][105];
void wa()
{
    puts("Impossible");
}
int check_ans[15];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int a,b;
    scanf("%d%d",&a,&b);
    int i,j;
    for (i=1;i<=a;i++)
    {
        for (j=1;j<=b;j++)
        {
            scanf("%d",&d[i][j]);
        }
    }
    int x,y;
    int sum=10401;
    for (x=0;x<=100;x++)
    {
        for (y=0;y<=100;y++)
        {
            xy[x][y]=-1;
            for (i=1;i<=a;i++)
            {
                for (j=1;j<=b;j++)
                {
                    xy[x][y]=max(xy[x][y],d[i][j]-i*x-j*y);
                }
            }
            if (xy[x][y]<0) sum--;
        }
    }
    for (i=1;i<=a;i++)
    {
        for (j=1;j<=b;j++)
        {
            int ans=105;
            for (x=0;x<=100;x++)
            {
                for (y=0;y<=100;y++)
                {
                    if (xy[x][y]<0) continue;
                    ans=min(ans,xy[x][y]+i*x+j*y);
                }
            }
            if (ans!=d[i][j])
            {
                wa();
                return 0;
            }
        }
    }
    puts("Possible");
    printf("202 %d\n",sum);
    for (i=1;i<=100;i++)
    {
        printf("%d %d X\n",i,i+1);
    }
    for (i=102;i<=201;i++)
    {
        printf("%d %d Y\n",i,i+1);
    }
    for (i=0;i<=100;i++)
    {
        for (j=0;j<=100;j++)
        {
            if (xy[i][j]<0) continue;
            printf("%d %d %d\n",i+1,202-j,xy[i][j]);
        }
    }
    printf("1 202\n");
    return 0;
} 


Measured memory_bytes: 384
# -*- coding: utf-8 -*-

def main():

    n = int(input())
    p = list(map(int, input().split()))

    ans = 0

    for i in range(n-2):
        if p[i] < p[i+1] <= p[i+2]:
            ans += 1

        elif p[i+2] < p[i+1] <= p[i]:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9012
/* 
        *** LONGEST COMMON PREFIX ***
*/

#pragma GCC optimize ("O3")

#pragma GCC optimize("Ofast")

/* 
   *********************************************************
    Code_Blooded Human == @{{ samrat_12   [  0_0  ^_^  ] }}
   *********************************************************
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
#define E "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  ipfile    ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define ll long long int
#define ull unsigned long long int
#define db long double
#define mod 1000000007
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define REVVEC(v) reverse(v.begin(),v.end())
#define REVARR(a) reverse(a,a+n)
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define outputarr(a,n) for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define rep(i,m, n)    for(int i = m; i < (n); ++i)
#define sp setprecison(10)
#define cint(x) scanf("%ld",&x)
#define cstr(s) scanf("%s",s)
#define sz(s) (s.length())
#define vz(v) v.size()

void TestCase1()
{
    
    int n,cnt=1,a=0,b=0,flag1,flag2;
    cin>>n;
    vector<int>v1(n),v2(n),v(n);
    rep(i,0,n)
        cin>>v1[i];
    rep(i,0,n)
        cin>>v2[i];
    rep(i,0,n)
        v[i]=i+1;
    
    do{
        flag1=0,flag2=0;
        
        rep(i,0,n)
        if(v[i]!=v1[i]){
        flag1=1;
        break;}
        
        rep(i,0,n)
        if(v[i]!=v2[i]){
        flag2=1;
        break;}
        
        if(flag1==0)
        {
            a=cnt;
        }
        
        if(flag2==0)
        {
            b=cnt;
        }
        
        cnt++;
    }while(next_permutation(all(v)));
    
    cout<<abs(a-b)<<endl;
    
}

void TestCase2()
{
    
    
    
}

signed main()
{
    FAST
    
    //TestCase2();
    
    TestCase1();
    
    return 0;
}

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

const int N = 100;
bool u[N + 2];

int main() 
{
	int x, n;
	scanf("%d%d", &x, &n);
	int v;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &v);
		u[v] = true;
	}
	bool pos = false;
	for (int d = 0;; ++d) {
		x = x + (pos * (-2) + 1) * d;
		if (!u[x]) {
			printf("%d\n", x);
			return 0;
		}
		pos = !pos;
	}
	return 0;
}


Measured memory_bytes: 1736
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();
    let S = read_String_Vec();
    let mut cnt = vec![0; 26];
    for i in 0..S.len() {
        cnt[S[i] as usize - 97] += 1;
    }

    let mut odd = false;
    for i in 0..26 {
        if cnt[i]%2 == 1 {
            odd = true;
        }
    }
    if odd {
        println!("No");
    } else {
        println!("Yes");
    }

}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int ans = h[0];
        for (int i = 1; i < n; i++) {
            ans += Math.max(h[i] - h[i - 1], 0);
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 22612
#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 ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int n;



void solve()
{
	long double a, b, n;
	cin >> a >> b >> n;

	n = min(b-1,n);

	int rt = 0, rt2 = 0;

	rt = floor(a*n*(1.0)/b);

	cout << rt-rt2;
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(2);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <class T> vector<T> arrange(const vector<T> &A, const vector<int>& B)
{
    vector<T> ans(A.size());
    for (int i = 0; i < A.size(); i++) ans[i] = A[B[i]];
    return ans;
}
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<Int> X(N); for (auto &x : X) cin >> x;
    vector<Int> D(N-1); for (int i = 0; i < N-1; i++) D[i] = X[i+1] - X[i];
    Int M, K; cin >> M >> K;
    vector<int> A(M); for (auto &a : A) cin >> a;
    vector<int> init(N-1); iota(begin(init), end(init), 0);
    vector<vector<int>> B(60, init);
    for (int j : A) swap(B[0][j-2], B[0][j-1]);
    for (int i = 1; i < B.size(); i++) B[i] = arrange(B[i-1], B[i-1]);
    for (int i = 0; i < B.size(); i++) if (K & (1LL << i)) D = arrange(D, B[i]);
    for (int i = 1; i < N; i++) X[i] = X[i-1] + D[i-1];
    for (auto x : X) cout << x << '\n';
    return 0;
}


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

double length(vector<pair<double, double>> x){
  double l = 0;
  rep(i, x.size()-1){
    int dx = x.at(i+1).first - x.at(i).first;
    int dy = x.at(i+1).second - x.at(i).second;
    l += sqrt(dx*dx+dy*dy);
  }
  return l;
}

int main(){
  int n;
  cin >> n;
  vector<pair<double, double>> x(n);
  
  rep(i,n){
  cin >> x.at(i).first >> x.at(i).second;
  }
  
  double sum = 0.00000;
  double p = 0.00000;
  sort(x.begin(), x.end());
  
  do {
    sum += length(x); 
    p++ ;
    
  } while( next_permutation(x.begin(), x.end()) );
  
  double ans = sum/p;
  printf("%.10f\n", ans);
  
  return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
m=[[0]*(w+2) for _ in range(h+2)]
#print(m)
x=y=1
for i in range(n):
  cnt=a[i]
  #print(i+1)
  while cnt>0:
    #print(x,y)
    m[x][y]=i+1
    cnt-=1
    if y+1<=w and m[x][y+1]==0:
        y+=1
    elif y-1>0 and  m[x][y-1]==0:
        y-=1
    else:
      x+=1
  #print(m,end=" after cnti\n")
for i in range(h):
  for j in range(w):
    print(m[i+1][j+1],end=' ') if j!=w-1 else print(m[i+1][j+1])
  #print('\n')
      


Measured memory_bytes: 3920
#include<stdio.h>
int main(){
	int i,j,H,W,a[100][100],b[100];
	long long int t;
	scanf("%d %d",&H,&W);
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<W;i++)scanf("%d",&b[i]);
	for(i=0;i<H;i++){
		t=0;
		for(j=0;j<W;j++)t+=a[i][j]*b[j];
		printf("%d\n",t);
	}
	return 0;
}
	

Measured memory_bytes: 636
#include <iostream>
using namespace std;
int main(void){
    int num[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k=0;
    cin >> k;
    cout << num[k-1];
    
    return 0;
    
}


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

int main() {
	long long a; cin >> a;
	string s; cin >> s;
	int b = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
	cout << a * b / 100 << endl;
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>

using namespace std;

#define N 100000

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

	int a, b, c;
	a = y / 1000;
	int f = 0;
	for (int i = 0; i <= y / 5000; i++) {
		if ((a - 4 * i - n) % 9 == 0) {
			b = i;
			c = (a - 4 * i - n) / 9;
			if (c < 0 || n - b - c < 0) continue;
			a = n - b - c;
			f = 1;
			break;
		}
	}

	if (f == 1) {
		cout << c << " " << b << " " << a << endl;
	} else {
		cout << -1 << " " << -1 << " " << -1 << endl;
	}


	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF 10000000000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())
long long fact[20015], invfact[20015];
long long mod = 1e9 + 7;
//5^9 = (5^4)^2 * 5
long long bigmod(long long a, long long p){
    if(p == 0){
        return 1;
    }
    long long ans = bigmod(a, p/2);
    ans = (ans * ans) % mod;
    if(p % 2 == 1){
        ans = (ans * a) % mod;
    }
    return ans;
}
//a^(p - 1) = 1 mod p [fermat's little theorem] so, a^(-1) = a^(p - 2) mod p
long long inverse(long long a){
    return bigmod(a, mod - 2);
}
void precalc(){
    fact[0] = 1;
    invfact[0] = inverse(fact[0]);
    for(long long i = 1; i <= 20005; i++){
        fact[i] = (fact[i - 1] * i) % mod;
        invfact[i] = inverse(fact[i]);
    }
}
//nCr = (fact[n]/(fact[r] * fact[n - r])) mod p = (fact[n] * invfact[r] * invfact[n - r]) mod p
long long nCr(long long n, long long m){
    long long ans = (fact[n] * invfact[m]) % mod;
    return (ans * invfact[n - m]) % mod;
}
int main(){
	ll m,n;
    cin>>n;
    m = bigmod(10,n) - 2*bigmod(9,n) + bigmod(8,n);
    m = (m+3*mod)%mod;
    cout<<m<<endl;
   
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
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;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N;
  cin >> N;

  string ans = "No";
  for (int i = 0; i <= 25; i++)
  {
    for (int j = 0; j <= 14; j++)
    {
      if (4 * i + 7 * j == N)
      {
        ans = "Yes";
        break;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    ll k;
    cin>>k;
    if(s[0]!='1')
    {
    	cout<<s[0];
    	return 0;
    }
    ll p=0;
    while(p<k)
    {
    	if(s[p]=='1')
    		p++;
    	else
    	{
    		cout<<s[p];
    		return 0;
    	}
    }
    cout<<1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
    #define M_PI 3.14159265358979323846
    int main()
    {
     // clock_t begin = clock();
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
     // #endif
   tani_nachi_ke  
    
    int n,k;
    cin>>n>>k;
    int arr[n+10]={0};
    for(int i=1; i<=n; i++)cin>>arr[i];
    int dp[n+1];
    for(int i=0 ;i<=n; i++)dp[i]=INT_MAX;
    dp[1]=0,dp[2]=abs(arr[2]-arr[1]);
    for(int i=3; i<=n; i++)
    {
      for(int j=i-1; j>=max(1,i-k); j--)
      {
        dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
      }
    }
    cout<<dp[n]<<endl;
    
  
    // #ifndef ONLINE_JUDGE 
    // clock_t end = clock();
    // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
    // #endif 
    // return 0;
}






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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;

ll sum(int i) {
	ll x = i * ((ll)i + 1) / 2;
	return x % MOD;
}

int main() {
	int n,k;
	cin >> n >> k;
	
	ll ans = 0;

	for (int i = k;i <= n + 1;i++) {
		ans+= sum(n)+ 1;
		ans += (MOD - sum(n - i));
		ans %= MOD;
		ans += (MOD - sum(i - 1));
		ans %= MOD;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
  int i,yen,count;
  int ks[]={500,100,50,10,5,1};

  do{
    scanf("%d",&yen);
    if(!yen) break;
    yen=1000-yen;
    for(i=0,count=0;i<6;i++){
      count+=yen/ks[i];
      yen=yen%ks[i];
    }
    printf("%d\n",count);
  }while(1);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
long long int gcd(int a,int b)
{
    if(b==0)
    {

        return a;
    }
    return gcd(b,a%b);
}
int main()
{
   long long a,b;
   cin>>a>>b;
   cout<<a/gcd(a,b)*b;

}


Measured memory_bytes: 256
// <head>
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
// </head>

// <library>
    const int MOD = 998244353;
    struct mint {
      ll x; // typedef long long ll;
      mint(ll x=0):x((x%MOD+MOD)%MOD){}
      mint operator-() const { return mint(-x);}
      mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
      }
      mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
      }
      mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
      }
      mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
      }
      mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
      }
      mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
      }
      mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
      }
      // for prime MOD
      mint inv() const {
        return pow(MOD-2);
      }
      mint& operator/=(const mint a) {
        return (*this) *= a.inv();
      }
      mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
      }
    };
    ostream& operator<< (ostream& os, const mint& value) {
      os << value.x;
      return os;
    }
    
// </library>
const int MX = 200005;
vector<vector<int>> g(MX);
vector<pair<int, int>> ls;
int last = -1;
void dfs_g(int u){
    int to = ls[u].second;
    auto it = lower_bound(ls.begin(), ls.end(),make_pair(to,-INF));
    int idx = distance(ls.begin(),it);
    for(int v=u+1; v < idx; ++v){
        if(last>=v) continue;
        g[u].emplace_back(v);
        last = v;
        dfs_g(v);
        v = last;
    }

}

mint dfs_dp(int u,int p=-1){
    mint res = 1;
    for(int v: g[u]){
        if(v==p) continue;
        res *= dfs_dp(v,u);
    }
    res += 1;
    return res;
}
int main(){
    ll n; cin >> n;
    for (int i = 0; i < n; i++){
        int x,d;
        cin >> x >> d;
        ls.emplace_back(x,x+d);
    }
    sort(ls.begin(),ls.end());

    vector<int> root;
    while(last<n-1){
        last++;
        root.emplace_back(last);
        dfs_g(last);
    }
    mint ans = 1;
    for(int r: root){
        ans*=dfs_dp(r);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 25200
A = int(input())
B = int(input())
C = int(input())
X = int(input())

counter = 0

for ai in range(A + 1):
    for bi in range(B + 1):
        for ci in range(C + 1):
            if X == ai * 500 + bi * 100 + ci * 50:

                counter += 1

print(counter)

Measured memory_bytes: 9168
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n,m = map(int,input().strip().split()) # nは行数 # mは列数
    if n>=2 and m>=2:
        print((n-2)*(m-2))
    elif n==1 and m==1:
        print(1)
    else:
        print(n*m-2)




if __name__ == '__main__':
    main()

Measured memory_bytes: 62188
from sys import stdin
import operator

readline = stdin.readline


n, total_wait = map(int, readline().split())
value_wait = [list(map(int, readline().split())) for _ in range(n)]
value_wait.sort(key=operator.itemgetter(1), reverse=True)

dp = [0] * (total_wait + 1)

for ni, (v, w) in enumerate(value_wait):
    for tw in range(w, total_wait + 1):
        if dp[tw] < dp[tw - w] + v:
            dp[tw] = dp[tw - w] + v
print(dp[-1])

Measured memory_bytes: 7028
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

const int INF=1001001001;

int main() {
  int H,W;
  cin>>H>>W;
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  vector<vector<int>>s(H,vector<int>(W));
  int i=0,j=0;
  for(int d=0;d<N;d++){
    int cnt=a[d];
    while(cnt--){
      s[i][j]=(d+1);
      j++;
      if(j>=W){j=0;i++;}
    }
  }
  for(int i=0;i<H;i++){
    if(i%2!=0){reverse(s[i].begin(),s[i].end());}
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<s[i][j];
      if(j<W-1){cout<<" ";}
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3620
n,k = map(int,input().split())
s = list(map(int,input().split()))
dp = [0]
for i in range(1,n):
        t = []
        for j in range(1,k+1):
                if i - j >=0:
                        t.append(dp[i-j] + abs(s[i]-s[i-j]))
        dp.append(min(t))
print(dp[-1])

Measured memory_bytes: 58208
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main () {
    int n , i = 0;
    cin >> n;
    vector<int> a(n);
    for(;i < n; i++){
        cin >> a[i];
    }
    int t = 0;
    for(i = 0; i < n; i++){
        if(a[t] == 2) {
            break;
        }  
        t = a[t] - 1;
    }
    if(i == n) {
        cout << -1 << endl;
    }
    else {
        cout << i + 1 << endl;
    }
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
#define int long long
#define INF (1<<29)
#define f(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

ll GCD(ll a, ll b) {
	if (b == 0)return a;
	return GCD(b, a%b);
}

ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}

ll mypow(ll a, ll b, ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c;
}

signed main() {
	string s;
	cin >> s;
	vector<char> v;
	f(i, s.size()) {
		if (s[i] == 'B') {
			if (v.size()) v.pop_back();
		}
		else v.push_back(s[i]);
	}
	f(i, v.size()) cout << v[i];
	cout << endl;
	return 0;
}


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

int main(){
	long long N;
	double D,d;
	long long X,Y;

	cin >> N;
	cin >> D;

	long long count =0;
	for(long long i=0;i<N;i++){
		cin >>X >>Y;
		d = sqrt(pow(X,2)+pow(Y,2));
		if(d<=D) count++;
	}

	cout << count;

	return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include <stdio.h>
using namespace std;
 
int main(){
    int a,b,c;
	int d=0;
	cin>>a>>b>>c;
	int f;
	int e;
	int g=0;
	for(e=1;e<a;e++){
		if(c%e==0){
		d++;}}
	for(f=1;f<b+1;f++){
		if(c%f==0){
		g++;}}
	cout<<g-d<<endl;
	return 0;}


Measured memory_bytes: 1160
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
 
typedef vector<int> vec;
typedef long long ll;
typedef unsigned long long ull;


int main(){
    fast_cin();
    int x, y, z;cin>>x>>y>>z;
    swap(x, y);
    swap(x, z);
    cout<<x<<" "<<y<<" "<<z<<endl;
}


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

int main() {
  int N;
  cin >> N;

  for (int i = 0; i * 4 <= N; i++) {
    for (int j = 0; j * 7 <= N; j++) {
      if (i * 4 + j * 7 == N) {
        cout << "Yes" << "\n";
        return 0;
      }
    }
  }

  cout << "No" << "\n";
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  string s; cin >> s;
  // 最初、すべてグーを出したものとする
  int ans = 0;
  int oppo_p_cnt = 0;
  rep(i, s.size()) {
    if (s[i] == 'p') {
      ans--;
      oppo_p_cnt++;
    }
  }
  // パーを貪欲選ぶ
  int max_p = s.size() / 2;
  cout << (ans + max_p) << endl;
}


Measured memory_bytes: 512
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    startt
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    int ans = 0;
    
    for(int i = 0; i < n; i++)
    {
        for(int j = i+1; j < n; j++)
        {
            for(int k = j+1; k < n; k++)
            {
                if(a[i]+a[j] > a[k] && a[i] != a[j])
                {
                    if(a[j] != a[k] && a[i] != a[k])
                    {
                        ans++;
                    }
                }
                else
                {
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int t = N, c = 0;
  
  while (t > 0) {
    c += t % 10;
    t /= 10;
  }
  
  if (N % c == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

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

	int n;
	vector<int> a;
	cin >> n;

	for(int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	
	for(int i = n - 1; i >= 0; i--) {
		cout << a[i];
		if(i == 0) break;
		cout << " ";
	}
	
	cout << "\n";
	return 0;
}

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



void solve(){
  int a, p;
  cin >> a >> p;
  int n = (a*3+p)/2;
  cout << n << endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MD 1000000007
using namespace std;
typedef long long ll;
ll dp[1<<22],cp[30][30];
int n;
ll ds(int id, int s) {
	if(id == n) {return 1;}
	if(dp[s] != -1) {return dp[s];}
	ll re = 0;
	for(int i=0;i<n;i++) {
		if(cp[id][i] && !(s & (1<<i))) {
			re += ds(id+1,s|(1<<i));
		}
	}
	return dp[s] = re%MD;
}
int main() {
	scanf("%d ",&n);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			int t;
			scanf("%d ",&t);
			cp[i][j] = t;
		}
	}
	printf("%lld\n",ds(0,0));
}

Measured memory_bytes: 33024
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 1;
  n -= k;
  ans += (n+k-2) / (k-1);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

bool B[50][50], W[50][50], used[50][50];
char a[50][50];
int w, h;

void dfs(int y, int x, bool flag) {
    if (y < 0 || h <= y || x < 0 || w <= x) return;

    if (a[y][x] == '.') (flag ? B[y][x] : W[y][x]) = true;

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

    rep (i, 4) rep (j, 4) {
        int toy = y + dy[i], tox = x + dx[i];
        if (toy < 0 || h <= toy || tox < 0 || w <= tox) continue;
        if (used[toy][tox] || a[toy][tox] != '.') continue;
        used[toy][tox] = true;
        dfs(toy, tox, flag);
    }
}

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

        rep (i, h) rep (j, w) used[i][j] = false, B[i][j] = false;
        rep (i, h) rep (j, w) if (! used[i][j]) if (a[i][j] == 'B') {
            used[i][j] = true;
            dfs(i, j, true);
        }

        rep (i, h) rep (j, w) used[i][j] = false, W[i][j] = false;
        rep (i, h) rep (j, w) if (! used[i][j]) if (a[i][j] == 'W') {
            used[i][j] = true;
            dfs(i, j, false);
        }

        int cntB = 0, cntW = 0;
        rep (i, h) rep (j, w) {
            cntB += (B[i][j] && ! W[i][j]);
            cntW += (! B[i][j] && W[i][j]);
        }
        cout << cntB << " " << cntW << endl;
    }
    return 0;
}


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

cnt = 0
Aorg = A
Aset = set(A)
Aset = list(Aset)
Aset.sort()
l = []
for i in Aset:
    l.append(Aorg.count(i))
    
for i in range(len(Aset)-2):
    for j in range(i+1,len(Aset)-1):
        for k in range(j+1,len(Aset)):
            if Aset[i] + Aset[j] > Aset[k]:
                cnt += l[i]*l[j]*l[k]
print(cnt)

Measured memory_bytes: 9128
#include <stdio.h>

int main(){
   int i, j, k;
   int n, x;
   int count;

   while(1){
       scanf("%d %d ", &n, &x);
       if(n==0&&x==0)break;
       count=0;
       for(i=1;3*i+3<=x;i++){
           for(j=i+1;i+2*j+1<=x;j++){
               for(k=n;k>j;k--){
                   if(x==i+j+k){
                       count++;
                       break;
                   }else if(x>=i+j+k){
                       break;
                   }
               }
           }
       }
       printf("%d\n", count);
   }
   return 0;
}


Measured memory_bytes: 2052
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, X, Y = map(int, input().split())

    ans = [0] * N
    for i in range(1, N):
        for j in range(i+1, N+1):
            if i >= Y or j <= X:
                ans[j-i] += 1
            else:
                ans[min(j-i, abs(X-i) + abs(Y-j)+1)] += 1
    print(*ans[1:], sep='\n')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <stdio.h>
#include <stdlib.h>
int main(void)
 { 
 	int a, b;
 	
 	scanf("%d%d", &a, &b);
 	
 	if (a < b)printf("a < b\n");
 	else if (a > b) printf("a > b\n");
 	else printf("a == b\n"); 
return 0;
 } 


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

int	main(void)
{
	int		n;
	double	d;
	int		i;
	double	x;
	double	y;
	int		num;
  
  	if (scanf("%d %lf", &n, &d) == EOF)
      return (-1);
  	num = 0;
	i = 0;
	while (i < n)
    {
    	if (scanf("%lf %lf", &x, &y) == EOF)
        	return (-1);
    	if (sqrt(pow(x, 2.0) + pow(y, 2.0)) <= d)
          num++;
		i++;
    }
	printf("%d", num);
	return (0);
}

Measured memory_bytes: 2228
package main

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

func main() {
	S := nextString()
	before, err := strconv.Atoi(S[:2])
	if err != nil {
		log.Fatal(err)
	}

	after, err := strconv.Atoi(S[2:])
	if err != nil {
		log.Fatal(err)
	}

	var okBefore, okAfter bool
	if 1 <= before && before <= 12 {
		okBefore = true
	}
	if 1 <= after && after <= 12 {
		okAfter = true
	}

	if okBefore && okAfter {
		fmt.Println("AMBIGUOUS")
		return
	} else if okBefore {
		fmt.Println("MMYY")
		return
	} else if okAfter {
		fmt.Println("YYMM")
		return
	}

	fmt.Println("NA")
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int N;
  cin >> N;
  
  int sum = 0, i;
  for(i = 1; sum < N; i++) {
    sum += i;
  }

  cout << i - 1 << endl;

  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		cout << s[i];
		if (i == 3) {
			cout << " ";
		}
	}
	cout << endl;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n)cin >> a.at(i);
    sort(a.begin(),a.end());
    cout << a[n-1] - a[0] << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include<climits>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
ll d[100001];
ll mod = 1e9 + 7;
ll go(ll x, ll y) {
	if (y == 0)return 1;
	else if (y == 1)return x;
	else if (y & 1) {
		return x * go(x, y - 1) % mod;
	}
	else {
		ll tmp = go(x, y / 2) % mod;
		return tmp * tmp%mod;
	}
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);

	ll n, k; cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		d[i] = go(k / i, n);
	}

	for (int i = k; i >= 1; i--) {
		for (int j = 2; j * i <= k; j++) {
			d[i] -= d[j  * i];
			while (d[i] < 0)d[i] += mod;
		}
	}

	ll ans = 0;
	for (int i = 1; i <= k; i++) {
		ans += d[i] * (ll)i;
		ans %= mod;
	}
	cout << ans << '\n';






}

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

const int N = 2000 * 1000 + 20, mod = 1e9 + 7;
int fact[N], factRev[N];

int sum(int a, int b) {
    return ((1LL * a + b) % mod + mod) % mod;
}

int mul(int a, int b) {
    return ((1LL * a * b) % mod + mod) % mod;
}

int pw(int a, int b) {
    int res = 1, tmp = a;
    while (b) {
        if (b & 1)
            res = mul(res, tmp);
        tmp = mul(tmp, tmp);
        b >>= 1;
    }
    return res;
}

int c(int a, int b) {
    return mul(fact[a], mul(factRev[b], factRev[a - b]));
}

int main() {
    fact[0] = 1;
    for (int i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
    factRev[N - 1] = pw(fact[N - 1], mod - 2);
    for (int i = N - 2; ~i; i--)
        factRev[i] = mul(factRev[i + 1], i + 1);
    int r1, r2, c1, c2, ans = 0;
    cin >> r1 >> c1 >> r2 >> c2;
    for (int i = r1; i <= r2; i++)
        ans = sum(ans, sum(c(c2 + i + 1, i + 1), -c(c1 + i, i + 1)));
    cout << ans << "\n";
}

Measured memory_bytes: 15872
import itertools
s = list(input())
ops = itertools.product('+-',repeat = 3)
for x,y,z in ops:
  if eval(s[0]+x+s[1]+y+s[2]+z+s[3]) == 7:
    print(s[0]+x+s[1]+y+s[2]+z+s[3]+'=7')
    exit()

Measured memory_bytes: 3060
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, k ] :: [Int] <- getList
	a :: [Int] <- getList
	let
		g = foldl1 gcd a
	putStrLn $ which "POSSIBLE" "IMPOSSIBLE" $ k <= maximum a && k `mod` g == 0


Measured memory_bytes: 7804
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
using namespace std;

constexpr int INF = (1 << 30) - 1;

int main(){
    int n;
    while(cin >> n){
        vector< vector<int> > g(n);
        for(int i = 0 ; i < n ; ++i){
            int r, k;
            cin >> r >> k;
            --r;
            for(int j = 0 ; j < k ; ++j){
                int t;
                cin >> t;
                g[r].push_back(t - 1);
            }
        }

        vector< vector<int> > cost(n, vector<int>(n, INF));
        for(int i = 0 ; i < n ; ++i){
            cost[i][i] = 1;
            queue< pair<int, int> > que;
            que.push({1, i});
            while(!que.empty()){
                pair<int, int> now = que.front();
                que.pop();
                if(cost[i][now.second] < now.first){
                    continue;
                }
                for(auto to : g[now.second]){
                    if(cost[i][to] > now.first + 1){
                        cost[i][to] = now.first + 1;
                        que.push({now.first + 1, to});
                    }
                }
            }
        }

        int p;
        cin >> p;

        while(p--){
            int s, d, v;
            cin >> s >> d >> v;
            --s;
            --d;

            if(cost[s][d] <= v){
                cout << cost[s][d] << endl;
            }else{
                cout << "NA" << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3164
import java.util.Arrays;

public class Main {

  private static void solve() {
    int n = ni();

    String[] a = new String[n];
    for (int i = 0; i < n; i++) {
      char[] s = ns();
      Arrays.sort(s);
      a[i] = new String(s);
    }

    Arrays.sort(a);
    long ret = 0;
    long cnt = 0;
    String pre = "";
    for (int i = 0; i < n; i++) {
      if (!pre.equals(a[i])) {
        ret += cnt * (cnt - 1) / 2;
        cnt = 1;
      } else {
        cnt++;
      }
      pre = a[i];
    }
    ret += cnt * (cnt - 1) / 2;

    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 47180
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b,c; cin>>a>>b>>c;
    cout<<(a+b+c>=22 ? "bust" : "win")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    if(n%2==0)n=n/2-1;
    else n=n/2;
    cout<<n<<endl;
}

Measured memory_bytes: 256
s = list(input())
N = 0
W = 0
S = 0
E = 0
for i in s:
  if i == 'N':
    N = 1
  if i == 'W':
    W = 1
  if i == 'S':
    S = 1
  if i == 'E':
    E = 1
if ((N == 0 and S == 0) or (N == 1 and S == 1)) and ((W == 0 and E == 0) or (W == 1 and E == 1)):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
	cout.precision(10);
	double r;
	cin >> r;
	double ans = r * 2.0 * M_PI;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3788
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int n;
    long long m;
    scanf("%d %lld", &n, &m);
    vector<long long> v;
    for(int i = 0 ; i < n ; i++){
        long long x;
        scanf("%lld", &x);
        v.push_back(x);
    }
    int j = 0;
    for(j = 50 ; j >= 0 ; j--) {
        if(m & (1LL<<j)) break;
    }
    long long ans = 0;
    long long tmp = 0;
    
    for(; j >= 0 ; j--) {
        if((ans ^ (1LL<<j)) > m) continue;

        long long a = 0, b = 0;
        for(int k = 0 ; k < n ; k++) {
            a += (v[k] & (1LL<<j));
            b += (v[k] & (1LL<<j)) ^ (1LL<<j);
        }

        if(a < b) ans ^= 1LL<<j;
    }
    for(auto e: v) {
        tmp += ans ^ e;
    }
    printf("%lld\n", tmp);
    return 0;
}


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

int main(){
  string N;
  cin>>N;
  if(N[0]==N[1]&&N[1]==N[2])	 cout<<"Yes"<<endl;
  else if(N[1]==N[2]&&N[2]==N[3])cout<<"Yes"<<endl;
  else 							 cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    ls = {i - 65: chr(i) for i in range(65, 91)}
    ans = []
    for i in range(len(s)):
        ans.append(ls[(ord(s[i]) - 65 + n) % 26])
    print("".join(ans))
    

if __name__ == '__main__':
    solve()


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

#define rep(i,q) for(int i = 0; q > i; i++)
int main(){
  int n,m;
  cin >> n >> m;
  rep(i,n){
    string s;
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
}

Measured memory_bytes: 256
main(){
	char s[10],cel[3][3];
	while(~scanf("%s",s)){
		char win='d';
		int i,j,cnt;
		for(i=0;i<3;i++)for(j=0;j<3;j++)cel[i][j]=s[3*i+j];

		for(i=0;i<3;i++){
			cnt=0;
			for(j=0;j<3;j++)	cnt+=cel[i][j];
			if(cnt==3*'o')	win='o';
			if(cnt==3*'x')	win='x';
		}

		for(i=0;i<3;i++){
			cnt=0;
			for(j=0;j<3;j++)	cnt+=cel[j][i];
			if(cnt==3*'o')	win='o';
			if(cnt==3*'x')	win='x';
		}

		for(i=cnt=0;i<3;i++)	cnt+=cel[i][i];
		if(cnt==3*'o')	win='o';
		if(cnt==3*'x')	win='x';

		for(i=cnt=0;i<3;i++)	cnt+=cel[i][2-i];
		if(cnt==3*'o')	win='o';
		if(cnt==3*'x')	win='x';

		printf("%c\n",win);
	}
	exit(0);
}

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

using namespace std;

typedef long long ll;

const int N = 2e5+20;

ll h[N],a[N],tr[N];
ll f[N];
ll n;
ll lowbit(ll x)
{
	return x&(-x);
}

void add(ll x,ll y)
{
	for(int i=x;i<=n;i+=lowbit(i))	tr[i]=max(tr[i],y);
}

ll query(ll x)
{
	ll ans=0;
	for( int i=x;i>=1;i-=lowbit(i))	
	ans=max(tr[i],ans);
	return ans;
}

int main()
{
	std::ios::sync_with_stdio(false);

	cin>>n;
	for(int i=1;i<=n;i++)	cin>>h[i];
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		f[i]=query(h[i])+a[i];
		add(h[i],f[i]);	
	}
	cout<<query(n)<<endl;

}

Measured memory_bytes: 6528