akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	vector<tuple<int,int,int,int>> ev; //(time, type, dist, id)
	
	int n, q; cin >> n >> q;
	rep(i, n){
		int s, t, x; cin >> s >> t >> x;
		ev.emplace_back(s - x, 0, x, i);
		ev.emplace_back(t - x, 1, x, i);
	}
	rep(i, q){
		int d; cin >> d;
		ev.emplace_back(d, 2, 0, i);
	}
	
	sort(all(ev));
	
	set<pi> s; //(dist, id)
	for(auto it : ev){
		int t, d, type, id; tie(t, type, d, id) = it;
		if(type == 0) s.insert(pi(d, id));
		if(type == 1) s.erase(pi(d, id));
		if(type == 2){
			if(s.empty()) cout << -1 << endl;
			else cout << s.begin()->first << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 20452
#include<cstdio>
#include<algorithm>
int main(){
	int A[3];
	for(int i = 0;i < 3;i++){
		scanf("%d",&A[i]);
	}
	std::sort(A,A+3);
		printf("%d %d %d\n",A[0],A[1],A[2]);
	return 0;
}

Measured memory_bytes: 2648
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    int w, h;
    cin >> w >> h;
    bool fld[w][h];
    for(int x = 0; x < w; x++) {
      for(int y = 0; y < h; y++) {
        fld[x][y] = false;
      }
    }
    for(int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      fld[x - 1][y - 1] = true;
    }
    int mx = 0;
    int s, t;
    cin >> s >> t;
    for(int x = 0; x < w - s + 1; x++) {
      for(int y = 0; y < h - t + 1; y++) {
        int cnt = 0;
        for(int i = 0; i < s; i++) {
          for(int j = 0; j < t; j++) {
            if(fld[x+i][y+j]) cnt++;
          }
        }
        if(cnt > mx) mx = cnt;
      }
    }
    cout << mx << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
	vector<ll> a(3);

	for (ll i = 0; i < 3; i++)
	{
		cin >> a[i];
	}

	sort(all(a));

	println(10 * a.back() + (a[0] + a[1]));
}

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

int main()
{
  int n;cin>>n;
  map<int,int>m;
  int t;
  for(int i=1;i<n;i++){cin>>t;m[t]++;}
  
  for(int i=1;i<=n;i++){cout<<m[i]<<endl;}
}

Measured memory_bytes: 13004
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
左からかえていきゃいいんじゃないのか
ああ、aにできない場合は次をかえるのか
あまったら末端をひたすらふやすか
10^5文字
aまでになんて必要か出す。
*/
int main(){
  string s; cin>>s;
  ll sz=s.size(),K; cin>>K;
  vector<ll> A(sz,0);
  for(int i=0; i<sz; i++){
    ll rest=0;
    if(s[i]=='a') continue;
    A[i]='z'-s[i]+1;
  }
  for(int i=0; i<sz; i++){
    if(K-A[i]>=0){
      s[i]='a';
      K-=A[i];
    }
  }
  if(K>0){
    K%=26;
    s[sz-1]+=K;
  }
  cout<<s<<endl;
}

Measured memory_bytes: 1408
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let d: f64 = iterator.next().unwrap().parse().unwrap();
    let t: f64 = iterator.next().unwrap().parse().unwrap();
    let s: f64 = iterator.next().unwrap().parse().unwrap();

    if d / s <= t {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 2196
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i] == L[j]:
            continue
        for k in range(j+1,N):
            if L[k] == L[i] or L[k] == L[j]:
                continue
            if L[i]+L[j] > L[k]:
                if L[j]-L[i] < L[k]:
                    ans += 1
print(ans)


Measured memory_bytes: 9192
import java.util.*;
class Main{
	static int n;
	static int count;
	static String str;
	static boolean R;
	static void solve(int a,int b){
	//	System.out.println(a+" "+b);
		int now=0;
		for(int i=a;i<=b;i++){
			if('0'<=str.charAt(i)&&str.charAt(i)<='9'){
				now*=10;
				now+=(int)(str.charAt(i)-'0');
			}else if(str.charAt(i)=='('){
				if(now==0)now=1;
				int K=1;
				int j;
				for(j=i+1;j<=b;j++){
					if(str.charAt(j)=='(')K++;
					if(str.charAt(j)==')')K--;
					if(K==0)break;
				}
				for(int k=0;k<now;k++){
					solve(i+1,j-1);
					if(R)return ;
				}
				i=j;
				now=0;
			}else{
				if(now==0)now=1;
				for(int j=0;j<now;j++){
					if(count==n){
						System.out.println(str.charAt(i));
						R=true;
						return;
					}
					count++;
				}
				now=0;
			}
		}
	}
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		while(true){
			str=s.next();
			int a=s.nextInt();
			n=a;
			count=0;
			R=false;
			if(str.equals("0"))break;
			solve(0,str.length()-1);
			if(!R)System.out.println("0");
		}
	}
}

Measured memory_bytes: 22828
n, m = map(int, input().split())
l = 1
r = 10**5
for _ in range(m):
  l_, r_ = map(int, input().split())
  l = max(l, l_)
  r = min(r, r_)
  
