akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

struct Card {
	char suit;
	char value;
};


void bubbleSort(Card A[], int N) {
	bool flag = true;
	int i = 1;
	while (flag) {
		flag = false;
		for (int j = N - 1; j >= i; j--) {
			if (A[j - 1].value > A[j].value) {
				Card temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				flag = true;
			}
		}
		i++;
	}
}


void selectionSort(Card A[], int N) {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j].value < A[minj].value) {
				minj = j;
			}
		}
		if (i != minj) {
			Card temp = A[i];
			A[i] = A[minj];
			A[minj] = temp;
		}
	}
}

void displayA(Card A[], int N) {
	for (int i = 0; i < N - 1; i++) {
		cout << A[i].suit << A[i].value << " ";
	}
	cout << A[N - 1].suit << A[N - 1].value << endl;
}



int main() {
	char table1[10][4], table2[10][4];
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 4; j++) {
			table2[i][j] = table1[i][j] = 'X';
		}
	}

	int N;
	Card A1[36], A2[36];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A1[i].suit >> A1[i].value;
		A2[i] = A1[i];
	}

	for (int i = 1; i <= 9; i++) {
		int num = 0;
		for (int j = 0; j < N; j++) {
			if ((int) A2[j].value - (int) '0' == i) {
				table1[i][num++] = A2[j].suit;
			}
		}
	}

	bubbleSort(A1, N);
	selectionSort(A2, N);

	for (int i = 1; i <= 9; i++) {
		int num = 0;
		for (int j = 0; j < N; j++) {
			if ((int)A2[j].value - (int) '0' == i) {
				table2[i][num++] = A2[j].suit;
			}
		}
	}

	bool isStable = true;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 4; j++) {
			if (table2[i][j] != table1[i][j]) {
				isStable = false;
				break;
			}
		}
		if (isStable == false) {
			break;
		}
	}


	displayA(A1, N);
	cout << "Stable" << endl;

	displayA(A2, N);
	if (isStable == true) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
def main():
    n=int(input())
    a,b=map(int, input().split())
    p = map(int,input().split())
    A,B,C = 0, 0, 0
    for pp in p:
        if pp <= a:
            A += 1
        elif pp <= b:
            B += 1
        else:
            C += 1
    print(min(A,B,C))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int N,M;
vector<vector<int>>G;
vector<bool>seen;

int dfs(int now){
  bool ok=true;
  for(int i=0;i<N;i++){
    if(seen[i]==false){ok=false;}
  }
  if(ok){return 1;}
  
  int cnt=0;
  for(int next:G[now]){
    if(seen[next]){continue;}
    seen[next]=true;
    cnt+=dfs(next);
    seen[next]=false;
  }
  return cnt;
}

int main() {
  cin>>N>>M;
  G.resize(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  seen.resize(N,false);
  seen[0]=true;
  cout<<dfs(0)<<endl;
  return 0;
}


Measured memory_bytes: 3604
//isaf27

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
#include <queue>
#include <bitset>
#include <cmath>
#include <time.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <deque>
#include <iomanip>
#include <complex>
#include <ctime>
#include <bits/stdc++.h>
//#include <ext/rope>

using namespace std;
//using namespace __gnu_cxx;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define fast_read cin.sync_with_stdio(0)
#define PREX(number) cout << fixed << setprecision(number)
#define nul point(0, 0)
#define random srand(time(NULL))
#define rand_int abs((rand() << 15) | rand())
#define str_to_int(stroka) atoi(stroka.c_str())
#define str_to_ll(stroka) atoll(stroka.c_str())
#define str_to_double(stroka) atof(stroka.c_str())
#define what_is(x) cerr << #x << " is " << x << endl
#define solve_system int number; cin >> number; for (int i = 0; i < number; i++) solve()
#define solve_system_scanf int number; scanf("%d", &number); forn(i, 0, number) solve()

//easy functions
template< typename T >
T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }

//constants
const ld pi = 3.141592653589793238462643383279;
const ld log23 = 1.58496250072115618145373894394781;
const ld eps = 1e-10;
const ld zero = 0;
const ll INF = 1e18;
const int COUT = 30;
const int prost = 239;
const ll prost64 = 239;
const int two = 2;
const int thr = 3;
const ll sr = 31;
const ll MOD = 1e9 + 7;
const ll MOD2 = MOD * MOD;
const int BIG = 1e9 + 239;
const int alf = 26;
const int M = 2 * 1e5 + 239;
const int N = 2 * 1e3 + 239;
const int T = (1 << 20);
const int B = trunc(sqrt(M)) + 1;
const int MAX_LOG = 19;
const int km = (1 << 18);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
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 bit_max = 32;
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
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 bt = 31;

// Code starts here

int n;
ll a[M], b[M];

