akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
2
80 70
)");
#define cin input
#endif

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

	REP (i, k)
		if (s[i] != '1')
		{
			cout << s[i] << endl;
			return 0;
		}

	cout << '1' << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long

int main(){
  char  s[11];
  int len, i, j;
  ll t, sum, res = 0;

  scanf("%s", s);

  len = strlen(s);
  // printf("%d",len - 1); //1をｓの文字数-1分だけビットシフト
  // printf("%d",1 << (len - 1)); //1をｓの文字数-1分だけビットシフト
  //125だと2桁ビットシフトするので４となる

  for(i = 0; i < (1 << (len - 1)); i++){ //全ての桁をbitによって列挙
    t = sum = 0;
    for(j = 0; j < len; j++){ //それぞれの桁をチェック
      t = t*10 + (s[j] - '0'); //10をかけることで桁が実装できる
      if( i>>j & 1 || j == len-1) sum+=t,t=0; //ビットによるフラグが立っているか
    }
    res += sum;
  }

  printf("%lld", res);
  return 0;
}


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

namespace A.Add_Sub_Mul
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = abcd[0];
            int b = abcd[1];
            int c = abcd[2];
            int d = abcd[3];

            bool flg1 = Math.Abs(a - c) <= d;
            bool flg2 = Math.Abs(a - b) <= d && Math.Abs(b - c) <= d;

            Console.WriteLine(flg1 || flg2 ? "Yes" : "No");

        }
    }
}


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

using namespace std;

int main(){
  string str;
  cin >> str;
  int ans = 700;
  for(int i = 0; i < 3; i++)
    if(str[i] == 'o')
      ans += 100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(A);CIN(B);
    int ins = B - A;
    int num = 1;
    for(int a = 2;a <= ins;a++){
        num+=a;
    }
    COUT(num-B);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			int n = Integer.parseInt(br.readLine());

			if (n == 0)
				break;

			int[] array = new int[26];
			String str[] = br.readLine().split(" ");
			String alp[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
					"S", "T", "U", "V", "W", "X", "Y", "Z" };

			for (int i = 0; i < n; i++) {
				char c[] = str[i].toCharArray();
				int a = c[0] - 'A';
				array[a]++;

				int max = 0;
				int now = 0;
				for (int j = 0; j < 26; j++) {
					if (max < array[j]) {
						max = array[j];
						now = j;
					}
				}

				// judge
				boolean judge = true;
				for (int j = 0; j < 26; j++) {
					if (now == j) {
						continue;
					}
					if (max <= array[j] + n - i - 1) {
						judge = false;
						break;
					}
				}

				// output
				if (judge) {
					System.out.println(alp[now] + " " + (i + 1));
					break;
				} else if (i == n - 1) {
					System.out.println("TIE");
				}
			}
		}
	}
}