if r>=l:
  print(r-l+1)
else:
  print(0)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define text_wali_bakchodi freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7 ;
const ld pi=3.1415926535897932384626433;
const ll inf = 1e18;
bool isprime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll sol=a>b?a:b;return sol;}
ll min(ll a,ll b){ll sol=a<b?a:b;return sol;}


int main ()
{
   bolt;
   ll n,m;
   cin>>n>>m;
   n%=m;
   cout<<min(n,m-n);
}


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

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int day;
int n;
VI ys, ms, ds;

int main(void) {
	day = 0;
	REP (i, 1, 1000) {
		day += i % 3 == 0? 200 : 195;
	}
	cin >> n;
	rep (i, n) {
		int y, m, d;
		cin >> y >> m >> d;
		ys.PB(y);
		ms.PB(m);
		ds.PB(d);
	}
	rep (i, n) {
		int yd = 0, md = 0, d;
		REP (j, 1, ys[i]) {
			yd += j % 3 == 0? 200 : 195;
		}
		REP (j, 1, ms[i]) {
			md += ys[i] % 3 != 0 && j % 2 == 0? 19 : 20; 
		}
		d = yd + md + ds[i] - 1;
		cout << day - d << endl;
	}
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

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

    int cnt = 0;
    rep(i,n+1)
    {
        if(i%2==0) continue;
        int gcnt = 0;
        rep2(j,1,i+1)
            if(i%j==0) gcnt++;
        if(gcnt == 8)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include <iomanip>

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;
#define M 1000000007

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

vector<ll> fac(3000001); 
vector<ll> ifac(3000001); 

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}


ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(int argc, const char *argv[]){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<3000000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ll x, y;
    cin >> x >> y;
    if (((2*x-y)<0) || ((2*x-y)%3)!=0){co(0);return 0;}
    if (((2*y-x)<0) || ((2*y-x)%3)!=0){co(0);return 0;}
    ll a = (2*x-y)/3;
    ll b = (2*y-x)/3;
    ll ans = 1;
    ans = comb(a+b,a);
    co(ans);
    return 0;
}

Measured memory_bytes: 47232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n,k; cin >> n >> k;
  vb res(k+1,0);
  vi opts(n); for(int& i: opts) cin >> i;
  rep(i,0,k){
    if(!res[i]){
      for(auto j: opts)
        if(i+j <= k) res[i+j] = 1;
    }
  }
  if(res[k]) cout << "First";
  else cout << "Second";
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	string s;
	cin >> s;
	int ans = 0, cur = 0;
	int n = s.size();
	while (cur < n) {
		int i = cur;
		while (i < n) {
			if (s[i] != s[cur]) break;
			++i;
		}
		if (i < n) ++ans;
		cur = i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stack>
using namespace std;
int main() {
    stack<int> ss;
    string s;
    while (1) {
        cin>>s;
        if (!cin) {
            break;
        }
        if (s[0] == '+') {
            int b = ss.top(); ss.pop();
            int a = ss.top(); ss.pop();
            ss.push(a+b);
        } else if (s[0] == '-') {
            int b = ss.top(); ss.pop();
            int a = ss.top(); ss.pop();
            ss.push(a-b);
        } else if (s[0] == '*') {
            int b = ss.top(); ss.pop();
            int a = ss.top(); ss.pop();
            ss.push(a*b);
        } else {
            int n = stoi(s);
            ss.push(n);
        }
    }
    cout<<ss.top()<<endl;
    return 0;
}



Measured memory_bytes: 3172
#include<string.h>
#include<stdio.h>
int main()
{
	int h,b,i,j;
	char r[5],a[5];
	while(1){
		scanf("%s %s",r,a);
		if(strcmp(r,"0")==0&&strcmp(a,"0")==0){
			break;
		}
		h=0;
		b=0;
		for(i=0;i<4;i++){
			if(r[i]==a[i]){
				h++;
				r[i]='r';
				a[i]='a';
			}
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(r[i]==a[j]){
					b++;
					r[i]='r';
					a[j]='a';
				}
			}
		}
		printf("%d %d\n",h,b);
	}
	return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
}

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

int main(){
	int ans;
	int n, y, m, d;
	cin >> n;
	while(n--){
		ans = 0;
		cin >> y >> m >> d;
		ans += (y-1)*200 + (m-1)*20 + d;
		ans -= 5*(y-((y-1)/3)-1);
		if(y%3)ans -= (m-1)/2;
		cout << 196470-ans+1 << endl;
	}
	return 0;
}

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

int main(){
	int num,i;
	string m;
	
	while(1){
		int sum=1;
		int temp;
		int over=1,under=6,n=5,s=2,w=3,e=4;
		
		cin>>num;
		if(num==0) break;
		
		for(i=0;i<num;i++){
			cin>>m;
			if(m=="North"){
				temp=over;
				over=s;
				s=under;
				under=n;
				n=temp;
			}
			else if(m=="South"){
				temp=over;
				over=n;
				n=under;
				under=s;
				s=temp;
			}
			else if(m=="East"){
				temp=over;
				over=e;
				e=under;
				under=w;
				w=temp;
			}
			else if(m=="West"){
				temp=over;
				over=w;
				w=under;
				under=e;
				e=temp;
			}
			else if(m=="Left"){
				temp=s;
				s=e;
				e=n;
				n=w;
				w=temp;
			}
			else if(m=="Right"){
				temp=s;
				s=w;
				w=n;
				n=e;
				e=temp;
			}
			sum+=over;
		}
		cout<<sum<<endl;
	}
return 0;
}

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

int main() {
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;

  ll min025 = q;
  ll min050 = min(min025 * 2, h);
  ll min100 = min(min050 * 2, s);
  ll min200 = min(min100 * 2, d);

  ll ans;
  if (n & 1) {
    ans = n / 2 * min(min100 * 2, min200) + min100;
  } else {
    ans = n / 2 * min(min100 * 2, min200);
  }

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		long N = Long.parseLong(st.nextToken());
		long M = Long.parseLong(st.nextToken());
		if (N > M) {
			N %= M;
		}
		System.out.println(Math.min(N, M - N));
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int n;
    
    cin >> n;
    
    cout << n / 3 << endl;
    
    return 0;
}

Measured memory_bytes: 764
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#define int long long
using namespace std;
inline int read() {
	int x=0,f=-1;	char ch = getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x = (x<<3)+(x<<1)+(ch^48); ch=getchar(); }
	return x * f;
}
const int N = 507;
int n,k,s,ans;
int a[N];
inline bool check(int x) {
	int ss=0 ,sss=0;
	vector<int> v;
	for(int i=1;i<=n;++i) {
		v.push_back(a[i]%x);
		sss += x - a[i] % x;
	}
	sort(v.begin(),v.end());
	ss = v[0] ,sss -= x - v[0];
	for(int i=1;i<v.size();++i) {
		if(ss+v[i] > k) break;
		ss += v[i] ,sss -= x - v[i];
	}
	return ss<=k&&sss<=k;
}
signed main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i)
		scanf("%lld",&a[i]) ,s += a[i];
	for(int i=1;i*i<=s;++i) {
		if(s != (s/i)*i) continue;
		if(check((s/i))) ans = max(ans,s/i);
		if(check(i)) ans = max(ans,i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%lf",&n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%lf ",n)
#define dprin(n) printf("%lf\n",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    int count=0;
    while(b<=a)
    {
        b*=2;
        count++;
    }
    while(c<=b)
    {
        c*=2;
        count++;
    }
   // cout<<a<<b<<c<<count<<endl;
    if(count<=k)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
return 0;
}

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

