akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

//=========================================
#define MAX_V 10000
const int INF = 1 << 30;

//辺を表す構造体(行先，容量，逆辺)
struct edge{
  int to, cap, rev;
};

vector<edge> G[MAX_V];
bool used[MAX_V];

//辺の追加
void add_edge(int from, int to, int cap){
  G[from].push_back(edge{to, cap, (int)G[to].size()});
  G[to].push_back(edge{from, 0, (int)G[from].size() - 1});
}

//増加パスをDFSで探す
int dfs(int v, int t, int f){
  if(v == t) return f;
  used[v] = true;
  for(int i = 0; i < (int)G[v].size(); i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

//sからtへの最大流を求める
int max_flow(int s, int t){
  int flow = 0;
  for(;;){
    fill(used, used + MAX_V, false);
    int f = dfs(s, t, INF);
    if(f == 0) return flow;
    flow += f;
  }
}

//==============================================
int main(){
  int N, M;
  cin >> N >> M;

  for(int i = 0; i < M; i++){
    int u, v, c;
    cin >> u >> v >> c;
    add_edge(u, v, c);
  }

  cout << max_flow(0, N - 1) << endl;
  return 0;
}



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

int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  if(a == b & b == c){
    if(a % 2 != 0){
      cout << 0;
    }else{
      cout << -1;
    }
    return 0;
  }
  long long count = 0;
  while(a % 2 == 0 & b % 2 == 0 & c % 2 == 0){
    long long tmp1 = a;
    long long tmp2 = b;
    a = (tmp2 + c) / 2;
    b = (c + tmp1) / 2;
    c = (tmp1 + tmp2) / 2;
    count++;
  }
  cout << count;
}


Measured memory_bytes: 256
N = int(input())
numbers = list(map(int, input().split()))
s = sorted(numbers, reverse = True)
total = 0
total += s[0]
s.pop(0)
z = N-2
if N%2 ==0:
    for i in range(N//2 -1):
        total += 2*s[i]
else:
    for i in range((N-3)//2):
        total += 2*s[i]
    total += s[(N-3)//2]
print(total)



Measured memory_bytes: 31552
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,z_cnt=0,aln,tmp;
  cin >> n;
  map<ll,ll> mp;
  ll a[n];
  bool can=true;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]==0){
      z_cnt++;
    }
  }
  if(z_cnt==n){
    cout <<"Yes\n";
    return 0;
  }
  if(n%3!=0){
    cout <<"No\n";
    return 0;
  }
  if(z_cnt==n/3){
    aln=-1;
    tmp=0;
    for(int i=0;i<n;i++){
      if(a[i]!=0){
        if(aln==-1){
          aln=a[i];
          tmp++;
        }else if(aln==a[i]){
          tmp++;
        }else{
          break;
        }
      }
    }
    if(tmp==2*n/3){
      cout <<"Yes\n";
      return 0;
    }
  }
  for(int i=0;i<n;i++){
    mp[a[i]]++;
  }
  if(mp.size()==3){
    tmp=0;
    for(auto i:mp){
      tmp^=i.first;
      if(i.second!=n/3){
        can=false;
      }
    }
    if(can&&tmp==0){
      cout <<"Yes\n";
      return 0;
    }
  }
  cout << "No\n";
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int n, m, t = -1;
vector<vector<int>> adj;
vector<ar<int, 2>> finish_time;
vector<int> topsort_order;
vector<int> parent;
vector<int> visited;

void dfs(int source, int p) {
	t++;
	//cout << "time : " << t << " " << source + 1 << " entered \n";
	parent[source] = p;
	visited[source] = true;
	for (int v : adj[source]) {
		if (v != p && !visited[v]) {
			dfs(v, source);
		}
	}
	t++;
	//cout << "time : " << t << " " << source + 1 << " finished \n";
	finish_time.push_back({t, source});
}

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	cin >> n >> m;
	adj.resize(n);/* finish_time.resize(n)*/; topsort_order.resize(n); parent.assign(n, -1); visited.assign(n, false);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		adj[a].push_back(b);
	}
	for (int i = 0; i < n; i++) {
		if (!visited[i]) {
			dfs(i, -1);
		}
	}
	sort(finish_time.rbegin(), finish_time.rend());
	for (int i = 0; i < n; i++) {
		topsort_order[i] = finish_time[i][1];
	}
	vector<int> longest_path(n, 0);
	int res = 0;
	for (int i = n - 1; i >= 0; i--) {
		int vtx = topsort_order[i];
		longest_path[vtx] = 0;
		for (int v : adj[vtx]) {
			longest_path[vtx] = max(longest_path[vtx], 1 + longest_path[v]);
		}
		res = max(res, longest_path[vtx]);
	}
	// for (int i = 0; i < n; i++) {
	// 	cout << finish_time[i][0] << " " << finish_time[i][1] << endl;
	// }
	// cout << endl;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 16760