Measured memory_bytes: 37576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;typedef double db;
typedef pair<int, int> pii;typedef pair<ll, ll> pll;
typedef pair<int,ll> pil;typedef pair<ll,int> pli;
#define Fi first
#define Se second
#define _Out(a)	cerr<<#a<<" = "<<(a)<<endl
const int INF = 0x3f3f3f3f, MAXN = 1e3 + 7;
const ll LINF = 0x3f3f3f3f3f3f3f3f, MOD = 1e9+7;
const db Pi = acos(-1), EPS = 1e-6;
void test(){cerr << "\n";}template<typename T,typename...Args>void test(T x,Args...args){cerr<<x<<" ";test(args...);}
inline ll qpow(ll a, ll b){return b?((b&1)?a*qpow(a*a%MOD,b>>1)%MOD:qpow(a*a%MOD,b>>1))%MOD:1;}
inline ll qpow(ll a, ll b,ll c){return b?((b&1)?a*qpow(a*a%c,b>>1,c)%c:qpow(a*a%c,b>>1,c)) %c:1;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll cede(ll a,ll b){if(b<0)return cede(-a,-b);if(a<0)return a/b;return (a+b-1)/b;}
inline ll flde(ll a,ll b){if(b<0)return flde(-a,-b);if(a<0)return (a-b+1)/b;return a/b;}
inline int sign(db x){return x<-EPS ? -1:x>EPS;}
inline int dbcmp(db l,db r){return sign(l - r);}
namespace Fast_IO{ //orz laofu
    const int MAXL((1 << 18) + 1);int iof, iotp;
    char ioif[MAXL], *ioiS, *ioiT, ioof[MAXL],*iooS=ioof,*iooT=ioof+MAXL-1,ioc,iost[55];
    char Getchar(){
        if (ioiS == ioiT){
            ioiS=ioif;ioiT=ioiS+fread(ioif,1,MAXL,stdin);return (ioiS == ioiT ? EOF : *ioiS++);
        }else return (*ioiS++);
    }
    void Write(){fwrite(ioof,1,iooS-ioof,stdout);iooS=ioof;}
    void Putchar(char x){*iooS++ = x;if (iooS == iooT)Write();}
    inline int read(){
        int x=0;for(iof=1,ioc=Getchar();ioc<'0'||ioc>'9';)iof=ioc=='-'?-1:1,ioc=Getchar();
        for(x=0;ioc<='9'&&ioc>='0';ioc=Getchar())x=(x<<3)+(x<<1)+(ioc^48);return x*iof;
    }
    inline long long read_ll(){
        long long x=0;for(iof=1,ioc=Getchar();ioc<'0'||ioc>'9';)iof=ioc=='-'?-1:1,ioc=Getchar();
        for(x=0;ioc<='9'&&ioc>='0';ioc=Getchar())x=(x<<3)+(x<<1)+(ioc^48);return x*iof;
    }
    template <class Int>void Print(Int x, char ch = '\0'){
        if(!x)Putchar('0');if(x<0)Putchar('-'),x=-x;while(x)iost[++iotp]=x%10+'0',x/=10;
        while(iotp)Putchar(iost[iotp--]);if (ch)Putchar(ch);
    }
    void Getstr(char *s, int &l){
        for(ioc=Getchar();ioc <'a'||ioc>'z';)ioc=Getchar();
        for(l=0;ioc<='z'&&ioc>='a';ioc=Getchar())s[l++]=ioc;s[l] = 0;
    }
    void Putstr(const char *s){for(int i=0,n=strlen(s);i<n;++i)Putchar(s[i]);}
} // namespace Fast_IO
using namespace Fast_IO;


void work()
{
    int n=read();
    ll sum=0,ans=0;
    for(int i=1;i<=n;i++)
    {
        int x=read();
        sum=(sum+x)%MOD;
        ans=(ans-x*sum%MOD+MOD)%MOD;
    }
    ans=(ans+sum*sum%MOD)%MOD;
    printf("%lld\n",ans);
}

int main()
{
    //std::ios::sync_with_stdio(false);
   // int T=read();for(int cas=1;cas<=T;cas++)
    //int T;scanf("%d",&T);for(int i=1;i<=T;i++)
    work();
    // Write();
}
/*
3
6 9 2 1 1 1 4 1 3 3
6 9 2 1 1 1 5 1 4 3
6 9 2 1 1 1 5 1 5 3
6 9 2 1 1 1 8 1 6 3
6 9 2 1 1 1 8 1 7 4

5 6 4 1 1 4 3 999 1 10
10 10 4 1 1 3 7 999 1 100
10 10 4 1 1 8 9 999 1 100
*/

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int h1 = 982339;
const int h2 = 37;
const int mod = 1e9+7;
string s, t;
ll h[2][4000005];
ll val1[2][4000005];
ll val2[2][4000005];
int main(){
    h[0][0] = h[1][0] = 1;
    for(int i=1;i<=4000000;i++){
        h[0][i] = (h[0][i-1]*h1)%mod;
        h[1][i] = (h[1][i-1]*h2)%mod;
    }
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s >> t;
    int n = s.length(), m = t.length();

    for(int i=1;i<=4*(n+m);i++){
        int c = s[(i-1)%n];
        val1[0][i] = (val1[0][i-1] + h[0][i]*c)%mod;
        val1[1][i] = (val1[1][i-1] + h[1][i]*c)%mod;
    }
    for(int i=1;i<=4*(n+m);i++){
        int c = t[(i-1)%m];
        val2[0][i] = (val2[0][i-1] + h[0][i]*c)%mod;
        val2[1][i] = (val2[1][i-1] + h[1][i]*c)%mod;
    }

    int lo = 1, hi = 4*(n+m)/m, ans = 0;
    while(lo <= hi){
        int mid = (lo+hi)/2;

        int le = mid*m, ok = 0;
        for(int i=1;i<=4*(n+m)-le+1;i++){
            ll hx1 = (val1[0][i+le-1] - val1[0][i-1] + mod)*h[0][4000000-(i+le-1)]%mod;
            ll hy1 = (val2[0][le])*h[0][4000000-le]%mod;

            ll hx2 = (val1[1][i+le-1] - val1[1][i-1] + mod)*h[1][4000000-(i+le-1)]%mod;
            ll hy2 = (val2[1][le])*h[1][4000000-le]%mod;

            if(hx1 == hy1 && hx2 == hy2){
                ok = 1;
                break;
            }
        }
        if(ok) ans = mid, lo = mid+1;
        else hi = mid-1;
    }
    if(ans >= 2*(n+m)/m) ans = -1;
    printf("%d\n", ans);
}

Measured memory_bytes: 189212
loop do
  n, x = gets.split.map{|str| str.to_i}
  count = 0
  break if n == 0 && x == 0
  for i in (1..n-2)
    for j in (i+1..n-1)
      for k in (j+1..n)
        count += 1 if i+j+k == x
      end
    end
  end
  puts count
end

Measured memory_bytes: 8792
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),r=Number(t[0]),n=t[1].split(" ").map(function(e){return Number(e)}),o=t[2].split(" ").map(function(e){return Number(e)}),u=0,i=0;i<r;i++)o[i]<=n[i]?(u+=o[i],n[i]-=o[i],o[i]=0):(u+=n[i],o[i]-=n[i],n[i]=0,n[i+1]>o[i]?(u+=o[i],n[i+1]-=o[i],o[i]=0):(u+=n[i+1],o[i]-=n[i+1],n[i+1]=0));console.log(u)}},function(e,t){e.exports=require("fs")}]);

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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  int n;
  cin >> n;
  vector<int> ls(n);
  rep(i,n){
    cin >> ls.at(i);
  }
  sort(ls.begin(),ls.end());
  int ans=0;
  for (int i=0; i < n; i++){
      for (int j=i+1; j < n; j++){
        int k=lower_bound(ls.begin(),ls.end(),ls[i]+ls[j])-ls.begin();
        
        ans+=max(k-(j+1),0);
      }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << std::fixed << std::setprecision(10);

	int r;
	cin >> r;
	cout << r * r << endl;

	return 0;
}

