akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int D;
vector<ll> c(27);
vector<vector<ll>> s;
vector<int> last;


void update_happy(ll& happy,int d,int t){
    happy += s[d][t];
    last[t] = d;
    for(int i = 1; i <= 26;i++){
        happy -= c[i]*(d-last[i]);
    }
    return;
}
ll check_happy(ll happy,int d,int t){
    int pre_d = last[t];
    happy += s[d][t];
    
    last[t] = d;
    for(int i = 1; i <= 26;i++){
        happy -= c[i]*(d-last[i]);
    }
    last[t] = pre_d;
    
    return happy;
}

void read_parameters(){
    cin >> D;
    for(int t = 1; t <= 26; t++){
        cin >> c[t];
    }
    s.resize(D+1,vector<ll>(27));
    for(int d = 1; d <= D; d++){
        for(int t = 1; t <= 26;t++){
            cin >> s[d][t];
        }
    }
    last.resize(27);
}
template<class Type>
Type solve(Type res = Type()){
    read_parameters();

    {// B
        ll happy = 0;
        for(int d = 1; d <= D;d++){
            int t; cin >> t;
            
            update_happy(happy, d, t);
            cout << happy << endl;
        }
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    return 0;
}


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

using namespace std;

#define T 380000

int main(){
    int N;
    cin >> N;
    vector< pair<double, string> > pairs(N);
    double ans = 0;
    for(int i = 0; i < N; i++){
        cin >> pairs[i].first >> pairs[i].second;
        if(pairs[i].second == "JPY"){
            ans += pairs[i].first;
        }else{
            ans += pairs[i].first * T;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import collections

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

c = collections.Counter(a)

temp=0
for item in c.keys():
    if c[item]>1:
        temp+=c[item]-1

if temp%2==0:
    print(len(list(c.keys())))
else:
    print(max(len(list(c.keys()))-1,1))


Measured memory_bytes: 18656
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )

int ma, n;
int d[260];
bool dp[260][260];

int main()
{
	while( scanf( "%d", &ma ), ma )
	{
		scanf( "%d", &n );
		memset( dp, false, sizeof( dp ) );
		repi( i, 1, n+1 )
			scanf( "%d", d+i );
		d[0] = d[n+1] = 0;

		rep( i, n+1 )
		{
			repi( j, 1, ma+1 )
			{
				if( i+j > n+1 )
					break;
				dp[i][std::max( std::min( i+j+d[i+j], n+1 ), 0 )] = true;
			}
		}

		rep( k, n+2 )
			rep( i, n+2 )
				rep( j, n+2 )
					if( dp[i][k] && dp[k][j] )
						dp[i][j] = true;

		bool fl = true;
		rep( i, n+1 )
			if( dp[0][i] && !dp[i][n+1] )
				fl = false;
		
		puts( fl ? "OK" : "NG" );
	}

	return 0;
}

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

#define DBG(x) ;//cerr<<#x<<"="<<x<<endl;

using FLOAT = double;
const FLOAT EPS = 1e-8;
const FLOAT INF = 1e12;
typedef complex<FLOAT> P;

inline void cin_P(P&p){
	FLOAT re,im;
	cin>>re>>im;
	p=P(re,im);
}

namespace std{
	bool operator < (const P&a,const P&b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

inline bool EQ(FLOAT a,FLOAT b){return abs(a-b) < EPS;}
inline bool EQV(P a,P b){return EQ(a.real(),b.real()) && EQ(a.imag(),b.imag());}

FLOAT cross(const P&a,const P&b){
	return imag(conj(a)*b);
}

FLOAT dot(const P&a,const P&b){
	return real(conj(a)*b);
}

typedef vector<P> G;

struct L : public vector<P>{
	L(const P&a,const P&b){
		push_back(a);push_back(b);
	}
};

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

bool intersectSS(const L&s,const L&t){
	return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0 && 
	ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}

G convexHull(G ps){
	int n = ps.size(),k = 0;
	assert(n >= 3);
	sort(ps.begin(),ps.end());
	G ch(2 * n);
	for(int i = 0;i < n;ch[k++] = ps[i++])
		while(k >= 2 && ccw(ch[k-2],ch[k-1],ps[i]) <= 0) --k;
	for(int i = n-2,t = k+1;i >= 0;ch[k++] = ps[i--])
		while(k >= t && ccw(ch[k-2],ch[k-1],ps[i]) <= 0) --k;
	ch.resize(k - 1);
	return ch;
}



P st,en;
int N;
G poly;

FLOAT solveConvex(){
	G conv = poly;
	conv.push_back(st);
	conv.push_back(en);
	conv = convexHull(conv);
	int si=-1,ei=-1;
	int M = conv.size();
	for(int i=0;i<M;++i){
		DBG(conv[i])
		if(EQV(conv[i],st))si=i;
		if(EQV(conv[i],en))ei=i;
	}
	assert(si>=0);assert(ei>=0);
	FLOAT one=0.0;
	for(int i=si;i!=ei;i=((i+1)%M)){
		int nx = (i+1)%M;
		one += abs(conv[i]-conv[nx]);
	}
	FLOAT two=0.0;
	for(int i=ei;i!=si;i=((i+1)%M)){
		int nx = (i+1)%M;
		two += abs(conv[i]-conv[nx]);
	}
	FLOAT res = min(one,two);
	return res;
}

FLOAT solveBinary(){
	auto score = [&](P a,P now,P b){
		return abs(a-now)+abs(now-b);
	};
	FLOAT res = INF;
	for(int i = 0;i < N;++i){
		FLOAT lo = 0.0,hi = 1.0;
		P a = poly[i];
		P b = poly[(i+1)%N];
		//a * k + b * (1-k)
		for(int loopcount=0;loopcount<30;++loopcount){
			FLOAT k1 = (lo + lo + hi) / 3;
			FLOAT k2 = (lo + hi + hi) / 3;
			P now1 = a * k1 + b * (1-k1);
			P now2 = a * k2 + b * (1-k2);
			FLOAT sc1 = score(st,now1,en);
			FLOAT sc2 = score(st,now2,en);
			DBG(now1);
			DBG(sc1);
			if(sc1<sc2){
				hi = k2;
			}else{
				lo = k1;
			}
		}
		DBG(res);
		res = min(res,score(st,a*lo+b*(1-lo),en));
	}
	return res;
}

int main(void){
	//cin >> st.real() >> st.imag();
	cin_P(st);
	cin_P(en);
	cin >> N;
	for(int i = 0;i < N;++i){
		P tmp;
		//cin >> tmp.real() >> tmp.imag();
		cin_P(tmp);
		poly.push_back(tmp);
	}
	L path(st,en);
	bool inter = false;//多角形が邪魔をしている
	for(int i = 0;i < N;++i){
		int j = (i + 1) % N;
		if(intersectSS(L(poly[i],poly[j]),path)){
			inter = true;
			break;
		}
	}
	FLOAT ans=0.0;
	DBG(inter);
	if(inter){
		ans = solveConvex();
	}else{
		ans = solveBinary();
	}
	cout.precision(15);
	cout << ans << endl;
	return 0;
}


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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = "No";
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '7')
            {
                ans = "Yes";
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}

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

#define int long long

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int N;
  int M;
  // array<int, 10000> A;
  // string S;
  // string T;

  array<int, 50> A;
  array<int, 50> B;
  // array<array<int, 50>, 50> E;
  
  // array<array<int, 2>, 50> E;

  cin >> N >> M;

  for (int i = 0; i < M; ++i) {
    cin >> A[i] >> B[i];
    A[i] -= 1;
    B[i] -= 1;
    // E[A[i]][B[i]] = 1;
    // E[B[i]][A[i]] = 1;
  }

  for (int i = 0; i < M; ++i) {
    // cout << "Remove edge: " << i << endl;

    array<bool, 50> visited;
    vector<int> stack;
    
    for (auto it = visited.begin(); it < visited.begin() + N; ++it) *it = false;
    stack.push_back(0);
    visited[0] = true;

    while(stack.size() > 0) {
      int v = stack.back();
      stack.pop_back();

      for (int j = 0; j < M; ++j) {
        if (i == j) continue;
        if (A[j] == v && !visited[B[j]]) {
          visited[B[j]] = true;
          stack.push_back(B[j]);
        }
        if (B[j] == v && !visited[A[j]]) {
          visited[A[j]] = true;
          stack.push_back(A[j]);
        }
      }
    }

    bool flag = true;
    for (auto it = visited.begin(); it < visited.begin() + N; ++it) if (!*it) flag &= false;
    if (!flag) ++num;
    
  }
  
  // cin >> N;
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   cin >> *it;
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   if (*it % 2 == 0) ++num;
  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, y, m, d, i;
  int mille=196471;
  int res;
  
  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d%d%d", &y, &m, &d);
    res=0;

    res+=((y-1)/3)*200+((y-1)-(y-1)/3)*195;

    if(y%3==0){
      res+=(m-1)*20+d;
    }else{
      res+=(m-1)/2*19+((m-1)-(m-1)/2)*20+d;
    }

    printf("%d\n", mille-res);
    
  }
  
  return 0;
}

Measured memory_bytes: 596
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long m = long.Parse(input[1]);
    long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[,] dp = new long[m+1,n+1];//m枚目のコインまでを使い、n円払う時の最小枚数
    for(long i = 0; i <= m; i++)
    {
      for(long j = 0; j <= n; j++)
      {
        dp[i,j] = 99999;
      }
    }

    dp[0,0] = 0;

    for(long i = 0; i <= m; i++)
    {
      for(long j = 0; j <= n; j++)
      {
        if(i>=1)
        {
          dp[i,j] = Math.Min(dp[i,j], dp[i-1, j]);
          if(j-nums[i-1] >= 0)
          {
            dp[i,j] = Math.Min(dp[i,j], dp[i, j-nums[i-1]] + 1);
            dp[i,j] = Math.Min(dp[i,j], dp[i-1, j-nums[i-1]] + 1);
          }
        }
      }
    }
    
		Console.WriteLine(dp[m,n]);
	}
}


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