def main():
    a, b, c = map(int, input().split())

    eval1 = a + b < c
    eval2 = 4*a*b < a**2 + b**2 + c**2 + 2*a*b - 2*a*c - 2*b*c
    print('Yes' if eval1 and eval2 else 'No')


if __name__ == '__main__':
    main()


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

void chuyenDoiCoSo(char s[], int n) {

	int coSo = 0, soDu = 0;
	cin >> coSo;

	int i = 0;
	while (n > 0) {
		soDu = n % coSo;
		if (soDu < 10) {
			s[i] = '0' + soDu;        
		}
		else {
			s[i] = 'A' + (soDu - 10);    
		}
		i++;
		n = n / coSo;
	}
        s[i] = '\0';
	cout << strlen(s);
}

int main(int argc, char const *argv[]) {
	
	int n = 0;
	char s[100];
	cin >> n;
	
	chuyenDoiCoSo(s, n);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ll mod = 1000000007;

ll pw(ll x, ll y, ll mod) {
    if (y == 0) return 1;
    else if (y == 1) return x % mod;
    else if (y % 2 == 0) {
        ll p = pw(x, y / 2, mod);
        return p * p % mod;
    }
    else {
        ll p = pw(x, y / 2, mod);
        return p * p % mod * x % mod;
    }
}

ll dv(ll x, ll y, ll mod) {
    x %= mod;
    y %= mod;
    return x * pw(y, mod - 2, mod) % mod;
}
 
ll comb(ll n, ll r, ll mod) {
    ll v = 1;
    if (n < r || n < 0 || r < 0) return 0;
    for (int i = 1; i <= r; i++) {
        v = v * dv(n - i + 1, i, mod) % mod;
    }
    return v;
}

int main() {
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    ll v1 = comb(c1 + r2 + 1, r2, mod), ans = 0;
    ll v2 = comb(c1 + r1, r1 - 1, mod);
    
    for (int i = c1; i <= c2; i++) {
        ans = (ans + v1 - v2 + mod) % mod;
        v1 = v1 * dv(i + r2 + 2, i + 2, mod) % mod;
        v2 = v2 * dv(i + r1 + 1, i + 2, mod) % mod;
    }
    cout << ans << endl;
    


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


// 753
signed main(){
  string str;
  cin >> str;
  int n = str.size(), ans = inf;
  int k = 3;
  rep(j, n - k + 1){
    string s = str.substr(j, k);
    ans = min(ans, llabs(753 - atoll(s.c_str())));
  }
  printf("%lld\n", ans);
  return 0;
}

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

namespace ITP1_8_B
{
    public class Program

    {
        public static void Main(string[] args)
        {

            while (true)
            {
                string line = ReadSt();
                if (line == "0") return;

                int rlt = 0;
                for (int i = 0 ; i < line.Length ; i++)
                {
                    rlt += int.Parse(line[i].ToString());
                }
                Console.WriteLine(rlt.ToString());

            }            
          
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 17988
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <set>
#include <utility>
#include <iomanip>
#include <climits>
#include <map>
using namespace std;
#define ll long long
#define MOD 1000000007
#define INF 1000000000000000000
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll stack<ll>
#define qll queue<ll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
int main() 
{ 
    fast_io;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
} 

Measured memory_bytes: 256
s = list(str(input()))

tt = list(sorted(list('abcdefghijklmnopqrstuvwxyz')))
u = []
for i in tt:
    if not (i in s):
        u.append(i)
        
uu = list(sorted(u))

if uu == []:
    print('None')
else:
    print(uu[0])
        

Measured memory_bytes: 3956
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


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

  vector<int> A(N);

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

  int gans = 100*100*N;
  for(int y=-100; y<=100; y++){
    int lans = 0;
    for(int i=0; i<A.size(); i++){
        lans += ((A[i]-y)*(A[i]-y));
    }
    if(lans < gans) gans = lans;
  }

  cout << gans << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
n = int(input())

g = [[] for _ in range(n)]
d = {}
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    d[(a-1,b-1)] = i
    g[a-1].append(b-1)
    g[b-1].append(a-1)
 

def dfs(v,p,j): #p: parent of v
    """
    vでの操作をここに
    """
    num = -1
    for c in g[v]:
        if c == p: continue
        num += 1
        col = (j+num)%m+1
        if c > v: ans[d[(v,c)]] = col
        else: ans[d[(c,v)]] = col
        dfs(c,v,col)

m = max(len(i) for i in g)
ans = [0]*(n-1)

dfs(0,-1,0)

#print(g,m,ans)
print(m)
print(*ans,sep = "\n")




Measured memory_bytes: 77784
#!/usr/bin/env python3
n,m = map(int,input().split())
a = [input() for i in range(n+m)]
bit = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        #if a[i][j][0] != a[n][j][0]: pass
        for k in range(m):
            if a[i+k][j:j+m] !=  a[n+k]: break
            if k == m-1: bit = 1
if bit: print("Yes")
else: print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;
typedef priority_queue<int> PQ;
typedef deque<int> DQ;

int main(){
    int n,k; cin>>n>>k;
    DQ deq;
    for(int i=0; i<n; i++) {
        int tmp; cin>>tmp;
        deq.push_back(tmp);
    }
    int min_nk = min(n,k);
    ll ans = 0;
    for(int a=0; a<=min_nk; a++){
        for(int b=0; b<=min_nk; b++){
            if(a+b <= min_nk){
                ll cnt = 0, tmp;
                DQ v = deq;
                PQ minus;
                for(int i=0; i<a; i++){
                    if(v.empty()) break;
                    tmp = v.front();
                    v.pop_front();
                    cnt += tmp;
                    if(tmp<0) minus.push(tmp*(-1));
                }
                for(int j=0; j<b; j++){
                    if(v.empty()) break;
                    tmp = v.back();
                    v.pop_back();
                    cnt += tmp;
                    if(tmp<0) minus.push(tmp*(-1));
                }
                for(int l=0; l<(k-a-b); l++){
                    if(minus.empty()) break;
                    cnt += minus.top();
                    minus.pop();
                }
                ans = max(ans,cnt);
            }
        }
    }
    OUT(ans);
}

Measured memory_bytes: 256
N = int(input())
s = input()
t = input()
sameLen = 0
for i in range(N):
    if s[i:] == t[: N - i]:
        sameLen = N - i
        break
    else:
        continue
if sameLen == 0:
    print(2 * N)
else:
    print(2 * N - sameLen)

Measured memory_bytes: 3060
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();
        int C = sc.nextInt();
        int K = sc.nextInt();

        int num = 0;
        while (A >= B) {
            B *= 2;
            num++;
        }
        while (B >= C) {
            C *= 2;
            num++;
        }
        System.out.println(num <= K ? "Yes" : "No");
    }
}


Measured memory_bytes: 35704
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void solve() {
	int n, k; cin >> n >> k;
	int nn = n - 1;
	int sup = nn * (nn - 1) / 2;
	if (k > sup) {
		cout << -1 << endl; return;
	}
	vector<vector<bool>> b(nn);
	rep(i, nn)b[i].resize(nn, false);
	int x = 0, y = 1;
	vector<P> ans;
	rep(i, nn) {
		ans.push_back({ i + 1, n });
	}
	while (sup > k) {
		k++;
		ans.push_back({ x+1,y+1 });
		y++;
		if (y == nn) {
			x++; y = x + 1;
		}
	}
	cout << ans.size() << endl;
	rep(i, ans.size()) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int H, W;
	int h, w;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	if (scanf("%d%d", &h, &w) != 2) return 1;
	printf("%d\n", (H - h) * (W - w));
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    int n,m,a[60],b[60],ans[60]={};
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&a[i],&b[i]);
        ans[a[i]-1]++;ans[b[i]-1]++;
    }
    for(int i=0;i<n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


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

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; }
#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
typedef pair<int, int> the;

const int INF = 1 << 29;
const ll LINF = 1LL << 60;

int main()
{
	string s, t;
	cin >> s >> t;
	vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));  //初期化
	//dp[0][0] = 0;  //初期条件済
	//dp
	for (int i = 0; i < (int)s.size(); i++) {
		for (int j = 0; j < (int)t.size(); j++) {
			if (s[i] == t[j])  chmax(dp[i + 1][j + 1], dp[i][j] + 1);
			chmax(dp[i + 1][j + 1], dp[i + 1][j]);
			chmax(dp[i + 1][j + 1], dp[i][j + 1]);
		}
	}

	string ans = "";
	int i = (int)s.size();
	int j = (int)t.size();
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j])  --i;
		else if (dp[i][j] == dp[i][j - 1])  --j;
		else {
			ans = s[i - 1] + ans;
			--i; --j;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 35584
N,K,C=map(int,input().split())
S=input()

mae=[]
rest=0
work=0
for i in range(len(S)):
    if S[i]=='o' and rest==0:
        mae.append(i)
        rest=C
        work+=1
    else:
        rest=max(rest-1,0)
    if work==K:
        break
        
usiro=[]
rest=0
work=0
S=S[::-1]
for i in range(len(S)):
    if S[i]=='o' and rest==0:
        usiro.append(len(S)-i-1)
        rest=C
        work+=1
    else:
        rest=max(rest-1,0)
    if work==K:
        break

usiro=usiro[::-1]

for i in range(K):
    if mae[i]==usiro[i]:
        print(mae[i]+1)

Measured memory_bytes: 102664
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
void solve(int tc){
    int s,w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe";
    else cout<<"safe";
}
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(20);
    int t=1,ctr=0;
    // cin>>t;
    while(t--){
        solve(ctr+1);
        ctr++;
    }
}

