akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

vector<vector<pair<int ,int>>> c;

int main(){
    int n;
    cin >> n;
    int a;
    int x, y;
    rep(i, n){
        cin >> a;
        vector<pair<int, int>> v;
        rep(j, a){
            cin >> x >> y;
            v.push_back(make_pair(x-1, y));
        }
        c.push_back(v);
    }
    int max_ = 0;
    for(int bit = 0; bit < (1<<n); bit++){
        bool flag = true;
        for(int i = 0; i < n; i++){
            if(!(bit & (1<<i))) continue;
            for(auto v: c[i]){
                if(!(bit & (1<<v.first)) && v.second) flag = false;
                if(bit & (1<<v.first) && !v.second) flag = false;
            }
        }
        if(flag){
            int cnt = 0;
            for(int i = 0; i < n; i++){
                if(bit & (1<<i)) cnt++;
            }
            max_ = max(cnt, max_);
        }
    }
    cout << max_ << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

signed main()
{
  ll A, B;
  cin >> A >> B;

  ll ans = -1;
  ll MAX = 1000;
  FOR(i, 1, MAX + 1)
  {
    ll a = floor((double)i * 0.08);
    ll b = floor((double)i * 0.1);
    if (a == A && b == B)
    {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

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

int main()
{
  int N,A,B ;
  cin>>N>>A>>B ;
  vector<int>P(N) ;
  for(int i=0;i<N;i++) cin>>P.at(i) ;
  
  sort(P.begin(),P.end()) ;
  int num_1=0,num_2=0,num_3=0 ;
  for(int i=0;i<N;i++){
    if(P.at(i)<=A) num_1++ ;
    else if(A+1<=P.at(i)&&P.at(i)<=B) num_2++ ;
    else if(B+1<=P.at(i)) num_3++ ;
  }
  int X=(num_1<num_2?num_1:num_2) ;
  cout<<(X<num_3?X:num_3)<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <vector>

using namespace std;

vector<pair<long long int, long long int>> dev;

// 約数
void devisor(vector<pair<long long int, long long int>> &dev,
    const long long int &N)
{
    long long n;
    int i = 1;

    n = N;

    while (i <= sqrt(n))
    {
        if (n % i == 0)
        {
            dev.push_back(make_pair(i, n / i));
        }

        i++;
    }
}

unsigned GetDigit(unsigned num) {
    return log10(num) + 1;
}

int main()
{
    long long N;
    if (scanf("%lld", &N) < 1) return 0;

    // 約数を求める
    devisor(dev, N);

    long long mn = 10000000001L;
    for (int i = 0; i < (signed)dev.size(); i++)
    {
        long long f = GetDigit(dev[i].first);
        long long s = GetDigit(dev[i].second);
        long long tmp = max(f, s);
        mn = min(mn, tmp);
    }

    printf("%lld\n", mn);
    return 0;
}


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

using namespace std;

int main(){
	int h, w, ans = 0;
	cin >> h >> w;
    vector<int> cnt(26);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c;
            cin >> c;
            cnt[c - 'a']++;
        }
    }
    int c1 = 0, c2 = 0, c4 = 0;
    for(int i = 0; i < 26; i++){
        c4 += cnt[i] / 4;
        c2 += (cnt[i] % 4) / 2;
        c1 += cnt[i] % 2;
    }
    int g1, g2, g4;
    if(h % 2 == 1 && w % 2 == 1){
        g1 = 1;
        g2 = (int)(h / 2) + (int)(w / 2);
        g4 = (int)(h / 2) * (int)(w / 2);
    }else if (h % 2 == 1 && w % 2 == 0){
        g1 = 0;
        g2 = w / 2;
        g4 = (int)(h / 2) * (int)(w / 2);
    }else if(h % 2 == 0 && w % 2 == 1){
        g1 = 0;
        g2 = h / 2;
        g4 = (int)(h / 2) * (int)(w / 2);
    }else if(h % 2 == 0 && w % 2 == 0){
        g1 = 0;
        g2 = 0;
        g4 = (int)(h / 2) * (int)(w / 2);
    }
    if(c4 > g4){
        c2 += 2 * (c4 - g4);
        c4 = g4;
    }
    if(c4 != g4 || c2 != g2 || c1 != g1){
        cout << "No" << endl;
    }else{
	    cout << "Yes" << endl;
    }
	return 0;
}


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

int main(){
    int S;
    cin >> S;
    int h = S/(3600);
    int m = (S%(3600))/60;
    int s = (S%(3600))%60;
    cout << h << ':' << m << ':' << s << endl; 
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    ll A,B;
    cin >> A >> B;
    rep(i,N-1){
        ll a,b;
        cin >> a >> b;
        ll c = (A+a-1)/a;
        ll d = (B+b-1)/b;
        A = max(c,d)*a;
        B = max(c,d)*b;
    }
    cout << A + B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin >> n;
	map <ll, ll> m;
	ll cnt = 0;
	for(ll i = 0; i < n; i++){
		ll a;
		cin >> a;
		cnt += m[i - a];
		m[i + a]++;
	}
	cout << cnt;
}

Measured memory_bytes: 26376
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int n; cin >> n;
	vector<string> str(n);
	vint t(n);
	ll sum = 0;
	rep(i, n){
		cin >> str[i] >> t[i];
		sum += t[i];
	}
	string x; cin >> x;
	ll hoge = 0;
	rep(i, n){
		hoge += t[i];
		if(str[i] == x) break;
	}
	ans = sum - hoge;

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

Measured memory_bytes: 256
n,k = map(int, input().split())
H = list(map(int, input().split()))
dp = [10**9 for i in range(n)]

dp[0] = 0
for i in range(n-1):
    for j in range(1,min(k+1,n-i)):
        dp[i+j] = min(dp[i+j],dp[i]+abs(H[i+j]-H[i]))
print(dp[n-1])

Measured memory_bytes: 56544
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	for (int u = 0; u < 100; u++)
	{
		int a[5],b[5];
		int p = 0;

		for (int i = 0; i < 5; i++)
		{
			cin >> a[i] >> b[i];
			if (a[i] == 0 && b[i] == 0)
			{
				p++;
				break;
			}
		}
		if (p != 0)
		{
			break;
		}

		int gg = 0,ggg = 0;
		for (int i = 0; i < 5; i++)
		{
			if (a[i] + b[i] > gg)
			{
				gg = 0;
				gg = a[i] + b[i];
				ggg = 0;
				ggg = i;
			}
		}


		if (ggg == 0)
		{
			cout << 'A';
		}
		else if (ggg == 1)
		{
			cout << 'B';
		}
		else if (ggg == 2)
		{
			cout << 'C';
		}
		else if (ggg == 3)
		{
			cout << 'D';
		}
		else if (ggg == 4)
		{
			cout << 'E';
		}
		cout << " " << gg << endl;
	}
}



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        System.out.println(getX(b, x) - getX(a - 1, x));
    }

    static long getX(long a, long x) {
        if (a < 0) {
            return 0;
        } else {
            return a / x + 1;
        }

    }

}