int GCD(int a,int b){
    if(a<b) swap(a,b);
    //cout << a << " " << b << endl;
    if(b == 0) return a;
    else return GCD(a%b, b);
}


int main(){
    int N;cin>> N;
    int A[N];
    int L[N];
    int R[N];
    for(int i=0;i<N;i++) cin >> A[i];
    L[0] = 0;
    R[0] = 0;
    for(int i=0;i<N-1;i++){
        L[i+1] = GCD(L[i],A[i]);
        R[i+1] =GCD(R[i],A[N-i-1]);
        //cout << L[i+1] << " " << R[i+1] << endl;
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        ans = max(ans,GCD(L[i],R[N-1-i]));
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#define D(x) std::cout << __LINE__ << ' ' << #x << " = " << x << std::endl;

int main() {
#ifndef LOCAL_STJO
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
	int n;
	std::cin >> n;
	int mina = 1<<30, maxb = -1, asd = 0;
	for(int i = 0;i < n;++ i) {
		int a, b;
		std::cin >> a >> b;
		a = std::min(a, mina);
		if(a > maxb) {
			maxb = a;
			asd = b;
		}
	}
	std::cout << maxb + asd << std::endl;
    return 0;
}



Measured memory_bytes: 256
A,B,C,D=map(int,input().split())
taka=[A,B]
ao=[C,D]
import sys
while True:
    ao[0]-=taka[1]
    if ao[0]<=0:
        print('Yes')
        sys.exit()
    taka[0]-=ao[1]
    if taka[0]<=0:
        print('No')
        sys.exit()

Measured memory_bytes: 61768
N = int(input())
*A, = map(int, input().split())
ans = 0
cnt = 0
pre = -1
for a in A:
    if pre < a:
        ans = max(ans, cnt)
        cnt = 0
    else:
        cnt += 1
    pre = a
ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 20460
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,temp,m=0,sum=0;
	cin >> n;
	while(n)
	{
		cin >> temp;
		sum += temp;
		m = max(m, temp);
		n--;
	}
	sum -= m;
	m<sum ? cout << "Yes" : cout << "No";
	return 0;
} 

Measured memory_bytes: 3624
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B, long T) {
    return T / A * B;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    long T;
    T = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B, T);
    else
        solve(A, B, T).writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 200005;
