akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] rDx=cin.ArrayInt(3,0);
        int x=0;
       for(int i=0;i<10;i++)
       {
         rDx[2]=rDx[0]*rDx[2]-rDx[1];
         Console.WriteLine(rDx[2]);         
       }
        
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 11220
n=int(input())
s=str(input())
t=len(s)
#setの方が参照速度が速い
r=set()
g=set()
b=set()
a=0
for i in range(n):
    if s[i]=='R':
        r.add(i)
    if s[i]=='G':
        g.add(i)
    if s[i]=='B':
        b.add(i)
d=len(r)*len(g)*len(b)
for ri in r:
    for gi in g:
        if 2*ri-gi in b:
            d-=1
        if 2*gi-ri in b:
            d-=1
        if (gi+ri)/2 in b:
            d-=1

print(d)

Measured memory_bytes: 9320
#include<iostream>
#include<algorithm>
#include<cmath>
using lint=int64_t;
using namespace std;

int main()
{
	int N,M;
	int k[15]={};
	int s[15][15]={};
	int p[15]={};

	cin >> N >> M;
	for(int i=0;i<M;i++)
	{
		cin >> k[i];
		for(int j=0;j<k[i];j++)
		{
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for(int i=0;i<M;i++)
		cin >> p[i];


	int ans=0;
	for(int bit=0;bit<pow(2,N);bit++)
	{
		int i=bit;
		int flag=true;
		
		for(int j=0;j<M;j++)
		{
			int cnt=0;
			for(int l=0;l<k[j];l++)
			{
				if((i>>s[j][l])&1)
					cnt++;
			}

			if(cnt%2!=p[j])
			{
				flag=false;
				break;
			}
		}

		if(flag)
			ans++;
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    string s,t;

    cin>>s>>t;
    cout<<t<<s<<endl;
}


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

using namespace std;

int main()
{
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector <int >p(a);
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
    vector< int > q(b);
    for(int i=0;i<b;i++){
        cin >> q[i];
    }
    vector<int > r(c);
    for(int i=0;i<c;i++){
        cin >> r[i];
    }
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    vector<int >d;
    for(int i=0;i<x;i++){
        d.push_back(p[i]);
    }
    for(int i=0;i<y;i++){
        d.push_back(q[i]);
    }
    for(int i=0;i<c;i++){
        d.push_back(r[i]);
    }
    sort(d.rbegin(),d.rend());
    long long ans =0;
    for(int i=0;i<x+y;i++){
        ans+=d[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool prime[MAX];
int prime_numbers[9999999],pos;
void sieve()
{
    prime[0]=1;
    prime[1]=1;
    for(int i=4; i<=MAX; i+=2)
        prime[i]=1;
    int root = sqrt(MAX);
    for(int i=3; i<=root; i+=2)
    {
        if(prime[i]==0)
        {
            for(int j=i*i; j<=MAX; j+=i)
            {
                prime[j]=1;
            }
        }
    }
    prime_numbers[pos++]=2;
    for(int i=3; i<MAX; i+=2)
        if(prime[i]==0)
            prime_numbers[pos++]=i;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    sieve();
    ll n,ans=1;
    cin>>n;

    for(int i=0; i<pos; i++)
    {
        if(prime_numbers[i]>n)
            break;
        ll cur=n,p=prime_numbers[i],cnt=0;
        while(p<=cur)
        {
            cnt+=cur/p;
            p*=prime_numbers[i];
        }
        if(cnt)
        {
            ans=(ans*(cnt+1))%MOD;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4892
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int n, l1, l2;
	string s1, s2;

	cin >> n;
	while (n--) {
		cin >> s1 >> s2;
		l1 = s1.size();
		l2 = s2.size();

		int dp[l1 + 1][l2 + 1];
		for (int i = 0; i <= l1; i++) {
			for (int j = 0; j <= l2; j++) {
				dp[i][j] = 0;
			}
		}
		for (int i = 1; i <= l1; i++) {
			for (int j = 1; j <= l2; j++) {
				if (s1[i - 1] == s2[j - 1]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				}
				else {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}
		cout << dp[l1][l2] << endl;
	}

	return 0;
}

Measured memory_bytes: 7024
#include "stdio.h"

int main()
{
  int a, b, count = 0;
  char c[100001];
  scanf("%d", &a);
  scanf("%s", c);
  for(b = 0; b < a; b++)
  {
    if(c[b] == c[b + 1])
    {
      count++;
    }
  }
  printf("%d", a - count);
  return 0;
}


Measured memory_bytes: 384
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x = sorted(x)
y = sorted(y)

if max(x[-1], X) < min(y[0], Y):
  print("No War")
else:
  print("War")

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    vector<LLONG> sums(N + 1, 0LL);
    LLONG sum = 0;
    for (int i = 0; i < N; ++i)
    {
        LLONG ai; cin >> ai;
        sums[i + 1] = sums[i] + ai;
    }
    map<LLONG, LLONG> sum2NumMap;
    for (int i = 0; i <= N; ++i)
    {
        ++sum2NumMap[sums[i]];
    }
    LLONG ans = 0;
    for (const auto &kvp : sum2NumMap)
    {
        LLONG num = kvp.second;
        ans += num * (num - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////
int main(){
    int n;
    cin>>n;
    vi num(1e5+5);
    ll sum=0;
    rep(i,n){
        int a;
        cin>>a;
        num[a]++;
        sum+=a;
    }
    int q;
    cin>>q;
    vl ans;
    rep(i,q){
        int b,c;
        cin>>b>>c;
        int diff=c-b;
        sum+=diff*num[b];
        num[c]+=num[b];
        num[b]=0;
        ans.push_back(sum);
    }
    rep(i,q){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    ll x; cin >> x;
    ll ans = 0;
    ll l = 0;
    ll i = 0;
    while (l<x) {
        i ++;
        l += i;
        ans ++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll,ll> mp;
    vll a(n);
    REP(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll sum = 0;
    REP(i,n+1){
        sum += mp[i]*(mp[i]-1)/2;
    }
    REP(i,n){
        cout << sum-(mp[a[i]]-1) << endl;
    }

    return 0;
}

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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************
ll mod=1000000007;
//vector<vector<ll>> dp;

vector<vector<int>> v;
  int dp[22][3000000];
    ll n;
ll match(ll i,ll women,string &wstr)
{
    if(dp[i][women]!=-1)
    {
        return dp[i][women];
    }
    if(i==0)
    {
        for(int j=0;j<n;j++)
        {
            if(wstr[j]=='1')
            {
                if(v[i][j]==1)
                return 1;
                else
                return 0;
            }
        }
    }
    else{

        
        ll ans=0;
        for(int j=0;j<n;j++)
        {
            if(wstr[j]=='1')
            {
                if(v[i][j]==1)
                {
                    ll temp=1;
                    temp=temp<<j;
                    string st=wstr;
                    st[j]='0';
                    ans+=match(i-1,temp^women,st)%mod;
                }
            }
        }
        ans=ans%mod;
        dp[i][women]=ans;
        return ans;
    }    
}

void solve()
{
    

    cin >> n;
    v.resize(n);
    for(int i=0;i<n;i++)
    {
        v[i].resize(n);
        for(int j=0;j<n;j++)
        {
            cin >> v[i][j];
        }
    }
	//dp.resize(n);
    /*for(int i=0;i<n;i++)
    {
        dp[i].resize(pow(2,n));
        for(int j=0;j<pow(2,n);j++)
        {
            dp[i][j]=-1;

        }
    }*/
    for(int i=0;i<22;i++)
    {
        for(int j=0;j<3000000;j++)
        {
            dp[i][j]=-1;
        }
    }
    ll ans=0;
    ll women=(ll)pow(2,n)-1;
    string wstr ="";
    for(int i=0;i<n;i++)
    {
        wstr+='1';
    }
    //cout << "input is fast " << endl;
    cout << match(n-1,women,wstr);
    /*for(int j=0;j<n;j++)
    {
        ll temp=1;
        if(v[n-1][j]==1)
        {
            temp<<j;
            wstr[i]=0;
            dp[n-1][women]+=match(n-2,women^temp,wstr)%mod;
            dp[n-1][women]%=mod;
        }
    }*/

}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 258048
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
char s[110],t[110];
int main()
{
	scanf("%d %s %s",&n,s+1,t+1);
	for(int i=1;i<=n;++i)putchar(s[i]),putchar(t[i]);
	return 0;
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define eb emplace_back
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=1e5+15;
  const int M=2001+21;
  

 void doit()         
 { 
   int a,b,c,d,f=1; cin>>a>>b>>c>>d;

   while(true){
    
    if(f)
    {  if(b>=c){
        cout<<"Yes"; return;
      }
      else
        c-=b;
    }
    else{
       if(d>=a){
           cout<<"No"; return;
       }
       else
        a-=d;
    }

    f=1-f;

   }

 }


signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

 
  
   int tc=1;                         
//  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }
  

 return 0; 
}

Measured memory_bytes: 3640
//#pragma GCC optimize("O3")
#ifdef ONPC
#include "bits/stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 y00
#define y1 y11
#define int ll

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dxk[8] = {-1, -2, -1, 2, -2, 1, 1, 2};
const int dyk[8] = {-2, -1, 2, -1, 1, -2, 2, 1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll bt = 30;
const ld eps = 1e-8;
const ll INF = (ll)(1e18 + 239);
const ll BIG = (ll)(1e9 + 239);
const int MOD = 998244353;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

//constants
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 18;
const int T = (1 << 19);
const int B = (int)sqrt(M);
const int X = 110;

int n, a[M], b[M];
set<int> q;

void upd(int i)
{
    if (a[i] > b[i])
    {
        cout << "-1";
        exit(0);
    }
    if (a[i] == b[i])
        return;
    int pr = (i + n - 1) %n;
    int nx = (i + 1) % n;
    if (b[i] > b[pr] && b[i] > b[nx])
        q.insert(i);
}

void change(int i, int x)
{
    if (x < a[i])
    {
        cout << "-1";
        exit(0);
    }
    b[i] = x;
    int pr = (i + n - 1) % n;
    int nx = (i + 1) % n;
    if (q.find(pr) != q.end())
        q.erase(pr);
    if (q.find(nx) != q.end())
        q.erase(nx);
    upd(pr);
    upd(nx);
    upd(i);
}

int32_t main() {
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    ll ans = 0;
    for (int i = 0; i < n; i++)
        upd(i);
    while (!q.empty())
    {
        int i = *q.begin();
        q.erase(q.begin());
        int cur = b[(i + n - 1) % n] + b[(i + 1) % n];
        int need = max(b[(i + n - 1) % n], b[(i + 1) % n]);
        need = max(need, a[i]);
        int cnt = (b[i] - need + cur - 1) / cur;
        change(i, b[i] - cur * cnt);
        ans += cnt;
    }
    for (int i = 0; i < n; i++)
        if (a[i] != b[i])
        {
            cout << "-1";
            return 0;
        }
    cout << ans;
    return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>

void swap( int , int , int , int , int* );

int main(void){
    // Your code here!
    int dice[6];
    int *p;
    int e;
    p = dice;
    char flg;
    
    for( int i = 0 ; i < 6 ; i++ ){
        scanf( "%d" , p + i );
    }
    
    while( ( e = scanf( "%c" , &flg ) ) != EOF ){
        switch( flg ){
            case 'N'://1 -> 5 / 5 -> 6 / 6 -> 2 / 2 -> 1 // 1と5 → 1と2 → 2と6
                swap( 0 , 1 , 5 , 4 , p );
                break;
            case 'S':
                swap( 0 , 4 , 5 , 1 , p );
                break;
            case 'E':
                swap( 0 , 3 , 5, 2 , p );
                break;
            case 'W':
                swap( 0 , 2 , 5 , 3 , p );
                break;
            default:
                break;
            

        }
        
    }
    
    printf("%d\n" , dice[0] );
    
    
}



void swap( int x1, int x2 , int x3 , int x4 , int *dice ){
    
    int tmp;
    tmp = *( dice + x1 );
    *( dice + x1 ) = *( dice + x2 );
    *( dice + x2 ) = *( dice + x3 );
    *( dice + x3 ) = *( dice + x4 );
    *( dice + x4 ) = tmp;
    return;
};





Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
ll m=1000000007;
int main()
{
	fast;
	ll n,m,t;
	cin>>n>>m>>t;
	map<ll,ll>r,c;
	map<pair<ll,ll>,ll > a;
	while(t--)
	{
		ll x,y;cin>>x>>y;
		x--;
		y--;
		r[x]++;
		c[y]++;
		a[{x,y}]=1;
	}
	
	ll count=0,rans=0;
	for(auto i:r)
	{
		if(i.second>=count)
		{
			count=i.second;
			rans=i.first;
		}
	}
	ll lclcount=count;
	ll cans;
	for(auto i:c)
	{
		ll tep=i.second;
		if(tep+lclcount>count && a[{rans,i.first}]==0 )
		{
			count=tep+lclcount;
			cans=i.first;
		}
		else if(tep+lclcount-1>count && a[{rans,i.first}]==1)
		{
			count=tep+lclcount-1;
			cans=i.first;
		}
	}



	ll count1=0;
	for(auto i:c)
	{
		if(i.second>=count1)
		{
			count1=i.second;
			cans=i.first;
		}
	}
	lclcount=count1;

	for(auto i:r)
	{
		ll tep=i.second;
		if(tep+lclcount>count && a[{i.first,cans}]==0 )
		{
			count1=tep+lclcount;
			cans=i.first;
		}
		else if(tep+lclcount-1>count && a[{i.first,cans}]==1)
		{
			count1=tep+lclcount-1;
			cans=i.first;
		}
	}
	
	//cout<<rans<<" "<<cans<<nl;
	cout<<max(count,count1);

}

Measured memory_bytes: 59852
N, K = map(int, input().split())
S = input()

ans = -1
prev_char = S[0]
for i in range(N):
    if S[i] == prev_char:
        ans += 1
    else:
        prev_char = S[i]

x = N - ans
if x%2 == 0:
    ans += min(2*K, x-1)
else:
    ans += min(2*K, x-1)

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

ll dp[105][110000];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, W;
	cin >> n >> W;
	vector<int> w(n), v(n);
	rep(i, n) cin >> w[i] >> v[i];
	rep(i, n)rep(j, 110000) dp[i][j] = inf;
	dp[0][0] = 0;
	int ans = 0;
	rep(i, n) {
		for (int j = 0; j < 110000; ++j) {
			dp[i + 1][j] = dp[i][j];
			if (j - v[i] >= 0) dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			if (dp[i + 1][j] <= W) maxs(ans, j);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong X, N;
  vector<llong> p;

  cin >> X >> N;
  p.resize(N);
  set<llong> s;
  for (auto &in: p) {
    cin >> in;
    s.insert(in);
  }

  for (int i = 0; i <= 100; ++i) {
    if (s.count(X - i) == 0) {
      cout << X - i << endl;
      return 0;
    }
    if (s.count(X + i) == 0) {
      cout << X + i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int n, a, b;
    cin >> n >> a >> b;
    if(n * a <= b)
    {
        cout << n * a;
    }
    else
    {
        cout << b;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int gcd(vector<int> nums) {
  int ret = nums[0];

  for (int i = 1; i < nums.size(); i++) {
    ret = gcd(ret, nums[i]);
  }

  return ret;
}

const int MAX_N = 1000000;

class Prime {
public:
  vector<int> prime_list;

  Prime() {
    bool checked[MAX_N + 1];
    memset(checked, false, sizeof(checked));

    for (int i = 2; i <= MAX_N; ++i) {
      if (!checked[i]) {
        prime_list.push_back(i);

        for (int j = 2 * i; j <= MAX_N; j += i) {
          checked[j] = true;
        }
      }
    }
  }

  map<int, int> prime_division(int n) {
    map<int, int> res;

    for (int i = 0; prime_list[i] <= sqrt(n); ++i) {
      int p = prime_list[i];

      while (n % p == 0) {
        ++res[p];
        n /= p;
      }
    }

    if (n != 1) {
      res[n] = 1;
    }

    return res;
  }
};

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

  Prime prime;
  vector<int> A;

  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    A.push_back(a);
  }

  int all_gcd = gcd(A);
  int max_v = 0;
  map<int, int> counter;

  for (int i = 0; i < N; ++i) {
    int a = A[i];
    map<int, int> res = prime.prime_division(a);

    for (auto e : res) {
      counter[e.first]++;

      if (e.first != 1) {
        max_v = max(max_v, counter[e.first]);
      }

      // fprintf(stderr, "e: %d, v: %d\n", e.first, e.second);
    }
  }

  if (max_v <= 1) {
    cout << "pairwise coprime" << endl;
  } else {
    if (all_gcd == 1) {
      cout << "setwise coprime" << endl;
    } else {
      cout << "not coprime" << endl;
    }
  }

  // fprintf(stderr, "all_gcd: %d\n", all_gcd);

  return 0;
}


Measured memory_bytes: 12296
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int v1[100001],v2[100001];
int main(){
    int n,vi;
    cin>>n;
    rep(i,n){
        cin>>vi;
        if(i%2) ++v1[vi];
        else ++v2[vi];
    }
    int id1=max_element(v1,v1+100001)-v1,id2=max_element(v2,v2+100001)-v2;
    sort(v1,v1+100001,greater<int>());
    sort(v2,v2+100001,greater<int>());
    if(id1!=id2){
        cout<<n-v1[0]-v2[0]<<endl;
    }
    else{
        cout<<min(n-v1[0]-v2[1],n-v1[1]-v2[0])<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int y=1;
    for(int i=0;i<n;i++){
        y=min(2*y,y+k);
    }
    cout<<y<<endl;
    return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll x, n;
    cin >> x >> n;
    ll p[n];
    rep(i, n) { cin >> p[i]; }
    bool d[200] = {};
    rep(i, n) { d[p[i]] = true; }

    rep(i, 1000) {
        ll a = x - i, b = x + i;
        if (0 <= a && a < 200 && !d[a]) {
            cout << a << endl;
            return 0;
        }
        if (a < 0) {
            cout << a << endl;
            return 0;
        }

        if (0 <= b && b < 200 && !d[b]) {
            cout << b << endl;
            return 0;
        }
        if (b < 0) {
            cout << b << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3600
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include "bits/stdc++.h"

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define deb(x) cerr << (#x) << " is " << (x) << '\n'

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

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

	int r;
	cin >> r;
	ld pi = 2 * acos(0);
	cout << fixed << setprecision(15) << pi * r * 2;
	return 0;               
}
// Write Here
	


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin >> n >> k;
  
  int ans;
  ans=(n-1)/(k-1);
  if((n-1)%(k-1)!=0) ans++;
  
  cout << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
ll f(int x){
    if (x<0)
        return -x;
    else
        return x;
}
int main () {
    ll N, ans=987654321;
    cin >> N;
    while (N/100>=1){
        int a=N%1000;
        ans=min(ans,f(753-a));
        N/=10;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e6 + 9;
int main()
{
    int n,sum=7;
    scanf("%d",&n);
    if(n%2==0) 
    {
        printf("-1\n");
        return 0;
    }
    if(n==1||n==7) 
    {
        printf("1\n");
        return 0;
    }
    for(int i=1;i<=n;i++)
    {
        if(sum==0) 
        {
            printf("%d\n",i);
            return 0;
        }
        sum=(sum*10+7)%n;
    }
    printf("-1\n");
    return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n,m;cin>>n>>m;
  string s="";
  for(int i=0;i<n;i++)s+='*';
  while(m--){
    int pos;char c;cin>>pos>>c;
    pos--;
    if(s[pos]=='*')s[pos]=c;
    else if(s[pos]!=c) {
      cout<<-1<<endl;
      return 0;
    }
    if(n>1&&pos==0&&c=='0') {
      cout<<-1<<endl;
      return 0;
    }
  }
  for(int i=0;i<n;i++){
    if(s[i]=='*'){
      if(i==0&&n>1)
        cout<<1;
      else
        cout<<0;
    }else{
      cout<<s[i];
    }
  }
  cout<<endl;

  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;
  ll res = 0; 
  for (int mask = 0; mask < (1 << (S.size() - 1)); mask++) {
    ll now = 0, t = 0;
    for (int i = 0; i < S.size(); i++) {
      t = t * 10 + S[i] - '0';
      if ((mask >> i) & 1) {
        now += t;
        t = 0;
      }
    }
    now += t;
    res += now;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;


int main(){  
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int ans = a[n/2] - a[n/2-1];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		string s;
		cin >> s;
		for(int i = 0; i < n; ++i)
		{
			string s2 = "";
			int pos = 0;
			while(pos < s.size())
			{
				char c = s[pos];
				int count = 0;
				while(pos < s.size() && c == s[pos])
				{
					++pos;
					++count;
				}
				vector<char> Vec;
				while(count >= 10)
				{
					Vec.push_back(count % 10 + '0');
					count /= 10;
				}
				Vec.push_back(count % 10 + '0');
				for(int j = Vec.size() - 1; j >= 0; --j)
				{
					s2 += Vec[j];
				}
				s2 += c;
			}
			s = s2;
		}
		cout << s << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1356
#include <cstdio>
using namespace std;
int n,m,ans;
int main(){
	scanf("%d",&n);
	m=n;
	while (m){
		ans+=m%10;
		m=m/10;
	}
	if (ans==1 && n%10==0) printf("10"); else printf("%d",ans);
} 

Measured memory_bytes: 128
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N+1)]
for a,b in AB:
    data[a].append(b)
    data[b].append(a)

visited={1}
stack=deque([1])
re=[-1 for i in range(N+1)]
re[0]=0
re[1]=0
while stack:
    #print(stack)
    a=stack.popleft()
    for p in data[a]:
        if not p in visited:
            visited.add(p)
            re[p]=a
            stack.append(p)
#print(re)
if -1 in re:
    print("No")
else:
    print("Yes")
    for i in range(2,N+1):
        print(re[i])


Measured memory_bytes: 141868
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int n,m,x,y;cin>>n>>m>>x>>y;
  int xs[100], ys[100];rep(i,n)cin>>xs[i];rep(i,m)cin>>ys[i];
  sort(xs,xs+n);sort(ys,ys+m);
  int mx = xs[n-1], mn = ys[0];
  repd(i,mx+1,mn+1){
    if(x < i && i <= y){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);



void solve(int T){
   string s;
   cin>>s;
   int n=(s[0]-'0')*10 + (s[1]-'0'),r=(s[2]-'0')*10 + (s[3]-'0');
    if(n>12 && r<=12 && r>0){
        cout<<"YYMM\n";
    }
    else if(n<=12 && n>0 && r>12){
        cout<<"MMYY\n";
    }
    else if(n<=12 && r==0 && n>0){
        cout<<"MMYY\n";
    }
    else if(n==0 && r<=12 && r>0){
        cout<<"YYMM\n";
    }
    else if(n<=12 && r<=12 && n>0 && r>0){
        cout<<"AMBIGUOUS\n";
    }
    else {
        cout<<"NA\n";
    }
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





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

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

  int y = a[0];
  long long int x = 1;
  for(long long int i = 1; i < n; i++) {
    if(y > a[i]) {
      y = a[i];
      x++;
    }
  }
  cout << x;
} 

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(void){
    int X;
    int flag=0;
    scanf("%d",&X);
    for(int i = X; i > 0; i--){
        for(int j = 2; j <= sqrt(i); j++){
            for(int l = 2; l <= sqrt(i); l++){
                if(i == pow(j,l)){
                    printf("%d\n",i);
                    flag = 1;
                    break;
                }
            }
            if(flag == 1) break;
        }
        if(flag == 1) break;
    }
    if(X == 1) printf("1");

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
ll a[200001];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    ll res = 0;
    for(int i = 2; i <= n; i++){
        if(a[i] < a[i-1]){
            ll need = a[i-1]-a[i];
            a[i] += need; res += need;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5124
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderTemplate {
    class Program {
        static void Main (string[] args) {
            var S = Console.ReadLine ();
            var zeroCount = S.Where (c => c == '0').Count ();
            var oneCount = S.Where (c => c == '1').Count ();
            var solve = S.Count () - Math.Abs (zeroCount - oneCount);
            Console.WriteLine (solve);
        }
        /* Input & Output*/
        static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }
        static List<int> ReadInts () {
            return Console.ReadLine ().Split (' ').Select (c => int.Parse (c)).ToList ();
        }
        static List<List<int>> ReadColumns (int n) {
            /*
            入力例
            A1 B1
            A2 B2
            ...
            An Bn

            出力例
            [[A1,A2,...,An], [B1,B2,...,Bn]]
            */
            var seq = Enumerable.Range (0, n).Select (i => ReadInts ()).ToList ();
            return Enumerable.Range (0, seq.First ().Count ()).Select (i => seq.Select (items => items[i]).ToList ()).ToList ();
        }
        static void PrintEnum<T> (IEnumerable<T> list) {
            Console.Write (list.First ());
            foreach (var item in list.Skip (1)) {
                Console.Write ($" {item}");
            }
            Console.Write ("\n");
        }
        static void PrintLnEnum<T> (IEnumerable<T> list) {
            foreach (var item in list) {
                Console.WriteLine (item);
            }
        }

        /* Numeric Function */
        static int Fact (int n) {
            return Enumerable.Range (1, n).Aggregate (1, ((i, k) => i * k));
        }
        static int PermNum (int n, int m) {
            if (m > n) {
                return 0;
            }
            return Enumerable.Range (n - m, m + 1).Aggregate (1, ((i, k) => i * k));
        }
        static int CombNum (int n, int m) {
            return PermNum (n, m) / Fact (m);
        }
        // 最大公約数 (m ≧ n)
        static int GCD (int m, int n) {
            if (n == 0) {
                return m;
            } else {
                return GCD (n, m % n);
            }
        }
        // 最小公倍数 (m ≧ n)
        static int LCM (int m, int n) {
            return GCD (m, n) / (m * n);
        }

    }
}

Measured memory_bytes: 13372
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define MAX 50010
bool sosu[MAX];
int main(){
	memset(sosu,true,MAX);
	for(int i=4;i<MAX;i+=2)sosu[i]=false;
	for(int i=3;i<MAX;i+=2)if(sosu[i])
	for(int j=i*3;j<MAX;j+=2*i)sosu[j]=false;
	
	int n;
	while(cin>>n,n){
		int co=0;
		loop(i,2,n/2+1)if(sosu[i]&&sosu[n-i])co++;
		cout<<co<<endl;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

ll dp[100100];

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

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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int ans=0;
		for(int i=0;i<n;i++)
		{
			int t=in.nextInt();
			if(t>=k)
			{
				ans++;
			}
		}
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 47648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  string S;cin>>S;
  vector<int> a(26);
  for(int i=0;i<N;i++)
    a.at(S.at(i)-'a')++;
  
  int long long ans=1;
  for(int i=0;i<26;i++){
    ans*=(a.at(i)+1);
      ans=ans%(1000000000+7);
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 512
A, B, C = list(map(int, input().split()))

mod_list = []
i = 1
while True:
    mod = (A * i) % B
    if mod in mod_list:
        break
    mod_list.append(mod)
    i += 1

if C in mod_list:
    print("YES")
else:
    print("NO")




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

int main() {
  int x;
  cin >> x;
 
  vector<int> primes;
  
  for (int i=2; ; i++) {
    if (all_of(primes.begin(), primes.end(), [&](int x) { return i % x != 0; })) {
      if (i >= x) {
        cout << i;
        return 0;
      } else {
        primes.push_back(i);
      }
    }
  }

}

Measured memory_bytes: 384
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
n = int(input())
s = [input()for _ in range(n)]
ac = 0
wa = 0
tle = 0
re = 0

for i in s:
    if i == "AC":
        ac += 1
    elif i == "WA":
        wa += 1
    elif i == "TLE":
        tle += 1
    else:
        re += 1

print("AC" + " x ", end = "")
print( ac)
print("WA" + " x ", end = "")
print( wa)
print("TLE" + " x ", end = "")
print( tle)
print("RE" + " x ", end = "")
print( re)


Measured memory_bytes: 16244
from collections import deque
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
G = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, s = map(int, input().split())
    G[u].append((v, s))
    G[v].append((u, s))
val = [None] * (n+1)
val[1] = (1, 0)
queue = deque([1])
while queue:
    u = queue.popleft()
    for v, s in G[u]:
        if val[v]:
            continue
        val[v] = (-val[u][0], s - val[u][1])
        queue.append(v)
ma = float('inf')
mi = 1
x = -1
for u in range(1, n+1):
    if val[u][0] == -1:
        ma = min(ma, val[u][1] - 1)
    else:
        mi = max(mi, -val[u][1] + 1)
    for v, s in G[u]:
        if u > v:
            continue
        if val[u][0] + val[v][0] == 0:
            if val[u][1] + val[v][1] != s:
                print(0)
                exit()
        else:
            a = val[u][0] + val[v][0]
            b = s - (val[u][1] + val[v][1])
            if a < 0:
                b *= -1
            if b <= 0 or b % 2 == 1:
                print(0)
                exit()
            if x == -1:
                x = b // 2
            elif x != b // 2:
                print(0)
                exit()
if x != -1:
    if mi <= x <= ma:
        print(1)
    else:
        print(0)
else:
    print(max(ma - mi + 1, 0))

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int m;
int ans = 0;

int main(){
	int a[110];
	int sum=0;
	int err = 0;
	cin >> n;
	forn(i) {
		cin >> a[i];
		sum += a[i];
	}
	err = sum;
	forn(i) {
		if (err > abs(a[i] * n - sum)) {
			ans = i;
			err = abs(a[i] * n - sum);
		}
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

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

int main() {
    int x;
    cin >> x;
    if(x >= 400 && x <= 599) {
        cout << 8 << endl;
    } else if(x >= 600 && x <= 799) {
        cout << 7 << endl;
    } else if(x >= 800 && x <= 999) {
        cout << 6 << endl;
    } else if(x >= 1000 && x <= 1199) {
        cout << 5 << endl;
    } else if(x >= 1200 && x <= 1399) {
        cout << 4 << endl;
    } else if(x >= 1400 && x <= 1599) {
        cout << 3 << endl;
    } else if(x >= 1600 && x <= 1799) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
// <head>
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
// </head>

// <library>
    
// </library>

int MX = 600;
vector<vector<int> > to(MX+5);
double dfs(int u, int cut, vector<double> &seen){
    double e = 0.0;
    double mxe = 0.0;
    for(int v: to[u]){
        double cost;
        if(seen[v] != -1){
            cost = seen[v];
        } else {
            cost = dfs(v,cut,seen);
        }
        e += cost + 1;
        mxe = max(mxe, cost+1);
    }
    if(to[u].size()>1 && cut == u) e = (e - mxe) / (to[u].size()-1);
    else if(to[u].size()) e = e / to[u].size();
    seen[u] = e;
    return e;
}

int main(){
    int n,m;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int s,t;
        cin >> s >> t;
        s--; t--;
        to[s].emplace_back(t);
    }
    double ans = 100100100.1;
    for (int i = 0; i < n; i++){
        vector<double> seen(MX,-1);
        ans = min(ans, dfs(0,i,seen)); 
    }
    cout << ans << '\n';

}

Measured memory_bytes: 1408