vector<string> X = {"Sunny", "Cloudy", "Rainy"};

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

    string S;
    cin >> S;

    for(int i=0; i<3; i++)
    {
        if(X[i] != S)
            continue;
        
        int j = (i + 1) % 3;

        cout << X[j] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
N=int(input())
data=[[0]*10 for i in range(10)]
for u in range(N+1):
    data[int(str(u)[0])][int(str(u)[-1])]+=1
ans=0
for i in range(1,10):
    for j in range(1,10):
        ans+=data[i][j]*data[j][i]
print(ans)

Measured memory_bytes: 40428
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, m;
   cin >> n >> m;
   vector<int> a(m);
   vector<int> b(m);
   map<int, int> mp;
   for(int i = 0;i < m;i++) {
       cin >> a[i] >> b[i];
       mp[a[i]]++;
       mp[b[i]]++;
   }
   for(int i = 1;i <= n;i++) {
       cout << mp[i] << endl;
   }
}

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

struct StExpr
{
  StExpr() : m_nPerson(0), m_nAttr(0) { }

  int m_nPerson;
  int m_nAttr;
};

void fnInput(vector<vector<StExpr>>& rvvoExpr)
{
  int nPersonSiz;
  cin >> nPersonSiz;
  rvvoExpr.resize(nPersonSiz);

  for (int i = 0; i < rvvoExpr.size(); i++)
  {
    int nAttrSiz;
    cin >> nAttrSiz;
    rvvoExpr[i].resize(nAttrSiz);

    for (int j = 0; j < rvvoExpr[i].size(); j++)
      cin >> rvvoExpr[i][j].m_nPerson >> rvvoExpr[i][j].m_nAttr;
  }
}
 
int fnHonestCheck(const vector<vector<StExpr>>& cnrvvoExpr, 
                  const vector<int>& cnrvnHonest, int nMan)
{
  if (cnrvnHonest[nMan])               // Honest
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 0;

    return 1;
  }
  else                                 // UnKind
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 1;

    return 0;
  }
}
  