int arr[MAXN], num[MAXN], n;

bool check(int mid) {
	for (int i = 1; i < 2 * n; i++) num[i] = arr[i] >= mid;
	num[0] = num[1], num[2 * n] = num[2 * n - 1];
	int l = n, r = n;
	while (num[l - 1] != num[l]) --l;
	while (num[r + 1] != num[r]) ++r;
	return r - n < n - l ? num[r] : num[l];
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < 2 * n; i++) scanf("%d", arr + i);
	int l = 1, r = 2 * n;
	while (l + 1 < r) {
		int mid = (l + r) >> 1;
		if (check(mid)) l = mid;
		else r = mid;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

const int N = 1e5 + 10;
vector<int> g[N];
int black[N], white[N], ans;

void dfs(int v, int p, int curh) {
	if (curh & 1) {
		black[v]++;
	}
	else {
		white[v]++;
	}
	for (auto u : g[v]) {
		if (u != p) {
			dfs(u, v, curh + 1);
			black[v] += black[u];
			white[v] += white[u];
			ans += abs(black[u] - white[u]);
		}
	}
}

int h[N], cycle_len, from, to, cnt_white, cnt_black;
int tin[N], tout[N], timer;
bool anc(int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}
void check(int v, int p = 0, int curh = 1) {
	h[v] = curh;
	tin[v] = ++timer;
	if (curh & 1) {
		cnt_black++;
	}
	else {
		cnt_white++;
	}
	for (auto u : g[v]) {
		if (u == p) {
			continue;
		}
		if (!h[u]) {
			check(u, v, curh + 1);
		}
		else {
			cycle_len = abs(h[v] - h[u]) + 1;
			from = v;
			to = u;
			if (h[v] > h[u]) {
				swap(from, to);
			} 
		}	
	}
	tout[v] = ++timer;
}

void dfs_even(int v, int p, int x) {
	if (h[v] & 1) {
		black[v] = 1;
		white[v] = 0;
	}
	else {
		white[v] = 1;
		black[v] = 0;
	}
	for (auto u : g[v]) {
		if (u == p || (min(u, v) == min(from, to) && max(u, v) == max(from, to))) {
			continue;
		}
		dfs_even(u, v, x);
		if (anc(from, v) && anc(u, to)) {
			ans += abs(x + black[u] - white[u]);
		}
		else {
			ans += abs(black[u] - white[u]);
		}
		white[v] += white[u];
		black[v] += black[u];
	}
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
	int n, m;
	cin	>> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	if (m == n - 1) {
		dfs(1, 0, 0);
		if (white[1] == black[1]) {
			cout << ans << '\n';
		}
		else {
			cout << -1 << '\n';
		}
	}
	else {
		check(1);
		if (cycle_len % 2 == 0) {
			if (cnt_white != cnt_black) {
				cout << -1 << '\n';
				exit(0);
			}
			int l = -n, r = n;
			while (r - l > 30) {
				int m1 = (l + l + r) / 3, m2 = (l + r + r) / 3;
				ans = 0;
				dfs_even(1, 0, m1);
				int kek1 = ans + abs(m1);
				ans = 0;
				dfs_even(1, 0, m2);
				int kek2 = ans + abs(m2);
				if (kek1 < kek2) {
					r = m2;
				}
				else {
					l = m1;
				}
			}
			int best = 1e18;
			for (int x = l; x <= r; x++) {
				ans = 0;
				dfs_even(1, 0, x);
				best = min(best, ans + abs(x));
			}
			cout << best << '\n';
		}
		else {
			if (cnt_white % 2 != cnt_black % 2) {
				cout << -1 << '\n';
				exit(0);
			}
			int add = abs(cnt_white - cnt_black) / 2;
			if (cnt_white < cnt_black) {
				white[from] += add;
				white[to] += add;
			}
			else {
				black[from] += add;
				black[to] += add;
			}
			for (int i = 0; i < SZ(g[from]); i++) {
				if (g[from][i] == to) {
					g[from].erase(g[from].begin() + i);
					break;
				}
			}
			for (int i = 0; i < SZ(g[to]); i++) {
				if (g[to][i] == from) {
					g[to].erase(g[to].begin() + i);
					break;
				}
			}
			dfs(1, 0, 1);
			cout << ans + add << '\n';
		}
	}
} 

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

int main() {
	int a, b;

	string pm;

	cin >> a>>pm>>b;

	if (pm == "+") {
		cout << a + b << endl;
	}

	else{
		cout << a - b << endl;
	}

	return 0;
}

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

int N;
double p[3010],dp[3010][3010];

int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> p[i];
	}
	double ans = 0;
	dp[0][0] = 1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=i;j++){
			dp[i][j] += dp[i-1][j]*(1-p[i]);
			if(j>0) dp[i][j] += dp[i-1][j-1]*p[i];
			if(i==N && j>=(N+1)/2) ans += dp[i][j];
		}
	}
	printf("%.10f\n",ans);
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define FOR(i,s,e) for(int i = s; i < e; i++)
#define all(x) (x).begin(),(x).end()
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair

