akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int bingo=0;
void checkBingo(int h){
    if(h==2 && bingo==0){
        printf("Yes\n");
        bingo=1;
    }
}

int main(void){
    int a[3+3][3+3];
    int n;
    for(int i=0; i<3; i++)scanf("%d %d %d", &a[0][i], &a[1][i], &a[2][i]);
    scanf("%d", &n);
    
    for(int i=0; i<n; i++){
        int b;
        scanf("%d", &b);
        for(int i=0; i<9; i++){
            if(a[i/3][i%3]==b){
                a[i/3][i%3]=0;
                break;
            }
        }
    }
    
    // check bingo
    for(int i=0; i<3; i++){
        for(int j=0; j<3 && a[i][j]==0; j++){
            checkBingo(j);
        }
    }
    for(int i=0; i<3; i++){
        for(int j=0; j<3 && a[j][i]==0; j++){
            checkBingo(j);
        }
    }
    for(int i=0; i<3 && a[i][i]==0; i++){
        checkBingo(i);
    }
    for(int i=0; i<3 && a[2-i][i]==0; i++){
        checkBingo(i);
    }
    if(bingo==0)printf("No\n");
    return 0;
}


Measured memory_bytes: 1644
#include <stdio.h>

int main(void){
    long int N,A,B,sum=0,a1,a2;
    scanf("%ld %ld %ld",&N,&A,&B);
    a1=N/(A+B)*A;
    a2=N%(A+B);
    if(a2>=A){
        a2=A;
    }
    sum=a1+a2;
    printf("%ld",sum);
    return 0;
}

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

