akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;  
typedef unsigned long long ull;         
typedef vector < pii > vpii;                                   	
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;
 
 
const int inf = 1e9, maxn = 1e6 + 48, mod = 1e9 + 7, N = 5e4 + 24;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int k;
string s;

main () {
	cin >> k >> s;
	cout << s.substr(0, min(sz(s), k));
	if (k < sz(s))
		cout << "...";
}

Measured memory_bytes: 3604
import itertools

from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
	return [int(s) for s in fetch_one_line().split()]
  
N = int(fetch_one_line())
P = fetch_int_input()
Q = fetch_int_input()

# l = ['a', 'b', 'c', 'd']
l = [i + 1 for i in range(N)]
n_list = itertools.permutations(l, len(l))

t_p = tuple(P)
t_q = tuple(Q)


for idx, n in enumerate(n_list):
	if n == t_p:
		p_idx = idx
	if n == t_q:
		q_idx = idx
    
print(abs(p_idx -  q_idx))

Measured memory_bytes: 39024
import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
n,=I()
l=I()
f=cc.defaultdict(int)
for i in l:
    f[i]+=1
s=sum(l)
for i in range(int(input())):
    x,y=I()
    if f[x]==0:
        print(s)
    else:
        s-=f[x]*x
        s+=f[x]*y
        f[y]+=f[x]
        f[x]=0
        print(s)
        
    
    

Measured memory_bytes: 88804
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll memo[401][401];
int n;
ll a[401];
ll s[401];
ll solve(int l, int r){
	if(l==r) return 0;
	if(memo[l][r]) return memo[l][r];
	ll ans=1e18+7;
	for(int i=l+1; i<=r; i++){
		ans=min(ans, solve(l, i-1)+solve(i, r)+s[r]-s[l-1]);
	}
	return memo[l][r]=ans;
}
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>a[i];
		s[i]=s[i-1]+a[i];
	}
	cout<<solve(1, n)<<endl;
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;

	set <pair <pair <int,int>, int> > s;
	vector <int> v;
	rep(i,n)
	{
		int t;
		cin>>t;
		v.pb(t);
	}
	sort(all(v));
	// for (auto j:s) v.pb(j), debug1(j);
	int ans = 0;
	rep(i,sz(v))
	{
		// debug1(v[i]);
		REP(j,i+1,sz(v)-1)
		{
			int x = v[i]+v[j];
			int k = lower_bound(all(v),x)-v.begin()-1;
			// debug4(x,v[k],k,j);
			ans+=k-j;
		}
	}
	cout<<ans;
	
}


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