typedef vector<int>       VI;
typedef pair<int, int> pii;
typedef long long ll;


int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    // freopen("out.txt", "w", stdout);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        puts("bust");
        return 0;
    }
    puts("win");
    return 0;
}

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

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

using namespace std;

int main(){
	int x[5];
	rep(i,5) scanf("%d",&x[i]);
	rep(i,5) if(x[i]==0) printf("%d\n",i+1);
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MOD = 1e9+7;
const long long INF = 1LL << 60;
const int INF_INT = 1e9;
typedef long long ll;

int main(){
    int n,d;
    cin >> n >> d;
    vector<vector<int> > x(n, vector<int> (d));
    rep(i,n)rep(j,d)cin>>x[i][j];
    int cnt=0;
    /* for(int i = 0; i < n; i++){
        double res=0;
        for(int l=i+1;l<n;l++){
            for(int j = 0; j < d; j++){
                double a = (pow((double)abs(x[i][j]-x[l][j]),2));
                res += a;
            }
        }
        res = sqrt(res);
        cout<<"res "<<res<<endl;
        if(ceil(res)==floor(res)){
            cnt++;
        }
    } */
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int res = 0;
            for(int k=0;k<d;k++){
                int a = abs(x[i][k]-x[j][k]);
                res += a * a;
            }
            bool flag = false;
            for(int k=0;k<=res;k++){
                if(k*k==res)flag=true;
            }
            if(flag) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int H = 0;

void maxHeapify(int *A,int i){
  int largest,ch,l,r;
  l = 2*i;
  r = 2*i+1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    ch = A[i];
    A[i] = A[largest];
    A[largest] = ch;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  for(i = H/2;i >= 1; i--) maxHeapify(A,i);
}


void insert(int *A,int n){
  int i = H + 1,ch;
  H++;
  A[H] = n;
  while(i > 1 && A[i] > A[i/2]){
    ch = A[i];
    A[i] = A[i/2];
    A[i/2] = ch;
    i = i/2;
  }
}

int extract(int *A){
  int max;
  if(H < 1) printf("cannot extract\n");
  max = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(A,1);
  return max;
}

int main(){
  int i,n;
  int A[2000000];
  char mai[20];
  while(1){
    scanf("%s",mai);
    if(mai[0] == 'i'){
      scanf("%d",&n);
      insert(A,n);
    }
    else if(mai[1] == 'x') printf("%d\n",extract(A));
    else break;
    }
  return 0;
}



Measured memory_bytes: 5604
#include<stdio.h>
int main() {
	int  a, b, c, d, e, f,sum;
		scanf("%d %d %d %d %d %d", &a,&b,&c,&d,&e,&f);
		sum = a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500;
		if (1000 <= sum) {
			printf("1\n");
		}
		else {
			printf("0\n");
		}

	return 0;
}


Measured memory_bytes: 2596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;




int main(){

    int n;
    cin >> n;
    vector<P> a(n);
    vector<int> ans(n,0);

    REP(i,n){
        cin >> a[i].first;
        a[i].second = i;
    }

    VSORT(a);

    REP(i,n){

        if(i < n/2){

            ans[a[i].second] = a[n/2].first;
        }else{

            ans[a[i].second] = a[n/2-1].first;
        }
    
    }


    REP(i,n){
        cout << ans[i] << endl;
    }

    return 0;

}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string s;
    cin >> s;
    if (s.back() == 's') s += "es";
    else s += 's';
    cout << s << '\n';
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,x; cin>>n>>x;
  if(x==1||x==2*n-1) return cout<<"No"<<endl,0;
  cout << "Yes" << endl;
  VI ans(2*n-1,-1);
  ans[n-2]=1, ans[n-1]=x, ans[n]=2*n-1;
  int cnt = 0;
  for(int i=2; i<2*n-1; i++){
    if(i==x) continue;
    while(ans[cnt]!=-1) cnt++;
    ans[cnt] = i;
  }
  rep(i,2*n-1) cout<<ans[i]<<endl;


  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	set<string> s;
	char c='A';
	bool ok=true;
	rep(i,0,n){
		string t; cin>>t;
		if(s.count(t)) ok=false;
		s.insert(t);
		char d=t[0];
		if(i!=0 && c!=d) ok=false;
		c=t[t.size()-1];
	}
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
		
	
	return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n;
	cin >> n;
	
	map<int,int> m;
	
	int a;
	f(i,0,n)
	{
		cin >> a;
		m[a] ++;
	}
	cout << (m.size() == n ? "YES" : "NO");
}



Measured memory_bytes: 12800
N=chomp(readline())
K=parse(Int,readline())
dp=zeros(Int,length(N)+1,2,4)
dp[1,1,1]=1
for i=1:length(N),j=1:2
	lim=j==1 ? Int(N[i])-48 : 9
	for k=1:K+1,l=0:lim
		nk=k+(l!=0)
		nj=j==2||l<lim ? 2 : 1
		if nk<=K+1
			dp[i+1,nj,nk]+=dp[i,j,k]
		end
	end
end
println(dp[length(N)+1,1,K+1]+dp[length(N)+1,2,K+1])


Measured memory_bytes: 164384
N = int(input())
X = list(map(int, input().split()))
 

cnt_min = 10000000000000000

for P in range(0, 101):
  cnt = 0
  for x in X:
    cnt += (P-x)**2
  if cnt < cnt_min:
    cnt_min = cnt
  
print(cnt_min)

Measured memory_bytes: 2940
m,d=map(int,input().split())
c=0
# print (m,d)
if d<22:
    print(0)
else:
    for i in range(1,m+1):
        for j in range(22,d+1):
            if ((j%10 )*((j-(j%10))//10))==i and j%10>=2:
                c+=1
    print(c)
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
const ll mod = 998244353;
double dp[maxn];
ll b[maxn];
int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        memset(dp,0,sizeof(dp));
        for(int i = k; i <= max(2*k,n); ++i)dp[i] = 1.0;
        for(int i = k-1; i > 0; --i)
            dp[i] = dp[i*2]/2.0;
        double ans = 0.0;
        for(int i = 1; i <= n; ++i)
            ans += dp[i];
        ans /= (double)n;
        printf("%.10lf\n",ans);
    }
}




















Measured memory_bytes: 9728
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main()
{
	char a[4];
	int sum=0;
	for(int i=0;i<4;i++)
	{
		cin>>a[i];
		if(a[i]=='+')
		{
			sum++;
		}
		else
		{
			sum--;
		}
	}
	cout<<sum;
	return 0;
 } 

Measured memory_bytes: 256
import numpy

N = int(input())
X = numpy.zeros(N)
Y = numpy.zeros(N)

for i in range(N):
  x, y = map(int, input().strip().split())
  X[i] = x
  Y[i] = y

diff_X = (X[None, :] - X[:, None]) ** 2
diff_Y = (Y[None, :] - Y[:, None]) ** 2

distances = (diff_X + diff_Y) ** .5
print(distances.mean() * N)


Measured memory_bytes: 12488
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
ll modpow(ll n, ll x, ll MOD){
	ll ret = 1;
	while(x){
		if(x&1){
			(ret*=n)%=MOD;
		}
		x >>= 1;
		(n*=n)%=MOD;
	}
	return ret;
}
int solve(int k, int MOD){
	if(__gcd(10, MOD) != 1){
		return -1;
	}
	for(int i = 1; i <= MOD; ++i){
		if(modpow(10, i, MOD) == 1){
			return i;
		}
	}
}
int main(){
	int k;
	cin >> k;
	if(k%7 == 0){
		cout << solve(k, 9*(k/7));
	}
	else{
		cout << solve(k, 9*k);
	}
}


Measured memory_bytes: 3632
n=int(input())
ans=10**5
for a in range(1,n//2+1):
  b=n-a
  ans=min(ans,a%10+a//10%10+a//100%10+a//1000%10+a//10000%10+b%10+b//10%10+b//100%10+b//1000%10+b//10000%10)
print(ans)
  

Measured memory_bytes: 2940
n = int(input())
odd = []
even = []
for i in range(n):
    s = int(input())
    if s % 2:
        odd.append(s)
    else:
        even.append(s)
odd = sorted(odd,reverse = True)

ans = 0
if len(odd) == 0:
    print(0)
    exit()
elif len(odd) == 1:
    ans += odd[0]
    ans += sum(even)
elif len(odd) % 2 == 1:
    ans += sum(odd)
    ans += sum(even)
else:
    ans += sum(odd[:len(odd)-1])
    ans += sum(even)
print(ans)


Measured memory_bytes: 3064
// Rasec
// https://atcoder.jp/contests/dp/tasks/dp_b
// dynamic programming

#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;
int N, K;
ll h[100010];

int main() {
	optimizar_io
	ll dp[100010];

	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> h[i];
	fill(dp, dp + N, 1e9);
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			if (i - j >= 0)
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[N - 1] << "\n";
	return 0;
}

Measured memory_bytes: 5188
w, h, x, y, r = gets.split(" ")
w = w.to_i;h = h.to_i;x = x.to_i;y = y.to_i;r = r.to_i;
if x - r >= 0 && y - r >= 0
    if x + r <= w && y + r <= h
        puts "Yes"
    else
        puts "No"
    end
else
    puts "No"
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int N, M, K; cin >> N >> M >> K;

// a個の行ボタンを押して， b 個の列ボタンを押して作れる数
rep(a, 0, N+1) rep(b, 0, M+1){
    if (K == a * M + b * N - 2 * a * b) {cout << "Yes\n"; return 0;}
}

cout << "No\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
n=int(input())
a=[int(x) for x in input().split()]#町のモンスターの数
b=[int(x) for x in input().split()]#それぞれが倒せる敵の数
count=0
for i in range(n):
    if a[i]<=b[i]:
        count+=a[i]
        b[i]-=a[i]
        a[i]=0
        if a[i+1]<=b[i]:
            count+=a[i+1]
            b[i]-=a[i+1]
            a[i+1]=0
        else:
            count+=b[i]
            a[i+1]-=b[i]
            b[i]=0
    else:
        count+=b[i]
        a[i]-=b[i]
        b[i]=0
print(count)

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

int main() {
 int R;
  cin >> R;
  
  if ( R < 1200 ){
    cout << "ABC" << endl;
    
  } else if ( R >= 1200 && R < 2800 ){ 
    cout << "ARC" << endl;
    
  } else{
    cout << "AGC" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
// *start on @date: 2020-03-01 20:18 
using namespace std;
typedef long long ll;
const int maxn = 1000 + 5;
const int inf  = 0x3f3f3f3f;

int nums[10];
int flag[10];

int f = 0;
void add(int x)
{
    for (int i = 0; i < 9; i++)
    {
        if(nums[i] == x){
            flag[i] = 1;
        }
    }
    
}   


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

    
    int n = 9,tmp;
    for (int i = 0; i < 9; i++)
    {
        cin>>nums[i];
    }
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>tmp;
        add(tmp);
    }
    
    for (int i = 0; i < 9; i+=3)
    {
        if(flag[i]&&flag[i+1]&&flag[i+2]){
            f= 1;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        if(flag[i]&&flag[i+3]&&flag[i+6])f=1;
    }
    /*
    0 1 2
    3 4 5
    6 7 8
    */
    
    if(flag[0]&&flag[4]&&flag[8])f=1;

    if(flag[2]&&flag[4]&&flag[6])f = 1;

    if(f){
        cout<<"Yes\n";
    }else
    {
        cout<<"No\n";
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	string S;
	cin >> S;

	int Z = S.size();
	vector<int>ans(Z);
	vector<int>dis(Z);
	for (int i = 0; i < Z - 2; i++) {
		int N = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2]) - '0';
		ans[i] = N;
	}
	for (int i = 0; i < Z; i++) {
		dis[i] = abs(753 - ans[i]);
	}

	sort(dis.begin(), dis.end());
	cout << dis[0] << endl;
}

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

int main(void){
   
    int n, m;
    cin>>n>>m;
    
    vector<string> a(n), b(m);
    
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    
    for(int i=0; i<m; i++){
        cin>>b[i];
    }
    
    bool bb=false;
    int idy=0;
    while(idy<=n-m){
        for(int i=0; i<n-m+1; i++){
            
            bb=true;
            for(int my=0; my<m; my++){
                for(int mx=0; mx<m; mx++){
                    if(b[my][mx]!=a[idy+my][i+mx]){
                        bb=false;
                    }
                }
            }
            
            if(bb){
                break;
            }
        }
        if(bb){
                break;
            }
        idy++;
    }
    
    if(bb){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[114514],b[114514];
int main() {
	ll n;
	string a,b,c;
	ll cnt=0;
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			if(b[i]!=c[i]){
				if(c[i]!=a[i])cnt+=2;
				else cnt++;
			}else cnt++;
		}else if(b[i]!=c[i])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	ll N,X;
	bool flag = false;
	ll ans = 1;
	ll MIN = 1000000000;
	ll x[100000];
	cin >> N >> X;
	REP(i, N) {
		cin >> x[i];
	}
	x[N] = X;
	sort(x, x + N + 1);
	REP(i, N) {
		MIN = min(x[i + 1] - x[i],MIN);
	}
	for (int D = MIN; D > 1; D--) {
		REP(i, N + 1) {
			if ((X - x[i]) % D == 0){
				flag = true;
			}
			if ((X - x[i]) % D != 0) {
				flag = false;
			}
			if (flag == false) break;
		}
		if (flag == true) ans = D;
		if (flag == true) break;
	}
	cout << ans;

	return 0;



}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();

            int min = 1000000;
            int max = -1000000;
            decimal sum = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] < min)
                {
                    min = a[i];
                }
                if (max < a[i])
                {
                    max = a[i];
                }

                sum += a[i];
            }

            Console.WriteLine(min + " " + max + " " + sum);
        }
    }
}


