akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

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

    for(;;){
        int R, C;
        cin >> R >> C;
        if(R == 0 && C == 0)    return 0;
        vector<vector<int>> c(C, vector<int>(R));
        for(int i = 0; i < C; ++i){
            for(int j = 0; j < R; ++j){
                cin >> c[i][j];
            }
        }
        vector<vector<bool>> used(C, vector<bool>(R, false));
        auto dfs = [&](auto&& self, int x, int y) -> void {
            used[x][y] = true;
            for(int i = 0; i < 8; ++i){
                int nx = x + dx[i], ny = y + dy[i];
                if(nx < 0 || nx >= C || ny < 0 || ny >= R)  continue;
                if(used[nx][ny] || c[nx][ny] == 0)  continue;
                self(self, nx, ny);
            }
            return;
        };
        int ans = 0;
        for(int i = 0; i < C; ++i){
            for(int j = 0; j < R; ++j){
                if(used[i][j] || c[i][j] == 0)  continue;
                ++ans;
                dfs(dfs, i, j);
            }
        }
        cout << ans << '\n';
    }
}


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

int main() {
    long long N, M;
    scanf("%lld %lld", &N, &M);

    long long ans;
    ans = min(N, M / 2) + max(0ll, (M - 2 * N) / 4);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char c[40000];
int main()
{int s;
scanf("%d",&s);
getchar();
	gets(c);
	int k=strlen(c);
	int i;
	for(i=0;i<k;i++)
	if(c[i]+s>90)
	printf("%c",c[i]+s-26);
	 else printf("%c",c[i]+s);
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    int n, m;
    cin >> n >> m;
    
    bool table[200001][2] = {0};
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        
        if (a == 0) {
            table[b][0] = 1;
        }
        if (b == n - 1) {
            table[a][1] = 1;
        }
    }
    
    rep3(i, 1, n) {
        if (table[i][0] && table[i][1]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  vi c(n);
  rep(i, 0, n) cin >> c[i];

  vi places[200001];
  vi dp(200001);

  rep(i, 0, n) places[c[i]].emplace_back(i);

  dp[0] = 1;
  rep(i, 1, n+1){
    (dp[i] += dp[i-1]) %= mod;

    int color = c[i-1];
    int it = lower_bound(all(places[color]), i-1) - places[color].begin();
    if(it > 0){
      int j = places[color][it-1];
      if((i-1) - j > 1) (dp[i] += dp[j+1]) %= mod;
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a;
	cin>>b;
	int c[b],d[a][b],g[a];
	for(int i=0;i<a;i++){g[i]=0;}
	for(int i=0;i<b;i++){cin>>c[i];c[i]-=1;}
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++){cin>>d[j][i]; d[j][i]-=1;}
	}
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++){
			if(d[j][i]==c[i]){g[j]++;}
			else{g[c[i]]++;}
		}
	}
	for(int i=0;i<a;i++){
		cout<<g[i]<<endl;
	}
}

Measured memory_bytes: 3108
#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()
const int INF = 100100100;
typedef long long ll;
 
int main() {
   string a,b,c;
   cin >> a >> b >> c;
   int ac=0,bc=0,cc=0;
   char turn='a';
   string ans="";
   
   while(1){
      if(turn=='a'){
         if(ac==a.size()){
         ans='A'; break;
         }
         turn=a[ac];
         ac++;
      }

      if(turn=='b'){
         if(bc==b.size()){
            ans='B'; break;
         }
         turn=b[bc];
         bc++;
      }

      if(turn=='c'){
         if(cc==c.size()){
            ans='C'; break;
         }
         turn=c[cc];
         cc++;
      }
   }
   
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)

void solve()
{
    int n,q;string s;cin>>n>>s>>q;
vector< set<int> > v(26);

f(i,0,n)
v[s[i]-'a'].insert(i);

while(q--)
{
	int ch;cin>>ch;
	if(ch==1)
	{
		int x;char y;cin>>x>>y;
		v[s[x-1]-'a'].erase(x-1);
		s[x-1]=y;
		v[y-'a'].insert(x-1);

	}
	else
	{
		int x,y;cin>>x>>y;
		x--;y--;
		ll ans=0;
		f(i,0,26)
		{
			auto minv=v[i].lower_bound(x);
			if(minv!=v[i].end()&&*minv<=y)
				ans++;
		}
		cout<<ans<<endl;
	}
}

}


int main()
{

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

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

}