Measured memory_bytes: 22868
import math

N = int(input())
root_N = int(math.sqrt(N)) + 1
A = 100000000000000000000000000000000000

for i in range(1, root_N):
    if N % i == 0:
        B = N//i
        A = min(A, B)

ans_1 = A
ans_2 = N//A
ans = ((ans_1)-1) + ((ans_2)-1)

print(ans)

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

int main()
{
  int x, y;
  cin >> x >> y;

  if (x == y)
    cout << "Yes" << endl;
  else if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11))
    cout << "Yes" << endl;
  else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12))
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
    

}


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

void solve() {
   int n;
   cin >> n;
   vector <int> v(n), vr(n);
   for(int i = 0; i < n; i++) {
      cin >> v[i];
      vr[v[i] - 1] = i;
   }

   for(int i = 0; i < n; i++) {
      cout << vr[i] + 1 << " ";
   }
   cout << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    VI a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    auto c = convolution<998244353>(a, b);
    int sz = n + m - 1;
    rep(i, sz) cout << c[i] << " \n"[i == sz-1];
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;

int A, B, C;

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

    std::cin >> A >> B >> C;

    int m_val = max({A, B, C});

    if(m_val == A) {
        std::cout << "A" << std::endl;
    }
    else if(m_val == B) {
        std::cout << "B" << std::endl;
    }
    else {
        std::cout << "C" << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3092
def fold(x,m):
    y = 0
    for _ in range(m):
        y |= x&1
        y <<= 1
        x >>= 1
    return x|y

lmi = lambda: list(map(int, input().split()))

h,w = lmi()
a = [lmi() for _ in range(2*h)]
g = [[abs(a[i][j] - a[i+h][j]) for j in range(w)] for i in range(h)]
m = 12801
mask = (1<<m) - 1

a = [0]*(w+1)
a[0] = 1
for i in range(h):
  for j in range(w):
    cur,par = g[i][j], a[j]|a[j-1]
    a[j] = par<<cur&mask|fold(par,cur)
v = a[-2]
print((v&-v).bit_length() - 1)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long ll;

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

template<class T>inline void read(T &res)
{
	char c;T flag=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
	while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}

const int N=105;

char s[N];
char s2[N]; 

int main()
{
	scanf("%s",s);
	scanf("%s",s2);
	int len1=strlen(s);
	int len2=strlen(s2);
	
	if(len1<len2)
	{
		bool f=false;
		for(int i=0;i<len1;i++)
		{
			if(s[i]!=s2[i])
			{
				f=true;
				break;
			}
		}
		if(f)printf("No\n");
		else printf("Yes\n");
	}
	else if(len1>len2)
	{
		bool f=false;
		for(int i=0;i<len2;i++)
		{
			if(s[i]!=s2[i])
			{
				f=true;
				break;
			}
		}
		if(f)printf("No\n");
		else printf("Yes\n");
	}
	else
	{
		bool f=false;
		for(int i=0;i<len1;i++)
		{
			if(s[i]!=s2[i])
			{
				f=true;
				break;
			}
		}
		if(f)printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 3760
A,B,K = map(int,input().split())
min_n = min(A,B)
gcd_ = []

for i in range(1,min_n+1):
  if A%i == 0 and B%i == 0:
    gcd_.append(i)
gcd_.sort(reverse=True)
print(gcd_[K-1])

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

typedef long long int64;

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

  int ab = a+b;
  int amib = a-b;
  int axb = a*b;

  int max = std::max({ab,amib,axb});
  printf("%d\n",max);

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,m,d,x,y,i;
	for(;scanf("%d",&n),n;puts(n?"No":"Yes")){
		int f[21][21] = {0};
		for(i=n;i--;f[y][x] = 1)
			scanf("%d %d",&x,&y);
		scanf("%d",&m);
		x=y=10;
		for(i=m;i--;)
			for(scanf(" %c %d",&m,&d);d--;f[y][x]?n--,f[y][x]=0:0){
				x+=m==69?1:m==87?-1:0,
				y+=m==78?1:m==83?-1:0;
			}
	}
}

Measured memory_bytes: 0
/*
 *Author : zsenshi
 testing 
 */
#include <bits/stdc++.h> //Only for gcc compilers
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define dg(x) cout << #x << ":"<<x<<endl
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl
#define rep(i,begin,end) for(__typeof(end) i = (begin)-((begin) > (end)); i != (end) - ((begin) > (end)); i += 1-2*((begin) > (end)))
using namespace std;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vector<pii>> vvpi;

int main()
{
  using ll = long long;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  cout << (n-1)*(n)/2;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(std::string s){
    cout << s.substr(0, 4) << ' '<< s.substr(4, 12) << endl;
}

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc142
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc142C();
        }

        public static void solve_abc142C()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Dictionary<int, int> dic = new Dictionary<int, int>();

            for (int i = 0; i < n; i++)
            {
                dic.Add(i, a[i]);
            }

            List<KeyValuePair<int, int>> srtList = dic.OrderBy(x => x.Value).ToList();

            for (int i = 0; i < n; i++)
            {
                Console.Write("{0} ", srtList[i].Key + 1);
            }
        }

        public static void solve_abc142B()
        {
            int[] nk = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = nk[0];
            int k = nk[1];
            int[] h = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int cnt = 0;

            for (int i = 0; i < n; i++)
            {
                if (h[i] >= k)
                {
                    cnt++;
                }
            }

            Console.WriteLine(cnt);
        }
        public static void solve_abc142A()
        {
            int n = Convert.ToInt32(Console.ReadLine());

            double res = n % 2 == 0 ? (double)(n / 2) / n : ((double)(n / 2) + 1) / n;

            Console.WriteLine("{0:F16}", res);
        }
    }
}