Measured memory_bytes: 256
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
#define rep2(i, N, s) for(int (i) = (s); (i) < (N) + (s); (i) ++)
#define rrep(i, N) for(int (i) = (N) - 1; (i) >= (0); (i) --)
#define rrep2(i, N, s) for(int (i) = (s); (i) >= (s) - (N) + 1; (i) --)
#define INF 1e9

#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

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

int main() {
    int N, K;
    cin >> N >> K;
    int a  = N / K;
    if(N % K == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
i = list(map(int, input().split()))
K = i[0]
N = i[1]
j = list(map(int, input().split()))

d = K - (j[-1] - j[0])

for n in range(1, N):
    if j[n] - j[n-1] > d:
        d = j[n] - j[n-1]

print(K - d)

Measured memory_bytes: 26420
n,y=[int(x) for x in input().split()]
import sys
for i in range(n+1):
    for j in range(n+1-i):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y:
            print("{0} {1} {2}".format(i,j,k))
            sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    k--;

    vec div;

    for (int i = 1; i <= max(a, b); i++) {
        if (a % i == 0 && b % i == 0) {
            div.push_back(i);
        }
    }
    sort(all(div), greater<int>());
    cout << div[k] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

int main() {
    string s; cin>>s;
    string t="CODEFESTIVAL2016";
    int c=0; repn(i, sz(s)) if(s[i]!=t[i]) ++c;
    cout<<c<<endl;
    return 0;
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n;
    cin1(n);
    lli a[n];
    ncin1(n,a);
    lli ans = 0;
    REP(i,0,n) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> pos, neg;
    for (int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        if (0 <= ai)
            pos.push_back(ai);
        if (ai < 0)
            neg.push_back(ai);
    }
    
    if (k == n) {
        mint ans = 1;
        for (int ai : pos)
            ans *= ai;
        for (int ai : neg)
            ans *= ai;
        cout << ans << endl;
        return 0;
    }
    
    if (k % 2 == 1 && neg.size() == (unsigned)n) {
        sort(neg.begin(), neg.end(), greater<int>());
        mint ans = 1;
        for (int i = 0; i < k; i++)
            ans *= neg[i];
        cout << ans << endl;
        return 0;
    }
    
    sort(pos.begin(), pos.end(), greater<int>());
    sort(neg.begin(), neg.end());
    int count = 0;
    mint ans = 1;
    while (count < k) {
        if (count == k - 1) {
            ans *= pos[0];
            pos.erase(pos.begin());
            count += 1;
            break;
        }
        if (pos.size() >= 2 && neg.size() >= 2) {
            if ((ll)neg[0]*neg[1] <= (ll)pos[0]*pos[1]) {
                ans *= pos[0];
                pos.erase(pos.begin());
                count += 1;
            }
            else {
                ans *= neg[0];
                ans *= neg[1];
                neg.erase(neg.begin());
                neg.erase(neg.begin());
                count += 2;
            }
            continue;
        }
        if (pos.size() < 2 && neg.size() >= 2) {
            ans *= neg[0];
            ans *= neg[1];
            neg.erase(neg.begin());
            neg.erase(neg.begin());
            count += 2;
            continue;
        }
        if (pos.size() >= 2 && neg.size() < 2) {
            ans *= pos[0];
            ans *= pos[1];
            pos.erase(pos.begin());
            pos.erase(pos.begin());
            count += 2;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4268
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto n = lread();
    writeln(800 * n - (n / 15) * 200);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3572
/*
Aldew
PROB: Multiple of Three
CLASSIFICATION: Math
DIFFICULTY:
*/

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <map>
#include <math.h>
#include <cstdio>
#define ll long long int


using namespace std;


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

    int ans;
    if (n == 0){
        ans = x;
    }
    else {
        vector<int> a(n);
        for (auto& it : a) cin >> it;

        sort(a.begin(), a.end());

        map<int, int> d;
        vector<int> in;

        bool isIn;

        for (int i = 0; i < a.size(); i++){
            d[abs(x - a[i])] ++;


            isIn = false;
            for (int j = 0; j < in.size(); j++){
                if (in[j] == (abs(x-a[i]))){
                    isIn = true;
                    break;
                }
            }
            if (!isIn) in.push_back(abs(x-a[i]));
        }

        sort(in.begin(), in.end());

        ans = x - (in[in.size() -1] + 1);
        bool good = true;
        for (int i = 0; i< a.size(); i++){
            if (a[i] == ans){
                good = false;
                break;
            }
        }
        if (!good) ans = x + in[in.size() -1] + 1;


        if (in[0] > 0) ans = x;
        else{
            for (int i = 0; i < in.size(); i++){
                if (i -1 >= 0 && in[i-1] + 1 != in[i]) {
                    ans = x - (in[i-1] + 1);
                    break;
                }
                else if (d[in[i]] < 2 && in[i] != 0){
                    int p1 = x + in[i];
                    int p2 = x - in[i];

                    ans = p2;
                    for (int i = 0; i < a.size(); i++){
                        if (a[i] == p1){
                            ans = p2;
                            break;
                        }
                        else if (a[i] == p2){
                            ans = p1;
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }



    cout << ans << endl;


}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long
int r,ANS[52][2600][52],n,m,ans,mo=1e9+7,ma=2500;
signed main() {
	scanf("%lld %lld",&n,&m);
	if(m&1)return printf("0\n"),0;
	r=n*n>>1,m>>=1;//sum(A.size())
	ANS[0][r][0]=1;
	for(int i=1; i<=n; i++) {
		for(int j=0; j<=(r<<1); j++) {
			for(int k=0; k<=n; k++) {
				if(!ANS[i-1][j][k])continue;
				if(k)(ANS[i][j+i][k-1]+=ANS[i-1][j][k]*k*k)%=mo;//<--
				(ANS[i][j][k]+=ANS[i-1][j][k]*(k<<1|1))%=mo;
				(ANS[i][j-i][k+1]+=ANS[i-1][j][k])%=mo;//-->
			}
		}
	}
	printf("%lld\n",ANS[n][m+r][0]);
	return 0;
}

Measured memory_bytes: 51840
H, W = map(int, input().split())
G = [input() for i in range(H)]
done = [[False]*W for i in range(H)]
def dfs(h, w):
    done[h][w] = True
    if h == H-1 and w == W-1:
        return
    if w+1 < W and G[h][w+1] == "#":
        dfs(h, w+1)
    elif h+1 < H and G[h+1][w] == "#":
        dfs(h+1, w)
dfs(0, 0)
ans = True
for i in range(H):
    for j in range(W):
        if G[i][j] == "#":
            if not done[i][j]:
                ans = False
if ans:
    print("Possible")
else:
    print("Impossible")


Measured memory_bytes: 3064
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
sumA = (sum(a) ** 2) % mod
ans = sumA
tmp = 0
for i in range(n):
    tmp += a[i] ** 2
    tmp %= mod
ans = (ans - tmp) % mod
print((pow(2, mod - 2, mod) * ans) % mod)
# print(ans // 2)



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

#define f(a,n) for(ll i=a;i<n;i++)
#define fe(a,n) for(ll i=a;i<=n;i++)
#define ain(arr,n) for(ll i1=0;i1<n;i1++ ) cin>>arr[i1]
#define aout(arr,n) for(ll i1=0;i1<n;i1++ ) cout<<arr[i1]
#define ll long long int
#define endl "\n"
#define space " "
#define TLE_na_ho ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MAX_SIZE 400

int main()
{
    TLE_na_ho;

    ll n;
    cin >> n;
    ll a[n];
    ain(a, n);
    ll count = 0;
    sort(a, a + n);
    f(0, n - 2)
    {
        for(ll j = i + 1; j < n-1; j++)
        {
            for (ll k = j + 1; k < n; k++) 
                if ( 
                    a[i] + a[j] > a[k] 
                    && a[i] + a[k] > a[j] 
                    && a[k] + a[j] > a[i] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]) 
                    count++; 


        }
    }
    cout << count;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

long long int solve(int n, int a[])
{
	long long int result[101][21];
	for(int i = 0; i < 101; i++){
		for(int j = 0; j < 21; j++){
			result[i][j] = 0;
		}
	}
	result[1][a[1]] = 1;
	for(int i = 2; i < n; i++){
		for(int j = 0; j < 21; j++){
			if(j + a[i] <= 20) result[i][j + a[i]] += result[i - 1][j];
			if(j - a[i] >= 0) result[i][j - a[i]] += result[i - 1][j];
		}
	}
	return result[n - 1][a[n]];
}

int main()
{
	int n, a[101];
	cin >> n;
	for(int i = 1; i < n + 1; i++){
		cin >> a[i];
	}
	cout << solve(n, a) << endl;
	return 0;
}

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

using namespace std;
const int N = 1e5 + 3;
map<string, int> freq;
char s[22];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	long long res = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%s", s);
		sort(s, s + 10);
		res += freq[s]++;
	}
	printf("%lld\n", res);
	return 0;
}


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

int main() {
  int n, a, b, c, d;
  cin>>n>>a>>b>>c>>d;
  --a;
  --b;
  --c;
  --d;
  string s;
  cin>>s;
  for (int i=a+1; i<c; i++) {
    if (s[i] == '#' && s[i+1] == '#') {
      cout<<"No"<<endl;
      return 0;
    }
  }
  for (int i=b+1; i<d; i++) {
    if (s[i] == '#' && s[i+1] == '#') {
      cout<<"No"<<endl;
      return 0;
    }
  }
  if (c < d) {
    cout<<"Yes"<<endl;
    return 0;
  }
  for (int i=b; i<d+1; i++) {
    if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 640
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
from fractions import gcd
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    for i in range(1,50001):
        if int(i*1.08) == n:
            print(i)
            exit()
    print(':(')
if __name__ == '__main__':
  main()


Measured memory_bytes: 5776
import sys
list = sys.stdin.readlines()

e=0
GCD = 0
def Euclide(a, b):
    if b == 0:
        return a
    if a < b:
        tmp = a
        a = b
        b = tmp
    e = a%b
    return Euclide(b, e)

for i in list:
    i = i.split(' ')
    GCD = Euclide(int(i[0]), int(i[1]))
    print(str(GCD)+" "+str(int(int(i[0])/GCD*int(i[1]))))

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

using namespace std;

#define MAX_N 405

int n, y[MAX_N];
long long ps[MAX_N], dp[MAX_N][MAX_N];

long long f_imp(int, int);

long long f(int l, int r)
{
	if (dp[l][r] == 0)
		dp[l][r] = f_imp(l, r) + 1;
	return dp[l][r] - 1;
}

long long f_imp(int l, int r)
{
	if (l == r)
		return 0;
	long long rs = LONG_LONG_MAX/2;
	for (int i = l; i < r; i++)
	{
		rs = min(rs, f(l, i) + f(i + 1, r) + ps[r] - ps[l - 1]);
	}
	return rs;
}

int main()
{
	scanf("%d", &n);
	long long s = 0;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", y + i);
		s += y[i];
		ps[i] = s;
	}
	printf("%lld\n", f(1, n));
}


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

using namespace std;
using ll = long long;

int main() {
	int n; scanf("%d", &n);
	vector<int> as(n), bs(n);
	for (int i = 0; i < n; ++i) scanf("%d %d", &as[i], &bs[i]);
	sort(begin(as), end(as));
	sort(begin(bs), end(bs));
	if (n % 2 == 1) {
		printf("%d\n", bs[n/2] - as[n/2] + 1);
	} else {
		printf("%lld\n", (ll)bs[n/2] + bs[n/2 - 1] - as[n/2] - as[n/2 - 1] + 1); 
	}
	return 0;
}


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

unordered_map<int, int> memo;

int solve(vector<int> &h, int i)
{
	if (memo.count(i) == 0) {
		int result;
		if (i == 0) {
			result = 0;
		}
		else if (i == 1) {
			result = abs(h[0] - h[1]);
		}
		else {
			result = min(abs(h[i] - h[i - 1]) + solve(h, i - 1), abs(h[i] - h[i - 2]) + solve(h, i - 2));
		}
		memo[i] = result;
		return result;
	}
	else {
		return memo[i];
	}
}

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

	vector<int> h(n);
	for (auto &hi : h) {
		cin >> hi;
	}
	
	cout << solve(h, n - 1) << endl;

    return 0;
}



Measured memory_bytes: 7076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
int main(){
	int n,m,i,k;
	cin>>n>>m>>k;
	int times=0;
	for(i=min(n,m);i>=1;i--){
		if(n%i==0&&m%i==0){
			times++;
			if(times==k){
				cout<<i;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 05/17/20 20:37:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  vector<int> graph[n];
  for (int i = 0; i < m; i++) {
    int a,b; cin>>a>>b; a--; b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  vector<int> next(n, -1);
  queue<int> qs;
  qs.push(0);
  while (not qs.empty()) {
    auto q = qs.front(); qs.pop();
    for (auto t:graph[q]) {
      if (next[t] != -1) continue;
      next[t] = q;
      qs.push(t);
    }
  }
  cout << "Yes" << endl;
  for (int i  =1; i < n; i++)
    cout << next[i]+1 << endl;

  return 0;
}


Measured memory_bytes: 10180
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 1000000000 + 7;
const ll INF = 1e+9;
const ld PI = acos((long double)(-1));

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x) << endl;
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define eb(e) emplace_back(e)
#define EPS 0.00000001

// ２点の距離を計算する
double dist(double x1, double y1, double x2, double y2){
    double x = std::abs(x2 - x1);
    double y = std::abs(y2 - y1);
    double dist = sqrt((x * x) + (y * y));
    return dist;
}

int main() {
    FAST;

    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << std::fixed << std::setprecision(15) << dist(x1, y1, x2, y2) << endl;
}




Measured memory_bytes: 3292
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 3000;
const int MAXM = MAXN*MAXN;
const int MOD = int(1E9) + 7;

int pow_mod(int b, int p) {
	int ret = 1;
	for(int i=p;i;i>>=1,b=1LL*b*b%MOD)
		if( i & 1 ) ret = 1LL*ret*b%MOD;
	return ret;
}

int fct[MAXM + 5], ifct[MAXM + 5];
int comb(int n, int m) {
	return 1LL*fct[n]*ifct[m]%MOD*ifct[n-m]%MOD;
}
void init() {
	fct[0] = 1;
	for(int i=1;i<=MAXM;i++)
		fct[i] = 1LL*fct[i-1]*i%MOD;
	ifct[MAXM] = pow_mod(fct[MAXM], MOD - 2);
	for(int i=MAXM-1;i>=0;i--)
		ifct[i] = 1LL*ifct[i+1]*(i+1)%MOD;
}

int f[MAXN + 5][MAXN + 5];

int main() {
	init();
	int N, K; scanf("%d%d", &N, &K);
	if( K == 1 ) {
		puts("1");
		return 0;
	}
	for(int i=1;i<=N;i++) f[1][i] = 1;
	for(int i=2;i<=N;i++) {
		for(int j=1;j<=i;j++) {
			int m = (K - 1)*(i - 1) + j, n = K - 2;
			f[i][j] = 1LL*f[i-1][j]*comb(n+m-1, n)%MOD;
		}
		for(int j=1;j<=N;j++)
			f[i][j] = (f[i][j] + f[i][j-1]) % MOD;
	}
	printf("%lld\n", 1LL*f[N][N]*fct[N]%MOD);
}

Measured memory_bytes: 95488
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

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

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

    //cout << fixed << setprecision(15);

    int N;
    cin >> N;

    ll x, y;

    for (int i = 0; i < N; ++i)
    {
        ll T, A;
        cin >> T >> A;
        if (i == 0)
        {
            x = T;
            y = A;
            continue;
        }

        if (T == A)
        {
            x = max(x, y);
            y = max(y, x);
            continue;
        }

        ll t = max(x / T, y / A);
        while (1)
        {
            if (t * T >= x && t * A >= y)
                break;
            t++;
        }
        x = t * T;
        y = t * A;
    }
    cout << x + y << endl;
    return 0;
}


Measured memory_bytes: 256
a = io.read("*n")
b = 0
if a < 600 then
  b = 8
elseif a < 800 then
  b = 7
elseif a < 1000 then
  b = 6
elseif a < 1200 then
  b = 5
elseif a < 1400 then
  b = 4
elseif a < 1600 then
  b = 3
elseif a < 1800 then
  b = 2
else
  b = 1
end
print(b)


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

int main()
{
  //int coin, thousand, fivehund,fiveyen, points;
  //thousand = 1000;
  //fivehund = 500;
  //fiveyen = 5;
  int coin, points;
  points = 0;
  cin >> coin;

  points = (coin / 500) * 1000;
  coin = coin % 500;
  points = points + (coin / 5) * 5;

  cout << points << endl;



}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, m; cin >> n >> m;
    cout << --n * --m << endl;
}

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

int main()
{
  char b;
  cin >> b;
  
  if(b == 'A')
    cout << 'T' << endl;
  else if(b == 'T')
    cout << 'A' << endl;
  else if(b == 'C')
    cout << 'G' << endl;
  else if(b == 'G')
    cout << 'C' << endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut p: Vec<_> = (0..n).map(|_| {
        let x: i64 = it.next().unwrap().parse().unwrap();
        let d: i64 = it.next().unwrap().parse().unwrap();
        (x, d)
    }).collect();
    p.sort();
    const MOD: u32 = 998_244_353;
    let mut dp = vec![0u32; n + 1];
    dp[n] = 1;
    let mut stack = vec![];
    for (i, &(x, d)) in p.iter().enumerate().rev() {
        let mut r = i + 1;
        while let Some((a, b)) = stack.pop() {
            if a >= x + d {
                stack.push((a, b));
                break;
            }
            r = std::cmp::max(r, b);
        }
        dp[i] = (dp[i + 1] + dp[r]) % MOD;
        stack.push((x, r));
    }
    println!("{}", dp[0]);
}

fn main() {
    run();
}


Measured memory_bytes: 16504
import java.io.*;
  
public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] inputs = br.readLine().split(" ");
    int a = Integer.parseInt(inputs[0]), b = Integer.parseInt(inputs[1]);

    if (a == b) {
      System.out.println("a == b");
    } else if (a > b) {
      System.out.println("a > b");
    } else {
      System.out.println("a < b");
    }
  }
}

Measured memory_bytes: 24344
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;

    int t = min(a, b);
    int k = max(a, b);
    
    for (int i = 0; i < k; i++)
        cout << t;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 62ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    void CCout(long long x, const char* end = "\n") { std::cerr << x << end; }
    template <typename T> void CCout(const T& x, const char* end = "\n") { std::cerr << x << end; }
    template <typename T> void CCout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cerr << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one
}

int main() {

    string s = inp1;

    string t[] = { "dream", "dreamer", "erase", "eraser" };

    reverse(allof(s));
    rep(i, 4) {
        reverse(allof(t[i]));
    }

    bool can = true;

    rep(i, s.length()) {
        string t_5 = s.substr(i, 5);
        string t_6 = s.substr(i, 6);
        string t_7 = s.substr(i, 7);
    
        if (t_5 == t[0] || t_5 == t[2]) {
            i += 4;
        }
        else if (t_6 == t[3]) {
            i += 5;
        }
        else if (t_7 == t[1]) {
            i += 6;
        }
        else {
            can = false;
            break;
        }
    }

    Cout(YES(can));

    return 0;
}

Measured memory_bytes: 512
import sys
si = sys.stdin.readline
so = sys.stdout.write


def main():
    n = int(si())
    s = si()[:-1]
    cnt = s.count('R')*s.count('G')*s.count('B')

    for i in range(n-2):
        for j in range(i+1, n-1):
            k = j+j-i
            if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                cnt -= 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int n = N;
      	int s = 0;
      	while(n>0){
          s += n%10;
          n /= 10;
        }
      	if(N % s== 0){
			System.out.println("Yes");
        }else{
          	System.out.println("No");
        }
	}
}


Measured memory_bytes: 21716
import numpy as np
from math import sqrt
def isPrime(n):
    if n == 1:
        return False
    if n == 2 or n == 3:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    for i in range(5, int(sqrt(n)) + 1, 2):
        if n % i == 0:
            return False
    return True
def main():
    q = int(input())
    Q = [list(map(int, input().split())) for _ in range(q)]
    a = np.array([1 if i%2 == 1 and isPrime(i) and isPrime((i+1)//2) else 0 for i in range(10**5+1)])
    np.cumsum(a, out=a)
    for l, r in Q:
        print(int(a[r] - a[l-1]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 46544
#include <bits/stdc++.h>
using namespace std; 
int main(){
  int n,m,x,y;
  cin >>n>>m>>x>>y;
  int i;
  int maxi=x,mini=y;
  vector<int> s(n),t(m);
  for(i=0;i<n;i++){
    cin >> s.at(i);
    maxi=max(maxi,s.at(i));
  }
  for(i=0;i<m;i++){
    cin >> t.at(i);
    mini=min(mini,t.at(i));
  }
  if(mini>maxi){
    cout <<"No War";
  }else{
    cout << "War";
    }
}   
	


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskF {
        public int n;
        public int m;
        public int mod = 1000000007;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            long[][][] dp = new long[2][n + 1][n + 1];
            dp[0][n][0] = 1;
            for (int slots = 1; slots <= m; slots++) {
                int cur = slots % 2, prev = 1 - cur;
                for (int x = 0; x <= n; x++) {
                    for (int y = 0; y <= n; y++) {
                        dp[cur][x][y] = 0;
                        if (x > 0 && x + y <= n) dp[cur][x][y] += x * dp[prev][x + y][0];
                        if (y > 0) dp[cur][x][y] += y * dp[prev][x][y];
                        if (n - x - y > 0 && y + 1 <= n) dp[cur][x][y] += (n - x - y) * dp[prev][x][y + 1];
                        dp[cur][x][y] %= mod;
                    }
                }
            }
            out.println(dp[m % 2][1][0]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(){
	int n;cin>>n;
  	vector<int> s(n);
  	for(int i=0;i<n;i++){cin>>s.at(i);}
  	int q;cin>>q;
  	vector<int> t(q);
  	for(int i=0;i<q;i++){cin>>t.at(i);}
  	sort(s.begin(),s.end());
  	sort(t.begin(),t.end());
  	int i=0,j=0,count=0;
  	while(i<n && j<q ){
    	if(s.at(i)==t.at(j)){
        	count++;
          	i++;j++;
        }else if(s.at(i)>t.at(j)){
        	j++;
        }else if(s.at(i)<t.at(j)){
        	i++;
        }
    }
  cout<<count<<endl;
}


Measured memory_bytes: 3156
import java.util.*;

class Main
{
	static Scanner scan = new Scanner(System.in);
	
	static int nextInt(){
		return scan.nextInt();
	}
	
	static int h1=nextInt(); // 浩が釣り上げたイワナの数
	static int h2=nextInt(); // 浩が釣り上げたヤマメの数
	
	static int k1=nextInt(); // 健次郎が釣り上げたイワナの数
	static int k2=nextInt(); // 健次郎が釣り上げたヤマメの数
	
	static int a=nextInt(); // イワナ１匹ごとの点数
	static int b=nextInt(); // ヤマメ１匹ごとの点数
	static int c=nextInt(); // イワナ１０匹ごとの追加点数
	static int d=nextInt(); // ヤマメ２０匹ごとの追加点数
	
	static int score(int iwana, int yamame){
		return a*iwana + c*(iwana/10) + b*yamame + d*(yamame/20);
	}
	
	public static void main(String args[]){
		int hiroshiScore = score(h1,h2);
		int kenjiroScore = score(k1,k2);
		if( hiroshiScore > kenjiroScore ){
			System.out.println("hiroshi");
		}else if( hiroshiScore < kenjiroScore ){
			System.out.println("kenjiro");
		}else{
			System.out.println("even");
		}
	}
}



Measured memory_bytes: 26228
#include<bits/stdc++.h>
using namespace std;
map<int,int>num;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int z,i,n;
    cin>>n;
    vector<int>a;
    for(i=0;i<n;i++){
        cin>>z;
        a.push_back(z);
        num[z]++;
    }
    sort(a.begin(),a.end());
    bool dp[a[n-1]+1];
    for(i=0;i<=a[n-1];i++) dp[i]=1;
    for(i=0;i<a.size();i++){
        z=a[i];
        for(int j=2;j*z<=a[n-1];j++){
            dp[j*z]=0;
        }
    }
    int cnt=0;
    for(i=0;i<n;i++){
        if(dp[a[i]] && num[a[i]]==1) cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 14048