Measured memory_bytes: 3640
import sys
from heapq import heappop, heappush
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def dijkstra(start):
    INF = 10 ** 5
    dist = [INF] * (N+1) # dist[0]は使わない
    dist[start] = 0
    que = [(0, start)]
    while que:
        # (d, v) はdが現在の最小の交通費、vが現在の場所
        d, v = heappop(que)
        # 今より安い交通費で既に来たことがある場合、continue
        if dist[v] < d:
            continue
        for next_city, cost in edges[v].items():
            # modeによって円かスヌークを使うか選ぶ
            d1 = d + cost
            # 次の場所の交通費より安くなる場合は、データを更新
            if dist[next_city] > d1:
                dist[next_city] = d1
                heappush(que, (d1, next_city))
    return dist

N, M = rl()
INF = 10 ** 5
edges = [{} for _ in range(N+1)]
for _ in range(M):
    a, b, c = rl()
    edges[a][b] = c
    edges[b][a] = c

answer = 0
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if j not in edges[i]:
            continue
        A = dijkstra(i)
        if A[j] < edges[i][j]:
            answer += 1
            edges[i].pop(j)
            edges[j].pop(i)

print(answer)
# 00


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

vector<int>g[100001];
int vis[100001];

void dfs(int node)
{
    vis[node]=1;

    for(int child : g[node])
    {
        if(vis[child]==0) dfs(child);
    }
}

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

    for(int i=1;i<=m;i++)
    {
        cin>>a>>b;
        
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int c=0;

    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0) 
        {
            dfs(i);
            c++;
        }
    }

    cout<<c-1<<"\n";
}

