akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

typedef long long ll;

#define pb push_back
#define rep(i, n) for(int i=0;i<(n);i++)
#define REP(i, n) for(int i=1;i<=(n);i++)
#define P pair<int,int>
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int mx8[] = {0, 0, 1, -1, -1, 1, -1, 1};
int my8[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int mx4[] = {1, -1, 0, 0};
int my4[] = {0, 0, -1, 1};

const int MOD = 1000000007;

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

    int n; cin >> n;
    vector<ll> x(n),y(n),h(n);
    rep(i,n) cin >> x[i] >> y[i] >> h[i];
    bool ok;

    for(ll cx = 0; cx <= 100; cx++)
    {
        for(ll cy = 0; cy <= 100; cy++)
        {
            ok = false;

            ll H, minH = 1e18, maH = 0, miH = 1e18;
            for(int i = 0; i < n; ++i)
            {
                H = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
                if(h[i])
                {
                    chmin(miH,H);
                    chmax(maH,H);
                }
                else
                {
                    chmin(minH,H);
                }
            }
            if(miH == maH && miH <= minH) ok = true;
            if(ok)
            {
                cout << cx << " " << cy << " " << miH << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define int long long
#define F first
#define S second
#define endl "\n"
using namespace std;

const int nax = 3e5+5;
const int inf = 1e18+7;
const int mod = 1e9+7;

int n,m;
int a[nax], b[nax];
vector<int>adj[nax];

/*
 * DO SOMETHING RATHER THAN DOING NOTHING
 * */
int dp[nax][101];

signed main(){
    fast;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cin>>b[i];
    }

    memset(dp, 0, sizeof(dp));

    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = dp[i][j-1];
            if(a[j]<=i){
                dp[i][j] = max(dp[i][j], dp[i-a[j]][j-1]+b[j]);
            }
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans = max(ans, dp[m][i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 247312
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define MAXN 105
using namespace std;

struct information
{
	int x;
	int y;
	int height;
};

int main()
{
	int h;
	int H = 0;
	int n;
	int flg = 1;
	int l;
	int count=0;
	cin >> n;
	int p;
	information info[MAXN];
	for (int i = 0; i<n; i++){
		cin >> info[i].x >> info[i].y >> info[i].height;
	}
	for (int i = 0; i<101; i++){
		for (int j = 0; j<101; j++){
		    for(p=0;info[p].height==0;p++);
            h = info[p].height + abs(i - info[p].y) + abs(j - info[p].x);
		    for(int k=0;k<n;k++){
                if(info[k].height!=max(h - abs(j - info[k].x) - abs(i - info[k].y), 0)) flg=0;
		    }
		    if(flg==1){
                cout << j<<" " << i <<" "<< h;
				break;
		    }
		    flg=1;
		}
	}
	return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  ll ans = 0;
  for(int i=0; i<n; i++) {
    if(i==n-1) {
      ans += a[i]/2;
    } else {
      ans += a[i]/2;
      a[i] = a[i]-(a[i]/2)*2;
      ans += min(a[i],a[i+1]);
      a[i+1] = a[i+1]-min(a[i], a[i+1]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
H, W = map(int,input().split())
S = []
for _ in range(H):
    S.append(input())

L = [[0]*W for _ in range(H)]
U = [[0]*W for _ in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            L[h][w] = 0
        elif w == 0:
            L[h][w] = 1
        else:
            L[h][w] = L[h][w-1] + 1
        
        if S[h][w] == "#":
            U[h][w] = 0
        elif h == 0:
            U[h][w] = 1
        else:
            U[h][w] = U[h-1][w] + 1

R = [[0]*W for _ in range(H)]
D = [[0]*W for _ in range(H)]
for h in range(H-1, -1, -1):
    for w in range(W-1, -1, -1):
        if S[h][w] == "#":
            R[h][w] = 0
        elif w == W-1:
            R[h][w] = 1
        else:
            R[h][w] = R[h][w+1] + 1

        if S[h][w] == "#":
            D[h][w] = 0
        elif h == H-1:
            D[h][w] = 1
        else:
            D[h][w] = D[h+1][w] + 1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, L[h][w]+R[h][w]+U[h][w]+D[h][w]-3)

print(ans)

Measured memory_bytes: 202044
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>

#define REP(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;

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

    string aa = to_string(a);
    string bb = to_string(b);
    string ab = aa+bb;    
    int num = atoi(ab.c_str());

    int sqr = sqrt(num);

    if((sqr * sqr == num) && (num / sqr) == sqr  && (num % sqr) == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

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

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

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
bool compare_by_b(pair<long, long> a, pair<long, long> b){
    return a.second < b.second;
}

ll distance(ll k, ll l, ll z){
    return abs(k - z) + abs(k+l);
}
int main(){
    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll>s(a), t(b), x(q);
    rep(i, a)cin >> s[i];
    rep(i, b)cin >> t[i];
    rep(i, q)cin >> x[i];
    s.push_back(-1000000000000000000);
    t.push_back(-1000000000000000000);
    s.push_back(1000000000000000000);
    t.push_back(1000000000000000000);

    sort(ALL(s));
    sort(ALL(t));


    rep(i, q){
        ll shr[2], tra[2];
        shr[0] = lower_bound(ALL(s), x[i]) - s.begin();
        shr[1]= shr[0]-1;
        tra[0] = lower_bound(ALL(t), x[i]) - t.begin();
        tra[1]= tra[0]-1;

        ll ans = 1000000000000000000;
        rep(k, 2)rep(l, 2){
            ll res1 = abs(s[shr[k]] - x[i]) + abs(t[tra[l]]- s[shr[k]]);
            ll res2 = abs(t[tra[k]] - x[i]) + abs(s[shr[l]]- t[tra[k]]);
            ans = min(ans, min(res1, res2));
        }
        cout << ans << endl;
    }


}

Measured memory_bytes: 3680
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
struct Data
{
	ll a,b;
}a[100005];
int n;
ll ans;
bool cmp(Data a,Data b)
{
	return a.a+a.b>b.a+b.b;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%lld%lld",&a[i].a,&a[i].b);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		if(i&1)ans+=a[i].a;
		else ans-=a[i].b;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
nums = [int(e) for e in input().split()]
STR1=[]
STR2 = []
count = 0
ans = 0
for i in range(nums[0]):
    s=input()
    t = len(s)
    STR1.append(s)
for k in range(nums[1]):
    s = input()
    u = len(s)
    STR2.append(s)
for i in range(nums[0] - nums[1] +1):
    for k in range(t-u+1):
        if(STR2[0][0] == STR1[i][k]):
            count = 0
            for j in range(nums[1]):
                for l in range(u):
                    if(STR2[j][l] != STR1[i+j][k+l]):
                        break
                else:
                    count += 1
            if(count == nums[1]):
                ans += 1
if(ans == 0):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 40432
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct aa {
	int x;
	int y;
	int time;

	const bool operator<(const aa&a)const  {
		return time>a.time;
	}
};

int main() {
	int N;cin>>N;
	vector<pair<int,int>>ps;

	vector<int>valid(31);

	
	for (int i = 0; i < N; ++i) {
		int a,b;cin>>a>>b;
		ps.emplace_back(a-1,b-1);
		for (int k = a - 1; k <= b - 1; ++k) {
			valid[k]=true;
		}
	}

	int ans=accumulate(valid.begin(),valid.end(),0);

	sort(ps.begin(),ps.end());

	priority_queue<int,vector<int>,greater<int>>que;

	for (int i = 0; i < 31; ++i) {
		for (auto p : ps) {
			if (p.first == i) {
				que.push(p.second);
			}
		}

		while (!que.empty()) {
			int now=que.top();
			que.pop();
			if(now==i-1)continue;
			else {
				ans++;
				break;
			}
		}
	}
	cout<<ans*50<<endl;
	return 0;
}


Measured memory_bytes: 3160
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
const int maxn=30005;
int a[maxn];
int main(){
	int n;
	long long sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	printf("%lld\n",sum-n);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<unordered_map>
#include<math.h>

using namespace std;
typedef long long ll;

#define INF 10e+11 + 7

int main(){
	string S1, S2, S3;
	cin>>S1>>S2>>S3;
	char turn = 'a';
	char last;
	while(1){
		switch(turn){
			case 'a':if(S1.empty()){cout<<'A'<<endl;return 0;}turn = S1.front();S1.erase(S1.begin());break;
			case 'b':if(S2.empty()){cout<<'B'<<endl;return 0;}turn = S2.front();S2.erase(S2.begin());break;
			case 'c':if(S3.empty()){cout<<'C'<<endl;return 0;}turn = S3.front();S3.erase(S3.begin());break;
		}
	}
	
	return 0;
}

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

using namespace std;

int main() {
  vector<string> S(3);
  for (int i = 0; i < 3; i++) cin >> S[i];
  int player = 0;

  while (true) {
    if (S[player].empty()) {
      break;
    }

    int next = S[player][0] - 'a';
    S[player] = S[player].substr(1);
    player = next;
  }

  cout << char('A' + player) << "\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

string S[6]={"abc", "acb", "bac", "bca", "cab", "cba"};
 
int main(){
  string s;
  cin >> s;

  for(int i=0; i<6; i++){
    if(s==S[i]){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////


int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    vector<int> b = a;
    sort(all(b));
    int d = 0;
    for(int i=0; i<n; i++) {
        if(a[i] != b[i]) d++;
    }
    if(d == 2 || d == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

// EOF



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        Deque<String> list = new ArrayDeque<>();

        for (int i = 0; i < n; i++) {
            String sp = br.readLine();
            if (sp.startsWith("insert")) {
                list.addFirst(sp.substring(sp.indexOf(" ") + 1));
            }else if (sp.equals("deleteFirst")) {
                list.removeFirst();
            } else if (sp.equals("deleteLast")) {
                list.removeLast();
            } else if (sp.startsWith("delete")) {
                list.remove(sp.substring(sp.indexOf(" ") + 1));
            }
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringBuilder ans = new StringBuilder();
        ans.append(list.poll());
        for (String s : list) {
            ans.append(" ");
            ans.append(s);
        }
        bw.write(ans.toString());
        bw.newLine();
        bw.close();
        br.close();
    }
}



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

using namespace std;

vector< int > g[100000];
int dist[100000], ans[100000];

void dfs1(int idx, int par)
{
  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs1(to, idx);
    dist[idx] = max(dist[idx], dist[to] + 1);
  }
}

void dfs2(int idx, int d_par, int par)
{
  vector< pair< int, int > > d_child;
  // d_child.emplace_back(0, -1);
  for(int &to : g[idx]) {
    if(to == par) d_child.emplace_back(d_par + 1, to);
    else d_child.emplace_back(dist[to] + 1, to);
  }
  sort(d_child.rbegin(), d_child.rend());
  ans[idx] = d_child[0].first;
  for(int &to : g[idx]) {
    if(to == par) continue;
    dfs2(to, d_child[d_child[0].second == to].first, idx);
  }
}

int main()
{
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  if(N == 2) {
    cout << 1 << endl << 1 << endl;
    return (0);
  }

  int root = 0;
  for(int i = 0; i < N; i++) if(g[i].size() >= 2) root = i;
  dfs1(root, -1);
  dfs2(root, 0, -1);
  for(int i = 0; i < N; i++) {
    cout << (N - 1) * 2 - ans[i] << endl;
  }
}

Measured memory_bytes: 26456
n,m = map(int,input().split())
WA = [0]*n
AC  = [0]*n
wa = 0
for i in range(m):
    x = input().split()
    x[0] = int(x[0])
    if x[1] == 'WA' and AC[x[0]-1] == 0:
        WA[x[0]-1] += 1
    elif x[1] == 'AC' and AC[x[0]-1] == 0:
        AC[x[0]-1] += 1
        wa += WA[x[0]-1]
print(sum(AC),wa)  

Measured memory_bytes: 4596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back


int main(void){
  int n, m, p;
  while(cin >> n >> m >> p, n+m+p){
    int sum = 0;
    int x[128];
    m--;
    rep(i,n){
      cin >> x[i];
      sum += x[i];
    }
    sum*=(100-p);
    if( x[m] == 0){
      cout << 0 << endl;
    }else{
      cout << sum/x[m] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3044
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[4];
int ff()
{
	for(int i=0;i<4;i++)
		{
			a[i]=a[i]-48;
		}
}
int main()
{
	for(int i=0;i<4;i++)
		cin>>a[i];
		ff();
		if(a[0]+a[1]+a[2]+a[3]==7)
		printf("%d+%d+%d+%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]-a[1]-a[2]-a[3]==7)
		printf("%d-%d-%d-%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]+a[1]+a[2]-a[3]==7)
		printf("%d+%d+%d-%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]-a[1]-a[2]+a[3]==7)
		printf("%d-%d-%d+%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]+a[1]-a[2]-a[3]==7)
		printf("%d+%d-%d-%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]-a[1]+a[2]+a[3]==7)
		printf("%d-%d+%d+%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]-a[1]+a[2]-a[3]==7)
		printf("%d-%d+%d-%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]+a[1]-a[2]+a[3]==7)
		printf("%d+%d-%d+%d=7\n",a[0],a[1],a[2],a[3]);
} 

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  for(int i=1;i<=b;i++){
    if(a*i%b==c){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
using namespace std;

int main()
{
	int min, max, ans = 0;
	string b;

	cin >> min >> max;
	for (int i = min; i <= max; i++) {
		b = to_string(i);
		if (b[0] == b[4] && b[1] == b[3]) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)
#define mid (l+r>>1)

using namespace std;
const int N=200005;
int n,a[N],m;
int s[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

bool check(int x)
{
	rep(i,1,m) s[i]=(a[i]>x);
	int p,q;
	rep(i,n,m) if(s[i]==s[n]) q=i; else break;
	repd(i,n,1) if(s[i]==s[n]) p=i; else break;
	if(q-p) return !s[n];
	p=n+1;
	while(p<m)
	{
		if(s[p]==s[p+1]) break;
		++p;
	}
	q=n-1;
	while(q>1)
	{
		if(s[q]==s[q-1]) break;
		--q;
	}
	if(p<m && q>1)
	{
		if(!s[q] && !s[p]) return 1;
		if(s[q] && s[p]) return 0;
		if(s[q] && !s[p]) return p-n<n-q;
		if(!s[q] && s[p]) return p-n>n-q;
	}
	if(p==m && q==1) return !s[1];
	return p<m?!s[p]:!s[q];
}

int main()
{
	n=getint(),m=2*n-1;
	rep(i,1,m) a[i]=getint();
	int l=1,r=m;
	while(l<=r) check(mid)?r=mid-1:l=mid+1;
	printf("%d\n",r+1);
	return 0;
}

Measured memory_bytes: 1792
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100000];
LL Q;
LL B[100000],C[100000];

LL ans[100000];

void solve(){
	//数iの数をnum[i]とおく
	LL sum = 0;
	map<LL,LL> num;
	for(int i=0;i<N;i++){
		sum += A[i];
		num[A[i]]++;
	}
	for(int i=0;i<Q;i++){
		sum = sum + (C[i]-B[i])*num[B[i]];
		ans[i] = sum;
		num[C[i]] += num[B[i]];
		num[B[i]] = 0;
	}
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    cin >> Q;
	for(int i=0;i<Q;i++) cin >> B[i] >> C[i];

    solve();

    for(int i=0;i<Q;i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 12104
s = input()
ans = 0
for i in range(0,3,2):
  if s[i] == "0" and s[i+1] == "0":
    continue
  elif s[i] == "0":
    ans += i+1
  elif (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2"):
    ans += i+1
if ans == 1:
  print("MMYY")
elif ans == 3:
  print("YYMM")
elif ans == 4:
  print("AMBIGUOUS")
else:
  print("NA")

Measured memory_bytes: 9036
def hoge():
    import sys
    input = lambda : sys.stdin.readline().rstrip()
    sys.setrecursionlimit(max(1000, 10**9))

    from collections import defaultdict
    n = int(input())
    ns = defaultdict(set)
    for _ in range(n-1):
        u,v = map(int, input().split())
        ns[u-1].add(v-1)
        ns[v-1].add(u-1)


    M = 10**9+7 # 出力の制限
    N = n # 必要なテーブルサイズ

    g1 = [None] * (N+1) # 元テーブル
    g2 = [None] * (N+1) #逆元テーブル
    inverse = [None] * (N+1) #逆元テーブル計算用テーブル
    g1[0] = g1[1] = g2[0] = g2[1] = 1
    inverse[0], inverse[1] = [0, 1] 

    for i in range( 2, N + 1 ):
        g1[i] = ( g1[i-1] * i ) % M 
        inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
        g2[i] = (g2[i-1] * inverse[i]) % M 


    ans = {}
    prevs = {}
    out = [None] * n
    def sub(i, j, prev):
        prevs[i,j] = prev
        if (i,j) in ans:
            return ans[i,j]
        if len(ns[j])==1 and i in ns[j]:
            ans[i,j] = (1, 1)
            return (1, 1)

        count = 1
        sum_size = 0
        for k in ns[j]:
            if k==i:
                continue
            val, size = sub(j, k, i)
            count = (count * val) % M
            count = (count * g2[size]) % M
            sum_size += size
        count = (count * g1[sum_size]) % M
        ans[i,j] = (count, sum_size+1)
        return (count, sum_size+1)

    def sub2(i, j, q):
        for k in ns[j]:
            if k==i:
                continue
            if (k, j) in ans:
                continue
            tmp_count, tmp_size = ans[j, k]
            total_count, total_size = ans[prevs[j, k], j]
            prev_count, prev_size = ans[j, i]
            new_size = total_size - tmp_size + prev_size
            new_count = (total_count * g2[total_size-1] * g1[new_size-1]) % M
            new_count = (new_count * prev_count * pow(tmp_count, M-2, M)) % M
            new_count = (new_count * g2[prev_size] * g1[tmp_size]) % M
            ans[k, j] = (new_count, new_size)
            val = tmp_count
            val = (val * new_count * g1[new_size+tmp_size-1] * g2[tmp_size-1] * g2[new_size]) % M
            out[k] = val
            q.appendleft((j, k))
#             sub2(j, k)
    #         print("total: ", total_count, total_size)
    #         print("tmp: ", tmp_count, tmp_size)
    #         print("prev: ", prev_count, prev_size)
    #         new_count = total_count / g1[total_size-1] * g1[new_size-1] * prev_count / tmp_count / g1[prev_size] * g1[tmp_size]
    #         print(new_count)
    #         print("")

    # 0を始点として木DP
    sub(-1, 0, None)

    ans[0, -1] = (1,0)

    # 逆向きを求める
    from queue import deque
    q = deque()
    q.appendleft((-1, 0))
    while q:
        u, v = q.pop()
        sub2(u, v, q)
    
    u = 0
    count = 1
    sum_size = 0
    for k in ns[u]:
        val, size = ans[u, k] # sub(u, k, None)
        count = (count * val) % M
        count = (count * g2[size]) % M
        sum_size += size
    count = (count * g1[sum_size]) % M
    out[0] = count
    return out
out = hoge()
print("\n".join(map(str, out)))

Measured memory_bytes: 248624
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;


int main() {
	int N;
	vector <int> X(1000);
	int count = 0;
	int count2 = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X.at(i);
	}

	for (int i = 0; i < N; i++) {
		if (X.at(i) % 2 == 0) {
			count++;
			if (X.at(i) % 3==0   || X.at(i) % 5 == 0) {
				count2++;
			}

		}

	}
	if (count == count2) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{int f=0,n;int i,j;
 cin>>n;
 for(i=0;i<=25;i++)
 for(j=0;j<=14;j++)
 if(n==4*i+7*j)
 f=1;
 if(f)
 cout<<"Yes";
 else cout<<"No";
	
	
}

Measured memory_bytes: 256
from fractions import gcd
#X=b_k*(2p+1)
N,M=map(int,input().split())
b=[int(i)//2 for i in input().split()]
def v2(n):
    tmp=n
    res=0
    while(tmp>0):
        if tmp%2==0:
            tmp=tmp//2
            res+=1
        else:
            return res
def lcm(x,y):
    return x*(y//gcd(x,y))
c=[v2(i) for i in b]
if min(c)!=max(c):
    print(0)
    exit()
L=1
for i in range(N):
    L=lcm(L,b[i])
print(M//L-M//(2*L))


Measured memory_bytes: 16308
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String firstStep = sc.nextLine();
		String[] first = firstStep.split(" ");
		int firstValue = Integer.parseInt(first[0]);
		int secondValue = Integer.parseInt(first[1]);
		int third = Integer.parseInt(first[2]);
		int[][] sikaku = new int[firstValue][secondValue];
		int count=0;
		for(int i=0;i<third;i++){
			String secondStep = sc.nextLine();
			String[] second = secondStep.split(" ");
			int a = Integer.parseInt(second[0]);
			int b = Integer.parseInt(second[1]);
			int c = Integer.parseInt(second[2]);
			switch(c){
			case 1:
				for(int j=0;j<a;j++){
					for(int k=0;k<secondValue;k++){
						sikaku[j][k]=1 ;
					}
				}
				break;
			case 2:
				for(int j=a;j<firstValue;j++){
					for(int k=0;k<secondValue;k++){
						sikaku[j][k]=1 ;
					}
				}
				break;
			case 3:
				for(int j=0;j<firstValue;j++){
					for(int k=0;k<b;k++){
						sikaku[j][k]=1 ;
					}
				}
				break;
			case 4:
				for(int j=0;j<firstValue;j++){
					for(int k=b;k<secondValue;k++){
						sikaku[j][k]=1 ;
					}
				}
				break;
			}
		}
		for(int i=0;i<firstValue;i++){
			for(int j=0;j<secondValue;j++){
				if(sikaku[i][j]==0){
					count++;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 11452
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vishal Burman
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CLowElements solver = new CLowElements();
        solver.solve(1, in, out);
        out.close();
    }

    static class CLowElements {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = in.nextInt();
            int lowest = a[0];
            int count = 1;
            for (int i = 1; i < n; i++) {
                if (a[i] <= lowest) {
                    lowest = a[i];
                    count++;
                }
            }
            out.println(count);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22868
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
#define ll long long

int main(){
    ll A,B;
    cin >> A >> B;
    if(A<6)cout << 0;
    if(A>12)cout << B;
    if(A>=6&&A<=12)cout << B/2;
    return 0;
}


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

using namespace std;
struct test
{
    int x,y;
};
test a[100005];
bool cmp(test m,test n)
{
    if(m.y==n.y) return m.x<n.x;
    return m.y<n.y;
}
int main()
{
    int n,m,k,ans=1,mn=1000000;
    cin >> n >> m;
    for(int i=0;i<m;i++)
    {
        cin >> a[i].x >> a[i].y;
        mn=min(mn,a[i].y);
    }
    sort(a,a+m,cmp);
    for(int i=0;i<m;i++)
    {
        if(a[i].x>=mn)
        {
            ans++;
            mn=a[i].y;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std;

const int MAX_V = 10000; //頂点の数の最大値
const int MAX_E = 100000; //辺の数の最大値
const int INF = INT_MAX; //適当な大きな値

struct E{
  int to, cost;
  E(int t, int c) : to(t), cost(c) {};
};
typedef pair<int, int> pii;


int v; //頂点数
vector<E> g[MAX_V]; //隣接リスト
int mincost[MAX_V]; //全域木と頂点を結ぶ辺の最小コスト
bool used[MAX_V]; //ある頂点が全域木に含まれているか


int prim()
{
  fill(mincost, mincost + v, INF);
  fill(used, used + v, false);
  mincost[0] = 0;
  int ans = 0; //最小全域木の辺の総コスト
  priority_queue<pii, vector<pii>, greater<pii> > q;
  q.push(pii(0, 0));

  while(!q.empty()){
    pii p = q.top();
    q.pop();
    int u = p.second;
    if(used[u] || mincost[u] < p.first) continue;

    ans += mincost[u];
    used[u] = true;

    for(int i = 0; i < g[u].size(); i++){
      int w = g[u][i].to;
      int cost = g[u][i].cost;


      if(mincost[w] > cost){
        mincost[w] = cost;
        q.push(pii(mincost[w], w));
      }
    }
  }

  return ans;
}

int main()
{
  int gv, ge;
  cin >> gv >> ge;
  v = gv;
  for(int i = 0; i < ge; i++){
    int gs, gt, gw;
    cin >> gs >> gt >> gw;
    g[gs].push_back(E(gt, gw));
    g[gt].push_back(E(gs, gw));
  }

  cout << prim() << endl;
}

Measured memory_bytes: 4436
food = [int(input()) for _ in range(5)]

total = 0
compare = 0
largest = 0

if sum(food)%10 == 0:
    print(sum(food))

else:
    for x in food:
        if (10 - (x % 10) > compare) and ((x % 10) != 0):
            largest = x
            compare = 10 - (x % 10)

    food.remove(largest)

    for i in range(len(food)):
        if food[i] % 10 != 0:
            total += round(food[i] + 5.1, -1)
        else:
            total += food[i]

    print(int(total+largest))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__;
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    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
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,K,ans(0);
    cin >> N >> K;
    int a[N];
    
    for(int i = 0 ;i < K;i++){
        int m;
        cin >> m;
        for(int j = 0;j < m;j++){
            int t;
            cin >> t;
            a[t-1] = 1;

        }

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

    }
    
    

Measured memory_bytes: 3628
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
constexpr ll mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define vsort(v) sort(all(v))

ll powmod(ll x, ll y);

int main() {
    int k,n;cin>>n>>k;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    vsort(h);
    // rep(i,n) cout<<h[i]<<' ';
    // cout<<endl;
    ll ans=(1e+10);
    for (size_t i = 0; i < n-k+1; i++)
    {
        ans = min(ans, h.at(i+k-1)-h.at(i));
        // cout<<h[i+k-1]<<' '<<h[i]<<' '<<ans<<endl;
    }
    cout<<ans<<endl;
    
}

/************************************/
ll powmod(ll x, ll y){
    ll res=1;
    rep(i,y) res=res*x%mod;
    return res;
}



Measured memory_bytes: 4000
#include <iostream>
#include <string>

using namespace std;

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

    string s;
    cin >> s;

    bool ans = true;
    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0 && s[i] == 'L' || i % 2 == 1 && s[i] == 'R') {
            ans = false;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int arr[2000];
	int i;
	int ans=0;
	for(i=1;i<=n;i++)
	{
		arr[i]=2;
	}
	for(i=n+1;i<=n+m;i++)
	{
		arr[i]=1;
	}
	for(int j=1;j<=n+m-1;j++)
	{
		for(int k=j+1;k<=n+m;k++)
		{
			if((arr[j]+arr[k])%2==0)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int64_t N, X, B[100000], L[100000], U[100000];
int64_t target;
int64_t full[100000], full_sorted[100000];

bool check(int64_t S){
    int q = S/X, r = S%X;
    int64_t fix = 0;
    for(int i=0; i<q; i++) fix += full_sorted[i];
    for(int i=0; i<N; i++){
        int64_t res = fix;
        if(q > 0 && full[i] >= full_sorted[q-1]) res += full_sorted[q] - full[i];
        if(r <= B[i]){
            res += L[i]*r;
        }else{
            res += U[i]*r - (U[i]-L[i])*B[i];
        }
        if(res >= target) return true;
    }
    return false;
}

int main(){
    cin >> N >> X;
    for(int i=0; i<N; i++){
        cin >> B[i] >> L[i] >> U[i];
        target += B[i] * L[i];
        full[i] = full_sorted[i] = U[i]*X - (U[i]-L[i])*B[i];
    }
    sort(full_sorted, full_sorted+N, greater<>());

    int64_t ok = N*X, ng = -1;
    while(ok-ng>1){
        int64_t mid = (ok+ng)/2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 55;
const int INF = 1e9;
const lli MOD = 1e9+7;


vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7



void solve(){
	string a,b; cin>>a>>b;
	int mn = sz(b);
	fore(i,0,sz(a)){
		int x = sz(b);
		fore(j,0,sz(b))if(i+sz(b)>sz(a))break;
		else x-=(a[i+j]==b[j]);
		mn = min(mn,x);
	}
	cout<<mn<<ENDL;

}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
using namespace std;
int main(){
  float n;
  cin >> n;
  int k=n;
  if (k%2==0){
    cout << "0.5000000000";
  }
  else{
    if(n==1){
      cout << "1.0000000000";
    }
    else{
      float a =ceil(n/2);
      double b= a/n;
      cout << b;
    }
  }
  return 0;
}
      
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                             \
  cerr << __LINE__ << ": " << #x << " = {";          \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) { \
    cerr << ((hoge) ? "," : "") << x[hoge];          \
  }                                                  \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K, N;
  cin >> K >> N;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  int ans = 1 << 30;
  for (int i = 0; i < N; i++) {
    ans = min(ans, K - (A[(i + 1) % N] - A[i] + K) % K);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n,d;
    cin >> n >> d;
    vector<vector<int>>data(n,vector<int>(d));
    rep(i,n){rep(j,d)cin >> data[i][j];}
    int ans = 0;
    rep(i,n){
        rep(j,n){
            if(i == j)continue;
            int sum = 0;
            rep(k,d)sum += pow(data[i][k]-data[j][k],2);
            
            rep(k,sum+1){
                if(k*k == sum){ans++;
                //cout << i << " " << j << endl;
                }
            }
            
        }
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100
water = []
sugar = []
for i in range(1 + f // a):
    for j in range(1 + f // b):
        if i * a + j * b <= f:
            water.append(i * a + j * b)
for i in range(1 + f // c):
    for j in range(1 + f // d):
        if i * c + j * d <= f:
            sugar.append(i * c + j * d)
max_sugar_percent = 0
max_sugarwater = 0
max_sugar = 0
water.sort()
sugar.sort()
for w in water:
    for s in sugar:
        if w + s > f:
            break
        if s > e * w / 100:
            break
        sugar_percent = w and (100 * s) / (w + s)
        if sugar_percent >= max_sugar_percent:
            max_sugar_percent = sugar_percent
            max_sugar = s
            max_sugarwater = w + s
print(max_sugarwater, max_sugar)

Measured memory_bytes: 13384
A, B, K = map(int, input().split())

A_max = min(B, A+(K-1))
B_min = max(A, B-(K-1))

range_A = list(range(A, A_max+1))
range_B = list(range(B_min, B+1))
for i in sorted(set(range_A + range_B)):
  print(i)

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

int main() {
  string b;
    cin >> b;
  if(b== "A")
    cout << "T" << endl;
  if(b== "T")
    cout << "A" << endl;
  if(b== "C")
    cout << "G" << endl;
  if(b== "G")
    cout << "C" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}
 
struct Prime {
    int n;
    vector<bool> used;
    vector<int> pr;
    vector<ull> bpr;
    Prime(int n) : n(n) {
        used = vector<bool>(n+1, false);
        for (int i = 2; i <= n; i++) {
            if (used[i]) continue;
            pr.push_back(i);
            bpr.push_back(((__int128(1)<<64)+i-1) / i);
            for (int j = 2*i; j <= n; j += i) {
                used[j] = true;
            }
        }
    }    
    map<ll, int> fact(ll x) {
        assert(x <= (ll)n*n);
        int pc = (int)pr.size();
        map<ll, int> mp;
        for (int i = 0; i < pc; i++) {
            ll d = pr[i]; ull rd = bpr[i];
//            if (x < d*d) break; 枝刈り
            while (true) {
                ll xd = __int128(x)*rd >> 64;
                if (xd * d != x) break;
                x = xd;
                mp[d]++;
            }
        }
        if (x > 1) mp[x]++;
        return mp;
    }
};
 
const int MP = 100100;
 
ll mul(ll a, ll b) {
    if (TEN(12)/a < b) return TEN(12);
    return a*b;
}
 
int main() {
    Prime pr(MP);
    using P = pair<ll, ll>;
    map<ll, P> g;
    int n;
    scanf("%d", &n);
    bool one = false;
    for (int i = 0; i < n; i++) {
        ll s;
        scanf("%lld", &s);
        map<ll, int> fac = pr.fact(s);
        ll d0 = 1, d1 = 1;
        for (auto p: fac) {
            p.second %= 3;
            if (p.second == 1) {
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
                d1 = mul(d1, p.first);
            } else if (p.second == 2) {
                d0 = mul(d0, p.first);
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
            }
        }
        if (d0 == 1) {
            one = true;
            continue;
        }
        if (d0 < d1) {
            g[d0].first++;
        } else {
            g[d1].second++;
        }
    }
 
    int ans = 0;
    for (auto p: g) {
        ans += max(p.second.first, p.second.second);
    }
    cout << ans + (one ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 6904
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

char s[500000];
int main(){
  scanf("%s",s);
  int len=strlen(s);
  int flg=1;
  reg(i,0,len-2){
    if(s[i]==s[i+1]){
      flg=0;
      printf("%d %d\n",i+1,i+2);
      break;
    }
  }
  if(flg){
    reg(i,0,len-3){
      if(s[i]==s[i+2]){
        flg=2;
        printf("%d %d\n",i+1,i+3);
        break;
      }
    }
  }
  if(flg==1) printf("-1 -1\n");



  return 0;

}


Measured memory_bytes: 384
l = [list(map(int, input().split())) for i in range(3)]
ans = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
N = int(input())

for i in range(N):
    search = int(input())
    f = 0
    for j in range(3):
        for k in range(3):
            if l[j][k] == search:
                f = 1
                ans[j][k] = 1
                break
        if f == 1:
            break

for i in range(3):
    if (ans[i][0] == 1) and (ans[i][1] == 1) and (ans[i][2] == 1):
        print("Yes")
        exit()
for j in range(3):
    if (ans[0][j] == 1) and (ans[1][j] == 1) and (ans[2][j] == 1):
        print("Yes")
        exit()
if ((ans[0][0] == 1) and (ans[1][1] == 1) and (ans[2][2] == 1)):
    print("Yes")
    exit()
if ((ans[0][2] == 1) and (ans[1][1] == 1) and (ans[2][0] == 1)):
    print("Yes")
    exit()
print("No")


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

int main(){
  int n;
  string str;
  map<int,char>data;
  int cnt;

  cin >> n;
  
  while(n--){
    cnt = 0;
    cin >> str;
    for(int i = 0;i < str.size();i++){
      if(isalpha(str[i]))data[cnt] = str[i];
      if(str[i] == '>')cnt++;
      if(str[i] == '<')cnt--;
    }

    for(map<int,char>::iterator it = data.begin();it != data.end();it++){
      cout << it->second;
    }
    cout << endl;
    data.clear();
  }
}

Measured memory_bytes: 1200