int fnMaxHonestGet(const vector<vector<StExpr>>& cnrvvoExpr)
{
  vector<int> vnHonest(cnrvvoExpr.size());
  int nMaxHonestCnt = 0;
  
  for (int n = 0; n < ( 1 << cnrvvoExpr.size() ); n++)
  {
    int nHonestCnt = 0;

    for (int i = 0; i < cnrvvoExpr.size() ; i++)
      if (n & ( 1 << i ))
      {
        vnHonest[i] = 1;               // Honest
        nHonestCnt++;
      }
      else
        vnHonest[i] = 0;               // UnKind

    bool bReslt = true;

    for (int nMan = 0; nMan < vnHonest.size(); nMan++)
      if (!fnHonestCheck(cnrvvoExpr, vnHonest, nMan))
      {
        bReslt = false;
        break;
      }

    if (bReslt) nMaxHonestCnt = max(nMaxHonestCnt, nHonestCnt);
  }
  return nMaxHonestCnt;
}

int main()
{
  vector<vector<StExpr>> vvoExpr;

  fnInput(vvoExpr);
  cout << fnMaxHonestGet(vvoExpr) << endl;

  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	int len = s.size();

	//s[0]='0'にする時
	string temp1 = s;
	Int count1 = 0;
	for (int i = 0; i < len; i++) {
		if (i == len - 1)break;
		if (i == 0 && temp1[i] != '0') {
			count1++;
			temp1[i] = '0';
			continue;
		}
		if (temp1[i] == '0' && temp1[i+1] == '0') {
			count1++;
			temp1[i+1] = '1';
			continue;
		}
		if (temp1[i] == '1' && temp1[i + 1] == '1') {
			count1++;
			temp1[i + 1] = '0';
			continue;
		}
	}

	//s[0]='1'にする時
	string temp2 = s;
	Int count2 = 0;
	for (int i = 0; i < len; i++) {
		if (i == len - 1)break;
		if (i == 0 && temp2[i] != '1') {
			count2++;
			temp2[i] = '1';
			continue;
		}
		if (temp2[i] == '0' && temp2[i + 1] == '0') {
			count2++;
			temp2[i + 1] = '1';
			continue;
		}
		if (temp2[i] == '1' && temp2[i + 1] == '1') {
			count2++;
			temp2[i + 1] = '0';
			continue;
		}
	}

	cout << min(count1, count2);
}

Measured memory_bytes: 592
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// ボールの数
		int N = sc.nextInt();
		// 人数
		int K = sc.nextInt();

		int rem = N - K;
      if(K == 1){
      	System.out.println(0);
      }
      else{
        System.out.println(rem);
      }
	}
}

Measured memory_bytes: 23120
//secreterror
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<n;i++)
#define rev(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>

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

    vector<ll>arr(n);

    rep(i,n) cin>>arr[i];

    vector<ll>dp(n+1);

    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(arr[1]-arr[0]);

    for(int i=3;i<=n;i++){
     dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+(abs(arr[i-1]-arr[i-3])));
    }

    cout<<dp[n]<<endl;


}

Measured memory_bytes: 1792
#!/usr/bin/python

from numpy import *

H, W = raw_input().split()

h = int(H)
w = int(W)

a = []

for i in range(h):
    a.append(raw_input())

for i in range(h):
    a[i] = '#' + a[i]
    a[i] = a[i] + '#'

temp = '#'

for i in range(len(a[i]) - 1):
    temp = temp + '#'

print temp

for i in range(h):
    print a[i]
    

print temp

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){

    long long x;
    cin>>x;
    long long ans=0;

    ans+=(x/500)*1000;

    x%=500;

    ans+=(x/5)*5;

    cout<<ans<<endl;
    
    return 0;

}
/*


*/