Measured memory_bytes: 9996
def depth(s, time):
    time += 1
    flag[s] = 1
    d[s] = time
    for i in range(1, n+1):
        if G[s][i] == 1:
            if flag[i] == 0:
                depth(i, time)
                time = f[i]
    f[s] = time + 1
 
n = int(raw_input())
G = [[0 for i in range(n+1)] for j in range(n+1)]
d = [0 for i in range(n+1)]
f = [0 for i in range(n+1)]
 
for i in range(n):
    v = map(int, raw_input().split())
    for j in range(v[1]):
        G[v[0]][v[2+j]] = 1
 
flag = [0 for i in range(n+1)]
for i in range(1, n+1):
    if flag[i] == 0:
        depth(i, max(f))
 
for i in range(1, n+1):
    print(str(i) + " " + str(d[i]) + " " + str(f[i]))

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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> A(N);
    for(auto& i : A)cin >> i;
    unsigned long l{accumulate(A.begin(), A.end(), 4 * M - 1) / (M * 4)};
    puts(count_if(A.begin(), A.end(), [&l](auto i){return i >= l;}) >= M ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;

    vector<int> a(n);
    map<int,int> p;
    rep(i,0,a.size())
    {
        cin>>a[i];
        p[a[i]]++;
    }
    vector<int> ans;
    rep(i,0,a.size())
    {
       p[a[i]]--;
       map<int,int>::iterator it = p.end();
        it--;
       if ( it->sd == 0 )
       {
           it--;
           ans.pb(it->ft);
       } 
       else
       {
           ans.pb(it->ft);
       }
       p[a[i]]++;
    }

    rep(i,0,ans.size())
    {
        cout<<ans[i]<<endl;
    }


}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 12272
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
//AtCoderC++.cpp