Measured memory_bytes: 33372
# まず, 答えは総和の約数となる
# 恐らく約数ごとに条件が成り立つか調べることになる

# 答えをdと仮定したとき, 各値はdの倍数となる
# 総和をどのように振り分けたらK以下で全てdの倍数になるか調べるのは無理
# そこでmod(d)で考えることにする
# 各値についてdで割った余りを記録していく
# それをソートして両端から-1/+1していけば
# 必ず全て0にでき, その操作回数もO(N)で分かる

# コードは累積和で境界を求めてる

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    from fractions import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    def yakusuu(N):
        n = int(N**.5)+1
        res1 = []
        res2 = []
        for i in range(1, n):
            if N%i==0:
                res1.append(i)
                if N!=i**2:
                    res2.append(N//i)
        res2.reverse()
        return res1+res2
        # 約数のリストを返す

    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    
    kouho = yakusuu(sum(a))

    for i in kouho[::-1]:
        nega = [0]*n
        posi = [0]*n
        for j in range(n):
            posi[j] = a[j] % i
        posi.sort()
        for j in range(n):
            nega[j] = posi[j] - i
        posi = [0] + posi
        nega = [0] + nega
        posi = list(accumulate(posi))
        nega = list(accumulate(nega))
        for j in range(1, n+1):
            if posi[j] == -(nega[-1]-nega[j]):
                total = posi[j]
                break
        if total <= k:
            print(i)
            break
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 68200
#include<stdio.h>
#define N 8
#define FREE 1
#define NOT_FREE -1
#define EXIST 2
#define NOT_EXIST -2

void Queenarrange(int);
void Judge(void);
int print(void);

int initq; //最初から置いてあるqの数
int input[N][N]; //最初から置いてあるqの位置
int board[N][N]; //qを並べていく盤
int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
/*
row: x = i
col: x = j
dpos: x = i + j
dneg: x = i - j + N - 1
*/
int main(){
  int r, c; //rは行 cは列
  int i, j;

  //初期化
  for(i=0;i<N;i++){
    row[i] = FREE;
    col[i] = FREE;
    for(j=0;j<N;j++){
      input[i][j] = NOT_EXIST;
      board[i][j] = NOT_EXIST;
    }
  }
  for(i=0;i<2*N-1;i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
  
  //qの入力
  scanf("%d", &initq);
  for(i=0;i<initq;i++){
    scanf("%d %d", &r, &c);
    input[r][c] = EXIST;
  }

  //0行目からスタート
  Queenarrange(0);
  
  return 0;
}

void Queenarrange(int i){
  int j;

  //qをN個配置できたら、inputと照らし合わせる
  if(i == N){
    //print();
    Judge();
  }

  //qの配置
  for(j=0;j<N;j++){
    //qが(i,j)に置ける
    if(row[i] == FREE && col[j] == FREE && dpos[i+j] == FREE && dneg[i-j+N-1] == FREE){
      board[i][j] = EXIST;
      row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] =  NOT_FREE;
      //print();
      //printf("\n");
      i++;
      Queenarrange(i);
      //バックしてきたら以下の処理が実行される
      i--;
      board[i][j] = NOT_EXIST;
      row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    }
  }

  return;
}

void Judge(){
  int i, j;
  int match = 0; //inputとboardのqが一致した数

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(board[i][j] == EXIST && input[i][j] == EXIST) match++;
    }
  }

  if(match == initq) print();
  else return;
  
}