Measured memory_bytes: 24220
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct PrimeList
{
	PrimeList()
	{
		prime.clear();
	};
	~PrimeList() {};

	void init(int n)
	{
		std::vector<bool> isComposite(n + 1);
		for (int i = 2; i <= n; ++i)
		{
			if (isComposite[i])continue;
			prime.push_back(i);
			for (int j = i; j <= n; j += i)
			{
				isComposite[j] = true;
			}
		}
	}

	std::vector<int> prime;
};

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

	PrimeList prime;
	prime.init(N);

	vector<int> num(prime.prime.size(),0);
	FOR(i, N + 1, 2)
	{
		int t = i;
		int index = 0;
		while (t > 1)
		{
			if (t%prime.prime[index] == 0)
			{
				t /= prime.prime[index];
				num[index]++;
				continue;
			}
			index++;
		}
	}

	int sum = 0;
	int n = prime.prime.size();
	//! a^74
	REP(i, n)
	{
		if (num[i] >= 74)
		{
			sum++;
		}
	}

	//! a^24*b^2
	REP(i, n)
	{
		REP(j, n)
		{
			if (i == j)
			{
				continue;
			}
			if (num[i] >= 24 && num[j] >= 2)
			{
				sum++;
			}
		}
	}

	//! a^14*b^4
	REP(i, n)
	{
		REP(j, n)
		{
			if (i == j)
			{
				continue;
			}
			if (num[i] >= 14 && num[j] >= 4)
			{
				sum++;
			}
		}
	}

	//! a^4*b^4*c^2
	REP(i, n)
	{
		FOR(j, n, i + 1)
		{
			REP(k, n)
			{
				if (i == k || j == k)
				{
					continue;
				}
				if (num[i] >= 4 && num[j] >= 4 && num[k] >= 2)
				{
					sum++;
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
}

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

int main( )
{
    int n, k;    cin >> n >> k;
    int i, d, c = 0;
    for (i = 1; i <= n; i++)    cin >> d;
    for (i = 1; i < n; i = i + k - 1)   c++;
    cout << c << "\n";
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]

max1 = 0
max1_ind = 0
max2 = 0
max2_ind = 0
 
for i in range(n):
    if max2 <= a[i]:
        if max1 <= a[i]:
            max2 = max1
            max2_ind = max1_ind
            max1 = a[i]
            max1_ind = i
            
        else:
            max2 = a[i]
            max2_ind = i
    
for j in range(n):
    if j == max1_ind:
        print(max2)
    else:
        print(max1)
        

Measured memory_bytes: 12660
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33508
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define INF 1e+8
class Data {
public:
	int to,cost,num;
	Data(){}
	Data(int to, int cost, int num):to(to),cost(cost),num(num){}
	bool operator<(const Data &s) const {
		if(cost != s.cost) return cost > s.cost;
		return to < s.to;
	}
};

int main() {
	int c,n,m,s,g;
	while(scanf("%d%d%d%d%d",&c,&n,&m,&s,&g),(c|n|m|s|g)) {
		vector<Data> G[128];
		for(int i = 0; i < m; i++) {
			int a,b,f;
			scanf("%d%d%d",&a,&b,&f);
			G[a].push_back(Data(b,f,0));
			G[b].push_back(Data(a,f,0));
		}
		bool memo[11][101] = {{}};
		priority_queue<Data> Q;
		Q.push(Data(s,0,c));
		int ans = -1;
		while(!Q.empty()) {
			Data e = Q.top();Q.pop();
			int v = e.to;
			if(memo[e.num][e.to]) continue;
			memo[e.num][e.to] = true;
			if(v == g) {
				ans = e.cost;
				break;
			}
			for(int i = 0; i < G[v].size(); i++) {
				Data E = G[v][i];
				if(e.num != 0) {
					Q.push(Data(E.to,E.cost/2 + e.cost,e.num-1));
				}
				Q.push(Data(E.to,E.cost + e.cost,e.num));
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
long long A,B,C,D;
long long gcd(long long a, long long b){
    return b?gcd(b,a%b):a;
}
long long lcm(long long a, long long b){
    return a*b/gcd(a,b);
}
int main(){
    scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
    printf("%lld",B-A+1-(B/C-(A-1)/C+B/D-(A-1)/D-B/lcm(C,D)+(A-1)/lcm(C,D)));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,i,j,k,count=0;
  	scanf("%d",&n);
  	if(n<3){
    	printf("0");
  	    return 0;
    }
  	int a[n];
  	for(i=0;i<n;i++){
    	scanf("%d",&a[i]);
    }
  	
  	for(i=0;i<n;i++){
    	for(j=i+1;j<n;j++){
        	for(k=j+1;k<n;k++){
            	if(a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]){
                	if((a[i]+a[j])>a[k] && (a[j]+a[k])>a[i] && (a[k]+a[i])>a[j])
                      count++;
                }
            }
        }
    }
 	printf("%d",count);
  	return 0;
}

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

void Main()
{
	string s;
	cin >> s;
	s[3] = '8';
	cout << s;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

void search(int n,int m,int a){
  vector<P> b[2000];

  rep(i,m){
    int h,p,q;
    cin>>h>>p>>q;
    b[h].push_back(P(p,q));
  }

  rrep(i,1000){
    rep(j,b[i].size()){
      if(a==b[i][j].first){
        a = b[i][j].second;
        break;
      }
      if(a==b[i][j].second){
        a = b[i][j].first;
        break;
      }
    }
  }

  cout<<a<<endl;
}


int main(){

  int n,m,a;
  while(1){
    cin>>n>>m>>a;
    if(n==0) break;
    search(n,m,a);
  }

  return 0;
}



Measured memory_bytes: 3040
#include<iostream>
//#include<algorithm>
#include<cmath>
//#include<string>
//#include<cctype>
//#include <vector>
using namespace std;
int main(){
	int a=100,n;
	cin >> n;
	while (n--) a = ceil(a*1.05);
	cout << a * 1000 << endl;
	return 0;
}

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

int my_ceil(int a, int b){
  return (a + b - 1) / b;
}

int main(){
  int N, D;
  cin >> N >> D;
  cout << my_ceil(N, (2*D+1)) << endl;
}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        P[] ps = new P[n];
        HashSet<Long> hash = new HashSet<>();
        for (int i = 0; i < n; i++) {
            ps[i] = new P(sc.nextLong(), sc.nextLong());
            hash.add(ps[i].toLong());
        }

        Arrays.sort(ps);

        int ans = n;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                long p = ps[j].x - ps[i].x;
                long q = ps[j].y - ps[i].y;
                int cnt = n;
                for (int k = j; k < n; k++) {
                    long dp = ps[k].x - p;
                    long dq = ps[k].y - q;
                    if (hash.contains(new P(dp, dq).toLong())) {
                        cnt -= 1;
                    }
                }
                ans = Math.min(ans, cnt);
            }
        }
        System.out.println(ans);
    }

    class P implements Comparable<P> {

        long x, y;
        P(long x, long y) {
            this.x = x;
            this.y = y;
        }

        long toLong() {
            return x * (long) (1e9 + 1) + y;
        }

        @Override
        public int compareTo(P o) {
            if (x != o.x) {
                return (x - o.x) > 0 ? 1 : -1;
            }
            return (y - o.y) > 0 ? 1 : -1;
        }
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 25684
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    if (n%10 == 3) cout << "bon" << endl;
    else if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

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

int main(){
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double hour_rad = (H * 3.1415926535897) / 6 + (M * 3.1415926535897) / 360;
    double minute_rad = (M * 3.1415926535897) / 30;
    cout << setprecision(11) << sqrt(A * A + B * B - 2 * A * B * cos(hour_rad - minute_rad)) << endl;
}


Measured memory_bytes: 4192
N,A,B,C,D = map(int, input().split())
#XとYをセットの数とする
X = N//A
if N % A != 0: X+=1   # 割り切れなれば+1
Y = N//C
if N % C != 0: Y+=1   # 割り切れなれば+1
print(min(X*B, Y*D))



Measured memory_bytes: 5596
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,e,m=0;
  cin>>a>>b>>c>>d>>e;
  if(m==a)
    cout<<1;
   if(m==b)
    cout<<2;
   if(m==c)
    cout<<3;
   if(m==d)
    cout<<4;
   if(m==e)
    cout<<5;
  return 0;
}

Measured memory_bytes: 3164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_1_a
{
    class Program
    {
        static void Main()
        {
            while (true)
            {

                string[] i = Console.ReadLine().Split(' ');
                int a = int.Parse(i[0]);
                string b = i[1];
                int c = int.Parse(i[2]);

                if (b == "+") Console.WriteLine(a + c);
                else if (b == "-") Console.WriteLine(a - c);
                else if (b == "*") Console.WriteLine(a * c);
                else if (b == "/") Console.WriteLine(a / c);
                else break;
            }
        }
    }
}


Measured memory_bytes: 17948
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int ans = a-1;
    cout << ans+((a<=b)?1:0) << endl;


    return 0;
}

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

int main(void){
  int n, m;
  vector<int> a(50), b(50), c(50), d(50);

  cin >> n >> m;

  for(int i = 0; i < n; i ++)
    cin >> a.at(i) >> b.at(i);
  for(int i = 0; i < m; i ++)
    cin >> c.at(i) >> d.at(i);

  // 人数分繰り返す
  for(int i = 0; i < n; i ++){
    int point = 99;
    int point_dist = 1000000000;
    for(int j = 0; j < m; j ++){
      int temp = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
      // cout << "student: (" << a.at(i) << "," << b.at(i) << ")" << endl;
      if(point_dist > temp){
        point = j;
        point_dist = temp;
      }
    }
     cout << point + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a >= b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll digit(ll n){
    ll ret=0;
    while(n){
        ret+=n%10;n/=10;
    }
    return ret;
}
double g(ll n){
    if(n==0)return INF;
    return (double)n/digit(n);
}
int main(){
    ll k;cin >> k;
    vl pos;
    ll dig=0;
    while(dig<12){
        rep(i,100000){
            pos.pb(i*pow(10,dig)+pow(10,dig)-1);
            //cout << *pos.rbegin() <<endl;
        }
        dig++;
    }
    sort(all(pos));pos.erase(unique(all(pos)),pos.end());
    //cout << pos.size() <<endl;
    vl ans;
    /*rep(i,pos.size()){
        bool ok=true;
        repl(j,i,pos.size()){
            if(g(pos[i])>g(pos[j]))ok=false;
        }
        if(ok)ans.pb(pos[i]);
        //if(ok)cout << pos[i] <<endl;
    }*/
    double now=INF;
    per(i,pos.size())if(chmin(now,g(pos[i])))ans.pb(pos[i]);
    rev(all(ans));
    rep(i,k)cout << ans[i] <<endl;
} 

Measured memory_bytes: 19964
#include <bits/stdc++.h>
#pragma GCC target("avx")

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
using ll = long long;

constexpr int SZ = 100000, prs = 10;
ll pre[1 << prs][SZ + 1];

int main() {
  int N;
  cin >> N;
  vector<int> V(N + 1), W(N + 1);
  REP(i, N) cin >> V[i + 1] >> W[i + 1];
  FOR(i, 1, min(N + 1, 1 << prs)) {
    if (i != 1) copy(pre[i / 2], pre[i / 2] + SZ + 1, pre[i]);
    for (int j = SZ; j >= W[i]; --j)
      pre[i][j] = max(pre[i][j], pre[i][j - W[i]] + V[i]);
    REP(j, SZ) pre[i][j + 1] = max(pre[i][j + 1], pre[i][j]);
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int v, L;
    cin >> v >> L;
    if (v < (1 << prs)) {
      cout << pre[v][L] << "\n";
    } else {
      int lvl = 32 - __builtin_clz(v) - prs;
      ll ans = 0;
      REP(b, 1 << lvl) {
        int w = 0;
        ll va = 0;
        REP(i, lvl) {
          if ((b >> i) & 1) {
            w += W[v >> i];
            va += V[v >> i];
          }
          if (w > L) break;
        }
        if (w <= L) ans = max(ans, pre[v >> lvl][L - w] + va);
      }
      cout << ans << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 804380
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  ll n = 0;

  cin >> n;

  vector<ll> a(n);

  for(ll i = 0; i < n; i++) cin >> a[i];

  sort(rall(a));

  ll ans = a[0], left = n - 2;

  for(ll i = 1; i < n; i++) {
    ans += a[i] * max(0ll, min(2ll, left));
    left -= 2;
  }

  cout << ans;

  return 0;
}
/*

*/


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

int main()
{
    string s; 
    int n;
    cin >> n >> s;
    for (auto &c : s)
    {
        c += n;
        if (c > 'Z') c -= 26;
    }
    
    cout << s << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
pair<int,int>a[1<<17];
int L[2<<17],R[2<<17];
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)L[i]=R[i]=i;
	L[n]=R[n]=n-1;
	for(int i=0;i<m;i++)
	{
		cin>>a[i].first>>a[i].second;
	}
	sort(a,a+m);
	for(int i=0;i<m;i++)
	{
		L[a[i].second]=L[a[i].second-1];
		R[a[i].second-1]=R[a[i].second];
	}
	for(int i=0;i<n;i++)
	{
		cout<<R[i]-L[i]+1<<(i==n-1?"\n":" ");
	}
}



Measured memory_bytes: 5444
#include <queue>
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;

struct state {
    int x,y,t;
};

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

int memo[6][205][206];
inline int idx(int p) { return p+100; }
inline int set(const state &s, int d) { return memo[(s.t)%6][idx(s.x)][idx(s.y)] = d; }
inline int get(const state &s) { return memo[(s.t)%6][idx(s.x)][idx(s.y)]; }
inline void print(const state &s) {
    cout<<s.x<<" "<<s.y<<" "<<s.t<<" "<<get(s)<<endl;
}

int bfs(int sx, int sy, int gx, int gy, int lx, int ly) {
    queue<state> q;
    set((state){sx,sy,0}, 0);
    q.push((state){sx,sy,0});

    while(!q.empty()) {
        const state s = q.front(); q.pop();
        int p = (abs(s.x))%2, nd = abs(s.x*s.y*s.t)%6;
        int nx = s.x + dx[nd], ny = s.y + dy[p][nd], nt = s.t+1;
        const state ns = (state){nx,ny,nt};
        if (abs(nx) <= lx && abs(ny) <= ly && (get(ns) == -1 || get(ns) > get(s))) {
            q.push(ns); set(ns, get(s));
        }

        for (int k=0; k<7; ++k) {
            nx = s.x + dx[k], ny = s.y + dy[p][k];
            const state ns = (state){nx,ny,nt};
            if (abs(nx) <= lx && abs(ny) <= ly && (get(ns) == -1 || get(ns) > get(s)+1)) {
                q.push(ns); set(ns, get(s)+1);
            }
        }
    }
    int ans = 1<<29;
    for (int t=0; t<6; ++t) {
        int p = get((state){gx,gy,t});
        if (p > -1) ans = min(ans, p);
    }
    if (ans == 1<<29) return -1;
    else return ans;
}

int main() {
    memset(memo, -1, sizeof(memo));
    int sx,sy,gx,gy,lx,ly;
    int n,x,y;
    cin>>sx>>sy>>gx>>gy;
    cin>>n;
    for (int i=0; i<n; ++i) {
        cin>>x>>y;
        for (int t=0; t<6; ++t) set((state){x,y,t}, -2);
    }
    cin>>lx>>ly;
    cout<<bfs(sx,sy,gx,gy,lx,ly)<<endl;
}

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

int main(){
    int x, y;
    
    while(1){
        cin >> x >> y;
        if (x == 0 && y == 0){
            break;
        }
        else {
            if(x < y){
                cout << x << " " << y;
            }
            else{
                cout << y << " " << x;
            }
        }
        cout << endl;
    }
}


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

int n;
int m;
int lim;
int ans;
int as[1145];
map<vector<int>, int> memo;

int dfs(vector<int> &vi) {
  int ret = m;
  if (memo.count(vi)) return memo[vi];
  if (vi.size() <= 1) return 0;

  for (int i=0; i<m; i++) {
    vector<int> a, b;
    for (int idx : vi) {
      if (as[idx] >> i & 1) a.emplace_back(idx);
      else b.emplace_back(idx);
    }
    if (a.empty() || b.empty()) continue;
    ret = min(ret, max(dfs(a), dfs(b))+1);
  }
  return memo[vi] = ret;
}

int main() {
  while (1) {
    scanf("%d%d", &m, &n);
    if ((m|n) == 0) return 0;

    memo.clear();
    vector<int> al;
    for (int i=0; i<n; i++) {
      al.emplace_back(i);
      as[i] = 0;
      for (int j=0; j<m; j++) {
        int t;
        scanf("%01d", &t);
        as[i] = (as[i] << 1) | t;
      }
    }
  
    printf("%d\n", dfs(al));
  }
} 

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
/*---define tricks---*/
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define revsort(b,e) sort(b,e),reverse(b,e)
/*---define types---*/
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
/*---define variables---*/
int n;
string s;
/*---define function---*/

/*---main code---*/
int main()
{
	FIO;
	cin>>n>>s;
	int l=0,r=0;
	for(int i=0;i<s.size();++i)
	{
		if(s[i]=='(')
		{
			++l;
		}
		else 
		{
			if(l<1)
			{
				++r;
			}
			else
			{
				--l;
			}
		}
	}
	for(int i=0;i<r;++i)
	{
		putchar('(');
	}
	for(int i=0;i<s.size();++i)
	{
		putchar(s[i]);
	}
	for(int i=0;i<l;++i)
	{
		putchar(')');
	}
	puts("");
	return 0;
}


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

using namespace std;

#define INF 1010101010

int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	int ans = INF;
	for (int i = 0; i < (1 << (h - 1)); i++) {
		vector<int> id(h);
		int g = 0;
		for (int j = 0; j < h; j++) {
			id[j] = g;
			if (((i >> j) & 1) == 1) {
				g++;
			}
		}
		g++;

		int now = g - 1;
		vector<int> num(g);
		vector<vector<int>> c(g, vector<int>(w));
		for (int j = 0; j < h; j++) {
			for (int l = 0; l < w; l++) {
				c[id[j]][l] += (s[j][l] - '0');
			}
		}
		auto add = [&](int j) {
			for (int p = 0; p < g; p++) {
				num[p] += c[p][j];
			}
			for (int p = 0; p < g; p++) {
				if (num[p] > k) {
					return false;
				}
			}
			return true;
		};
		
		for (int j = 0; j < w; j++) {
			if (!add(j)) {
				now++;
				num = vector<int>(g);
				if (!add(j)) {
					now = INF;
					break;
				}
			}
		}
		ans = min(ans, now);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
map<string,int> mp;
vector<int> G[1100];
bool vis[1100];
bool isgroup[1100];
int ans;
void dfs(int v){
	vis[v]=1;
	if(!isgroup[v]) ans++;
	for(int u:G[v]) if(!vis[u]) dfs(u);
}
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		mp.clear();
		ans=0;
		rep(i,1100) vis[i]=0,isgroup[i]=0,G[i].clear();
		int I=0;
		rep(i,N){
			string s;
			cin>>s;
			int it=0;
			while(s[it]!=':') it++;
			string g=s.substr(0,it++);
			if(mp.count(g)==0) mp[g]=I++;
			int p=mp[g];
			isgroup[p]=1;
			while(true){
				int it2=it;
				while(islower(s[it2])) it2++;
				string g=s.substr(it,it2-it);
				if(mp.count(g)==0) mp[g]=I++;
				int x=mp[g];
				G[p].pb(x);
				if(s[it2]=='.') break;
				it=it2+1;
			}
		}
		dfs(0);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1396
//
//  main.cpp
//  beginner20200412_1
//
//  Created by zer0 on 2020/04/12.
//  Copyright © 2020 zer0. All rights reserved.
//


#include <iostream>
#include <string>

int main(int argc, const char * argv[]) {
    
    std::string m;
    std::cin >> m;
    
    if(m.find("7") == std::string::npos){
        std::cout << "No";
    }else{
        std::cout << "Yes";
    }

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

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

class Circle{
public:
    int x, y, r, c;
    Circle(int x_, int y_, int r_, int c_) : x(x_), y(y_), r(r_), c(c_){};
};

bool over(Circle &c1, Circle &c2){
    return (c1.x-c2.x)*(c1.x-c2.x) + (c1.y-c2.y)*(c1.y-c2.y) < (c1.r+c2.r)*(c1.r+c2.r);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    while(cin>>N, N){
        vector<vector<int>> is_over(N, vector<int>(N, false));
        vector<Circle> circles;
        for(int i=0; i<N; i++){
            int x, y, r, c;
            cin >> x >> y >> r >> c;
            circles.push_back(Circle(x, y, r, c));
        }
        
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                if(i < j && over(circles[i], circles[j]))
                    is_over[i][j] = true;
            }
        }
        vector<vector<int>> colors(4);
        for(int i=0; i<N; i++)
            colors[circles[i].c-1].push_back(i);
        
        vector<bool> dp(1<<N, false);
        dp[(1<<N)-1] = true;
        
        for(int i=(1<<N)-1; 0<=i; i--){
            if(!dp[i])
                continue;
            
            for(int c=0; c<4; c++){
                for(int j=0; j<colors[c].size(); j++){
                    for(int k=j+1; k<colors[c].size(); k++){
                        int uppper = colors[c][j];
                        int lower = colors[c][k];
                        if(!is_over[uppper][lower] && i>>uppper&1 && i>>lower&1){
                            bool is_ng = false;
                            for(int l=0; l<uppper; l++){
                                if(i>>l&1)
                                    is_ng |= is_over[l][uppper];
                            }
                            for(int l=0; l<lower; l++){
                                if(i>>l&1)
                                    is_ng |= is_over[l][lower];
                            }
                            if(!is_ng)
                                dp[i-(1<<uppper)-(1<<lower)] = true;
                        }
                    }
                }
            }
        }
        
        int ans = 0;
        for(int i=0; i<1<<N; i++){
            if(!dp[i])
                continue;
            int count = 0;
            for(int j=0; j<N; j++){
                count += (i>>j)&1;
            }
            ans = max(ans, N-count);
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3352
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1000000007;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int N = 1e6+10;
string s;
vector<int> v[N];
int n,m,x,y;
int a[N];
mint result;

const int MAX = 1000000;

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

// テーブルを作る前処理
void COMBinit() {
    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 mod(long long a, long long m) {
    return (a % m + m) % m;
}

long long mul(long long a, long long b, long long m) {
    a = mod(a, m); b = mod(b, m);
    if (b == 0) return 0;
    long long res = mul(mod(a + a, m), b>>1, m);
    if (b & 1) res = mod(res + a, m);
    return res;
}

// 二項係数計算
long long COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return mul(fac[n], (mul(finv[k], finv[n - k], MOD)), MOD);
}

int main () {
  ios::sync_with_stdio(false);
  cin >> x >> y;
  if((x+y) % 3 != 0 || y > 2*x || y < x/2) {
    cout << 0 << endl;
    return 0;
  }
  ll tempy = (x+y) / 3;
  ll y_time = y - tempy;
  COMBinit();

  cout << COMB(tempy,y_time) << endl;
}


Measured memory_bytes: 49024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            int n = s.length();

            boolean[] ss = new boolean[n];
            for (int i = 0; i < n; i++) {
                if (s.charAt(i) == 'R') {
                    ss[i] = true;
                } else {
                    ss[i] = false;
                }
            }

            int[] c = new int[n];

            for (int i = 0; i < n; i++) {
                if (ss[i] == true) {
                    for (int j = i + 1; j < n; j++) {
                        if (ss[j] == false) {
                            c[j - 1] += (j - i + 1) / 2;
                            c[j] += (j - i) / 2;
                            i = j - 1;
                            break;
                        }
                    }
                } else {
                    for (int j = i + 1; j < n; j++) {
                        if (ss[j] == true || j == n - 1) {
                            c[i] += (j - i + 1) / 2;
                            c[i - 1] += (j - i) / 2;
                            i = j - 1;
                            break;
                        }
                    }
                }

                if (i == n - 1) {
                    for (int j = n - 2; j >= 0; j--) {
                        if (ss[j] == true) {
                            if ((i - j) % 2 == 1) {
                                c[j + 1]++;
                            } else {
                                c[j]++;
                            }
                            break;
                        }
                    }
                }
            }

            System.out.print(c[0]);
            for (int i = 1; i < n; i++) {
                System.out.print(" " + c[i]);
            }
        }
    }

}


Measured memory_bytes: 47968
#include<iostream>
#include<vector>
using namespace std;
int main(){
	char a[3];
	cin>>a[0]>>a[1]>>a[2];
	if(a[0]=='R'&&a[1]=='R'&&a[2]=='R'){
		cout<<"3"<<endl;
	}else if((a[0]=='R'&&a[1]=='R' ) ){
		cout<<"2"<<endl;
	}
	else if((a[1]=='R'&&a[2]=='R' )){
			cout<<"2"<<endl;
	} else if(a[0]=='R'&&a[2]=='R'){
		cout<<"1"<<endl;
	}else if (a[2]=='R' || a[0]=='R'||a[1]=='R'){
		cout<<"1"<<endl;
	}else{
		cout<<"0"<<endl;
	}
	
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
int n,d1,d2,color[606][606],N;
void paint(int d){
    int b=0;
    while(!(d&3))d>>=2,++b;
    if(d&1){
        for(int i=0;i<N;++i)
        for(int j=0;j<N;++j)
        if(((i>>b)+(j>>b))&1)color[i][j]=1;
    }else{
        for(int i=0;i<N;++i)
        for(int j=0;j<N;++j)
        if((i>>b)&1)color[i][j]=1;
    }
}
int main(){
    scanf("%d%d%d",&n,&d1,&d2);
    N=n<<1;
    paint(d1),paint(d2);
    int NN=n*n;
    for(int i=0;i<N;++i)
    for(int j=0;j<N;++j)
    if(!color[i][j]){
        printf("%d %d\n",i,j);
        if(!--NN)return 0;
    }
}

Measured memory_bytes: 2304
#include<stdio.h>

int isRightTriangle( int a, int b, int c)
{
	int res=0;
	
	if( a <= b ) {
		if( b <= c ) {
			if( c*c == (a*a+b*b) ) {
				res=1;
			} else {
				res=0;
			}
		} else {
			if( b*b == (a*a+c*c) ) {
				res=1;
			} else {
				res=0;
			}
		}
	} else {
		if( a <= c ) {
			if( c*c == (b*b+a*a) ) {
				res=1;
			} else {
				res=0;
			}
		} else {
			if( a*a == (b*b+c*c) ) {
				res=1;
			} else {
				res=0;
			}
		}	
	}

	return res;
}

int main( void ) 
{
	int i;	
	int n;
	int a,b,c;
	
	scanf( "%d", &n );
	
	for( i=0; i<n; i++) {
		scanf( "%d%d%d", &a, &b, &c); 
		if( isRightTriangle( a, b, c) ) {
			printf( "YES\n" );			
		} else {
			printf( "NO\n" );
		}
	}

	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>

int main(void) {
    int N;
    scanf("%d", &N);

    int d[N], count=0;
    for (int i = 0; i < N; i++) {
        scanf("%d", &d[i]);

        int k;
        for (int j = i; j > 0; j--) {
            k = j;
            if (d[j-1] < d[j]) {
                int tmp;
                tmp = d[j - 1];
                d[j - 1] = d[j];
                d[j] = tmp;
            } else {
                break;
            }
        }
        if (d[k -1] != d[k]) {
            count++;
        }
    }

    printf("%d\n", count);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=2e5+100;
const int mod=1e9+7;
LL a[N];
int main()
{
	LL n,A,B;
	while(cin>>n>>A>>B)
	{
		for(int i=1;i<=n;i++)cin>>a[i];
		sort(a+1,a+1+n);
		LL ans=0;
		for(int i=1;i<n;i++)
		{
			LL tmp=(a[i+1]-a[i])*A;
			ans+=min(tmp,B);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS (1e-10)

using namespace std;

template<class T>
struct point{
	T x, y;
	point &operator+=(const point &a ){ x += a.x; y += a.y; }
	point &operator-=(const point &a ){ x -= a.x; y -= a.y; }
	point operator+(const point &a )const{ return (point){x+a.x, y+a.y }; }
	point operator-(const point &a )const{ return (point){x-a.x, y-a.y }; }
	operator point<double>()const{ return (point<double>){x, y }; }
};

template<class T>
point<T> operator*(T c, const point<T> &a ){ return (point<T>){c*a.x, c*a.y }; }
point<double> &operator/=(point<double> &a, double c ){ a.x /= c; a.y /= c; return a; }
template<class T>
point<double> operator/(const point<T> &a, double c ){ return (point<double>){ a.x/c, a.y/c }; }

template<class T>
struct line{
	point<T> a, b;
	operator line<double>()const{ return (line<double>){a, b}; }
};

// inner product
template<class T>
T dot(const point<T> &a, const point<T> &b ){ return a.x*b.x + a.y*b.y; }

// outer product
template<class T>
T cross(const point<T> &a, const point<T> &b ){ return a.x*b.y - a.y*b.x; }


/*
	2直線の位置関係

	説明
		2直線が平行か垂直かまたはそうでないかの判定
	引数
		直線 l1, l2
	戻り値
		l1 // l2 のとき 2
		l1 ⊥ l2 のとき 1
		それ以外 0
	制約
		なし
	計算量
		O(1)
	備考

		AOJ - Courses CGL CGL_D_1 Parallel/Orthogonal

*/
enum{OTHER = 0, ORTHOGONAL = 1, PARALLEL = 2 };
template<class T>
int pos_2_line (const line<T> &L1, const line<T> &L2 ){
	double res = dot (L1.b - L1.a, L2.b - L2.a );

	if (abs (res ) < EPS ) return ORTHOGONAL;

	res = cross (L1.b - L1.a, L2.b - L2.a );

	if (abs (res ) < EPS ) return PARALLEL;

	return OTHER;
}

int main()
{
	ios_base::sync_with_stdio(0);
	int q; cin >> q;
	rep (i, q ){
		line<double> l1, l2;
		cin >> l1.a.x >> l1.a.y >> l1.b.x >> l1.b.y >> l2.a.x >> l2.a.y >> l2.b.x >> l2.b.y;
	
		int res = pos_2_line (l1, l2 );
		cout << res << endl;
	} // end rep
	
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int solve(int h, int w, const auto& g) {
    int ret = 0;
    REP(b, 1 << h) { // row choice
        auto ng = g;

        REP(i, h) { // row
            if ((b >> i) & 1) {
                REP(j, w) ng[i][j] = 1 - ng[i][j];
            }
        }

        int score = 0;
        REP(j, w) {
            int cnt = 0;
            REP(i, h) {
                if (ng[i][j]) cnt++;
            }
            score += max(cnt, h - cnt);
        }

        ret = max(ret, score);
    }

    return ret;
}

int main() {
    int h, w;

    while(cin >> h >> w, h && w) {
        auto g = make_v(h, w, 0);
        REP(i, h)REP(j, w) cin >> g[i][j];

        cout << solve(h, w, g) << endl;
    }

    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long INF = MOD*MOD;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k;
string s,s1,s2;

int main(){
  cin >> n;
  string s[n]; int a[n];
  rep(i,n ){
    cin >> s[i] >> a[i];
  }
  cin >> s1;
  bool frag = false;
  int ans = 0;
  rep(i,n){
    if(frag) ans += a[i];
    if(s[i] == s1) frag = true;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String str = sc.next();
		Pattern p = Pattern.compile("^[0-9]{"+ A +"}-[0-9]{" + B + "}$");
        Matcher m = p.matcher(str);
        if(m.find()) {
        	System.out.println("Yes");
        }else {
            System.out.println("No");
        }
	}

}

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

#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int

int32_t main()
{
	fastIO;
	
	int n,i;
	cin>>n;
	if(n==1)
	cout<<"Hello World";
	else
	{
		int a,b,c;
		cin>>a>>b;
		c=a+b;
		cout<<c;
	}	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair < int, int >
#define pll pair < ll, ll >
using namespace std;

int main()
{
    int n;

    cin >> n;

    set < string > s;

    while(n--){
        string st;

        cin >> st;

        s.insert(st);
    }

    cout << s.size() << endl;

    return 0;
}



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

#define MAX_N 10
#define MAX_D 10
int N, D;

int x[MAX_N][MAX_D];
int cnt=0;

double dist(int i, int j) {
  double d = 0;
  for(int k=0; k<D; k++) {
    d += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
  }
  return sqrt(d);
}

int main() {
  cin >> N >> D;
  for(int i=0; i<N; i++) {
    for(int j=0; j<D; j++) {
      scanf("%d", &x[i][j]);
    }
  }
  for(int i=0; i<N; i++) {
    for(int j=i+1; j<N; j++) {
      double d = dist(i, j);
      if(d - (int)d < 1e-6) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[[]for _ in range(m)]
for i in range(m):
    l[i]=list(map(int,input().split()))
p=list(map(int,input().split()))

ans=0
#all_bits=[]
for i in range(1<<n): 
    #print(i)
    all_bits=[] 
    for j in range(n-1,-1,-1):
        all_bits.append((i>>j)&1) 
    check=True    
#&で取るときにbit計算
#左桁から値を見ていきに任意のBitsをリストへ
    for k in range(m):
        cnt=0
        for idx in range(l[k][0]):
            cnt+=all_bits[l[k][idx+1]-1]
        if cnt%2!=p[k]:
            check=False
            break
    if check==True:
        ans+=1
print(ans)

Measured memory_bytes: 3064