Measured memory_bytes: 20316
from collections import defaultdict
from collections import deque


class UnionFindTree:
    def __init__(self):
        self.p = {}
        self.rank = {}

    def make(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def find(self, x):
        if x in self.p:
            if self.p[x] != x:
                # 経路圧縮
                self.p[x] = self.find(self.p[x])
            return self.p[x]
        return None

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        return self._unite(self.find(x), self.find(y))

    def _unite(self, x, y):
        if self.rank[x] < self.rank[y]:
            self.p[x] = y
            return y
        else:
            self.p[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            return x


def nc2(n):
    return (n * (n - 1)) >> 1


N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

utf = UnionFindTree()
for n in range(1, N + 1):
    utf.make(n)

h = {}
ans = deque([])
total = nc2(N)
now = 0
for i in range(M):
    ans.appendleft(total)

    a, b = ab[M - i - 1]
    x, y = utf.find(a), utf.find(b)
    a = utf.unite(x, y)
    if x != y:
        nx, ny = h.get(x, 1), h.get(y, 1)
        n = nx + ny
        total += nc2(nx) + nc2(ny)
        total -= nc2(n)

        h[x] = 1
        h[y] = 1
        h[a] = n

for v in ans:
    print(v)

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

ll H, W, K;
char c[10][10];
char now_c[10][10];

bool count(int h, int w, char c[10][10]) {
    for(int i = 0; i < H; i++) {
        if(h & 1) {
            for(int j = 0; j < W; j++) {
                c[i][j] = '.';
            }
        }
        h >>= 1;
    }
    for(int i = 0; i < W; i++) {
        if(w & 1) {
            for(int j = 0; j < H; j++) {
                c[j][i] = '.';
            }
        }
        w >>= 1;
    }
    int cnt = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(c[i][j] == '#') {
                cnt++;
            }
        }
    }
    return (cnt == K);
}