int main (void){
    string s;
    cin >> s;
    if (s == "SUN"){
        cout << 7 << endl;
    } else if (s == "MON"){
        cout << 6 << endl;
    } else if (s == "TUE"){
        cout << 5 << endl;
    } else if (s == "WED"){
        cout << 4 << endl;
    } else if (s == "THU"){
        cout << 3 << endl;
    } else if (s == "FRI"){
        cout << 2 << endl;
    } else if (s == "SAT"){
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[225816],segtree[816225],ans[225816];
std::vector<int> g[225816];
std::set<int> st;
std::set<int>::iterator itr;

void solve(int v, int p){
	int u,i,sv;
	itr = st.lower_bound(a[v]);
	sv = (itr==st.end())?INF:(*itr);
	st.erase(sv);
	st.insert(a[v]);
	ans[v] = st.l_ength();
	for(i=(g[v].l_ength()-1); i>=0; --i){
		u = g[v][i];
		if(u == p){
			continue;
		}
		solve(u,v);
	}
	st.erase(a[v]);
	if(sv<INF){
		st.insert(sv);
	}
}

int main(void){
	int n,u,v,i;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a[i];
	}
	for(i=1; i<n; ++i){
		std::cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	solve(0,-1);
	for(i=0; i<n; ++i){
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 34028
macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };

    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn main() {
    let (n, k) = scan!(usize, usize);
    let mut vs = scan!(i64;;);
    vs.sort_by_key(|k| -k);

    println!("{}", vs.iter().take(k).sum::<i64>());
}


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

int main() {
    ll N; cin >> N;
    vector<ll> v(N);

    ll all = 0;
    for (int i = 0; i < N; i++){
        cin >> v[i];
        all += v[i];
    } 
    ll mean1 = all / N;
    ll mean2 = all / N +1;

    ll ans1 = 0;
    ll ans2 = 0;
    for (int i = 0; i < N; i++)
    {
        ans1 += (mean1 - v[i]) * (mean1 - v[i]);
        ans2 += (mean2 - v[i]) * (mean2 - v[i]);
    }
    cout << min(ans1, ans2) << endl;
}

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

using namespace std;

typedef long long ll;

ll n, ans;
ll a[200005];
ll b[200005];
ll c[200005];

int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &b[i]);
    }
    for(ll i = 0; i < 29; i++)
    {
        ll cnt = 0;
        for(ll j = 0; j < n; j++)
        {
            c[j] = b[j] % (1 << (i + 1));
        }
        sort(c, c + n);
        for(ll j = 0; j < n; j++)
        {
            ll t = a[j] % (1 << (i + 1));
            ll t2 = (1 << i);
            cnt += upper_bound(c, c + n, t2 * 2 - 1 - t) - lower_bound(c, c + n, t2 - t);
            cnt += upper_bound(c, c + n, t2 * 4 - 1 - t) - lower_bound(c, c + n, t2 * 3 - t);
            cnt %= 2;
        }
        if(cnt == 1) ans += (1 << i);
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=3e5;
typedef int fuko[yuzu|10];
char c[yuzu|10];
fuko sum1,sum2;
int main(){
int n=read(),ans=0x3f3f3f3f;
scanf("%s",c+1);
for (int i=1;i<=n;++i) sum1[i]=sum1[i-1]+(c[i]=='W');
for (int i=n;i;--i) sum2[i]=sum2[i+1]+(c[i]=='E');
for (int i=1;i<=n;++i) ans=min(sum1[i-1]+sum2[i+1],ans);
write(ans);
}

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

int main() {
	int n , i, j, ca, ci;
	char max[9], min[9], num[9];
	long re;
	scanf("%d", &n);
	while(0<n--) {
		ca=0; ci=0;
		scanf("%s", &num);
		for(i=0;i<10;i++) {
			for(j=0;j<8;j++) {
				if (num[j]==i+'0') min[ci++]=i+'0';
				if (num[j]==9-i+'0') max[ca++]=9-i+'0';
			}
		}
		max[8]='\0'; min[8]='\0';
		re = atol(max) - atol(min);
		printf("%ld\n",re);
	}
	return 0;
}

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

void fnInput(vector<int>& rvnNode, vector<vector<int>>& rvvnEdge)
{
  int nNodeSiz, nEdgeSiz;
  cin >> nNodeSiz>> nEdgeSiz;
  rvnNode.resize(nNodeSiz);
//rvvnEdge.resize(nNodeSiz, vector<int>(nNodeSiz, 0));
  rvvnEdge.resize(nNodeSiz);

  for (int& rnNode : rvnNode)
    cin >> rnNode;

  for (int i = 0; i <= nEdgeSiz; i++)
  {
    int nLeft, nRigt;
    cin >> nLeft >> nRigt;
    rvvnEdge[ nLeft - 1 ].push_back( nRigt - 1 );
    rvvnEdge[ nRigt - 1 ].push_back( nLeft - 1 );
  }
}

int fnPeakCnt(const vector<int> cnrvnNode, const vector<vector<int>>& cnrvvnEdge)
{
  int nPeakCnt = 0;

  for (int nBgn = 0; nBgn < cnrvnNode.size(); nBgn++)
  {
    bool bPeak = true;

    for (int nEnd : cnrvvnEdge[nBgn])
      if (cnrvnNode[nBgn] <= cnrvnNode[nEnd])
      {
        bPeak =false;
        break;
      }

    if (bPeak) nPeakCnt++;
  }
  return nPeakCnt;
}
  
int main()
{
  vector<int> vnNode;
  vector<vector<int>> vvnEdge;

  fnInput(vnNode, vvnEdge);
  cout << fnPeakCnt(vnNode, vvnEdge) << endl;

  return 0;
}

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


class Program
{
    static void Main(string[] args)
    {
        const long mod = 1000000007;

        // 入力
        //var s = Console.ReadLine();
        //var n = long.Parse(Console.ReadLine());
        long[] xy = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var x = xy[0];
        var y = xy[1];

        var n = Math.Max(x, y);
        long ans = 0;
        if ((x + y) % 3 == 0)
        {
            long tmp1 = (x + y) / 3;
            long tmp2 = 0;
            while (tmp1 >= 0)
            {
                if (1 * tmp1 + 2 * tmp2 == x && 2 * tmp1 + 1 * tmp2 == y)
                {
                    ans += Ncr( tmp1+tmp2, tmp1,mod);
                }

                tmp1--;
                tmp2++;
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}
	public static long Ncr(long n,long r,long m)
	{
		long ans = 1;
		for(var i=n-r+1;i<=n;i++){
			ans = ans * i % m;
		}
		for(var i=2;i<=r;i++){
			ans = ans * Mpow(i,m-2,m) % m;
		}
		return ans;
	}
}

Measured memory_bytes: 13268
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

#define int long long

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        for (int j = 2; j <= k; j++) {
            if (i > j - 1)
                chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int mod=1000000007;
int n,f[2003];
inline int read()
{
	int x=0,w=0;char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return w?-x:x;
}
int main()
{
	n=read();
	f[0]=1;
	for(int i=0;i<n;i++)
	for(int j=i+3;j<=n;j++)
		f[j]=(f[j]+f[i])%mod;
	cout<<f[n]<<'\n';
}

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

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

    std::vector<int> a(N);
    for (int i=0; i<N; ++i)
        std::cin >> a[i];

    std::sort(a.begin(), a.end());
    auto n = std::unique(a.begin(), a.end());
    a.erase(n, a.end());
    std::cout << a.size() << std::endl;
}

Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())

p1 = X *A +Y *B
p2 = 2 * max(X,Y) * C
if X > Y:
    p3 = 2 * min(X,Y) * C + (X-Y) *A
else:
    p3 = 2 * min(X,Y) * C + (Y-X) *B
print(min(p1,p2,p3))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
	int main(){
	int N ;
	cin >>N ;
	vector<int> dish(N);
	for(int i = 0 ; i < N ; i ++ ){
		cin >>dish[i];
	}
	//入力終わり
	//小さい順に並べさせよう
	sort(dish.begin(),dish.end());
	
	dish.push_back(dish[N]);
	int pile = 1;
	for ( int i = 0 ; i < N-1 ; i ++ ){
		if (dish[i] == dish[i+1])
			continue;
		else{
			pile ++;
		}
		if ( dish[N-1] == dish[N])
			pile ++;
	}
	cout << pile <<endl;
}



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

//n以上の最小の10の倍数を返す
int f(int n) {
	int ret = 1;
	while (!(10 * (ret - 1) < n && n <= 10 * ret)) ret++;
	return ret * 10;
}

int main() {
	vector<int> dif(5);
	int sum = 0;
	rep(i, 5) {
		int a;
		cin >> a;
		int b = f(a);
		sum += b;
		dif[i] = b - a;
	}
	sort(dif.begin(),dif.end());
	cout << sum - dif[4] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x, y;
    while(true){
        cin >> x >> y;
        if ( x == 0 && y == 0 ) break;
        if ( x < y ){
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    stack <long long> st;
    while(cin>>s)
    {
        if(s[0]>='0' && s[0] <= '9')
        {
            long long num = 0;
            for(int i=0;i<s.length();i++)
            {
                long long temp = (s[i]-'0');
                num = num*10+temp;
            }
            st.push(num);
        }
        else
        {
            long long a,b;
            b = st.top();
            st.pop();
            a = st.top();
            st.pop();
            if(s[0] == '*')
                a = a*b;
            else if(s[0] == '+')
                a = a+b;
            else if(s[0] == '-')
                a = a-b;
            else if(s[0] == '/')
                a = a/b;
            st.push(a);
        }
    }
    long long ans = st.top();
    st.pop();
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 3336
#include<stdio.h>

long max(long x,long y){
    if(x>=y) return x;
    else return y;
}

int main(void){
    long K,A,B;
    long x,y;
    long bis;
    scanf("%ld %ld %ld",&K,&A,&B);
    if(B-A<2){
        bis=1+K;
    }else if(K<=A){
        bis=1+K;
    }else{
        x=A+((K-A+1)/2)*(B-A)+((K-A+1)%2);
        y=1+K;
        bis=max(x,y);
    }
    printf("%ld",bis);
    return 0;

}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> nums;
    int now = 1;
    int cnt = 0;
    for (size_t i = 0; i < n; i++)
    {
        if(s[i] == (char)('0' + now)) cnt++;
        else {
            nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if(cnt != 0) {
        nums.push_back(cnt);
    }

    if(nums.size() % 2 == 0) nums.push_back(0);
    int ans = 0;
    int add = 2 * k + 1;
    for (size_t i = 0; i < nums.size(); i+=2)
    {
        int tmp = 0;
        int left = i;
        int right = min(i + add, nums.size());
        for (size_t j = left; j < right; j++)
        {
            tmp += nums[j];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1020
// Problem : D - String Formation
// Contest : AtCoder - AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{ 
	string str;
	cin>> str;
	int q,flag=0;
	cin >> q;
	while(q--)
	{
		int x;
		cin >> x;
		if(x == 1)
		{
			flag = 1-flag;
			continue;
		}
		char y;
		cin >> x >> y;
		if(x == 1)
		{
			if(flag)
			str+=y;
			else str = y+str;
		}
		else {
			if(flag)
			str = y+str;
			else str += y;
		}
	}
	if(flag)
	reverse(str.begin(),str.end());
	cout << str <<"\n";
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 4628
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;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(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define VI vector<int>
#define PB(x) push_back(x)
#define SZ(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void CO(auto &a) {REP(i, SZ(a)) cout << i << ": " << a[i] << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int a,b,c;
	cin >> a >> b >> c;
	if (a == b and b == c) cout << "Yes" << endl;
	else	cout << "No" << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

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

    cin>>n;

    vector<pii> res;

    if(n&1){

        for(int i=1;i<=n;i++)
            for(int j=1;j<i;j++){
                if(i+j==n)continue;
                res.push_back(pii(j,i));
            }
    }
    else {

        for(int i=1;i<=n;i++)
            for(int j=1;j<i;j++){
                if(i+j==n+1)continue;
                res.push_back(pii(j,i));
            }
    }

    cout<<(int)res.size()<<"\n";

    for(int i=0;i<res.size();i++)
        cout<<res[i].f<<" "<<res[i].s<<"\n";

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	string s;
	cin >> s;
	bool f = false;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] == 'C') {
			f = true;
		}
		if (s[i] == 'F' && f) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin>>n>>m;
    ll dp[m+1][(1<<n)+2];
    ll lim = 1LL<<45;
    ll bit[m];
    ll a[m];
    rep(i,(1<<n)+2){
        rep(j,m+1){
            dp[j][i]=lim;
        }
    }
    rep(i,m){
        ll b;cin>>a[i]>>b;
        ll bitt = 0;
        rep(i,b){
            ll tmp;cin>>tmp;
            tmp--;
            bitt += 1<<tmp;
        }
        bit[i]=bitt;
    }
    DEBUG{
        cout << "tt " << endl;
    }
    dp[0][0]=0;
    rep(i,m){
        rep(j,1<<n){
            DEBUG{
                cout << bit[i] << endl;
            }
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][j|bit[i]],min(dp[i][j]+a[i],dp[i][j|bit[i]]));
        }
    }
    ll res = dp[m][(1<<n)-1];
    cout << (res == lim ? -1 : res) << endl;
    return 0;
}


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

int main()
{
	int a[1000],max,min,n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	sort(a,a+n);
	max=a[n-1];
	min=a[0];
	cout<<max-min<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from functools import reduce
import sys
try:
    from typing import List
except ImportError:
    pass


def gcd(a: int, b: int):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a


def solve(N: int, X: int, x: "List[int]"):
    x2 = [abs(xi - X) for xi in x]
    print(reduce(gcd, x2))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19848
#include<iostream>
main(){int p[14][14],x,y,a,m=0;std::string s;for(x=0;x<14;x++)for(y=0;y<14;y++)p[x][y]=0;while(std::cin>>s){x=s.at(0)-45;y=s.at(2)-45;a=s.at(4)-48;p[x][y]++,p[x-1][y]++,p[x+1][y]++,p[x][y-1]++,p[x][y+1]++;if(a>1)p[x-1][y-1]++,p[x+1][y-1]++,p[x-1][y+1]++,p[x+1][y+1]++;if(a>2)p[x-2][y]++,p[x][y-2]++,p[x+2][y]++,p[x][y+2]++;}for(x=3,a=0;x<13;x++)for(y=3;y<13;y++)p[x][y]==0?a++:0,p[x][y]>m?m=p[x][y]:0;std::cout<<a<<"\n"<<m<<"\n";}

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

int main(){
    int a[9];
    for(int i=0;i<9;i++) cin >> a[i];
    int n;
    cin >>n;
    int b,c[9]={0};
    for(int i=0;i<n;i++){
        cin >> b;
        for(int j=0;j<9;j++){
            if(b == a[j]){
                c[j]=1;
            }
        }
    }
    for(int i=0;i<3;i++){
        if(c[i]*c[i+3]*c[i+6]){
            cout << "Yes" <<endl;
            return 0;
        }
        if(c[3*i]*c[3*i+1]*c[3*i+2]){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    if(c[0]*c[4]*c[8]==1 || c[2]*c[4]*c[6]==1){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n;
    int i;
    int a[100];

    scanf("%d",&n);

    for(i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }

    for(i = n-1; i >= 0; i--){
        printf("%d",a[i]);
        if(i != 0){
            printf(" ");
        }else{
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  int ans = 1;
  int p = 0;
  for (int i = 0; i < n; ++i) {
    p += l[i];
    if (p <= x) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int r;cin >> r;
  cout << 6.28318530717958623200*r << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int N,sum;
  sum =0;
  cin >> N;
  for (long long int i=1;i <= N; i++){ 
    if ((i%3 !=0 && i%5 !=0))
      sum +=i;
  }
  cout << sum <<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,K;
  vector<long long> v[11];
  cin>>n>>K;
  for(int i=0,c,g;i<n;i++){
    cin>>c>>g;
    v[g-1].push_back(c);
  }
  for(int i=0;i<10;i++){
    sort(v[i].begin(),v[i].end());
    reverse(v[i].begin(),v[i].end());
    for(int j=1;j<v[i].size();j++)
      v[i][j]+=v[i][j-1]+j*2;
  }
  long long dp[11][2001]={};
  for(int i=0;i<10;i++)
    for(int j=0;j<=K;j++){
      for(int k=0;k+j+1<=K&&k<v[i].size();k++){
	dp[i+1][k+j+1]=max(dp[i+1][k+j+1],dp[i][j]+v[i][k]);
      }
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
  cout<<dp[10][K]<<endl;
  return 0;
}

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

namespace IO {
    const int maxn((1 << 21) + 1);

    char ibuf[maxn], *iS, *iT, c;
    int f, tp;

    inline char Getc() {
        return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, maxn, stdin), (iS == iT ? EOF : *iS++)) : *iS++);
    }
    
    template <class Int> inline void Input(Int &x) {
        for (f = 1, c = Getc(); c < '0' || c > '9'; c = Getc()) f = c == '-' ? -1 : 1;
        for (x = 0; c <= '9' && c >= '0'; c = Getc()) x = (x << 3) + (x << 1) + (c ^ 48);
        x *= f;
    }
}

using IO :: Input;

const int maxn(2e5 + 5);
const int mod(1e9 + 7);

int n, a[maxn], t[maxn], ans, lst[maxn], id[maxn], half;
int inv[maxn], cnt[maxn], icnt[maxn], acnt, c1[maxn], c2[maxn];

inline void Inc(int &x, const int y) {
	x += y;
	if (x >= mod) x -= mod;
}

inline void Add(int *c, int x, const int v) {
	for (; x <= n; x += x & -x) Inc(c[x], v);
}

inline int Query(int *c, int x) {
	int ret = 0;
	for (x = max(0, x); x; x -= x & -x) Inc(ret, c[x]);
	return ret;
}

inline bool Cmp(int x, int y) {
	return a[x] == a[y] ? x < y : a[x] < a[y];
}

int main() {
	Input(n);
	acnt = icnt[0] = cnt[0] = inv[0] = inv[1] = 1;
	for (int i = 2; i <= n; ++i) inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 1; i <= n; ++i) Input(a[i]), ++t[a[i] = min(a[i], n)];
	for (int i = n; i; --i) t[i] += t[i + 1];
	for (int i = 1; i <= n; ++i) {
		int cur = t[i] - (n - i);
		if (cur <= 0) return puts("0"), 0;
		cnt[i] = 1LL * cnt[i - 1] * cur % mod;
		icnt[i] = 1LL * icnt[i - 1] * inv[cur] % mod;
		acnt = 1LL * cur * acnt % mod;
		lst[i] = lst[i - 1];
		if (cur > 1) {
			icnt[i] = 1LL * icnt[i] * (cur - 1) % mod;
			cnt[i] = 1LL * cnt[i] * inv[cur - 1] % mod;
		}
		else lst[i] = i;
	}
	half = 1LL * acnt * inv[2] % mod;
	for (int i = 1; i <= n; ++i) {
		int cur = half, sum;
		sum = Query(c2, a[i]);
		Inc(sum, mod - Query(c2, lst[a[i]] - 1));
		cur = 1LL * cur * icnt[a[i]] % mod * sum % mod;
		Inc(ans, cur);
		Add(c2, a[i], cnt[a[i]]);
	}
	for (int i = 1; i <= n; ++i) c1[i] = c2[i] = 0;
	for (int i = n; i; --i) {
		int cur = half, sum;
		sum = Query(c1, a[i] - 1);
		Inc(ans, 1LL * acnt * sum % mod);
		sum = (Query(c2, a[i] - 1) - Query(c2, lst[a[i]] - 1) + mod) % mod;
		cur = 1LL * cur * icnt[a[i]] % mod * sum % mod;
		Inc(ans, mod - cur);
		Add(c1, a[i], 1), Add(c2, a[i], cnt[a[i]]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void)
{
	int n;
	int i,j;
	int jadge[3];
	int count = 0;

	cin >> n;

	if (n < 3 || n > 20)
	{
		return -1;
	}

	vector<int> p(n);

	for (i = 0; i < n; i++)
	{
		cin >> p[i];
	}

	for (i = 0; i < n; i++)
	{
		if (p[i] < 1 || p[i] > n)
			return -1;

		for (j = 0; j < i; j++)
		{
			if (p[i] == p[j])
				return -1;
		}
	}

	for (i = 1; i < n - 1; i++)
	{
		jadge[0] = p[i - 1];
		jadge[1] = p[i];
		jadge[2] = p[i + 1];

		if ((jadge[1] > jadge[0] && jadge[1] < jadge[2]) || (jadge[1] < jadge[0] && jadge[1] > jadge[2]))
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma warning (disable:4996)
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int inputstr(char *str){
	unsigned short int i;
	scanf("%s", str);
	if (!strcmp(str, "END_OF_TEXT"))return 0;
	for (i = 0; str[i] != '\0'; i++)
		str[i] = tolower(str[i]);
	return 1;
}
void cmpword(int *cnt, char *word, char *str){
	if (!strcmp(word, str))++*cnt;
}
int main(void){
	int cnt = 0;
	char str[1000];
	char word[10];
	scanf("%s", word);
	while (inputstr(str)){
		cmpword(&cnt, word, str);
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 552
# Otoshidama
N, Y = map(int, input().split())

for x in range(N+1): # xは10000円札の枚数
	for y in range(N+1): # yは5000円札の枚数
		z = N - (x + y) # zは1000円札の枚数
		if Y == 10000*x + 5000*y + 1000*z and 0 <= z:
			print(x, y, z)
			break
	if Y == 10000*x + 5000*y + 1000*z and 0 <= z:
			break
else:
	print(-1, -1, -1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
}

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

int a[2000007];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];

    sort(a,a+n);
    for(int i=0;i<n;i++)
        (i)?printf(" %d",a[i]):
            printf("%d",a[i]);
    printf("\n");


}

Measured memory_bytes: 10920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n;
	string s;
	map<string, int> m;
	vector<pair<int,string>>v;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		m[s]++;
	}
	for (auto i = m.begin(); i != m.end(); ++i) 
	{
        v.push_back(make_pair(i->second,i->first));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
    	if(v[i].first!=v[v.size()-1].first)v[i].first=-1;
    }
    for(int i=0;i<v.size();i++)
    {
    	if(v[i].first!=-1)cout<<v[i].second<<endl;
    }
    return 0;
}

Measured memory_bytes: 29172
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
long long a[4];
int main(){
    rep(i,1,3) scanf("%lld",&a[i]);
    sort(a+1,a+1+3);
    rep(i,1,3) if (a[i]%2==0) {
        puts("0"); return 0;
    }
    printf("%lld\n",a[1]*a[2]);
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = [input() for _ in range(n)]
cnt = Counter(s)
print(len(cnt))

Measured memory_bytes: 136920
import bisect as bi

N = int(input())
A = [int(t) for t in input().split()]

A = sorted([A[i]-i-1 for i in range(N)])

nega_cnt = bi.bisect_left(A, 0)
posi_cnt = N - bi.bisect_right(A, 0)
zero_cnt = N - nega_cnt - posi_cnt


def calc():
    if nega_cnt + zero_cnt >= posi_cnt and posi_cnt + zero_cnt >= nega_cnt:
        return sum([abs(t) for t in A])

    if posi_cnt > nega_cnt + zero_cnt:
        idx = (posi_cnt-(nega_cnt + zero_cnt)) // 2 + 1
        a = A[-posi_cnt:][idx-1]
        return sum([abs(t-a) for t in A])

    if posi_cnt + zero_cnt < nega_cnt:
        idx = (nega_cnt-(posi_cnt + zero_cnt))//2 + 1
        a = A[:nega_cnt][-idx]
        return sum([abs(t-a) for t in A])


print(calc())


Measured memory_bytes: 25840
def palindrome(string):

	for i in range(2):
		if string[i] != string[5-i-1]:
			return False;
	return True; 


A,B = list(map(int,input().split()));


count = 0;

for i in range(A,B+1):

	if palindrome(str(i)):
		count += 1;

print (count);


Measured memory_bytes: 2940
s = input()
l = 0
r = len(s)-1
c = 0
if s.count("x") == len(s):
  print(0)
  exit()
while l < r:
  c_l = 0
  c_r = 0
  while s[l] == "x":
    c_l += 1
    l += 1
  while s[r] == "x":
    c_r += 1
    r -= 1
  if s[l] != s[r]:
    print(-1)
    exit()
  c += abs(c_l-c_r)
  l += 1
  r -= 1
print(c)

Measured memory_bytes: 41712
N,M=map(int,input().split())
AC=[0]*N
WA=[0]*N
wa=0
for i in range(M):
    p,s=input().split()
    p=int(p)-1
    if AC[p]==0 and s=="AC":
        AC[p]=1
        wa+=WA[p]
    WA[p]+=1
print(sum(AC),wa)

Measured memory_bytes: 4724
s = input()

ans = 0
if s[0] == 'R':
    ans += 1
    if s[1] == 'R':
        ans += 1
        if s[2] == 'R':
            ans += 1
elif s[1] == 'R':
    ans += 1
    if s[2] == 'R':
        ans += 1
elif s[2] == 'R':
    ans += 1

print(ans) 


Measured memory_bytes: 8992
#include <stdio.h>

int main(void){

  int max, x, y;
  int ans = 0;

  scanf("%d %d %d", &max, &x, &y);

  while(-1){
    if(max == (ans*x)+((ans+1)*y)){
      break;
    }else if(max < (ans*x)+((ans+1)*y)){
      ans--;
      break;
    }
    ans++;
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	queue<long> q;
	for(int i=1; i<=9; i++){
		q.push(i);
	}
	
	int ct = 0;
	long num, y;
	while(ct != k){
		num = q.front();
		q.pop();
		
		if(num % 10 != 0){
			y = 10*(num) + (num%10) - 1;
			q.push(y);
		}
		y = 10*(num) + (num%10);
		q.push(y);
		if(num%10 != 9){
			y = 10*(num) + (num%10) + 1;
			q.push(y);
		}
		
		ct++;
	}
	cout<<num;
	
	
	
	return 0;
}

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

using namespace std;

int n;
char s[4010];
int main()
{
	cin >> n;
	int num[3] = {0};
	for(int i = 1; i <= n; i++)
	{
		cin >> s[i];
		if(s[i] == 'R')
		{
			num[0]++;
		}
		else if(s[i] == 'G')
		{
			num[1]++;
		}
		else
		{
			num[2]++;
		}
	}
	long long ans = 1ll * num[0] * num[1] * num[2];
	long long minum = 0;
	int eq = 'R' + 'G' + 'B';
	for(int i = 1; i <= n; i++)
	{
		for(int d = 1; i + d + d <= n; d++)
		{
			if(s[i] + s[i+d] + s[i+d+d] == eq)
			{
				minum++;
			}
		}
	}
	ans -= minum;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3648
open Printf open Scanf
open Array

let binary_search ng ok f =
  let d = if ng <= ok then 1 else -1 in
  let rec f0 ng ok =
    if abs (ok - ng) <= 1 then ok
    else let mid = ng + (ok - ng) / 2 in if f mid then f0 ng mid else f0 mid ok
  in f0 (ng-d) (ok+d)

let () = scanf " %d %d" @@ fun n k ->
  let a = init n (fun _ -> scanf " %d" @@ fun v -> v) in
  sort compare a;
  print_int @@ binary_search 0 (n-1) (fun i ->
    let u = a.(i) in
    if u >= k then true
    else (
      let f = ref false in
      let dp = make (k+1) false in
      dp.(u) <- true;
      iteri (fun j v ->
        if j=i then ()
        else (
          for w=k downto 1 do
            if dp.(w) then (
              if k <= w+v && w+v < k + u then
                f := true
              else if w+v < k then
                dp.(w+v) <- true
            )
          done
        );
      ) a; !f
    )
  )





Measured memory_bytes: 4352
a = list(map(int,input().split()))
N = a[0]
A = a[1]
B = a[2]

if (B - A) % 2 == 0:
  ans = (B - A) // 2
else:
  if (N - A) > (B - 1):
    ans = A - 1
    A = 1
    B = B - ans
    ans = ans + 1
    B = B - 1
    ans = ((B - A) // 2) + ans
  else:
    ans = N - B
    B = N
    A = A + ans
    ans = ans + 1
    A = A + 1
    ans = ((B - A) // 2) + ans
  
print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

S = input()
i = 0
dif = 100000

while i <= len(S) - 3:
    nuki = int(S[i:i+3])
    # print(nuki)
    sa = 753 - nuki if nuki <= 753 else nuki - 753
    # print(sa)
    if sa <= dif:
        dif = sa
    i += 1

print(dif)




Measured memory_bytes: 2940
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int r = sc.nextInt();
        // スペース区切りの整数の入力
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int ans = 0;
        //for文
        for(int i = 0; i < n / r + 1; i++){
            for(int j = 0; j < (n - (i * r)) / g + 1; j++){
                if((n - (i * r + j * g)) % b == 0){
                    ans++;
                }
                /*for(int k = 0; k < (n - (i * r + j * g)) / b + 1; k++){
                    if(i * r + j * g + k * b == n){
                        ans++;
                        break;
                    }
                }*/
            }
        }
        // 出力
        System.out.println(ans);

    }

}

Measured memory_bytes: 21844
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var X = parseInt(input[0].split(" ")[1]);
  x = new Array(N).fill(0);
  tmp=input[1].split(" ");
  for(i=0;i<N;i++){
    x[i]=parseInt(tmp[i]);
  }
  x.push(X);
  x.sort(function(a,b){
    if( a < b ) return -1;
    if( a > b ) return 1;
    return 0;
  });
  dif=new Array();
  for(i=0;i<N;i++){
    if(x[i+1]-x[i]!=0){
    dif.push(x[i+1]-x[i]);
    }
  }
  var ans=0;
  if(dif.length==1){
    ans=dif[0];
  }else{
  for(i=1;i<dif.length;i++){
    if(i==1){
      ans=gcd(dif[i],dif[i-1]);
    }else{
      ans=gcd(ans,dif[i]);
    }
  }
}

  console.log('%s', ans);
}
function gcd(m, n) {
  var r;

  if(m < n) {
    r = m;
    m = n;
    n = r;
  }

  while ((r = m % n) != 0) {
    m = n;
    n = r;
  }

  return n;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30896
def code_for_B(test=None):

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

    pre = list_p[0]
    count = 0

    for i in range(1,n-1):
        cur = list_p[i]
        nxt = list_p[i+1]

        if pre >= cur > nxt:
            count += 1
        elif pre < cur < nxt:
            count += 1

        pre, cur = cur, nxt

    print(count)

code_for_B()


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int n,prize[10000];
	int i,z,one,n2;
	int a=0;
	
	while (a++ < 100){
		z = 0;
		one = 0;
		scanf("%d", &n);
		
		if (n == 0)break;
		
		for (i = 0; i < n; i++){
			scanf("%d", &prize[i]);
			if (prize[i] == 0)z++;
			if (prize[i] <= 1)one++;
		}
		if (one == n)printf("NA\n");
		else {
			n2 = n-z;
			printf("%d\n", n2+1);
		}
	}
	return (0);
}

Measured memory_bytes: 648
N, X, M = map(int, input().split())

existence = [0] * M
a = []
A = X
for i in range(N):
    if existence[A] != 0:
        break
    existence[A] = 1
    a.append(A)
    A = A * A % M

for i in range(len(a)):
    if a[i] == A:
        break
j = i

result = sum(a[:j])
a = a[j:]
N -= j
x = N // len(a)
y = N % len(a)
result += sum(a) * x + sum(a[:y])
print(result)

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

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

	int S[13] = { 0 };
	int H[13] = { 0 };
	int C[13] = { 0 };
	int D[13] = { 0 };

	std::string picture;
	int rank;

	for (int i = 0; i < n; i++) {
		std::cin >> picture >> rank;
		if (picture == "S") {
			S[rank-1] = 1;
		}
		else if (picture == "H") {
			H[rank-1] = 1;
		}
		else if (picture == "C") {
			C[rank-1] = 1;
		}
		else {
			D[rank-1] = 1;
		}
	}

	for (int i = 0; i < 13; i++) {
		if (S[i] == 0) {
			std::cout << "S " << i + 1 << std::endl;
		}
	}
	for (int i = 0; i < 13; i++) {
		if (H[i] == 0) {
			std::cout << "H " << i + 1 << std::endl;
		}
	}
	for (int i = 0; i < 13; i++) {
		if (C[i] == 0) {
			std::cout << "C " << i + 1 << std::endl;
		}
	}
	for (int i = 0; i < 13; i++) {
		if (D[i] == 0) {
			std::cout << "D " << i + 1 << std::endl;
		}
	}
}

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

int main() {
    char ch;
    cin >> ch;

    if ( ch == 'a' || ch == 'i' || ch == 'u' || ch == 'e' || ch == 'o') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        
        ll len;
        string str;
        cin>>len>>str;
        vector<char> v;
        if(len==1)
            cout<<"1";
        else
        {

        for (int i = 0; i < len-1; ++i)
        {
            if(str[i+1]==str[i] && i!=len-2)
            {
                continue;
                
            }
            if(str[i+1]!=str[i] && i==len-2)
            {
                v.push_back(str[i+1]);   
            }
            
            v.push_back(str[i]);
            
            
            

        }
            cout<<v.size();

        }
        
        return 0;
    }


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

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    if (S == "ABC")
    {
        cout << "ARC" << endl;
    }else
    {
        cout << "ABC" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
        cout<<1<<endl;
    else if(b==0)
          cout<<2<<endl;
    else if(c==0)
          cout<<3<<endl;
          else if(d==0)
          cout<<4<<endl;
          else if(e==0)
          cout<<5<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,mini=INT_MAX,maxi=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int num;
        cin>>num;
        mini=min(num,mini);
        maxi=max(num,maxi);
    }
    cout<<maxi-mini<<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * StandardDeviation
 */
public class Main{

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                if (n == 0) {
                    break;
                }

                int[] scores = new int[n];
                int sum = 0;
                double average = 0, variance = 0, sum_a = 0;

                for (int i = 0; i < scores.length; i++) {
                    scores[i] = sc.nextInt();
                    sum += scores[i];
                }
                average = (double) sum / scores.length;
                for (int i = 0; i < scores.length; i++) {
                    sum_a += (scores[i] - average) * (scores[i] - average);
                }
                variance = (double) sum_a / scores.length;

                System.out.println(Math.sqrt(variance));
            }
        }
    }
}


Measured memory_bytes: 31264
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string s;
	cin>>s;
	
	int cnt=0;
	for(int i=1;i<s.size();++i){
		if(s[i-1]!=s[i]) cnt++;
	}
	
	cout<<cnt<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int x, y, stock, rev, sumc;

  rev = 0;
  sumc = 0;

  scanf("%d %d",&x,&y);



  while(x != 0 || y != 0){

    sumc += 1;

    if(rev == 0 && x <= y){
      stock = x;
      x = y;
      y = stock;
      rev += 1;
    }


    x = x % y;
    
    if(rev != 0){
      stock = x;
      x = y;
      y = stock;
    }

    if(y == 0){

      printf("%d %d\n",x,sumc);
      scanf("%d %d",&x,&y);
      sumc = 0;
      rev = 0;

    }

  }

  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int maxn = 1e6 + 5;


bool pal(int x) {
  vector<int> v;
  while (x>0) {
    v.push_back(x%10); x=x/10;
  }
  int n = v.size();
  for (int i=0; i<n/2; i++) {
    if (v[i]!=v[n-i-1]) return false;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);

  int a,b; cin>>a>>b;
  int ans = 0;
  for (int i=a; i<=b; i++) {
    ans += pal(i);
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256