int main()
{   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /**/
    fast_read;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    bool ch = 1;
    for (int i = 0; i < n; i++)
        ch &= (a[i] == b[i]);
    if (ch)
    {
        cout << 0;
        return 0;
    }
    ll s = 0;
    for (int i = 0; i < n; i++)
        s += b[i];
    ll mx = BIG;
    for (int i = 0; i < n; i++)
        if (a[i] > b[i])
            mx = min(mx, b[i]);
    cout << (s - mx);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int n;
  string s;
  cin >> n;
  int x = 0;
  cin >> s;
  int ans = 0;
  rep(i,s.size()){
    if(s[i] == 'I') x++;
    if(s[i] == 'D') x--;
    ans = max(ans,x);
  }
  cout << ans << endl;
  return 0;
}


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


int main() {
  int N,Y;
  cin>>N>>Y;
  
  for(int x=0;x<=N;x++){
    for(int y=0;y<=N-x;y++){
      if(10000*x+5000*y+1000*(N-x-y)==Y){
        cout<<x<<" "<<y<<" "<<N-x-y<<endl; 
        return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
    
  
}


Measured memory_bytes: 256
def s():
 import sys
 r=sys.stdin.readline
 for e in iter(r,'0\n'):
  R=[[]for _ in[0]*-~int(e)]
  for _ in[0]*int(r()):
   a,b=map(int,r().split())
   R[a]+=[b];R[b]+=[a]
  for m in R[1][:]:R[1]+=R[m]
  print(len({*R[1]}-{1}))
if'__main__'==__name__:s()


Measured memory_bytes: 6304
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define R register
using namespace std;
namespace chu_xuan{
    void swap(int &a,int &b){R int tmp=a;a=b,b=tmp;}
    void read(int &a) {a=0;int b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b;}
    int In() {int a=0,b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*b;}
    int max(int a,int b){return a>b?a:b;}
    int min(int a,int b){return a>b?b:a;}
}using namespace chu_xuan;

const int N=1e5+5;
int n,x,ans;

int main()
{
    read(n);
    for(int i=1;i<=n;i++)
    {
    	read(x);ans=__gcd(x,ans);
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n=int(input())
e=[[] for _ in range(n)]
a=[0]*n
b=[0]*n
d={}
def dfs(x,last=-1,ban=-1):
    c=1
    for to in e[x]:
        if to==last:
            continue
        if c==ban:
            c+=1
        d[(x,to)]=c
        dfs(to,x,c)
        c+=1

for i in range(n-1):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
    e[a[i]].append(b[i])
    e[b[i]].append(a[i])

dfs(0)
print(max(d.values()))
for i in range(n-1):
    if (a[i],b[i]) in d:
        print(d[(a[i],b[i])])
    else:
        print(d[(b[i],a[i])])


Measured memory_bytes: 101532
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;

char s[200001];

int main(void)
{
	int n, a;
	scanf("%d", &n);
	scanf("%s", s);
	a = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == 'W')
			a++;
	for (int i = n - a; i < n; i++)
		if (s[i] == 'W')
			a--;
	printf("%d\n", a);
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;

vi normarize(const vi &v)
{
    vector<vi> r;
    rep(i,4)
    {
        vi t;
        rep(j,4) t.pb(v[(i+j)%4]);
        r.pb(t);
    }
    sort(all(r));
    return r[0];
}

void print(const vi &v)
{
    rep(i,4)
    {
        if(i) printf(" ");
        printf("%d", v[i]);
    }
    printf("\n");
}

inline ll P(int n, int r)
{
    if(n<r) return 0;

    ll ret=1;
    rep(i,r) ret*=n-i;
    return ret;
}

inline ll POW(int x, int n)
{
    ll ret=1;
    rep(i,n) ret*=x;
    return ret;
}

inline ll DIM(const vi &v)
{
    if(v[0]==v[1] && v[1]==v[2] && v[2]==v[3]) return 4;
    else if(v[0]==v[2] && v[1]==v[3]) return 2;
    return 1;
}

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

    vector<vi> c(n,vi(4));
    rep(i,n)rep(j,4) scanf(" %d", &c[i][j]);

    map<vi,int> ct;
    rep(i,n)
    {
        c[i]=normarize(c[i]);
        if(ct.find(c[i])==ct.end()) ct[c[i]]=1;
        else ++ct[c[i]];
    }

    ll ans=0;
    // 上面i, 下面j
    rep(i,n)rep(j,i)
    {
        if(i==j) continue;
        // 下面の向きを設定
        rep(k,4)
        {
            vi u;
            rep(x,4) u.pb(c[j][(k+x)%4]);
            swap(u[1],u[3]);

            // printf("c[i]: ");
            // print(c[i]);
            // printf("u: ");
            // print(u);

            vector<vi> sides(4);
            map<vi,int> sides_ct;
            rep(x,4)
            {
                vi t(4);
                t[0]=c[i][(x+1)%4];
                t[1]=c[i][x];
                t[2]=u[x];
                t[3]=u[(x+1)%4];
                // print(t);
                t=normarize(t);

                sides[x]=t;
                if(sides_ct.find(t)==sides_ct.end()) sides_ct[t]=1;
                else ++sides_ct[t];
            }

            // printf("   go (%d,%d,%d)\n",i,j,k);
            ll add=1;
            for(const auto &x:sides_ct)
            {
                vi key=x.fi;
                int value=x.se;

                // printf("key = ");
                // print(key);
                // printf("value= %d\n", value);

                // 使ってないタイルのうち当てはめられる個数
                int num=ct[key];
                if(c[i]==key) --num;
                if(c[j]==key) --num;

                // 選び方、向き、位置
                add*=P(num,value)*POW(DIM(key),value);
            }
            ans+=add;
        }
    }

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


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

int main(void)
{
  int N, M;
  cin >> N >> M;

  int count1 = 0;
  for (int i = 1; i < N; i++)
  {
    count1 += i;
  }
  int count2 = 0;
  for (int i = 1; i < M; i++)
  {
    count2 += i;
  }

  cout << count1 + count2 << endl;
}

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

using namespace std;

const int md = 1e9 + 7;

long long inv[111111], f[111111];

int n;
int a[111111], p[111111], q1, q2;

long long pw(long long a, int b){
	if (b == 0) return 1;
	long long tmp = pw(a, b / 2);
	tmp = tmp * tmp % md;
	if (b % 2) tmp = tmp * a % md;
	return tmp;
}

long long c(int b, int a){
	if (b > a) return 0;
	return f[a] * inv[b] % md * inv[a - b] % md;
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	++n;
	for(int i = 1; i <= n; ++i) scanf("%d",&a[i]);
	for(int i = 1; i <= n; ++i) if (!p[a[i]]) p[a[i]] = i; else q1 = p[a[i]], q2 = i;
	f[0] = inv[0] = 1;
	for(int i = 1; i <= n; ++i){
		f[i] = f[i - 1] * i % md;
		inv[i] = pw(f[i], md - 2);
	}
	for(int i = 1; i <= n; ++i){
		printf("%lld\n", (c(i, n) - c(i - 1, q1 - 1 + n - q2) + md) % md);
	}
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
 string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>k>>s;
  s[k-1] = s[k-1] - 'A' +'a';
  cout<<s;
}

signed main(){
 
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);

	const int a = s[0], b = s[1];

	AtCoder::Ans* ans = new AtCoder::Ans();

	ans->increment(a * b);

	if (a < 10 && b < 10) {
		ans->showResult();
	} else {
		printf("-1\n");
	}

	delete(ans);

	return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

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

	return true;
}
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	rep2(i, n , MD){
		if(isPrime(i)){
			cout << i <<"\n"; return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


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


	if (n % 7 == 0) n /= 7;

	if ((n % 2 == 0) || (n % 5 == 0)) {
		cout << "-1" << endl;
		return 0;
	}
	
	if (n == 1) {
		cout << "1" << endl;
		return 0;
	}

	int answer = 1;
	long long nowMod = 1;
	long long totalMod = 0;

	while(1) {

		totalMod = ((totalMod * 10) + 1) % n;

		if(totalMod == 0){
			cout << answer << endl;
			break;
		}

		answer++;
	}

}

Measured memory_bytes: 3620
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {
         if (n == r){dp[n][n] = 1;}
	else if (r == 0) {return dp[n][0] = 1;}
	else if (r == 1) {return dp[n][1]=n;}
	else {dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
	return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;}
}
int main() {
	int N;
	cin >> N;
	if (N % 2 == 0)cout << N / 2 << endl;
	else cout << N / 2 + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000001
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    vector<int> cnt(MAX, 0);
    bool pairwise = true;
    for (int ai : a) {
        // 修正点1
        if (ai == 1) {
            continue;
        }
    
        // cnt.at(ai)++;
        // 修正点2
        if (ai == 2) {
            if (cnt.at(ai) >= 1) {
                pairwise = false;
                break;
            } 
            cnt.at(ai)++;
            continue;
        }
        if (cnt.at(ai) >= 1) {
            pairwise = false;
            break;
        }
        cnt.at(ai)++;
        for (int d = 2; d * d <= ai; d++) {
            if (ai % d == 0) {
                if (cnt.at(d) >= 1) {
                    pairwise = false;
                }
                if (d != ai) {
                    cnt.at(d)++;
                }
                if (d != ai / d) {
                    if (cnt.at(ai / d) >= 1) {
                        pairwise = false;
                    }
                    if (ai != ai / d) {
                        cnt.at(ai / d)++;
                    }
                }
            }
            if (!pairwise) {
                break;
            }
        }
        if (!pairwise) {
            break;
        }
    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int tmp_gcd = a.at(0);
    bool setwise = false;
    for (int i = 1; i < n; i++) {
        int new_gcd = gcd(tmp_gcd, a.at(i));
        // if (new_gcd == 1) {
        //     setwise = true;
        //     break;
        // }
        tmp_gcd = new_gcd;
    }
    if (tmp_gcd == 1) {
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;
    return 0;
}

Measured memory_bytes: 11164
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		for(int i=1;i<=10000;i++){
			if(((int)(i*0.08)==A)&&((int)(i*0.1)==B)){
				System.out.println(i);
				System.exit(0);
			}
		}
		System.out.println(-1);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<math.h>
#define ll long long int
#define lp(i,n) for(ll i=0;i<n;i++)
using namespace std;
int main()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	ll dp[n];
	
	lp(i,n)
	cin>>a[i];
dp[0]=0;
	lp(i,n)
	if(i!=0)	
	{
		ll lol;
		if(i-k>=0)
			lol=i-k;
		else
			lol=0;
		ll min=999999999;
ll minindex=-1;
ll j;
		for( j=lol;j<i;j++){
			if(abs(a[i]-a[j])+dp[j]<min){
				min=abs(a[i]-a[j])+dp[j];
				minindex=j;
//				cout<<"1. "<<a[i]<<" "<<dp[j]<<" "<<j<<endl;

}
//			else
//			cout<<a[i]<<" "<<dp[j]<<endl;
			//cout<<abs(a[i]-dp[j])<<endl;
			
		}
		dp[i]=min;
//cout<<dp[i]<<endl;

	}
	cout<<dp[n-1]-dp[0]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#define INF -2000000000
using namespace std;
vector <int> s;
int check(int x){
  for(int i=1;i<s.size()-1;i++){
    int ima = s[i],nx = s[i+1],mae = s[i-1];
    if(ima == INF) ima = x;
    if(nx == INF) nx = x;
    if(mae == INF) mae = x;
    
    if(i%2 == 0 && (ima >= mae || ima>= nx)) 
      if(s[i] == INF)return -1;
      else return 1;

    else if(i%2==1 &&(mae >= ima||nx >= ima)) 
      if(s[i] == INF)  return 1;
      else return -1;
  }

  if(s.size() == 2) {
    int ima = s[0],nx = s[1];
    if(s[0] == INF) ima = x;
    if(s[1] == INF) nx  = x;
    if(ima >= nx) 
      if(s[0] == INF) return -1;
      else return 1;
  }
  return 0;
}

int main() {
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;
    s.clear();
    for(int i=0;i<n;i++) {
      char str[100];
      cin >> str;
      if(str[0] == 'x') s.push_back(INF);
      else s.push_back(atoi(str));
    }
  
    int R = 1000000010,L=-1000000011,M,ans = INF,cnt = 0;
    while(L < R) {
      cnt ++;
      int t = M;
      M = (L+R)/2;
      if(M == t) L--,R++,M=(L+R)/2;
      if(cnt > 35) break;
      int res = check(M);
      if(res == -1) R = M;
      else if(res == 1) L=M+1;
      else if(res == 0) {
	ans = M;
	break;
      }
    }

    if(ans == INF) cout << "none"<<endl;
    else if(check(ans+1) == 0 || check(ans-1) == 0) cout << "ambiguous"<<endl;
    else cout << ans <<endl;
  }
  return 0;

}

Measured memory_bytes: 1240
#include<iostream>
#include<cstdio>
using namespace std;
int n, m;

int main() {
	scanf("%d%d", &n, &m);
	if (n > m) for (int i = 1; i <= n; i++) printf("%d", m);
	else for (int i = 1; i <= m; i++) printf("%d", n);
	return 0;
}

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

int main() {
	bool hantei = false;
	int k, a,b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			hantei = true;
			break;
		}
	}
	if (hantei) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
import java.util.*

fun main(args: Array<String>) {
    val cin = Scanner(System.`in`)
    val x1: Int = cin.nextInt()
    val y1: Int = cin.nextInt()
    val x2: Int = cin.nextInt()
    val y2: Int = cin.nextInt()
    
    val x3: Int = x2 + y1 - y2
    val y3: Int = y2 + x2 - x1
    val x4: Int = x1 + y1 - y2
    val y4: Int = y1 + x2 -x1
    println("$x3 $y3 $x4 $y4")
}

Measured memory_bytes: 29352
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());
		ArrayList<Integer> cost = new ArrayList<>();
		int left = 0;
		int right = 0;
		for(int i = 0; i < M; i++) {
			cost.add(Integer.parseInt(sc.next()));
			if(cost.get(i) < X) {
				left++;
			}else {
				right++;
			}
		}
		sc.close();

		System.out.println(Math.min(left, right));

	}

}


Measured memory_bytes: 21204
import sys
readline = sys.stdin.buffer.readline

import numpy as np

n = int(readline())
a = np.array(readline().split(), np.int64)

ai = np.argsort(a)[::-1]
a = a[ai]
ai += 1

dp = np.zeros(n + 1, np.int64)
for k, (i, e) in enumerate(zip(ai, a), 1):
    dp_new = dp.copy()

    add_left = e * np.abs(np.arange(1, k + 1) - i)
    dp_new[1:k+1] = np.maximum(dp_new[1:k+1], dp[:k] + add_left)

    add_right = e * np.abs(np.arange(n - k + 1, n + 1) - i)
    dp_new[:k] = np.maximum(dp_new[:k], dp[:k] + add_right)

    dp = dp_new

ans = dp.max()
print(ans)


Measured memory_bytes: 27760
#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);
int freq[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
     int n,m;
     cin>>n>>m;
     for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        freq[a]++;
        freq[b+1]--;
     }
     int cnt=0;
     for(int i=1;i<=n;i++){
        freq[i]+=freq[i-1];
        if(freq[i]==m)
            cnt++;
     }
     cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3956
# こっちの方がわかりやすい気がする
N, X = map(int, input().split())
l_list = list(map(int,input().split()))

d_list = [0,]
s = 0
for l in l_list:
    s += l
    d_list.append(s)

for i,d in enumerate(d_list):
#     print(i,d)
    if d>X:
        cnt = i
        break
    if i == N:
        cnt = i+1
        break

print(cnt)

Measured memory_bytes: 38384
# operator.add(a, b)
# operator.mul(a, b)

"""
https://komiyam.hatenadiary.org/entry/20131202/1385992406
大雑把に言って、平衡二分探索木からinsert,delete,split,mergeなどができないよう制限したのがsegment treeで、
segment treeの区間[L,R)に対するクエリをL=0に制限したのがbinary indexed treeだと見なすことができます。
"""


class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n)
        for i in range(len(A)):
            self.__node[i + n] = A[i]
        for i in range(n - 1, 0, -1):
            self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])
    
    def update(self, i, c):
        i += self.__n
        node = self.__node
        node[i] = c
        while i > 1:
            i //= 2
            node[i] = self.__dot(node[2 * i], node[2 * i + 1])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n
        r += self.__n
        while (l < r):
            if l & 1:
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l //= 2
            if r & 1:
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r //= 2
        return self.__dot(vl, vr)
    

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A
def AOJ_DSL_2_A():
    n, q = map(int, input().split())
    e = (1 << 31) - 1
    A = [e] * n
    seg = SegmentTree(A, min, e)

    for i in range(q):
        t, x, y = map(int, input().split())
        if t == 0:
            seg.update(x, y)
        else:
            print(seg.get(x, y + 1))


# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B
def AOJ_DSL_2_B():
    from operator import add
    import sys
    n, q = map(int, input().split())
    e = 0
    A = [e] * n
    seg = SegmentTree(A, add, e)
    
    query = sys.stdin.readlines()
    for i in range(q):
        t, x, y = map(int, query[i].split())
        x -= 1
        if t == 0:
            A[x] += y
            seg.update(x, A[x])
        else:
            y -= 1
            print(seg.get(x, y + 1))


def ABC125_C():
    from fractions import gcd
    N = int(input())
    A = list(map(int, input().split()))
    
    seg = SegmentTree(A, gcd, 0)
    ans = 0
    for i in range(N):
        ans = max(ans, gcd(seg.get(0, i), seg.get(i + 1, N)))
    print(ans)


# AOJ_DSL_2_A()
AOJ_DSL_2_B()
# ABC125_C()



Measured memory_bytes: 18956
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
 
ll N;
vector<ll> a;
 
int main(){
    cin >> N;
    a.resize(3*N);
    rep(i,3*N) cin >> a[i];
 
    ll s = 0;
    rep(i,N) s += a[i];
 
    priority_queue<ll,vector<ll>,greater<ll>> qs;  // 小さい順
    rep(i,N) qs.push(a[i]);
 
 
    vector<ll> dp1(3*N+10,0); // [0,i)での上位N個の和
    dp1[N] = s;
    for(int i=N;i<2*N;i++){
        ll nxt = a[i];
        ll mn = qs.top();
        if(nxt > mn){
            s = s + nxt - mn;
        }
        dp1[i+1] = s;
        qs.push(nxt);
        qs.pop();
    }
 
    reverse(all(a));
    //cout << a << endl;
    s = 0;
    rep(i,N) s += a[i];
    priority_queue<ll> qt;
    rep(i,N) qt.push(a[i]);
 
    vector<ll> dp2(3*N+10,0);
    dp2[N] = s;
    for(int i=N;i<2*N;i++){
        ll nxt = a[i];
        ll mx = qt.top();
        //cout << nxt << " " << mx << endl;
        if(nxt < mx){
            s = s + nxt - mx;
        }
        dp2[i+1] = s;
        qt.push(nxt);
        qt.pop();
    }
 
    //cout << dp1 << endl;
    //cout << dp2 << endl;
 
    ll ans = -1 * 1e16;
    for(int i=N;i<=2*N;i++){
        ll x = dp1[i];
        ll y = dp2[3*N-i];
        //cout << i << " " << x << " " << y << endl;
        //cout << x - y << endl;
        chmax(ans,x-y);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8948
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static final long MOD = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int x = in.nextInt();
		int y = in.nextInt();
		long r = solve(x, y);
		System.out.println(r);
		in.close();
	}

	private static long solve(int x, int y) {
		if (2 * x - y < 0 || 2 * y - x < 0)
			return 0;
		if ((2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0)
			return 0;
		int a = (2 * x - y) / 3;
		int b = (2 * y - x) / 3;
		long r = 1, q = 1;
		for (int i = a + b, j = Math.min(a, b); j > 0; i--, j--) {
			r *= i;
			r %= MOD;
			q *= j;
			q %= MOD;
		}
		r *= invMod(q);
		r %= MOD;
		return r;
	}

	private static long invMod(long q) {
		q %= MOD;
		for (long r = 1; r < MOD; r++)
			if ((q * r) % MOD == 1)
				return r;
		return 0;
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define MAXN 1010
using namespace std;

int n,x[MAXN],y[MAXN],tx,ty,p;
vector <int> v;

inline int abs(int a){return a<0?-a:a;}

inline int read()
{
	int x=0;char ch=getchar();bool f=false;
	while (ch<'0'||ch>'9'){if (ch=='-') f=true;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?-x:x;
}

int main()
{
	n=read();
	x[1]=read();y[1]=read();p=(abs(x[1])+abs(y[1]))%2;
	for (int i=2;i<=n;i++)
	{
		x[i]=read();y[i]=read();
		if ((abs(x[i])+abs(y[i]))%2!=p)
		{
			puts("-1");
			return 0;
		}
	}
	for (int i=30;~i;i--) v.push_back(1<<i);
	if (!p) v.push_back(1);
	printf("%d\n",v.size());
	for (int i=0;i<v.size();i++) printf("%d%c",v[i],i==v.size()-1?'\n':' ');
	for (int i=1;i<=n;i++)
	{
		tx=x[i];ty=y[i];
		for (int j=0;j<v.size();j++)
		{
			if (abs(tx)>abs(ty))
			{
				if (tx>0){tx-=v[j];putchar('R');}
				else{tx+=v[j];putchar('L');}
			}
			else
			{
				if (ty>0){ty-=v[j];putchar('U');}
				else{ty+=v[j];putchar('D');}
			}
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> a(N);
  int suma=0,sumb=0;
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i=0;i<N;i++){
    if(i%2==0)suma+=a.at(i);
    else sumb+=a.at(i);
  }
  cout<<suma-sumb<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<char> S(N);
    for (int i=0; i<N; i++) {
        cin >> S[i];
    }
    vector<pair<int, int>> P(Q);
    for (int i=0; i<Q; i++) {
        int l, r;
        cin >> l >> r;
        P[i] = pair<int, int> {l-1, r-1};
    }

    vector<int> S_acm(N, 0);
    char last_letter = ' ';
    for (int i=0; i<N; i++) {
        if (i != 0) S_acm[i] = S_acm[i-1];
        char letter = S[i];
        if ((last_letter == 'A') & (letter == 'C')) {
            S_acm[i] += 1;
        }
        last_letter = letter;
    }

    for (pair<int, int>& p: P) {
        cout << (S_acm[p.second] - S_acm[p.first]) << endl;
    }

    return 0;
}

Measured memory_bytes: 2048
module mod_stack
  implicit none
  type t_node
    private
    integer :: item
    type(t_node), pointer :: prev => null()
    type(t_node), pointer :: next => null()
  end type t_node
  type t_stack
    private
    integer :: num = 0
    type(t_node), pointer :: head => null()
    type(t_node), pointer :: tail => null()
  contains
    procedure :: push => push
    procedure :: pop => pop
    procedure :: peek => peek
    procedure :: clear => clear
    procedure :: size => size_of
  end type t_stack
contains
  function new_node(item) result(node)
    integer, intent(in) :: item
    type(t_node), pointer :: node
    allocate(node)
    node%item = item
  end
  subroutine push(this,item)
    class(t_stack), intent(inout) :: this
    integer, intent(in) :: item
    type(t_node), pointer :: node
    node => new_node(item)
    if (associated(this%head)) then
      node%prev => this%tail
      this%tail%next => node
    else
      this%head => node
    end if
    this%tail => node
    this%num = this%num+1
  end
  function pop(this) result(item)
    class(t_stack), intent(inout) :: this
    integer :: item
    type(t_node), pointer :: node
    item = this%tail%item
    node => this%tail%prev
    deallocate(this%tail)
    this%tail => node
    if (associated(node)) then
      node%next => null()
    else
      this%head => null()
    end if
    this%num = this%num-1
  end
  function peek(this) result(item)
    class(t_stack), intent(in) :: this
    integer :: item
    item = this%tail%item
  end
  subroutine clear(this)
    class(t_stack), intent(inout) :: this
    type(t_node), pointer :: node, prev
    if (.not.associated(this%tail)) return
    node => this%tail
    do while (associated(node%prev))
      prev => node%prev
      deallocate(node)
      node => prev
    end do
    this%head => null()
    this%tail => null()
    this%num = 0
  end
  integer function size_of(this)
    class(t_stack), intent(in) :: this
    size_of = this%num
  end
end module mod_stack
program robot_racing
  use mod_stack
  implicit none
  integer(8), parameter :: md = 1000000007_8
  type(t_stack) :: stack
  integer :: n, x(100000) = 0, i, k, tmp
  integer(8) :: ans = 1_8
  read(*,*) n
  read(*,*) x(1:n)
  do i = 1, n
    call stack%push(x(i))
    k = stack%size()
    if (x(i) < 2*k-1) then
      tmp = stack%pop()
      ans = mod(ans*int(k,8),md)
    end if
  end do
  do i = 1, stack%size()
    ans = mod(ans*int(i,8),md)
  end do
  write(*,'(i0)') ans
end program robot_racing

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
using namespace std;
int main(){
	string s;
	cin >> s;
	vector<string> v {"SAT", "FRI" , "THU", "WED", "TUE", "MON", "SUN"};
	for(int i = 0; i < 7; i++)
		if(s == v[i]) cout << i+1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
int keta1[10];
int keta2[10];
int keta3[10];
int k1, k2, k3;

int cti(char c) { return c - '0'; }
void input() {
  cin >> N;
  cin >> S;
}
map<int, int> mp;
bool check(int keta1, int keta2, int keta3) {
  int state = 0;
  rep(i, 0, N - 1) {
    if (state == 0) {
      if (cti(S[i]) == keta1) {
        state++;
      }
    } else if (state == 1) {
      if (cti(S[i]) == keta2) {
        state++;
      }
    } else if (state == 2) {
      if (cti(S[i]) == keta3) {
        state++;
        return true;
      }
    }
  }
  return false;
}
void solve() {
  // 1000tooritamesu
  int ans = 0;
  rep(i, 0, 999) {
    int keta1 = (i / 100) % 10;
    int keta2 = (i / 10) % 10;
    int keta3 = i % 10;
    // debug2(i, keta1);
    // debug2(keta2, keta3);
    if (check(keta1, keta2, keta3)) {
      // debug(i);
      ans++;
    }
  }

  cout << ans << endl;
  // for (int i = 0; i < N; ++i) {
  //   int k = cti(S[i]);
  //   mp[k]++;
  //   if (i < N - 2) {
  //     keta1[k] = 1;
  //   }
  //   if (i >= 1 && i < N - 1) {
  //     keta2[k] = 1;
  //   }
  //   if (i >= 2) {
  //     keta3[k] = 1;
  //   }
  // }

  // // shuukei
  // rep(i, 0, 9) {
  //   if (keta1[i]) {
  //     debug2(i, keta1[i]);
  //     k1++;
  //   }
  //   if (keta2[i]) {
  //     debug2(i, keta2[i]);
  //     k2++;
  //   }
  //   if (keta3[i]) {
  //     debug2(i, keta3[i]);
  //     k3++;
  //   }
  // }
  // set<int> st;
  // rep(i, 0, 9) {
  //   rep(j, 0, 9) {
  //     rep(k, 0, 9) {
  //       if (keta1[i] && keta2[j] && keta3[k]) {
  //         st.insert(i * 100 + j * 10 + k);
  //       }
  //     }
  //   }
  // }
  // // int ans = k1 * k2 * k3;
  // // cout << ans << endl;
  // cout << "anss" << endl;
  // for (auto x : st) {
  //   cout << x << endl;
  // }
  // cout << st.size() << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O2147483647")
//#pragma GCC optimize("inline")
//#pragma GCC optimize("-ffast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("inline-small-functions")
//#pragma GCC optimize("-finline-small-functions")
//#pragma GCC optimize("-fexpensive-optimizations")
//#pragma GCC optimize("-funsafe-loop-optimizations")
//#pragma GCC optimize("inline-functions-called-once")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC optimze("fast-math")
//#define GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include "testlib.h"
#define rep(i, j, k) for (int i = (int)(j); i<(int)(k); i++)
#define per(i, j, k) for (int i = (int)(k); i>=(int)(j); i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)((x).size())
#define fprd fprintf(stderr,
#define fi first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
//#define int ll
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int N=2e5+5;
int n,k,a[N]; ll sum=0;

int main() {
    scanf("%d%d",&n,&k);
    rep(i,0,n) scanf("%d",&a[i]);
    sort(a,a+n);
    rep(i,0,n-k) sum+=a[i];
    printf("%lld\n",sum);
}

Measured memory_bytes: 1024
#include<iostream>
#include <stdio.h>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;

ll n;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	cin >> n;
	cout << 0 << endl;
	string s1, s;
	cin >> s1;
	if (s1 == "Vacant")
		return 0;
	ll l = 0, r = n, m;
	while (l + 1 < r)
	{
		m = (l + r) / 2;
		cout << m << endl;
		cin >> s;
		if (s == "Vacant")
			return 0;
		if (m % 2 == 0 && s == s1 || m % 2 == 1 && s != s1)
			l = m;
		else
			r = m;
	}
	cout << l;
	return 0;
}

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

int i,j,c,ans=0;

int main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> vec(m);

    for(i=0;i<m;i++){//i:電球番号
        int k;cin>>k;//iの電球につながっているswitchの数
        for(j=0;j<k;j++){
            vec[i].resize(k);
            cin>>vec[i][j];//電球とswitchの関係
            vec[i][j]--;
        }
    }
    
    vector<int> p(m);//電球が偶奇のいずれで付くのか
    for(i=0;i<m;i++){cin>>p[i];}



    for(i=0;i<(1<<n);i++){//iは桁ごとに電球が付いているかどうかを表す(2進数で)
        bool light=true;
        for(j=0;j<m;j++){
            int c=0;//switchの偶奇
            for(int id:vec[j]){//j番の電球について
                if((i>>id)&1){//もし付いているならば
                    c++;
                }
            }
            if(c%2!=p[j]){//電球が点灯しているのか
                light=false;
            }
        }
        if(light){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		System.out.println(getMaximum(A, B));
	}
	
	private static int getMaximum(int a, int b) {
		return a == b? a * 2 : 2 * Math.max(a, b) - 1;
	}
}

Measured memory_bytes: 21712
import sys
readline = sys.stdin.readline
from collections import deque
directions = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def main():
    H, W = map(int, readline().rstrip().split())
    mat = [list(readline().rstrip()) for _ in range(H)]

    start = []
    for h in range(H):
        for w in range(W):
            if mat[h][w] == '#':
                start.append((h, w))
    
    res = 0
    que = deque(start)
    while que:
        next_que = deque()
        for h, w in que:
            for dh, dw in directions:
                if not (0 <= h+dh < H and 0 <= w+dw < W):
                    continue
                if mat[h+dh][w+dw] == '#':
                    continue
                mat[h+dh][w+dw] = '#'
                next_que.append((h+dh, w+dw))

        res += 1
        que = next_que

    print(res - 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 134352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
       // int t=scanner.nextInt();
        //for(int j=0;j<t;j++){
            int n=scanner.nextInt();
            int m=scanner.nextInt();
            long ans=n*(n-1)/2+m*(m-1)/2;
            System.out.println(ans);
        //}
    }

}


Measured memory_bytes: 23636
def cumsum(inlist):
    s = 0
    outlist = [0]
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist

mod = 10**9+7
n, k = [ int(v) for v in input().split() ]
a_list = [ int(v) for v in input().split() ]

dp_list = [ 0 for i in range(k+1) ]
dp_list[0] = 1

for i in range(n):
    cum_dp_list = cumsum(dp_list)

    new_dp_list = [ 0 for i in range(k+1) ]
    for j in range(k+1):
        r = min(j+1,k+1)
        l = max(0,j-a_list[i]) 
        new_dp_list[j] = cum_dp_list[r] - cum_dp_list[l]
    dp_list = [ i % mod for i in new_dp_list ]

print(dp_list[-1])

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

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

constexpr int INF = 1 << 30;

void solve() {
    int n, m, k;
    std::cin >> n >> m >> k;

    std::vector<int> cs(n);
    auto xss = vec(n, vec(m, 0));
    for (int i = 0; i < n; ++i) {
        std::cin >> cs[i];
        for (int j = 0; j < m; ++j) {
            std::cin >> xss[i][j];
        }
    }

    int ans = INF;
    for (int b = 0; b < (1 << n); ++b) {
        std::vector<int> sums(m, 0);
        int cost = 0;

        for (int i = 0; i < n; ++i) {
            if ((b >> i) & 1) {
                cost += cs[i];
                for (int j = 0; j < m; ++j) {
                    sums[j] += xss[i][j];
                }
            }
        }

        if (std::all_of(sums.begin(), sums.end(),
                        [&](int x) { return x >= k; })) {
            ans = std::min(ans, cost);
        }
    }

    std::cout << (ans == INF ? -1 : ans) << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    intmax_t N, D;
    intmax_t ans = 0;

    scanf("%jd%jd", &N, &D);

    ans = (N % (D * 2 + 1)) ? (N / (D * 2 + 1) + 1) : (N / (D * 2 + 1));

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

    return 0;
}


Measured memory_bytes: 256