int main() {
    cin >> H >> W >> K;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < (1 << H); i++) {
        for(int j = 0; j < (1 << W); j++) {
            for(int k = 0; k < H; k++) {
                for(int l = 0; l < W; l++) {
                    now_c[k][l] = c[k][l];
                }
            }
            if(count(i, j, now_c)) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3564
use std::io;

fn read_line<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn solve_a(n: usize) -> usize {
    n * (n + 1) / 2
}

fn main() {
    let input = read_line::<usize>()[0];
    println!("{}", solve_a(input));
}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;

int main(){
  double a;
  ll b,n;
  cin>>a>>b>>n;
  if(n<=b-1){
    cout<<(int)floor(a*n/b);
  }else{
    cout<<(int)floor(a*(b-1)/b);
  }
}

Measured memory_bytes: 3840
n = int(input())
A = [input() for i in range(n)]
m = int(input())
B = [input() for i in range(m)]
T = [""] * n
ans = 0

for i in range(n):
    if A[i] not in T:
        T[i] = A[i]
        ans = max(ans, A.count(A[i]) - B.count(A[i]), 0)

print(ans)

Measured memory_bytes: 3064
# 200 points
import math

# -*- coding: utf-8 -*-
dic = [0, 0, 0, 0]
# スペース区切りの整数の入力
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

dic[a1-1] += 1
dic[a2-1] += 1
dic[a3-1] += 1
dic[b1-1] += 1
dic[b2-1] += 1
dic[b3-1] += 1

x1 = len([i for i, x in enumerate(dic) if x == 1])
x2 = len([i for i, x in enumerate(dic) if x == 2])

if x1 == 2 and x2 == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

vector<vector<int>> v;
void calc1(int x,int y){
    rep(i,0,4){
        int nx=x+dx[i],ny=y+dy[i];
        if(0<=nx&&0<=ny&&nx<10&&ny<10)v[ny][nx]++;
    }
}

void calc2(int x,int y){
    for(int i=-1;i<=1;i++){
        for(int j=-1;j<=1;j++){
            if(i!=0||j!=0){
                int nx=x+i,ny=y+j;
                if(0<=nx&&0<=ny&&nx<10&&ny<10)v[ny][nx]++;
            }
        }
    }
}

void calc3(int x,int y){
    calc2(x,y);
    rep(i,0,4){
        int nx=x+dx[i]*2,ny=y+dy[i]*2;
        if(0<=nx&&0<=ny&&nx<10&&ny<10)v[ny][nx]++;
    }
    
}
int main() {
    v.resize(10,vector<int>(10,0));
    int x,y,mode;
    char c;
    while(cin>>x>>c>>y>>c>>mode){
        if(mode==1)calc1(x,y);
        else if(mode==2)calc2(x,y);
        else if(mode==3)calc3(x,y);
        
        v[y][x]++;
    }
    
    int blank=0,ma=-INF;
    rep(i,0,10){
        rep(j,0,10){
            if(v[i][j]==0)blank++;
            ma=max(ma,v[i][j]);
        }
    }
    cout<<blank<<endl<<ma<<endl;
    
  
    return 0;
}



Measured memory_bytes: 3048
n = gets.to_i

line = readlines.map(&:chomp)

h = line.group_by(&:itself).transform_values(&:size)

puts "AC x #{h["AC"]||= 0}"
puts "WA x #{h["WA"]||= 0}"
puts "TLE x #{h["TLE"]||= 0}"
puts "RE x #{h["RE"]||= 0}"

Measured memory_bytes: 26200
/**
 * Created by hiramekun at 15:13 on 2019-08-23.
 */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl x(n), y(n), h(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
    }

    for (ll Cx = 0; Cx <= 100; ++Cx) {
        for (ll Cy = 0; Cy <= 100; ++Cy) {
            ll H = -1;
            rep(i, n) {
                if (h[i] != 0) {
                    ll dx = abs(x[i] - Cx), dy = abs(y[i] - Cy);

                    ll tmp = h[i] + dx + dy;
                    if (H == -1) H = tmp;
                    if (H != tmp) break;
                }
                
                if (i == n - 1) {
                    rep(j, n) {
                        ll dx = abs(x[j] - Cx), dy = abs(y[j] - Cy);
                        if (h[j] == 0 && dx + dy < H) break;
                        if (j == n - 1) {
                            cout << Cx << " " << Cy << " " << H << '\n';
                        }
                    }
                }
            }
        }
    }


}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

ll gcd (ll x, ll y) {
  if(x==0) return y;
  return gcd(y%x,x);
}

ll lcm (ll x, ll y){
  return x / gcd(x, y) * y;
}


int main() {
  ll a, b; cin >> a >> b;
  ll ans = lcm(a, b);
  cout << ans << endl;
}


Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
N=int(input())

# 1 2 3 4 5
# 2 3 4 5 1

ans = 0

for i in range(N-1):
    ans += i+1

print(ans)

Measured memory_bytes: 77592
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char a[20];
int main()
{
	int len=0,flag=1;
	cin>>a;
	len=strlen(a);
	for(int i=0;i<len;i++)
		{
			
			if(a[i]=='A'&&a[i+1]=='C')
				{
					cout<<"Yes"<<endl;
					flag=0;
					break;
				}
		}
		if(flag)
		cout<<"No"<<endl; 
}


Measured memory_bytes: 256