int main(){
	int n,m,l[100001]={},r[100001]={};
	int low,high;
	
	cin>>n>>m;
	low=1; 
	high=n;
	
	for (int i=1; i<=m; i++)
	{
		cin>>l[i]>>r[i];
	}
	for (int i=1; i<=m; i++)
	{			
		if (l[i] >= low)
		{	
			low = l[i];
	    }
		if (r[i] <= high)
		{				
			high = r[i];
	    }
	}
	if (high >= low)
	{
	 cout << (high - low + 1) << endl;		
	}
	else
	{
	 cout << 0 << endl;	
	}	 
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
using namespace std;
static const int MAX_N = 50;
int ps[MAX_N];

int main() {
    int n, p, tp, i;
    for (; ;) {
        scanf("%d %d", &n, &p);
        if (n == 0 && p == 0) break;
        fill(ps, ps+n, 0);
        i = 0, tp = p;
        for (; ; ) {
            if (tp > 0) {
                ps[i]++; tp--;
                if (ps[i] == p) break;
                i=(i+1)%n; continue;
            }
            else if (tp == 0) {
                tp = ps[i]; ps[i] = 0;
                i=(i+1)%n;
            }
        }
        printf("%d\n", i);
    }
    return 0;
}



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

//#define DEBUG

#ifdef DEBUG
using std::endl;
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#endif // DEBUG
#ifndef DEBUG
using namespace std;
#endif // DEBUG

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void yuttori(){
    unsigned int N, K, C;
    std::string S;
    cin >> N >> K >> C;
    cin >> S;
    std::vector<int> L, R;
    L.reserve(K); R.reserve(K);
    //fill L
    int count = 0;
    for(int i = 0 ; i < N ; i++){
        if(S[i] == 'o'){
            count++;
            L.push_back(i);
            i += C ;
            // problem says it will reach this point
            if(count == K) break;
        }
    }
    //print_vect(L);

    //fill R
    count = 0;
    for(int i = N - 1 ; i >= 0 ; i--){
        if(S[i] =='o'){
            count ++;
            R.push_back(i);
            i -= C;
            if( count == K) break;
        }
    }
    //print_vect(R);
    int i = 0;
    int j = K - 1;
    if( R[0] - L[K-1] > C){
        return;
    }
    while( i < K && j >=0 ){
        if( L[i] < R[j]){
            i++;
        }else if( L[i] == R[j]){
            cout << L[i] + 1 << endl;
            i++; j--;
        }else{
            j--;
        }
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 4;
    while(TEST_CASES--){
    #endif // DEBBUG

    yuttori();

    #ifdef DEBUG
    }
    #endif // DEBUG

    return 0;
}


Measured memory_bytes: 3348
/*ITS FUCKING O(N) now
GET ACCEPTED FOR FUCK'S SAKE*/
#define _USE_MATH_DEFINES
 
#include <cmath>

#include <iostream>
# include <bits/stdc++.h>
using namespace std;

long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=v.size()-1;i>=0;i--)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;

#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  
  
int main()
{
  int flag=0;
  ll sum=0;
  int flag1=1;
  ll tot=0;
  int ans=0;
  map<int,int>m;
  vi v;
  set<int>st;
  string s;
   scii(n,k);
   while(k--)
   {
    sci(d);
    rep(i,0,d-1)
    {
      int a;
      cin>>a;
      st.insert(a);
    }
   }
   cout<<n-st.size();
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

struct UF{
  int par[10001];
  int rank[10001];

  UF(int n){ init(n); }
  void init(int n){
    for(int i=0;i<n;i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  int same(int x,int y){
    return find(x) == find(y);
  }
};

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

  rep(i, q){
    int com, x, y;
    scanf("%d%d%d", &com, &x, &y);
    if(com){
      printf("%d\n", uf.same(x, y)?1:0);
    }else{
      uf.unite(x, y);
    }
  }
  
  return 0;
}

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

int main()
{
    int n;
    long long int k;
    cin >> n >> k;
    map<int, long long int> nums;
    for (int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        if (nums.find(a) == nums.end())
        {
            nums.insert(make_pair(a, b));
        }
        else
        {
            nums[a] += b;
        }
    }
    long long int sum = 0;
    int ans;
    map<int, long long int>::iterator it;
    for (it = nums.begin(); it != nums.end(); ++it)
    {
        //cout << "debug: " << it->first << " " << it->second << endl;
        if (k <= sum)
        {
            break;
        }
        sum += it->second;
        ans = it->first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *A=(int *)malloc(sizeof(int)*(N+1));
  int *B=(int *)malloc(sizeof(int)*N);
  rep(i,N+1){
    scanf("%d",&A[i]);
  }
  getchar();
  rep(i,N){
    scanf("%d",&B[i]);
  }

  long sum=0;
  rep(i,N){
    int temp=A[i]-B[i];
    if(temp<0){
      sum+=A[i];
      B[i]=B[i]-A[i];
      temp=A[i+1]-B[i];
      if(temp<0){
        sum+=A[i+1];
        A[i+1]=0;
      }
      else{
        sum+=B[i];
        A[i+1]=temp;
      }
    }
    else{
      sum+=B[i];
    }
  }

  printf("%ld\n", sum);

}


Measured memory_bytes: 896
#include<iostream>

int main(void){
    int n, ans;
    std::cin >> n;
    if(n % 1000 != 0) ans = 1000 * (n / 1000 + 1) - n;
    else ans = 1000 * n / 1000 - n;

    std::cout << ans << std::endl;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 998244353;
void compress(vector<int> &X) {
    vector<pair<int, int>> Y(X.size());
    for (int i = 0; i < X.size(); i++) {
        Y[i] = make_pair(X[i], i);
    }
    sort(begin(Y), end(Y));
    for (int i = 0; i < X.size(); i++) {
        X[Y[i].second] = i+1; // 1-indexed
    }
}
struct BIT {
    vector<int> A;
    int N;
    BIT(int n) : A(n+1), N(n) {}
    void add(int i, int x) {
        if (i > N) return;
        A[i] += x;
        add(i + (i & -i), x);
    }
    int sum(int i) {
        if (!i) return 0;
        return A[i] + sum(i - (i & -i));
    }
};
int main()
{
    int N; cin >> N;
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    compress(X);
    compress(Y);
    vector<int> I(N);
    iota(begin(I), end(I), 0);
    sort(begin(I), end(I), [&](int i, int j) { return X[i] < X[j]; });
    vector<int> A(N), B(N), C(N), D(N);
    auto bit = BIT(N);
    for (int i = 0; i < N; i++) {
        int j = I[i];
        A[j] = bit.sum(Y[j]);
        B[j] = i - A[j];
        bit.add(Y[j], 1);
    }
    bit = BIT(N);
    for (int i = 0; i < N; i++) {
        int j = I[N-1-i];
        C[j] = bit.sum(Y[j]);
        D[j] = i - C[j];
        bit.add(Y[j], 1);
    }
    vector<Int> POW2(N+1);
    POW2[0] = 1;
    for (int i = 1; i <= N; i++) POW2[i] = POW2[i-1] * 2 % MOD;
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        int a = A[i], b = B[i], c = C[i], d = D[i];
        ans += POW2[N] - 1 - (POW2[a+b] + POW2[b+d] + POW2[d+c] + POW2[c+a]
                              - POW2[a] - POW2[b] - POW2[c] - POW2[d]);
        ans += 1000 * MOD;
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

int a[3]={1,1,1};

 int gcd(int a,int b)

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

int main()
{
    int num=0;
    int n;
    cin>>n;
    while(1){
        int suam=gcd(a[1],a[2]);
        int jieguo=gcd(suam,a[0]);
        num=num+jieguo;
        if(a[2]==n&&a[1]==n&&a[0]==n){
            cout<<num;
            return 0;
        }
        else if(a[2]==n&&a[1]==n){
            a[0]=a[0]+1;
            a[1]=1;
            a[2]=1;
        }
        else if(a[2]==n){
            a[1]=a[1]+1;
            a[2]=1;
        }
        else {a[2]=a[2]+1;}


    }
    return 0;
}


Measured memory_bytes: 3632
n,k = map(int, input().split())
a = list(map(int, input().split()))
ans = 100000000 * n
for i in range(n - k + 1):
    l = i
    r = i + k - 1
    ans = min([ans, abs(a[l]) + abs(a[r] - a[l]), abs(a[r]) + abs(a[r] - a[l])])
print(ans)

Measured memory_bytes: 14384
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int D1,D2,count=0;
    for(int i = 0; i < N; ++i){
        cin >> D1 >> D2;
        if(D1 == D2){
            count++;
        }else{
            count = 0;
        }
        if(count == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $h = explode(" ", trim(fgets(STDIN)));

  $road = [];
  for($i=1;$i<=$n;$i++){
    $road[$i] = [];
  }

  for($i=0;$i<$m;$i++){
    list($a, $b) = explode(" ", trim(fgets(STDIN)));    
    $road[$a][] = $b;
    $road[$b][] = $a;
  }

  $ans = 0;
  for($i=1;$i<=$n;$i++){
    $hikaku_roads = $road[$i];
    $isGood = true;
    foreach($hikaku_roads as $hr){
//      echo $i." ".$h[$i-1]." ".$h[$hr-1].PHP_EOL;
      if($h[$i-1] <= $h[$hr-1]){
        $isGood = false;
        break;
      }
    }
    if($isGood){
      $ans++;
    }
  }

  echo $ans;

Measured memory_bytes: 64540
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

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 dpcombination[10000][10000];

ll modi = 1000000007;
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) % modi + combination(n - 1, r) % modi; }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)

void printVec(std::vector<int> &vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}


int main() {

	ll n, k;
	cin >> n >> k;
	vector<ll>h(n);
	ll summan = 0;
	for (int i = 0;i < n;i++) { 
		cin >> h[i];
		summan = summan + h[i];
	}
	sort(h.begin(), h.end());
	reverse(h.begin(), h.end());

	if (k >= n) {
		cout << 0 << endl;
		return 0;
	}
	for (int j = 0;j < k;j++) {
		summan = summan - h[j];
	}
	cout << summan << endl;

	return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;
int n;
vector<string> ans;

void dfs(string s,int d,int cnt){
    if(d == n){
        ans.push_back(s);
        return;
    }
    rep(i,cnt){
        dfs(s+char('a'+i),d+1,cnt);
    }
    dfs(s+char(cnt+'a'),d+1,cnt+1);
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    cin >> n;
    string s = "";
    dfs(s,0,0);   
    sort(ALL(ans));
    for(int i=0;i<ans.size();i++){
        if(i>0 && ans[i]==ans[i-1])continue;
        cout << ans[i] << endl;
    }
}

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

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            int answer = 0;
            //while (true)
            //{
                input = Console.ReadLine();
                for(int i = 0; i < input.Length;i++){
                    int numb = Int32.Parse(input[i].ToString());
                    if(numb == 1)
                    {
                        answer++;
                    }
                }
                Console.Write(answer + "\n");
                answer = 0;

            //}

        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
int main(void){
    int x,y,z;
    
    while(1){
        scanf("%d %d\n",&x,&y);
        if(x == 0 && y == 0){
            break;
        }
        if(x > y){
            z = x;
            x = y;
            y = z;
        }
        printf("%d %d\n",x,y);
    }
    
}

Measured memory_bytes: 1692
#include <iostream>
#include <map>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    ll N, P;
    cin >> N >> P;
    if(P == 1){
        cout << 1 << endl;
        return 0;
    }
    map<ll, ll> m;
    for(ll i = 2; i <= (ll)(sqrt(P) + 1); ++i){
        while(P % i == 0 && P > 1){
            P /= i;
            m[i]++;
        }
    }
    if(P != 1){
        m[P] = 1;
    }
    ll ans = 1;
    for(auto it = m.begin(); it != m.end(); ++it){
        ll A = it->first;
        ll B = it->second;
        if(B >= N){
            ll C = B / N;
            for(ll i = 0; i < C; ++i){
                ans *= A;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int N=to_string(b).size(),X=a;
  while(N>0){
    X*=10;
    N--;
  }
  X+=b;
  cout<<((X==int(sqrt(X))*int(sqrt(X)))?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<long long int>A(N);
  for(int i=0; i < N; i++)
    cin >> A[i];
  int state=0;
  int s = 0;
  int ans = 1;
  for(int i=1; i < N; i++){
    if(s == 0){
      if(A[i-1] > A[i]){
	state = 1;
	s = 1;
      }
      if(A[i-1] < A[i]){
	state = 2;
	s = 1;
      }
    }else{
      if(state == 1){
	if(A[i-1] < A[i]){
	  s = 0;
	  ans++;
	}
      }
      if(state == 2){
	if(A[i-1] > A[i]){
	  s = 0;
	  ans++;
	}
      }
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int p=1000000007;
int main()
{
  int n,a,t,i,j;
  int h[3];
  long long res=1;
  fill(h,h+3,0);
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    t=0;
    for(j=0;j<3;j++)
      if(h[j]==a)
        t++;
    if(t==0){
      cout << "0" << endl;
      return 0;
    }
    res*=t;
    res%=p;
    for(j=0;j<3;j++)
      if(h[j]==a){
        h[j]++;
        break;
      }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

ll power(ll a, int b) {
  if(!b) return 1;
  ll c = power(a, b/2);
  if(b%2) return c*c%INF*a%INF;
  return c*c%INF;
}

int main() {
  int r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  vl fac(r2+c2+2,1);
  rep(i,r2+c2+1) fac[i+1]=fac[i]*(i+1)%INF;
  vl facinv(c2-c1+1);
  rep(j,c2-c1+1) facinv[j]=power(fac[j+c1+1],INF-2);
  ll R1=power(fac[r1-1],INF-2),R2=power(fac[r2],INF-2);
  
  ll ans=0;
  rep2(j,c1,c2+1) {
    ans+=fac[r2+j+1]*facinv[j-c1]%INF*R2%INF-fac[r1+j]*facinv[j-c1]%INF*R1%INF;
    ans=(ans+INF)%INF;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 26640
x = sorted(list(map(int, input().split())))
count = 0
while(x[0] != x[2]):
    if(x[1] != x[2]):
        x[0] += 1
        x[1] += 1
    else:
        x[0] += 2
    count += 1
    x = sorted(x)
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define int long long 
#define test int qt;cin>>qt;while (qt--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
int mod = 1e9 + 7;

int32_t main()
{
    IOS;
	int n;cin>>n;
	FOR(n)
		cout<<"ACL";
    return 0;
}

Measured memory_bytes: 3520
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int c = b;
    int count = 0;
    while (b) {
        count++;
        b /= 10;
    }
    for (int i = 0; i < count; i++) {
        a *= 10;
    }
    c += a;
    for (int i = 1; i * i <= c; i++) {
        if (c % i == 0 && c / i == i) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(k):
	q = [1,2,3,4,5,6,7,8,9]
	last = 0
	i = 0
	while(k > 0):
		last = q[i]
		rem = last%10
		lower = 0
		bigger = 0
		if(rem != 0):
			lower = 10*last + rem - 1
		if(rem != 9):
			bigger = 10*last + rem + 1
		equal = 10*last + rem
		# print('last:',last,rem,'::',lower,equal,bigger)
		if(lower):
			q.append(lower)
		q.append(equal)
		if(bigger):
			# print(rem)
			q.append(bigger)
		i += 1
		k -= 1
	# print(len(q),len(set(q)))
	return last
	

K = int(stdin.readline())
ans = solve(K)
print(ans)


Measured memory_bytes: 59632
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Main().main();
    }

    public void main() {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        for (int i = 0; i < n; i++) {
            int[] row = new int[n];

            String[] line = scanner.nextLine().split(" ", -1);
            for (int j = 0; j < Integer.parseInt(line[1]); j++) {
                row[Integer.parseInt(line[2 + j]) - 1] = 1;
            }

            for (int j = 0; j < n; j++) {
                System.out.print(row[j]);
                System.out.print((j == n - 1) ? "\n" : " ");
            }
        }
    }
}



Measured memory_bytes: 34236
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 2005;
const int mod = 1e9 + 7;

int n;
long long k;
int arr[N];

int main()
{
  cin >> n >> k;
  long long v = k * (k - 1) / 2;
  v %= mod;
  long long ans = 0;
  for(int i = 0 ; i < n ; i++)
    cin >> arr[i];
  for(int i = 0 ; i < n ; i++){
    int p = 0;
    for(int j = 0 ; j < i ; j++)
      p += arr[j] > arr[i];
    int r = 0;
    for(int j = 0 ; j < n ; j++)
      r += arr[j] > arr[i];
    long long cur = p * k + r * v;
    cur %= mod;
    ans = (ans + cur) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,T=map(int,input().split())
    AB=[tuple(map(int,input().split())) for _ in range(n)]
    ans=-INF

    # 何も考えずやる
    dp=[0]*T
    for i in range(n):
        a,b=AB[i]
        ndp=dp[:]
        for t in range(T):
            if(t+a<T):
                ndp[t+a]=max(ndp[t+a],dp[t]+b)
            else:
                ans=max(ans,dp[t]+b)
        dp=ndp
    ans=max(ans,max(dp))

    # 時間が最もかかるもののうち、価値が最大のものを最後にする
    AB.sort()
    la,lb=AB[-1]

    dp=[0]*T
    for i in range(n-1):
        a,b=AB[i]
        ndp=dp[:]
        for t in range(T):
            if(t+a<T):
                ndp[t+a]=max(ndp[t+a],dp[t]+b)
            else:
                ans=max(ans,dp[t]+b)
        dp=ndp
    ans=max(ans,max(dp)+lb)

    # 価値が最大のもののうち、時間が最もかかるものを最後にする
    AB.sort(lambda x:(x[1],x[0]))
    la,lb=AB[-1]

    dp=[0]*T
    for i in range(n-1):
        a,b=AB[i]
        ndp=dp[:]
        for t in range(T):
            if(t+a<T):
                ndp[t+a]=max(ndp[t+a],dp[t]+b)
            else:
                ans=max(ans,dp[t]+b)
        dp=ndp
    ans=max(ans,max(dp)+lb)

    print(ans)
resolve()

Measured memory_bytes: 47580
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

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

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long LL;

const LL N=LL(5e5+5);

struct data {
    LL t1, t2;
    bool operator < (const data &T) const {
        return t2<T.t2;
    }
} A[N];
priority_queue <LL> Q;
LL n, ans, cur;

int main() {
    while(scanf("%lld", &n)!=EOF) {
        for(LL i=0; i<n; i++) scanf("%lld%lld", &A[i].t1, &A[i].t2);
        sort(A, A+n);
        while(!Q.empty()) Q.pop();
        cur=ans=0;
        for(LL i=0; i<n; i++) {
            if(A[i].t1+cur<=A[i].t2) ans++, Q.push(A[i].t1), cur+=A[i].t1;
            else {
                if(Q.empty()) continue;
                LL val=Q.top();
                if(val<=A[i].t1) continue;
                cur-=val-A[i].t1;
                Q.pop();
                Q.push(A[i].t1);
            }
        }
        printf(ans==n?"Yes":"No");
    }
    return 0;
}

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

using namespace std;

const double pi = acos(-1.0);

class fenwick {
 public:
  int n;
  vector<int> f;

  fenwick(int _n) : n(_n) {
    f.resize(n);
  }

  void add(int x, int y) {
    for (int i = x; i < n; i = i | (i + 1)) {
      f[i] = max(f[i], y);
    }
  }

  int get(int x) {
    int ret = 0;
    for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {
      ret = max(ret, f[i]);
    }
    return ret;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  vector<pair<int, int>> ps;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (min(x1, x2) <= x && x <= max(x1, x2) && min(y1, y2) <= y && y <= max(y1, y2)) {
      ps.emplace_back(x, y);
    }
  }
  sort(ps.begin(), ps.end());
  map<int, int> map_y;
  for (auto& p : ps) {
    map_y[p.second];
  }
  int size_y = 0;
  for (auto& it : map_y) {
    it.second = size_y++;
  }
  if (x1 > x2) {
    swap(x1, x2);
    swap(y1, y2);
  }
  fenwick f((int) ps.size());
  if (y1 > y2) {
    reverse(ps.begin(), ps.end());
  }
  for (auto& p : ps) {
    p.second = map_y[p.second];
  }
  int use = 0;
  for (int i = 0; i < (int) ps.size(); i++) {
    int y = ps[i].second;
    int g = f.get(y);
    f.add(y, g + 1);
    use = max(use, g + 1);
  }     
  int half_turn = 0;
  if (min(abs(x1 - x2), abs(y1 - y2)) + 1 == use) {
    half_turn = 1;  
  }
  double ans = abs(x1 - x2) * 100LL + abs(y1 - y2) * 100LL - 20 * use + pi * 20 * (use - half_turn) / 4 + pi * 20 * half_turn / 2;
  cout << setprecision(10) << fixed << ans << '\n';   
  return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
  string s;
  int ans=0;
  cin >>s;
  char last=s[0];
  int len=0;
  rep(i,s.size()){
    if(last!=s[i]){
      ans++;
    }
    last=s[i];
  }
  cout<<ans<<endl;
}

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

/*IndexOfメソッドを使うことで、配列やコレクション内の要素を検索することができます。
検索する値と一致する要素が見つかれば、はじめに見つかったインデックス番号を返します。
見つからなければ、 -1 を返します。
IndexOfメソッドは、配列の場合は、スタティックメソッド（Array.IndexOfメソッド）です。
コレクションでは、ArrayList（ArrayList.IndexOfメソッド）や
List（List<T>.IndexOfメソッド）で使用でき、こちらはインスタンスメソッドです。
*/

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        

//       Scanner sc = new Scanner(System.in);
//       int n = sc.nextInt();//　n個ある

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(reader.readLine());
        
        int j;
        String[] mycards = new String[2];//入れる箱
        int num = 0;//トランプの番号
        
        ArrayList<Integer> S = new ArrayList<Integer>();//不揃いカードスペード用
        ArrayList<Integer> H = new ArrayList<Integer>();//不揃いカードハート用
        ArrayList<Integer> C = new ArrayList<Integer>();//不揃いカードクローバー用
        ArrayList<Integer> D = new ArrayList<Integer>();//不揃いカードダイヤ用
       
        for(int i = 0; i < n; i++){
            
            mycards = reader.readLine().split(" ");
            num =  Integer.parseInt(mycards[1]);
            
            if("S".equals(mycards[0])){
                S.add(num);
//                System.out.println(mycards[1]);
                
            }else if("H".equals(mycards[0])){
                H.add(num);
//                System.out.println(mycards[1]); 
            }else if("C".equals(mycards[0])){
                C.add(num);
            }else if("D".equals(mycards[0])){
                D.add(num);
            }
        }
            for( j = 1; j <= 13; j++){
                if( S.indexOf(j) == -1){
                    System.out.println("S " + j);
                }
                
            }
            for( j = 1; j <= 13; j++){
                if( H.indexOf(j) == -1){
                    System.out.println("H " + j);
                }
            }
            for( j = 1; j <= 13; j++){
                if( C.indexOf(j) == -1){
                    System.out.println("C " + j);
                }
            }
            for( j = 1; j <= 13; j++){
                if( D.indexOf(j) == -1){
                    System.out.println("D " + j);
                }
            }
    }
}




Measured memory_bytes: 24484
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	unsigned long ans = 0;
	int i, j, k;
	cin >> n;
	unsigned long *l = new unsigned long[n];
	for (i = 0; i < n; i++) {
		cin >> l[i];
	}

	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			for (k = j + 1; k < n; k++) {
				if (l[i] < l[j] + l[k]) {
					if (l[j] < l[i] + l[k]) {
						if (l[k] < l[i] + l[j]) {
							if (l[i] != l[j] && l[j] != l[k] && l[i]!=l[k]) {
								ans++;
//								cout << i << " / " << j << " / " << k << endl;
							}
						}
					}
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

const int INF = 1000000000;

int root[101];
int getRoot(int v){ return ~root[v] ? root[v] = getRoot(root[v]) : v; }

int main(){
	int n, m;
	while(cin >> n >> m, n){
		int a, b, w;
		vector< pair<int, pair<int, int> > > vp;
		for(int i=0;i<m;i++){
			cin >> a >> b >> w;
			vp.push_back(make_pair(w, make_pair(a, b)));
		}
		sort(vp.begin(), vp.end());
		int start = 0, res = INF;
		while(start < m){
			int cnt = 0, curw = vp[start].first;
			memset(root, -1, sizeof(root));
			for(int i=start;i<m;i++){
				int p = getRoot(vp[i].second.first );
				int q = getRoot(vp[i].second.second);
				if(vp[i].first == curw) start = i+1;
				if(p!=q){
					root[q] = p;
					cnt++;
					if(cnt == n-1){
						res = min(res, vp[i].first-curw);
						break;
					}
				}
			}
			if(cnt != n-1) break;
		}
		printf("%d\n", res < INF ? res : -1);
	}
}

Measured memory_bytes: 1076
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int a,b,c,d,e;
  while(scanf("%d,%d,%d,%d,%d",&a,&b,&c,&d,&e)!=EOF){
    vi v(14,0);
    v[a]++;
    v[b]++;
    v[c]++;
    v[d]++;
    v[e]++;

    bool ans=false;
    if(v[1]&&v[10]&&v[11]&&v[12]&&v[13]){
      cout<<"straight"<<endl;
      ans=true;
    }
    rep(i,10)
      if(v[i]&&v[i+1]&&v[i+2]&&v[i+3]&&v[i+4]){
	cout<<"straight"<<endl;
	ans=true;
      }
    if(ans)continue;

    int na=0,nb=0,nc=0;
    rep(i,14)
      if(v[i]==2)na++;
      else if(v[i]==3)nb++;
      else if(v[i]==4)nc++;

    if(nc)cout<<"four card"<<endl;
    else if(na&&nb)cout<<"full house"<<endl;
    else if(nb)cout<<"three card"<<endl;
    else if(na==2)cout<<"two pair"<<endl;
    else if(na)cout<<"one pair"<<endl;
    else cout<<"null"<<endl;
  END:;
  }
}

Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 10005

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

ll dp[105][15][1005];

ll dfs(ll rest, ll n, ll s) {

	
	if (rest < 0)
	{
		if (n == 0 && s == 0)
		{
			return 1LL;
		}
		else
		{
			return 0LL;
		}
	}
	
	if (n < 0 || s < 0)
	{
		return 0;
	}

	if (dp[rest][n][s] != -1)
	{
		return dp[rest][n][s];
	}

	ll cnt = 0;
	cnt += dfs(rest - 1, n, s);//restを選ばない
	cnt += dfs(rest - 1, n - 1, s - rest);//restを選ぶ

	return dp[rest][n][s] = cnt;
}

int main() {

	ll n, s;
	while (cin >> n >> s, n | s)
	{
		for (int i = 0; i < 105; i++)
		{
			for (int j = 0; j < 15; j++)
			{
				for (int k = 0; k < 1005; k++)
				{
					dp[i][j][k] = -1;
				}
			}
		}
		cout << dfs(100LL, n, s) << endl;
	}


	return 0;
}


Measured memory_bytes: 15452
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
ll a[1010][3];
vector<ll> v;
ll res=-lSHN;
int main()
{
	cin >>n>>m; 
	for (int i=0;i<n;i++)
	    cin >>a[i][0]>>a[i][1]>>a[i][2];
	for (int i=0;i<8;i++)
	{
		v.clear();
		for (int j=0;j<n;j++)
		{
			ll r=0;
			for (int k=0;k<3;k++)
			{
				if (i & (1<<k)) r+=a[j][k];
				else r-=a[j][k];
			}
			v.push_back(r);
		}
		sort(v.begin(),v.end());
		ll r=0;
		for (int j=0;j<m;j++) r+=v[n-j-1];
		//cout <<r<<" "<<res<<" ##\n";
		res=max(res,r);
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  string S, T;
  int A = 0;
  cin >> S;
  cin >> T;
  if (S[0] == T[0]) {
   A++; 
  }
  if (S[1] == T[1]) {
   A++; 
  }
  if (S[2] == T[2]) {
   A++; 
  }
  cout << A;
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    
    for(int i=0; i<n; i++){
        int v = a[i];
        int j = i-1;
        while(j>=0 && a[j]>v){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        
        rep(i,n){
            if(i) printf(" ");
            printf("%d",a[i]);
        }
        printf("\n");
    }
    
    return 0;
}




Measured memory_bytes: 3208
n = int(input())
h = list(map(int, input().split()))
ans = 0
m = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        m += 1
        ans = max(ans, m)
    else:
        ans = max(ans, m)
        m = 0
print(ans)

Measured memory_bytes: 20512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<string> vec;

int main(){
  string s; cin>>s;
  cout<<(s[0]=='7'||s[1]=='7'||s[2]=='7'?"Yes":"No");

}

Measured memory_bytes: 3620
D, G = map(int, input().split())
PC = [list(map(int, input().split())) for _ in range(D)]

ans = 10 ** 4

for bits in range(2 ** D + 1):
    num, score = 0, 0
    # ここはただBitが立ってる箇所の完全に解き切ることをしているだけ
    for i in range(D):
        if (0x01 << i) & bits:
            score += PC[i][0] * (i + 1) * 100 + PC[i][1]
            num += PC[i][0]

    i = D - 1
    pnum = 0
    #while score < G and i >= 0:
    #     # bitが立っていない、つまり完全に解き切っていない問題の時
    #     if not (0x01 << i) & bits:
    #         score += (i + 1) * 100
    #         num += 1
    #         pnum += 1
    #         # これである点数の
    #         if pnum >= PC[i][0]:
    #             pnum = 0
    #             i -= 1
    #     else:
    #         i -= 1
    while score < G and i >= 0:
        # bitが立っていない、つまり完全に解き切っていない問題の時
        if not (0x01 << i) & bits:
            for t in range(PC[i][0]):
                # これである点数の
                if score < G:
                    score += (i + 1) * 100
                    num += 1
            break
        else:
            i -= 1


    if score >= G:
        ans = min(ans, num)

print(ans)

Measured memory_bytes: 3192
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)

ans = 1
if a[-1] == 0:
  ans = 0
else:
  for i in range(n):
    ans *= a[i]
    if ans > 10**18:
      ans = -1
      break
    elif a[i] == 1:
      break
      
print(ans)

Measured memory_bytes: 21784
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int x, y;
	cin >> x >> y;
	cout << 6 - x - y  << '\n';
	return 0;
}


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

int main()
{
  int n, j;
  int X, Y, W, H;
  int i, x, y;
  int cat;
  int ans = 0;

  cin >> n;
  for(j = 0; j < n; j++){

    cin >> X >> Y >> W >> H;
    cin >> cat;
    
    ans = 0;
    for (i = 0; i < cat ; i++){
      cin >> x >> y;
      if (X <= x && x <= W+X){
	if (Y <= y && y <= H+Y){
	  ans++;
	}
      }
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 1160
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
vs in;
int n;
bool f(){
	bool h=true;
	rep(i,n)rep(j,n)if(in[i][j]!=in[j][i])h=false;
	return h;
}
int main(){
	cin>>n;
	in=vs(n);
	rep(i,n)cin>>in[i];
	int out=0;
	rep(i,n){
		if(f())out+=n;
		in.pb(in[0]);
		in.erase(in.begin());
	}
	cout<<out<<endl;
}









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


int main() {
  int N;
  cin >> N;
  vector<double> V(N);
  for(int i=0; i<N; i++){
    cin >> V.at(i);
  }
  sort(V.begin(), V.end());
  double ans;
  ans = (V.at(0) + V.at(1)) / 2;
  if(N > 2){
    for(int i=2; i<N; i++){
      ans = (ans + V.at(i)) / 2;
    }
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256