using namespace std;


inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}

int main() {
	char a, b; cin >> a >> b;
	cout << (a == b ? 'H' : 'D') << endl;
}

Measured memory_bytes: 256
q = int(input())
u = []
for i in range(q):
    u.append(list(map(int,input().split())))

import math
def sosu(n):
    k = 0
    if n == 1:
        return 0
    if n == 2:
        return 1
    elif n%2 == 0:
        return 0
    else:
        for i in range(3,math.floor(n**(0.5))+1,2):
            if n%i == 0:
                k += 1
        if k == 0:
            return 1
        else:
            return 0

v=[3]
for j in range(25000):
    if sosu(4*j+1)*sosu(2*j+1)==1:
        v.append(4*j+1)

t = []
for i in range(50000):
    if 2*i+1 in v:
        t.append(1)
    else:
        t.append(0)

s = [0]
for i in range(50000):
    s.append(t[i]+s[i])

for k in u:
    l = k[0]
    r = k[1]
    print(s[int((r+1)/2)]-s[int((l-1)/2)])

Measured memory_bytes: 70744
#include<iostream>

int main (void) {
  int N, P;
  int A[110];
  std::cin >> N >> P;

  int i;
  int odd = 0;
  int even = 0;
  for (i=0;i<N;i++) {
    std::cin >> A[i];
    if (A[i]%2==1) {
      odd++;
    } else {
      even++;
    }
  }

  // if (P%2==1) {                                                                                    
  //   odd--;                                                                                         
  // }                                                                                                

  long long int ans;
  if (odd==0 && P==1) {
    ans = 0;
  } else {
    ans = 1;
    if (odd>1) {
      for (i=0;i<(odd-1);i++) {
        ans *= 2;
      }
    }
    for (i=0;i<even;i++) {
      ans *= 2;
    }
  }

   std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n = int(input())
    nana = 7
    for i in range(n):
        if nana % n == 0:
            print(i+1)
            exit()
        nana = (nana * 10 + 7) % n
    print(-1)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def bfs(H, W, black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d + 1
                black_cells.append((new_h, new_w))
    return d


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 77480
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db long double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi totor<int>
#define vl totor<ll>
#define rep(i, x, y) for(register int i = x; i <= y; i ++)
#define rrep(i, x, y) for(register int i = x; i >= y; i --)
#define eps 1e-15
#define lb(x) x & -x
#define sz(x) (x).size()
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 * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll 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 * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
ll f(ll A, ll B)
{
    ll lim = A*B;
    ll l = 0, r = B;
    while (r - l > 1)
    {
        ll mid = (l + r) / 2;
        bool f = true;
        if (mid * (A + 1) >= lim)f = false;
        ll x = (A + mid + 1) / 2;
        for (ll xx = x - 2; xx < x + 3; ++xx) {
            if (xx >= 1 && xx <= mid) {
                ll y = xx * (A + 1 + mid - xx);
                if (y >= lim)f = false;
            }
        }
        (f ? l : r) = mid;
    }
    return l;
}

int main()
{
    int Q = read();
    while (Q --)
    {
        ll A, B;
        A = read1();
        B = read1();
        ll bb = f(A, B);
        ll aa = f(B, A);
        ll ans = aa + bb;
        ll x = B - bb - 1, y = A - aa - 1;
        ans += max(0ll, min(x, y));
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

int main(){
  ll N;
  cin>>N;
  ll a[N];
  ll sum=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum+=a[i];
  }
  ll x=N*(N+1)/2, k=sum/x;
  bool flag=(sum%x==0);
  for(int i=0;i<N;i++){
    ll d=a[(i+1)%N]-a[i]-k;
    flag&=(d<=0&&d%N==0);
  }
  cout<<(flag?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
const ll MAX_N = 1e5;

Vec t(MAX_N+1, LINF);

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

	Vec a;
	a.pb(1);
	ll m = 6;
	while(m <= n){
		a.pb(m);
		m *= 6;
	}
	m = 9;
	while(m <= n){
		a.pb(m);
		m *= 9;
	}
	sort(all(a));

	ll cnt = 1;
	for(ll i : a) t[i] = cnt;
	while(t[n] == LINF){
		cnt++;
		repnr(i, n){
			if(t[i] != LINF){
				for(ll j : a){
					if(i+j > n) break;
					t[i+j] = min(t[i+j], cnt);
				}
			}
		}
	}
	co(t[n]);

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll                      long long int
#define pb                      push_back
#define mp                      make_pair
#define in                      insert
#define all(x)                  (x).begin(),(x).end() 
#define rep(i,a,n)              for(int i=0;i<n;++i)
#define per(i,a,n)              for(int i=n-1;i>=0;--i)
#define mod                     1000000007
using namespace std;

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin>>n;
    int m;
    cin>>m;
    int a[n];
    rep(i,0,m) cin>>a[i];
    int sum=0;
    rep(i,0,m) sum+=a[i];
    if(sum>n){
    	cout<<-1<<'\n';
    }
    else{
    	cout<<n-sum<<'\n';
    }
    
    return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	string s;
	cin >> s;
	int a = 0;
	for (int i = 0;i < 4;i++) {
		if (s[i] == '+') a++;
		else a--;
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        int inputCount = int.Parse(Reader.ReadLine());

        long[] list = Reader.GetLongs();
        string ans = "YES";
        if(list.Count(a=>a%2>0)%2>0) {
            ans = "NO";
        }
        Console.WriteLine(ans);

    }





    public class Reader {
        public static bool IsDebug = true;

        public static long[] GetLongs(char delimiter) {
            string inpt = Reader.ReadLine();
            return inpt.Split(delimiter).Select(a=>long.Parse(a)).ToArray();
        }

        public static long[] GetLongs() {
            return GetLongs(' ');
        }
        private static System.IO.StringReader SReader;
        private static string InitText = @"


5
1 2 3 4 5


";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 14552
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
typedef double D; 
typedef complex<D> P;  
typedef pair<P, P> L;  
typedef vector<P> VP;
typedef vector<VP> Vcon;

const D EPS = 1e-10;

#define X real()
#define Y imag()

D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) { return (conj(a)*b).Y;}

int ccw(P a,P b,P c){
  b-=a;c-=a;
  if(cross(b,c) >  EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) <   -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

P proj(P a1, P a2, P p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

bool isecSP(P a1, P a2, P b) {
  return !ccw(a1, a2, b);
  //return abs(a1 - b) + abs(a2 - b) - abs(a2 - a1) < EPS;  //Perfective
}

bool isecSS(P a1,P a2,P b1,P b2){
  return ccw(a1,a2,b1)*ccw(a1,a2,b2) <= 0   && ccw(b1,b2,a1)*ccw(b1,b2,a2) <=0;
}

D distSP(P a1, P a2, P p) {
  P r = proj(a1, a2, p);
  if (isecSP(a1, a2, r)) return abs(r-p);
  return min(abs(a1-p), abs(a2-p));
}

D distSS(P a1,P a2,P b1,P b2){
  if(isecSS(a1,a2,b1,b2)) return 0;
  return min( min(distSP( a1,a2,b1) , distSP(a1,a2,b2) ), min(distSP( b1,b2,a1),distSP( b1,b2,a2)));
}

int main(){
  int A,B;
  vector<P>v1,v2;
  
  v1.push_back(P(0,0));
  v2.push_back(P(0,1000));

  cin>>A;
  rep(i,A){
    D x,y;
    cin>>x>>y;
    v1.push_back(P(x,y));
  }

  cin>>B;
  rep(i,B){
    D x,y;
    cin>>x>>y;
    v2.push_back(P(x,y));
  }

  v1.push_back(P(1000,0));
  v2.push_back(P(1000,1000));

  A=v1.size();
  B=v2.size();

  double ans=1e10;
  
  for(int i=0;i<A-1;i++){
    for(int j=0;j<B-1;j++){
      // cout<<ans<<endl;
      ans = min( ans , distSS( v1[i],v1[i+1],v2[j],v2[j+1] ) );
    }
  }

  printf("%.9f\n",ans);
  
}


Measured memory_bytes: 3360
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli dp[3][100010];

signed main(){

	lli n;
	cin>>n;
	map<lli,vector<lli>> d;
	REP(i,0,n){
		lli a,b,c;
		cin>>a>>b>>c;
		d[0].push_back(a);
		d[1].push_back(b);
		d[2].push_back(c);
	}


	REP(i,0,3)REP(j,0,100010)dp[i][j]=0;

	REP(i,0,3){
		dp[i][0]=d[i][0];
		if(DEBUG)cout<<dp[i][0]<<" ";
	}

	if(DEBUG)cout<<endl;

	for(lli i=1;i<n;i++){/*深さ*/
		for(lli j=0;j<3;j++){//今の行動
			for(lli k=0;k<3;k++){//前の行動
				if(j==k)continue;
				dp[j][i] = max(dp[j][i],dp[k][i-1]+d[j][i]);
			}
			if(DEBUG)cout<<dp[j][i]<<" ";
		}
		if(DEBUG)cout<<endl;
	}

	lli ans=0;
	REP(i,0,3)ans = max(ans,dp[i][n-1]);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    int W,a,b;
    cin >> W >> a >> b;
    if (a <= b) {
        cout << max(0,b - a - W) << endl;
    }
    else {
        cout << max(0,a - b - W) << endl;
    }
}



Measured memory_bytes: 3596
s = input()
slist = [int(ss) for ss in s]
slen = len(slist)

result = 99999999999999999


for i in range(0, slen - 2):
    ssum = slist[i] * 100 + slist[i+1] * 10 + slist[i+2]
    result = min(abs(ssum - 753), result)

print(result)


Measured memory_bytes: 2940
#include"bits/stdc++.h"
using namespace std;

void Main() {
	int A, B, K;
	cin >> K >> A >> B;
	bool isOK = false;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			isOK = true;
			break;
		}
	}
	if (isOK) {
		cout << "OK";
	}
	else {
		cout << "NG";
	}
	cout << endl;
}

int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        string[] inpt = Console.ReadLine().Split(' ');
        int x = int.Parse(inpt[0]);
        int y = int.Parse(inpt[1]);

        List<int> yakusu = this.GetYakusu(x);
        yakusu.Sort();
        for(int i=yakusu.Count-1; i>=0; i--)
        {
            if(y % yakusu[i] == 0)
            {
                Console.WriteLine(yakusu[i]);
                return;
            }
        }
        Console.WriteLine("-1");
    }

    private List<int> GetYakusu(int src)
    {
        List<int> ret = new List<int>();
        int tmp = src;
        for(int i=1; i<=src; i++)
        {
            if(i>tmp)
            {
                break;
            }
            if(src % i == 0)
            {
                ret.Add(i);
                tmp = src / i;
                ret.Add(tmp);
            }
        }
        return ret;
    }

    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 9228
#include<bits/stdc++.h>
#define INF 1000000000000000
using namespace std;
template <typename T> T Max(T x,T y){return x>y?x:y;}
int n,k,c[5005],p[5005];
short g[5005][5005];
long long ans=-INF,f[5005][5005];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&c[i]);
	
	for(int i=1;i<=n;i++)
	{
		g[i][0]=i;
		f[i][0]=0;
		for(int j=1;j<=min(n,k);j++)
		{
			g[i][j]=p[g[i][j-1]];
			f[i][j]=f[i][j-1]+(long long)c[g[i][j]];
			ans=Max(ans,f[i][j]);
		}
	}
	
	if(k<=n)
	{
		cout<<ans<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		int j=1;
		while(g[i][j]!=i) j++;
		for(int l=0;l<=k%j;l++)
			ans=Max(ans,(k/j)*f[i][j]+f[i][l]);
		for(int l=0;l<j;l++)
			ans=Max(ans,(k/j-1)*f[i][j]+f[i][l]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 248144
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    X = list(map(int, readline().split()))
    ans = INF

    for i in range(1, 101):
        score = 0
        for x in X:
            score += (x - i) ** 2
        ans = min(ans, score)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63528
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 50;
const long long mod_const = 1e9 + 7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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; }

using pll = pair<long long, long long>;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
		
	ll N;
	string S;
	cin >> N >> S;

	if (N % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}

	bool same = true;
	for (int i = 0; i * 2 < N; ++i) {
		if (S[i] != S[i + N/2]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000000)

N,X,Y=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

memo={}
def func(n,last,turn):  #n:カードの残り枚数、last:前の手番が最後に引いたスコア、turn: 0先手の番 1後手の番
    #print "func(",n,",",last,",",turn,")"
    if (n,turn) in memo:    #カードの残り枚数と、どちらの手番かで最終スコアはいつも同じ
        return memo[(n,turn)]
    if n==1:
        ret=abs(last-A[N-n])
    elif turn==0:
        ret=max( func(n-1,last,0) , func(n-1,A[N-n],1) ) #手番がXのまま  手番がYに移動
    elif turn==1:
        ret=min( func(n-1,last,1) , func(n-1,A[N-n],0) ) #手番がYのまま  手番がXに移動
    memo[(n,turn)]=ret
    return ret


print func(N,Y,0)

Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
	ios;
	int n,x,t,c=0;
	cin>>n>>x>>t;
	if(n%x!=0)  c++;
	c+=n/x;
	cout<<t*c;
	return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        System.out.println(calc(a, b, c));
//        test();
    }

    private static long calc(long a, long b, long c) {
        long [] array = new long[]{a, b, c};
        Arrays.sort(array);
        if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
            return 0;
        } else {
            return array[0] * array[1];
        }
    }

    private static void test() {
        assert calc(3, 3, 3) == 9 : "calc(3, 3, 3) == 9";
        assert calc(2, 2, 4) == 0 : "calc(2, 2, 4) == 0";
        assert calc(5, 3, 5) == 15 : "calc(5, 3, 5) == 15";
    }
}


Measured memory_bytes: 9812
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3836
#include <iostream>

int main(int argc, char *argv[]) {
	int ubase = 0;
	int base = 0;
	int height = 0;

	std::cin >> ubase;
	std::cin >> base;
	std::cin >> height;

	std::cout << ((ubase + base) * height) / 2 << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

ll solve(ll a, ll b) {
    if (a == b) return (a - 1) * 2;
    ll limit = a * b - 1;
    ll low = 1, high = 1LL << 31;
    ll rv;
    while (low <= high) {
        ll mid = (low + high) / 2;
        ll x = (mid + 1) / 2;
        if(x * (mid + 1 - x) <= limit) {
            rv = mid;
            low = mid + 1;
        }
        else 
            high = mid - 1;
    }
    return rv - 1;
}

int main() {
    int q;
    scanf("%d", &q);
    while (q--) {
        long long a, b;
        cin >> a >> b;
        cout << solve(a, b) << endl;
    }
}

Measured memory_bytes: 256
import math
a, b, C = map(float, input().split())
rad = (C/180)*math.pi
S = 0.5*a*b*math.sin(rad)
print(S)
L = a + b + math.sqrt(a*a + b*b - 2*a*b*math.cos(rad))
print(L)
h = (S / a)*2
print(h)


Measured memory_bytes: 5692
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string a[7]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
  string b;
  cin>>b;
  for(int i=0;i<7;i++){
    if(a[i]==b){
      cout<<i+1<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main(){

	int N,d[105],ans,c=0;

	cin >> N;

	for(int i=0; i<N; i++){

		cin >> d[i];

	}
	sort(d,d+N);

	
	for(int i=0; i<N-1; i++){

		if(d[i] ==d[i+1]) c++;

	
	}

	cout << N-c <<endl;

}

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

using namespace std;

int x, y;

bool valid(int x) {
	return (x != 0) && (x <= 12);
}

int main() {
	scanf("%2d%2d", &x, &y);
	
	if (valid(x) && valid(y)) printf("AMBIGUOUS\n");
	else if (valid(x)) printf("MMYY\n");
	else if (valid(y)) printf("YYMM\n");
	else printf("NA\n");
}


Measured memory_bytes: 256