Measured memory_bytes: 256
import java.util.*;

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		System.out.println(lcm(A, B));
	}

	public static long lcm(int A, int B){
		int temp;
		long C = A;
		C *= B;
		while((temp = A%B) != 0){
			A = B;
			B = temp;
		}
		return (C / B);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
using namespace std;

void addBIT(long long* BIT,int N,int index, long long v){
    int i;
    for(i = index;i < N;i+= i&-i) BIT[i] += v;
}

long long sumBIT(long long* BIT,int index){
    long long retValue = 0;
    int i;
    for(i = index;i > 0;i-= i& -i) retValue += BIT[i];
    return retValue;
}

int main()
{
    // 整数の入力
    long long i,j,N,K,temp,count,total;
    count = 0;
    total = 0;
    vector<long long> b;
    map<long long,long long> dic;
    cin >> N >> K;
    long long* c = new long long[N+2];
    for (i=0;i<N+2;i++){
        c[i] = 0;
    }
    b.push_back(0);
    for (i=1;i<N+1;i++){
        cin >> temp;
        total += temp;
        b.push_back(total - K * i);
    }

    vector<long long> sorted_b(b);
    sort(sorted_b.begin(),sorted_b.end());

    temp = sorted_b[0] - 1;
    j = 0;
    for (i=0;i<=N;i++){
        if (temp != sorted_b[i]){
            temp = sorted_b[i];
            dic.insert(make_pair(sorted_b[i],j));
            j++;
        }
    }

    count = 0;
    for (i=0;i<=N;i++){
        count += sumBIT(c,dic.at(b[i])+1);
        addBIT(c,N+2,dic.at(b[i])+1, 1);
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 17392
#include <iostream>
using namespace std;
#include <vector>
int fib[8];
const int mod = 1000000007;

int fibonacci(int i)  {
    if(i < 0) return 1;
    else return fib[i];
}

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    fib[0] = 1; fib[1] = 2;
    for(int i=2; i<8; ++i) fib[i] = fib[i-1] + fib[i-2];
    vector< vector<long long> > A(H+1, vector<long long>(W,0));
    A[0][0] = 1;
    for(int i=1; i<=H; ++i) {
        for(int j=0; j<W; ++j) {
            A[i][j] += A[i-1][j] * fibonacci(j-1) * fibonacci(W-j-2) % mod;
            if(j > 0) A[i][j] += A[i-1][j-1] * fibonacci(j-2) * fibonacci(W-j-2) % mod;
            if(j < W-1) A[i][j] += A[i-1][j+1] * fibonacci(j-1) * fibonacci(W-j-3) % mod;
            A[i][j] %= mod;
        }
    }
    cout << A[H][K-1] << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS = 1e-9;
#define rep(i,s,n) for(int i=(s); i < int(n); ++i)

const int N = 101;
const int V = 1e5 + 1;
int v[N], w[N];
int n, wlim;
int tv[N];

int dp[N][V];
const int INF = 0x2fffffff;
const int DEBUG = 0;

int solve(void) {
  dp[0][0] = 0;
  int total_v = 1;
  rep(i, 0, n) {
    total_v += v[i];
  }
  rep(j, 1, total_v) {
    dp[0][j] = INF;
  }
  rep(i, 1, n + 1) {
    rep(j, 0, total_v) {
      int res = dp[i-1][j];
      int val = v[i-1];
      int wei = w[i-1];
      if (val <= j) {
	res = min(res, dp[i - 1][j - val] + wei);
      } else {
	res = min(res, wei);
      }
      if(DEBUG) {
	cout << "dp[" << i << "][" << j << "] = " << res << endl;
      }
      dp[i][j] = res;
    }
  }
  int q = 0;
  rep(i,0,total_v) {
    if (dp[n][i] <= wlim) {
      q = i;
    }
  }
  if(DEBUG) {
    cout << "q = " << q << endl;
  }
  int rem = q;
  int sum = 0;
  for (int i = n; i > 0; --i) {
    int val = v[i-1];
    int wei = w[i-1];
    if (val <= rem && dp[i][rem] - wei == dp[i - 1][rem - val]) {
      // output (i - 1)
      sum += tv[i - 1];
      rem -= val;
    }
  }
  return sum;
}


int main(void) {
  cin >> n >> wlim;
  double max_v = 0.0;
  rep(i, 0, n) {
    cin >> tv[i] >> w[i];
    max_v = max(max_v, (double) tv[i]);
  }
  double k = 36;
  double scale = max(1.0, max_v / (k + 1) / n);
  rep(i, 0, n) {
    v[i] = (int) floor(tv[i] / scale);
  }
  cout << solve() << endl;
}

Measured memory_bytes: 40612
N,M=map(int,input().split())
S=input()
ans=''
i=N
flg=0
while i>0:
  j=M
  if i-M<0:
    ans=str(i)+' '+ans
    i=0
  else:
    while j>=0:
      if j>0 and S[i-j] == '0':
        ans=str(j)+' '+ans
        i-=j
        j=0
      elif j==0:
        flg=1
        i=0
      j-=1
if flg==1:
  print(-1)
else:
  print(ans)

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

void up(int,double*);
double ave(double,double);
double mix(int,double*);

int main(){
  int n,i;
  cin>>n;
  double a[n],ans;
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  up(n,a);
  ans=mix(n,a);
  cout<<ans<<endl;
  return 0;
}

void up(int n,double *a)
{
  int i,j,tmp;
  for(i=0;i<=n-2;i++){
    for(j=i+1;j<n;j++){
      if(a[i]<a[j]){
        tmp=a[i];a[i]=a[j];a[j]=tmp;
      }
    }
  }
}

double ave(double x,double y)
{
  return (x+y)/2;
}

double mix(int n,double *a)
{
  if(n==2){
    return ave(a[0],a[1]);
  }
  a[n-2]=ave(a[n-2],a[n-1]);
  return mix(n-1,a);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,k,s;
	long a;
	while(cin>>n>>k>>s){
		if(n==0&&k==0&&s==0) break;
		int h[k],t=0;
		h[0]=0;
		for(int i=0;i<k-1;i++){
			h[k-1-i]=n-i;
			t=t+n-i;
		}
		int ct=0;
		do{
			if(s-t<h[1]&&s-t>0){
				ct++;
			}
			for(int i=0;i<k-1;i++){
				if(h[i+1]-h[i]>1){
					h[i+1]--;
					break;
				}
				else if(h[i+1]-h[i]==1&&h[i+2]-h[i+1]>1){
					h[i+2]--;
					for(int j=0;j<i+1;j++){
						h[i+1-j]=h[i+2-j]-1;
					}
					break;
				}
			}
			t=0;
			for(int i=0;i<k-1;i++){
				t=t+h[i+1];
			}
		} while(t>(k-1)*k/2);
		if(k==1&&s<=n){
			cout<<1<<endl;
		}else{
			cout<<ct<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int n,m;

int main() {
  cin >> n >> m;
  map<int,int> mp;

  rep(i,m){
    int s,t;
    cin >> s >> t;

    if(n==3){
      if(s==1&&t==0){cout << -1;return 0;}
    }
    if(n==2){
      if(s==1&&t==0){cout << -1;return 0;}
    }

    auto itr= mp.find(s);
    if( itr!=mp.end()){
      if(mp[s]!=t){cout << -1;return 0;}
    }else{mp[s]=t;}
  }

  reps(i,n){
    auto itr= mp.find(i);
    if(itr==mp.end()){
      if(n==1&&i==1){cout << 0;return 0;}
      else if(n==2&&i==2){mp[2]=0;}
      else if(n==2&&i==1){mp[1]=1;}
      else if(n==3&&i==3){mp[3]=0;}
      else if(n==3&&i==2){mp[2]=0;}
      else if(n==3&&i==1){mp[1]=1;}
      else mp[i]=0;
    }
  }

  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        cout << itr->second;    // 値を表示
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> TP;
typedef pair<string, string> PS;

int main() {
  string s;
  cin >> s;
  int ans = 0, zen = 0, ren = 0;
  REP(i, s.size()) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      ren++;
      zen = 1;
    } else {
      ans = max(ans, ren);
      ren = 0;
      zen = 0;
    }
  }
  cout << max(ren, ans) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define DBG 1
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

vector<int> c;
vector< vector<int> > s;

struct State {
  vector<int> t;
  int d, score;

  State() {  }

  void set(int _d, vector<int>& _t) {
    d = _d;
    //t = _t;
    t.resize(d);
    forr(i,0,d-1) t[i] = _t[i];
    compscore0();
  }

  void compscore0() {
    vector<int> last(26,-1);
    int sc = 0;
    forr(i,0,d-1) {
      int tt = t[i];
      last[tt] = i;
      forr(j,0,25) sc -= c[j]*(i-last[j]);
      sc += s[i][tt];
    }
    score = sc;
  }

  void add(int day, int con) {
    int bef = day-1;
    while (bef>=0 && t[bef]!=con) bef--;
    int aft = day+1;
    while (aft<d && t[aft]!=con) aft++;
    int inc = s[day][con] + c[con]*(day-bef)*(aft-day);
    //cerr << "add inc " << inc << " s " << s[day][con] << " c " << c[con] << " dy-bf " << day-bef << " af-dy " << aft-day << " sc " << score << endl;
    score += inc;
    t[day] = con;
  }

  void sub(int day) {
    int con = t[day];
    int bef = day-1;
    while (bef>=0 && t[bef]!=con) bef--;
    int aft = day+1;
    while (aft<d && t[aft]!=con) aft++;
    int inc = s[day][con] + c[con]*(day-bef)*(aft-day);
    //cerr << "sub inc " << inc << " s " << s[day][con] << " c " << c[con] << " dy-bf " << day-bef << " af-dy " << aft-day << " sc " << score << endl;
    score -= inc;
    t[day] = -1;
  }

  void chg(int day, int con) {
    //cerr << "chg day " << day << " con " << con << endl;
    sub(day);
    //cerr << "sub done" << endl;
    add(day,con);
    //cerr << "add done score " << score << endl;
  }
};

int main() {
  int d;
  cin >> d;
  //c = vector<int>(26);
  c.resize(26);
  //s = vector< vector<int> >(d, vector<int>(26));
  s.resize(d);
  forr(i,0,d-1) s[i].resize(26);

  forr(i,0,25)
    cin >> c[i];
  forr(i,0,d-1)
    forr(j,0,25)
      cin >> s[i][j];
  vector<int> t;

  State st;

  forr(i,0,d-1) {
    t.push_back(0);
    st.set(i+1,t);
    t.pop_back();
    int sc = st.score;
    //cerr << "i " << i << " presc " << sc << endl;
    int mxj = 0;
    forr(j,1,25) {
      st.chg(i,j);
      if (sc<st.score) {
        sc = st.score;
        mxj = j;
        //cerr << " j " << j << " sc " << sc << endl;
      }
    }
    t.push_back(mxj);
    cout << mxj+1 << endl;
  }
}


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

int main(){
    int N, L;
    cin >> N >> L;
    int sum = N * L;
    for(int i = 0; i < N; i++){
        sum += i;
    }
    int sum2 = sum - (L + 1 - 1);
    for(int i = 2; i <= N; i++){
        int sum3 = sum - (L + i - 1);
        if(abs(sum2 - sum) > abs(sum3 - sum)){
            sum2 = sum3;
        }
    }
    cout << sum2 << endl;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    int ans = 0;
    int num = 1;
    for (int i = 0; i < N; i++)
    {
        if (a[i] == num)
            num++;
        else
            ans++;
    }

    if (num == 1)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;

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

  unordered_map<string, bool> dic;

  for (int i = 0; i < n; i++)
  {
    string op, str;
    cin >> op >> str;
    if (op == "insert")
    {
      dic[str] = true;
    }
    else
    {
      string res = dic[str] ? "yes" : "no";
      cout << res << endl;
    }
  }
}



Measured memory_bytes: 49844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

struct edge { long long to, cost;};
typedef pair<long long, long long> P_dij;

/* params
 * @s -> start, n -> 要素数, G -> グラフ, d -> 結果(参照渡し)
*/
void dijkstra(const long long s, const long long n,
  vector< vector<edge> > const &G, vector<long long> & d){
  d.resize(n);
  for(int i=0; i<n; i++) d[i] = INF; 
  priority_queue<P_dij, vector<P_dij>, greater<P_dij>> que;
  d[s] = 0;
  que.push(P_dij(0, s));
  while (!que.empty()) {
    P_dij p = que.top();
    que.pop();
    long long v = p.second;
    if(d[v] < p.first)continue;
    for(int i=0;i<G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P_dij(d[e.to], e.to));
      }
    }
  }
}

/* END END END */
int main() {
  int n;
  cin >> n;
  vector<vector<edge>> G(n+1);
  
  int a,b;
  rep(i, n-1) {
    cin >> a >> b;
    --a, --b;
    G[a].push_back({b, 1});
    G[b].push_back({a, 1});
  }

  vector<ll> d1, d2;
  dijkstra(0, n, G, d1);
  dijkstra(n-1, n, G, d2);

  int cntf = 0, cnts = 0;
  for (int i = 0; i < n; ++i) {
    if (d1[i] < d2[i]) cntf += 1;
    else if (d1[i] == d2[i]) cntf += 1;
    else cnts += 1;
  }

  if (cnts > cntf or cnts == cntf) {
    cout << "Snuke" << endl;
  } else {
    cout << "Fennec" << endl;
  }
}


Measured memory_bytes: 9744
<?php
$a=0;$un=0;$f=0;
fscanf(STDIN, "%d", $N);

for ($i=0; $i < $N; $i++) { 
	fscanf(STDIN, "%s", $S);
	if ($S=="A") {
		$a++;
		$f++;
	}else{
		$un++;
		if($f>0){
			$f--;
		}
		if($i==0){
			$un+=$N;
		}
	}
}
if ($a==$un&&$f==0) {
	printf("YES\n");
}else{
	printf("NO\n");
}


Measured memory_bytes: 9204
#include <iostream>

using namespace std;

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


Measured memory_bytes: 1664
n,d = map(int,input().split())
#x=[]
#y=[]
kyori = []
count = 0
for i in range(n):
    
    x0,y0=map(int,input().split())
    kyori.append((x0**2+y0**2)**0.5)
    
    if (x0**2+y0**2)**0.5 <= d:
        
        count+=1
    
print(count)

Measured memory_bytes: 83960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
const ll mod=1000000007;
int n,m;
ll a[N],s[N];
ll fac[N],inv[N];
ll po(ll x,ll k){
	if(!k) return 1;
	ll s=po(x,k>>1);s=s*s%mod;
	if(k&1) return s*x%mod;
	return s; 
}
ll s0[N],s1[N];
int main(){
	int i,j;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		s[i]=(s[i-1]+a[i])%mod;
	}
	fac[0]=1;
	for(i=1;i<N;i++) fac[i]=(fac[i-1]*i)%mod;
	inv[N-1]=po(fac[N-1],mod-2);
	for(i=N-2;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(i=1;i<=n;i++)
		s0[i]=(s0[i-1]+a[i]*i)%mod;
	for(i=n;i;i--)
		s1[i]=(s1[i+1]+a[i]*(n-i+1))%mod;
	ll ans=0;
	for(i=1;i<n;i++){
		int k=min(i,n-i+1);
		ll tmp=((s0[k]+s1[n-k+1]+(s[n-k]-s[k]+mod)*k-s[i]-(s[n]-s[n-i]))%mod+mod)%mod;
		if(i+2<=n) ans=(ans+((tmp*inv[i+2]%mod)*2*fac[i]%mod)*fac[n])%mod;
		ans=(ans+((s[i]*inv[i+1]%mod)*fac[i]%mod)*fac[n])%mod;
		ans=(ans+(((s[n]-s[n-i]+mod)*inv[i+1]%mod)*fac[i]%mod)*fac[n])%mod;
	}
	ans=(ans+s[n]*fac[n]%mod)%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  for(int i=1;i<=n;i++){
    int q;
    cin >> q;
    a[i-1] = make_pair(q,i);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){cout << a[i].second;
  if(n-1!=i){cout << " ";}else{cout << endl;}
  }
}

Measured memory_bytes: 1664
n, m, l = map(int, input().split())
a = []
b = []
for _ in range(n):
    a.append(list(map(int, input().split())))
for _ in range(m):
    b.append(list(map(int, input().split())))
for i in range(n):
    li = [sum([a[i][j]*b[j][k] for j in range(m)]) for k in range(l)]
    print(' '.join(map(str, li)))



Measured memory_bytes: 6300
N = int(input())
ans = 0
for i in [1,2,3,4,5,6,7,8,9]:
    if N%i == 0 and N/i<10:
        ans = 1
        break
    else:
        ans = 0
        
if ans == 1:
    print("Yes")
else:
    print("No")
    

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

long long N, mod;
long long S1[525], S2[525];
long long V[252525];
long long dp[525][525];
vector<int> R[525];

void init() {
	for (int i = 1; i <= 500; i++) {
		for (int j = i * i; j < (i + 1) * (i + 1); j++) V[j] = i;
	}
}

long long solve(int pos) {
	// [1] 初期化
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) dp[i][j] = 0;
	}

	// [2] 計算
	int cx = 0; dp[N][0] = 1;
	for (int i = N - 1; i >= 0; i--) {
		for (int j : R[i]) {
			cx++;
			for (int k = 0; k <= N; k++) {
				int s0 = k + cx;
				dp[i + 1][k] *= 1LL * max(0LL, 2LL + S2[j] - s0);
				dp[i + 1][k] %= mod;
			}
		}
		for (int j = 0; j <= N; j++) {
			if (dp[i + 1][j] == 0) continue;

			// 違反する場合
			int s1 = cx + j + 1;
			if (2LL + S1[i] - s1 >= 1) {
				dp[i][j + 1] += 1LL * (2LL + S1[i] - s1) * dp[i + 1][j];
				dp[i][j + 1] %= mod;
			}

			// 違反しない場合
			int s2 = N + pos + (N - i - j);
			if (2LL + S2[i] - s2 >= 1) {
				dp[i][j + 0] += 1LL * (2LL + S2[i] - s2) * dp[i + 1][j];
				dp[i][j + 0] %= mod;
			}
		}
	}

	long long val = dp[0][pos];
	for (int i = 2 * N - 1; i >= N; i--) {
		if (S2[i] <= N - 1) continue;
		int s3 = pos + (2 * N - i);
		val *= 1LL * max(0LL, 2LL + S2[i] - s3);
		val %= mod;
	}
	return val;
}

int main() {
	// ステップ 1. 入力
	init();
	cin >> N >> mod;

	// ステップ 2. 初期化
	for (int i = 0; i <= N - 1; i++) S1[i] = V[N * N - 1 - i * i];
	for (int i = 0; i <= 2 * N - 1; i++) S2[i] = min(2 * N - 1, V[4 * N * N - i * i]);
	for (int i = 2 * N - 1; i >= N; i--) {
		int border = -1;
		for (int j = N - 1; j >= 0; j--) {
			if (S1[j] >= S2[i]) { border = j; break; }
		}
		if (border >= 0) R[border].push_back(i);
	}

	// ステップ 3. DP
	long long Answer = 0;
	for (int i = 0; i <= N; i++) {
		long long val = solve(i);
		if (i % 2 == 0) Answer += val;
		if (i % 2 == 1) Answer -= val;
		Answer = (Answer + mod) % mod;
	}

	// ステップ 4. 出力
	cout << Answer << endl;
	return 0;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            //var N = int.Parse(Console.ReadLine());
            //var txylist = Enumerable.Range(0, N)
            //    .Select(_ => Console.ReadLine().Split(' ').Select(int.Parse).ToArray());

            var N = Io.Read<int>();
            //var txylist = Enumerable.Range(0, N).Select(_ => Io.ReadSplit<int>());

            var txylist = Io.ReadSplitRepeat<int>(N);

            var currentT = 0;
            var currentX = 0;
            var currentY = 0;
            var can = true;
            foreach (var txy in txylist)
            {
                var t = txy[0];
                var x = txy[1];
                var y = txy[2];

                var dt = t - currentT;
                var dx = Math.Abs(x - currentX);
                var dy = Math.Abs(y - currentY);

                if (dx + dy > dt
                    || (dx + dy) % 2 != dt % 2
                    )
                {
                    can = false;
                    break;
                }
            }

            Console.WriteLine(can ? "Yes" : "No");
        }
    }

    class Io
    {
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static IEnumerable<string> ReadRepeat(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read());
        }

        public static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        public static IEnumerable<T> ReadRepeat<T>(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read<T>());
        }

        public static string[] ReadSplit(char devide = ' ')
        {
            return Read().Split(devide);
        }

        public static T[] ReadSplit<T>(char devide = ' ')
        {
            return ReadSplit(devide)
                .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                .ToArray();
        }

        public static IEnumerable<T[]> ReadSplitRepeat<T>(int count, char devide = ' ')
        {
            return Enumerable.Range(0, count).Select(_ => ReadSplit<T>(devide));
        }
    }
}


Measured memory_bytes: 17428
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String).chars().collect::<Vec<_>>();
    let mut count1 = 0u64;
    let mut count2  = 0u64;
    for i in 0..s.len() {
        if i % 2 == 0 {
            if s[i] == '0' {
                count1 += 1;
            }
        } else {
            if  s[i] == '1' {
                count1 += 1;
            }
        }
    }
    for i in 0..s.len() {
        if i % 2 == 0 {
            if s[i] == '1' {
                count2 += 1;
            }
        } else {
            if  s[i] == '0' {
                count2 += 1;
            }
        }
    }
    println!("{}", min!(count1, count2));
}


Measured memory_bytes: 8572