int print(){
  int i, j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(board[i][j] == NOT_EXIST) printf(".");
      else printf("Q");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2104
use proconio::{input, fastout};

fn main() {
    input!(
        x: usize,
        y: usize,
    );
    let n = x*2;
    if y >= n && y & 1 == 0 && y <= 2*n {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2100
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, q = rm()
s = rr()
cnt_li = [0]*n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        cnt_li[i+1] += 1
    cnt_li[i+1] += cnt_li[i]
for _ in range(q):
    l, r = rm()
    print(cnt_li[r-1] - cnt_li[l-1])













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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  int k = 1;
  int ans = 0;
  for(int i=0;i<n;i++) {
    cin >> a[i];
    if(a[i] == k)
      k++;
    else
      ans++;
  }

  if(k > 1)
    cout << ans << endl;
  else
    cout << -1 << endl;

  return 0;
}


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

long long llgcd(long long a, long long b){
    long long imax,imin;
    if( a>=b ){
        imax=a;
        imin=b;
    }else{
        imax=b;
        imin=a;
    }

    long long r;

    r = imax % imin;

    while( r!=0 ){
        imax = imin;
        imin = r;
        r = imax % imin;
        //cout << "imax imin r " << imax << " " << imin << " " << r << endl;
    }    

    return imin;
}

int main(){
    int N;
    cin >> N;
    long long T[N];
    long long a,b,ans;
    for(int i=0; i<N; i++){
        cin >> T[i];
    }

    if( N==1 ){
        ans=T[N-1];
    }

    for(int i=1; i<N; i++){
        if( i==1 ){
            a= T[i-1];
            b= T[i];
        }else{
            a= ans;
            b= T[i];            
        }
        
        ans= b / llgcd(a,b);
        ans= ans*a;        
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 100000
#define NIL -1
struct Node{
  int parent;
  int depth;
  int root;
};
struct Node A[N];
int B[N];

void res(int r, int w)
{
  
  B[r] = w;
  if(A[r].root !=NIL) res(A[r].root,w);
  if(A[r].depth != NIL) res(A[r].depth,w+1);
}

void output(int n)
{
  int i,p;
  printf("node %d: parent = %d, depth = %d, ",n,A[n].parent,B[n]);
    if(A[n].parent ==NIL) printf("root, [");
    else if(A[n].depth ==NIL) printf("leaf, [");
    else printf("internal node, [");

    for(i=0, p=A[n].depth; p!=NIL; i++,p=A[p].root){
      if(i)printf(", ");
      printf("%d",p);
    }
    printf("]\n");
}
int main()
{
  int i,j,n,m,l,s,q,r;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    A[i].parent =A[i].depth =A[i].root =NIL;
  }
  for(i=0; i<n; i++){
    scanf("%d",&m);
    scanf("%d",&l);
    
    for(j=0; j<l; j++){
      scanf("%d",&s);
      
      if(j==0)A[m].depth = s;
      else A[q].root =s;
      q = s;
      A[s].parent = m;
    }
  }
    for(i=0; i<n; i++) if(A[i].parent==NIL) r = i;
 
  res(r, 0);
  for(i=0; i<n; i++) output(i);
    
    return 0;
}



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

using namespace std;
typedef long long ll;
const int maxn=1e4+7;


int main() {
	int n,m,k,t;
	
	scanf("%d",&n);
	int res=1000-n%1000;
	if(res==1000) puts("0");
	else printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define maxn 102333
#define maxm 406666
#define mod 1000000007
using namespace std;

typedef pair<long long, int> pli;

struct Graph {
	
	int n, m;
	int head[maxn], nxt[maxm], to[maxm], len[maxm], ec;
	
	inline void add (int u, int v, int d) {
		nxt[++ec] = head[u], head[u] = ec, to[ec] = v, len[ec] = d;
	}

} G;

void Dijkstra (const Graph &G, int S, long long dist[], bool done[], long long ans[]) {
	const long long INF = 0x3F3F3F3F3F3F3F3F;
	const int N = G.n;
	priority_queue< pli, vector<pli>, greater<pli> > Heap;
	fill(dist + 1, dist + N + 1, INF);
	fill(done + 1, done + N + 1, false);
	fill(ans + 1, ans + N + 1, 0);
	dist[S] = 0;
	ans[S] = 1;
	Heap.push(make_pair(0, S));
	while (!Heap.empty()) {
		int x;
		long long d;
		tie(d, x) = Heap.top();
		Heap.pop();
		if(done[x]) continue;
		done[x] = true;
		for (int e = G.head[x]; e; e = G.nxt[e]) {
			long long dd = d + G.len[e];
			if (dd <= dist[G.to[e]]) {
				if (dd != dist[G.to[e]]) {
					ans[G.to[e]] = 0;
					dist[G.to[e]] = dd;
					Heap.push(make_pair(dd, G.to[e]));
				}
				ans[G.to[e]] += ans[x];
				ans[G.to[e]] %= mod;
			}
		}
	} 
}

bool done[maxn];
long long d1[maxn], d2[maxn];
long long a1[maxn], a2[maxn];

int main () {
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	G.n = n, G.m = m;
	for (int i = 1; i <= m; ++i) {
		int u, v, d;
		scanf("%d%d%d", &u, &v, &d);
		G.add(u, v, d);
		G.add(v, u, d);
	}
	Dijkstra(G, s, d1, done, a1);
	Dijkstra(G, t, d2, done, a2);
	long long ans = a1[t] * a1[t] % mod, L = d1[t];
	for (int i = 1; i <= n; ++i) {
		if (d1[i] * 2 == L && d2[i] * 2 == L) {
			ans += (mod - a1[i] * a2[i] % mod * a1[i] % mod * a2[i] % mod);
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int e = G.head[i]; e; e = G.nxt[e]) {
			if (d1[i] * 2 < L && d2[G.to[e]] * 2 < L && d1[i] + G.len[e] + d2[G.to[e]] == L) {
				ans += (mod - a1[i] * a2[G.to[e]] % mod * a1[i] % mod * a2[G.to[e]] % mod);
			}
		}
	}
	ans %= mod;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 15132
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const ll INF = 1LL << 50;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    vector<ll> dp(N + 1, -INF);
    dp[0] = 1000;
    rep(i, 1, N + 1) {
        chmax(dp[i], dp[i - 1]);
        rep(j, 1, i) {
            chmax(dp[i], (dp[0] / A[j - 1]) * A[i - 1] + dp[0] % A[j - 1]);
        }
        rep(j, 1, i) rep(k, j, i) {
            chmax(dp[i], (dp[j] / A[k - 1]) * A[i - 1] + dp[j] % A[k - 1]);
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  int n,m,s,memo; cin>>n>>m;
  s=0;
  rep(i,m){cin>>memo; s+=memo;}
  
  cout<<(n-s>=0? n-s:-1)<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main(){
  vector<ll> s(3);
  rep(i,3){cin >> s[i];}
  sort(s.begin(),s.end());
  if(s[0]==5 && s[1]==5 && s[2]==7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3628
from bisect import bisect_left
N = int(input())
S = list(map(int, input().split()))
a = []
S.sort()
ans = 0
for i in range(N):
  for j in range(i+1,N):
    t = S[i]+S[j]
    idx = bisect_left(S, t)
    ans += max(0, idx-j-1)
print(ans)

Measured memory_bytes: 3188
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double r = s.nextDouble();
		s.close();
		String a1 = new BigDecimal(Math.PI*r*r).toPlainString();
		String a2 = new BigDecimal(Math.PI*r*2).toPlainString();
		System.out.println(a1 + " " + a2);
	}

}

Measured memory_bytes: 28424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
		scan.close();
		if(S.length()==1) {
			System.out.println(S);
			return;
		}
		int[] N = new int[S.length()];

		int patternCount = 1;
		String tmpBit = "";
		for(int i=0; i<N.length; i++) {
			N[i] = Integer.parseInt(String.valueOf(S.charAt(i)));
			if(i>0) {
				patternCount*=2;
				tmpBit = tmpBit + "1";
			}
		}

		long sum=0;
		for(int i=0; i<patternCount; i++) {
			String bin = Integer.toBinaryString(i);
			//while(bin.length()<tmpBit.length()) {
			while(bin.length()<Integer.toBinaryString(patternCount-1).length()) {
				bin = "0" + bin;
			}
			String add = String.valueOf(N[0]);
			for(int j=0; j<bin.length(); j++) {
				if(bin.charAt(j)=='1') {
					sum+=Integer.parseInt(add);
					add = "";
				}
				add = add + N[j+1];
			}
			if(add.length()>0) {
				sum+=Long.parseLong(add);
			}
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>
#include <sstream>
#include <numeric>
#include <set>
#include <unordered_map>

int main()
{
    std::string s;
    std::cin >> s;
    std::string nick(s.begin(),s.begin() + 3);

    std::cout << nick;

    return EXIT_SUCCESS;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


int N;
vint G[222222];
signed main(){
    cin>>N;
    rep(i,N){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }

    vint deg(N);
    rep(i,N)deg[i]=G[i].size();
    queue<int>que;
    rep(i,N)if(deg[i]==1)que.push(i);
    vint used(N);
    while(que.size()){
        int v=que.front();
        que.pop();
        used[v]=true;
        for(auto u:G[v]){
            if(used[u])continue;
            if(--deg[u]==1){
                used[u]=true;
                que.push(u);
            }
        }
    }

    int Q;cin>>Q;
    while(Q--){
        int a,b;
        cin>>a>>b;
        a--;b--;
        if(used[a]||used[b])cout<<1<<endl;
        else cout<<2<<endl;
    }
    return 0;
}



Measured memory_bytes: 13136
import sys
def input():
    return sys.stdin.readline().strip()

n = int(input())
s = []
for _ in range(n):
    s.append(input())

'''
N = sum([len(i) for i in s])
R = sum([i.count('(') for i in s])
if N % 2 == 1 or s.count('(') != N // 2:
    print('No')
    exit()
'''

bothleft = []
bothright = []
bothneutral = [0]
left = [0]
right = [0]

for i in s:
    lnum = 0
    now = 0
    for j in range(len(i)):
        if i[j] == '(':
            now -= 1
        else:
            now += 1
            lnum = max([lnum, now])

    rnum = 0
    now = 0
    for j in range(len(i) - 1, -1, -1):
        if i[j] == ')':
            now -= 1
        else:
            now += 1
            rnum = max([rnum, now])
    
    if lnum > 0:
        if rnum > 0:
            if lnum > rnum:
                bothleft.append((rnum, lnum - rnum))
            elif rnum > lnum:
                bothright.append((lnum, rnum - lnum))
            else:
                bothneutral.append(lnum)
        else:
            left.append(lnum)
    elif rnum > 0:
        right.append(rnum)

bothneutral = max(bothneutral)
bothleft.sort()
bothright.sort()

lsum = sum(left)
for i in range(len(bothleft)):
    if bothleft[i][0] > lsum:
        print('No')
        exit()
    lsum += bothleft[i][1]

if bothneutral > lsum:
    print('No')
    exit()

rsum = sum(right)
for i in range(len(bothright)):
    if bothright[i][0] > rsum:
        print('No')
        exit()
    rsum += bothright[i][1]

if lsum != rsum:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 40224
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <complex>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

typedef complex<double> Point;

int n;
Point point[200];
pair<double, int> radian[1000];
bool used[1000];

int calc(int index) {
  int m = 0;
  REP(i, n) {
    double d = abs(point[index] - point[i]) / 2.0;
    if (i == index || d - 1.0 > EPS) { continue; }
    Point center = (point[index] + point[i]) / 2.0;
    Point vect = (point[i] - point[index]) * Point(0, -1);
    vect /= abs(vect);
    double l = sqrt(1 - d * d);
    if (isnan(l)) { l = EPS; }
    Point c1 = center + vect * l;
    Point c2 = center - vect * l;
    double arg1 = arg(c1 - point[index]) - EPS;
    double arg2 = arg(c2 - point[index]) + EPS;
    radian[m++] = make_pair(arg1, (i + 1));
    radian[m++] = make_pair(arg2, -(i + 1));
  }
  sort(radian, radian + m);
  MEMSET(used, false);
  int lsum = 1;
  int ret = 1;
  REP(iter, 2) {
    REP(i, m) {
      int p = abs(radian[i].second) - 1;
      bool start = radian[i].second > 0 ? true : false;
      if (start) {
        used[p] = true;
        lsum++;
      } else if (used[p]) {
        used[p] = false;
        lsum--;
      }
      ret = max(ret, lsum);
    }
  }
  return ret;
}

int main() {
  while (scanf("%d", &n), n) {
    REP(i, n) {
      double x, y;
      scanf("%lf,%lf", &x, &y);
      point[i] = Point(x, y);
    }
    int ans = 1;
    REP(i, n) {
      ans = max(ans, calc(i));
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 0
n,k = map(int, input().split())
a = list(map(int, input().split()))
if 0 in a:
  a.remove(0)
  n -= 1
  k -= 1
if k == 0:
  print(0)
  exit()
m = 300000000
for i in range(n+1-k):
  if a[i+k-1] < 0:
    x = -a[i]
  elif a[i] > 0:
    x = a[i+k-1]
  else:
    x = (a[i+k-1]-a[i]) + min(-a[i],a[i+k-1])
  m = min(m,x)
print(m)

Measured memory_bytes: 14664
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};
typedef struct node * Tree;

Tree root, NIL;
int max;

Tree treeSearch(Tree u, int k){
  while(u != NIL && k != u->key){
    if (k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  int H;
  Tree y = NIL;
  Tree x = root;
  Tree z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if (z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == NIL){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Tree u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Tree u){
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int i, n, x;
  char com[20];
  scanf("%d", &n);
  max = 0;
  for (i = 0; i < n; i++){
    scanf("%s", com);
    if (com[0] == 'f'){
      scanf("%d", &x);
      Tree t = treeSearch(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    } else if (com[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    } else if (com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20448
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            String ss = in.next();
            String ans = "";
            int i = 0, j = 0, cnt = 1;
            while (cnt != s.length() + ss.length() + 1) {
                if (cnt % 2 != 0) {
                    ans += s.charAt(i);
                    i++;
                } else {
                    ans += ss.charAt(j);
                    j++;
                }
                cnt++;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    string s;
    char c;
    int i,j,k;
    for(i=0;i<n;i++){
      cin >> c;
      s+=c;
    }
    int l,r,x,y;
    int ans = n;
    for(i=0;i<n;i++){
      for(k=1;k<3;k++){
	l=i-1;r=i+1;x=1;y=0;c=k+'0';
	while(1){
	  while(l>=0&&s[l]==c){
	    x++;
	    l--;
	  }
	  while(r<n&&s[r]==c){
	    x++;
	    r++;
	  }
	  if(x<4) break;
	  y+=x;
	  x=0;
	  if(l<0||n<=r) break;
	  if(s[l]!=s[r]) break;
	  c=s[l];
	}
	//cout << i << k << ":" << y << endl;
	ans=min(ans,n-y);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (void){
  
    int len;
    int i;
    char a = 'A';
    char b = 'B';
	char S[3];
    char *A = "AAA";
    char *B = "BBB";
  
    scanf("%s\n",S);
  
    len = strlen(S);
    if(len != 3){
    return (1);
    }
    
    //for(i=0;i<len;i++){
      //if(strstr(S,a) != null){
        //printf("a含\n");
          //if(strstr(S[i],b) != null){
            //return (1);
        //}
      //}
    //}
  
    
    if(strcmp(A,S) == 0 || strcmp(B,S) == 0){
    printf("No\n");
    }else{
    printf("Yes\n");
    }
  
    return (0);
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
   int n, ten;
   int i=0;
   int sum, min, max;
   while(1) {
      scanf("%d", &n);
      if (!n) break; // もしn=0ならループ終了
      sum = 0;
      max = 0;
      min = 1000;
      for(i=0; i<n; i++) { 
         scanf("%d", &ten);
         sum += ten;
         if(ten > max)
            max = ten;
         if(ten < min)
            min = ten;
      }
      sum = sum - (max+min);
      printf("%d\n", sum/(n-2));
   }

   return (0);
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main() {
  long numbers[200001];

  long N,i,A;
  cin >> N;

  for (i=1;i<=N;i++)
    numbers[i] = 0;

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

  for (i=1;i<=N;i++) {
    cout << numbers[i] << endl;
  }
  return 0;

}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t n, a, b;
	cin >> n >> a >> b;
	int64_t ans = 0;
	for (int i = 1; i < n + 1; i++) {
		int digit_sum = 0;
		int cur = i;
		for (int j = 0; j < 5; j++) digit_sum += cur % 10, cur /= 10;
		if (a <= digit_sum && digit_sum <= b) ans+=i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= (_T)base;
	}
	return ans;
}

static void D();

int main()
{
	D();
	fflush(stdout);
	return 0;
}

static void D()
{
	int N, P;
	get(N, P);

	std::vector<int> ai(N);
	int odd = 0, even = 0;
	for (int i = 0; i < N; i++) {
		get(ai[i]);
		if (ai[i] % 2) odd++;
		else even++;
	}

	LLONG ans = 0;
	if (N == 1) {
		if (P) {
			if (odd) ans = 1;
		}
		else {
			if (even) ans = 2;
			else ans = 1;
		}
	}
	else if (P == 1 && odd == 0) {
		ans = 0;
	}
	else if (P == 0 && odd == 0) {
		ans = tp_pow<LLONG>(2, N);
	}
	else {
		ans = tp_pow<LLONG>(2, N - 1);
	}
	printf("%lld\n", ans);
}


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

string S;

int main(){
    cin >> S;
    int cnt = 0;
    for(int i=0;i<S.size();i++){
        if(S[i] == 'o') cnt++;
    }

    string ans;
    if( 8 <= 15 - S.size() + cnt )   ans = "YES";
    else    ans = "NO";

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
   ll h,w,k;
   cin>>h>>w>>k;

   char ch[h][w];
   vector<pair<ll,ll> > v;
   for(ll i=0;i<h;i++)
   {
   	for(ll j=0;j<w;j++)
   	{
   		cin>>ch[i][j];
   		if(ch[i][j]=='#')
   			v.pb(mp(i,j));
   	}
   }
   sort(v.begin(),v.end());

   //cout<<v[1].ff<<v[1].ss<<endl;
   ll ans[h][w];
   for(ll i=0;i<h;i++)
   	{for(ll j=0;j<w;j++)
   		{ans[i][j]=0;}}

   	for(ll e=0;e<k;e++)
   	{
   		ll x=v[e].ff,y=v[e].ss;
   		ll yl=y-1,yr=y+1;
   		ans[x][y]=e+1;

   		while(yr<w and ans[x][yr]==0 and ch[x][yr]=='.' )
   			yr++;

   		while(yl>-1 and ans[x][yl]==0 and ch[x][yl]=='.')
   			yl--;
   		yl++;
   	
   		//cout<<e<<" "<<x<<" "<<y<<" "<<yr<<" "<<yl<<" ";
   		ll x1=x+1;
   		for(ll i=yl;i<yr;i++)
   		{
   			if(x1>h-1 or ans[x1][i]!=0 or  ch[x1][i]!='.' )
   				break;
   			else if(i==yr-1 and x1<h and  ans[x1][y]==0 and ch[x1][y]=='.')
   				{x1++;
   					i=yl-1;
   				}
   		}

   		//cout<<x1<<endl;
   		for(ll i=x;i<x1;i++)
   			for(ll j=yl;j<yr;j++)
   				{//cout<<i<<" "<<j<<" nxt";
   			ans[i][j]=e+1;}
   			//cout<<endl;
   	}

   	for(ll i=0;i<v[0].ff;i++)
   	{
   		for(ll j=0;j<w;j++)
   			{
   				if(ans[i][j]==0)
   					ans[i][j]=ans[v[0].ff][j];
   			}
   	}

   	for(ll i=0;i<h;i++)
   	{
   		for(ll j=0;j<w;j++)
   			cout<<ans[i][j]<<" ";
   		cout<<endl;
   	}

}




Measured memory_bytes: 3056
import heapq

K=int(input())
q=[1,2,3,4,5,6,7,8,9]
count=0
while K>count:
    x=heapq.heappop(q)
    count+=1
    if count==K:
        print(x)
    else:
        a=x%10
        if a!=0:
            heapq.heappush(q,10*x+a-1)
        heapq.heappush(q,10*x+a)
        if a!=9:
            heapq.heappush(q,10*x+a+1)


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

int main(){
  string s;
  cin >> s;
  if ((s.at(2) == s.at(3)) && (s.at(4) == s.at(5))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {

  int n, m;
  while( cin >> n, n ) {
    int  student[n+1]; // 2:friend 1:friends_frined 0:others
    for(int i=1; i<=n; i++) student[i] = 0;
    cin >> m;
    int a[m+1], b[m+1];
    for(int i=0; i<m; i++) {
      cin >> a[i] >> b[i];
      if( a[i] == 1 ) student[b[i]] = 2;
    }

    for(int i=0; i<m; i++) {
      if( student[a[i]] == 2 && student[b[i]] != 2 ) {
	student[b[i]] = 1;
      }
      else if( student[b[i]] == 2 && student[a[i]] != 2 ) {
	student[a[i]] = 1;
      }
    }

    int ans = 0;
    for(int i=2; i<=n; i++) {
      if( student[i] > 0 ) ans++;
    }

    cout << ans << endl;
  }
}

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

const long long SIZE = 100030, MOD = 1000000007;

int main() {
  long long n, m, factorial[SIZE], ifactorial[SIZE], inv[SIZE], result = 1;
  cin >> n >> m;
  inv[1] = 1;
  factorial[0] = 1;
  factorial[1] = 1;
  ifactorial[0] = 1;
  ifactorial[1] = 1;
  for (long long i = 2; i < SIZE; i++) {
      inv[i] = (-MOD / i + MOD) * inv[MOD % i] % MOD;
      factorial[i] = factorial[i - 1] * i % MOD;
      ifactorial[i] = ifactorial[i - 1] * inv[i] % MOD;
  }
  auto C = [&](long long n, long long k) {
    return factorial[n] * ifactorial[k] % MOD * ifactorial[n - k] % MOD;
  };
  for (long long i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      long long current = 0;
      do {
        current++;
        m /= i;
      } while (m % i == 0);
      result = result * C(current + n - 1, current) % MOD;
    }
  }
  if (m > 1) {
    result = result * n % MOD;
  }
  cout << result;
  return 0;
}

Measured memory_bytes: 2688
def IsPrime(x):
    if x == 1:
        return False
    p = int(pow(x, 0.5)) + 1
    i = 2
    while i <= p and i < x:
        if x % i == 0:
            return False
        else:
            i += 1
    return True

n = int(input())
c = 0
i = 0
while i < n:
    x = int(input())
    if IsPrime(x) == True:
        c += 1
    i += 1
print(c)


Measured memory_bytes: 5704
#include <stdio.h>
#include <stdlib.h>

#define NUM 200000

long absl(long a) {
    return a >= 0 ? a : - a;
}

void print_array(long *a, long size) {
    for(int i = 0; i < size; i++) {
        printf("%ld\n", a[i]);
    }
}

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


long median(long *a, long size) {
    long idx, idx2;
    qsort(a, size, sizeof(long), compare_int);
    if(size % 2 == 1) return a[size / 2];
    idx = size / 2;
    idx2 = (size / 2) - 1;
    return (a[idx] + a[idx2]) / 2;
}

int main() {
    long N;
    long m;
    long sum = 0;
    long a[NUM];
    char s[NUM];
    scanf("%ld\n", &N);
    for(int i = 0; i < N; i++) {
        scanf("%ld", &a[i]);
    }
    for(int i = 0; i < N; i++) {
        a[i] = a[i] - (i + 1);
    }
    m = median(a, N);
    for(int i = 0; i < N; i ++) {
        sum += absl(a[i] - m);
        a[i] = absl(a[i] - m);
    }
    printf("%ld\n", sum);
    return 0;
}

Measured memory_bytes: 3324