akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  invar(string, S); invar(string, T);
  
  rep(i, N) {
    cout << S[i] << T[i];
  }
  cout << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int p, q;
        if(!(cin >> p >> q))
            return 0;

        bool repeat = true;
        int i = 0;
        map<int, int> rest;
        rest.insert(make_pair(p, 0));
        for(;;){
            p *= 10;
            int a = p / q;
            cout << a;
            p %= q;
            if(p == 0){
                repeat = false;
                break;
            }
            if(rest.find(p) != rest.end())
                break;
            ++ i;
            rest.insert(make_pair(p, i));
        }

        cout << endl;
        if(repeat){
            int x = rest.find(p)->second;
            cout << string(x, ' ') << string(i-x+1, '^') << endl;
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 100000000000;

signed main() {
  int N;
  cin >> N;
  vector<int> num(3);
  cin >> num[0] >> num[1] >> num[2];
  
  vector<string> S(N);
  for( int i = 0; i < N; i++ ) cin >> S.at(i);
  
  string abc = "ABC";
  
  
  vector<char> ans;
  for( int i = 0; i < N; i++ ){
    
    int X, Y;
    for( int j = 0; j < 3; j++ ){
      if( S.at(i).at(0) == abc.at(j) ) X = j;
      else if( S.at(i).at(1) == abc.at(j) ) Y = j;
    }
    
    //どちらも0だったら
    if( num[X] == 0 && num[Y] == 0 ){ 
      cout << "No" << endl;
      return 0;
    //片一方だけ0だったら
    }else if( num[X] == 0 ){
      num[Y]--;
      num[X]++;
      ans.push_back(abc.at(X));
    }else if( num[Y] == 0 ){
      num[X]--;
      num[Y]++;
      ans.push_back(abc.at(Y));
    //どちらも1だったら
    }else if( num[X] == 1 && num[Y] == 1 ){
      if( i == N-1 ){
        ans.push_back(abc.at(X));
        continue;
      }
      int NX, NY;
      for( int j = 0; j < 3; j++ ){
        if( S.at(i+1).at(0) == abc.at(j) ) NX = j;
        else if( S.at(i+1).at(1) == abc.at(j) ) NY = j;
      }
      if( X == NX || X == NY ){
        num[Y]--;
        num[X]++;
        ans.push_back(abc.at(X));
      }else{
        num[X]--;
        num[Y]++;
        ans.push_back(abc.at(Y));
      }
    }else{
      if( num[X] > num[Y] ){
        num[X]--;
        num[Y]++;
        ans.push_back(abc.at(Y));
      }else{
        num[Y]--;
        num[X]++;
        ans.push_back(abc.at(X));
      }
    }
  }
  
  cout << "Yes" << endl;
  for( int i = 0; i < N; i++ ) cout << ans.at(i) << endl;
  
}


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

int main()
{
	int x;
	int p = 0;
	cin >> x;
	
	while (x > 499)
	{
		x -= 500;
		p += 1000;
	}

	while (x > 4)
	{
		x -= 5;
		p += 5;
	}
	printf("%d\n", p);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int v[13];
bool check(int a){
  string s = to_string(a);
  bool r = true;
  rep(i,s.size()){
    if(v[s[i] - '0'] == 1)r = false;
  }
  return r;
}
int main(){
  int n,k;
  cin >> n >> k;
  int tmp;
  rep(i,k){
    cin >> tmp;
    v[tmp] = 1;
  }
  while(1){
    if(check(n)){
      cout << n << endl;
      return 0;
    }
    n++;
  }
  return 0;
}

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


int main() {
    const long mod = 1000000007L;
    ll n;
    cin >> n;
    ll s = 1, t = 1, u = 1;
    rep(i, n) {
        s *= 10;
        s %= mod;
    }
    rep(i, n) {
        t *= 9;
        t %= mod;
    }
    t *= 2;
    t %= mod;
    rep(i, n) {
        u *= 8;
        u %= mod;
    }
    ll ans;
    ans = s - t;
    if (ans < 0) ans += mod;
    ans %= mod;
    ans += u;
    ans %= mod;

    cout << ans << endl; 

    return 0;    
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

string s;
ll N, K;

int main() {
    cin >> N;
    int cnt = 0;
    while (N > 1) {
        N /= 2;
        cnt++;
    }
    ll k = pow(2, cnt+1)-1;
    cout << k << endl;
    return 0;
}


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

int main() {
	long long N, ANS = 0;
	map<string, long long> mp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string T;
		cin >> T;
		sort(T.begin(), T.end());
		mp[T]++;
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ANS += (it->second - 1) * (it->second) / 2;
	}
	cout << ANS << endl;
}

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

int direction_x[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int direction_y[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int h,w;
IslandsMap islands_map;
CheckMap check_map;

void dfs(int x, int y) {
    int dx, dy;
    check_map[y][x] = true;
    rep(i, 8) {
        dx = x + direction_x[i];
        dy = y + direction_y[i];
        if(dx >= 0 && dx < w && dy >= 0 && dy < h &&
           check_map[dy][dx] == false && islands_map[dy][dx] == 1) {
            dfs(dx, dy);
        }
    }
}

int countIslands() {
    int ans = 0;
    rep(y, h) {
        rep(x, w) {
            if(check_map[y][x] == false && islands_map[y][x] == 1) {
                dfs(x, y);
                ans++;
            }
        }
    }
    return ans;
}

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int c;
    while(true) {
        cin >> w >> h;
        if(w == 0 && h == 0)
            break;

        islands_map.resize(h);
        rep(i, h) {
            islands_map[i].resize(w);
            rep(j, w) {
                cin >> c;
                islands_map[i][j] = c;
            }
        }

        check_map.resize(h);
        rep(i, h) {
            check_map[i].resize(w);
            check_map[i].assign(w,false);
        }
        cout << countIslands() << endl;
    }
}


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

int main(){
     int x;

     cin >> x;

     if(x%7 == 4){
    	 cout << "mon" << endl;
     }
     if(x%7 == 5){
    	 cout << "tue" <<endl;
     }
     if(x%7 == 6){
    	 cout << "wed"<<endl;
     }
     if(x%7 == 0){
    	 cout << "thu"<<endl;
     }
     if(x%7 == 1){
    	 cout <<"fri"<<endl;
     }
     if(x%7 == 2){
    	 cout <<"sat"<<endl;
     }
     if(x%7 == 3){
    	 cout <<"sun"<<endl;
     }

     return 0;

}


Measured memory_bytes: 3112
#!/usr/bin/perl
use POSIX qw(floor);

my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @A = map { $_ - 0 } split(/\s+/,<STDIN>);

if( $n == 1 ){
  print "1\n";
  exit(0);
}

my %ka = ();
for(my $i=0;$i<$n;$i++){
  $ka{$A[$i]} ++;
}

my @f = ();
$#f = 1000000;

if( $ka{'1'} > 1 ){
  print "0\n";
  exit(0);
}
if( $ka{'1'} == 1 ){
  print "1\n";
  exit(0);
}

my @ka1 = sort { $a <=> $b } map { $_ - 0 } keys %ka;

my $tot = $n;
for(my $i=0;$i<=$#ka1;$i++){
  my $ka2 = $ka1[$i] - 0;
  if( $f[$ka2] ){
    $tot -= $ka{$ka2};
    next;
  }
  if( $ka{$ka2} > 1 ){
    $tot -= $ka{$ka2};
  }
  my $j = 2;
  while( $ka2 * $j <= 1000000 ){
    $f[$ka2 * $j] = 1;
    $j++;
  }
}
print "$tot\n";

exit(0);


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

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
int main() {
  int x;
  cin>>x;
  cout<<360 / gcd(360, x)<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;

int main() {
  cin >> N;

  for (int i = 1; i < 10; ++i)
    for (int j = 1; j < 10; ++j) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string N,M;
    
    rep(i, 4){
        string inp;
        cin >> inp;
        N+=inp;
    }
    M = "1794";

    sort(all(N));
    sort(all(M));
    if(N==M) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    
    //cout << fixed << setprecision(16) << 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 n = sc.nextInt();
		int w = sc.nextInt();
		int[] wei = new int[n + 10];
		long[] val = new long[n + 10];
	    long[][] dp = new long[n + 10][w + 10];
		for(int i = 0 ; i < n ; i++) {
			wei[i] = sc.nextInt();
			val[i] = sc.nextLong();
		}
		for(int i = 0 ; i < n ; i++) {
			for(int sum_wei = 0 ; sum_wei <= w ; sum_wei++) {
				if(sum_wei - wei[i] >= 0) {
					dp[i + 1][sum_wei] = Math.max(dp[i + 1][sum_wei] , dp[i][sum_wei - wei[i]]) + val[i];  //選ぶ
				}
					dp[i + 1][sum_wei] = Math.max(dp[i + 1][sum_wei],dp[i][sum_wei]); //選んだ時 vs 選ばなかったとき
			}
		}

		sc.close();
		System.out.println(dp[n][w]);

	}

}



Measured memory_bytes: 141084
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <deque>
#include <bitset>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i) = 0; (i) <= (n); (i)++)
using namespace std;

int R, C, N;

using P = pair<int, int>;

int GetLen(int x, int y)
{
	if (y == 0)
	{
		return x;
	}
	else if (x == R)
	{
		return R + y;
	}
	else if (y == C)
	{
		return R + C + (R - x);
	}
	else if (x == 0)
	{
		return R + C + R + (C - y);
	}

	return -1;
}

signed main()
{
	cin >> R >> C >> N;

	priority_queue<P> q;

	REP(i, N)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;

		if ((x1 == 0 || x1 == R || y1 == 0 || y1 == C) && (x2 == 0 || x2 == R || y2 == 0 || y2 == C))
		{
			int l1 = GetLen(x1, y1);
			int l2 = GetLen(x2, y2);
			q.push(P(l1, i));
			q.push(P(l2, i));
		}
	}

	stack<int> s;

	while (q.size() > 0)
	{
		P p = q.top();
		q.pop();

		if (s.empty() || s.top() != p.second)
		{
			s.push(p.second);
		}
		else
		{
			s.pop();
		}
	}

	if (s.empty())
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 6256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    ArrayList<Integer> X,Y;

    private void solve() {
        N = nextInt();
        X = new ArrayList<>();
        Y = new ArrayList<>();
        for(int i = 0;i < N;i++) {
            int x = nextInt();
            X.add(x);
            Y.add(x);
        }

        Collections.sort(X);
        Collections.reverse(X);

        int index = N / 2 - 1;
        for(int i = 0;i < N;i++) {
            int search = Collections.binarySearch(X,Y.get(i),Collections.reverseOrder());
            if (search < index) {
                out.println(X.get(index+1));
            } else if(search > index) {
                out.println(X.get(index));
            } else {
                out.println(X.get(index+1));
            }
        }
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 53636
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%MMM)if(y&1)z=1ll*z*x%MMM;return z;}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
ll int dp[205][200002];
int main()
{
	faltu;
	ll int n,ww;
	cin>>n>>ww;
	ll int val[n+1],we[n+1];
	for(ll int i=0;i<n;i++)
	{
		cin>>we[i]>>val[i];
	}
	for(ll int i=0;i<=n;i++)
	{
		for(ll int w=0;w<=ww;w++)
		{
			if(i==0||w==0)dp[i][w]=0;
			else if(we[i-1]<=w)
			{
				dp[i][w]=max(val[i-1]+dp[i-1][w-we[i-1]],dp[i-1][w]);
			}
			else dp[i][w]=dp[i-1][w];
		}
	}
	cout<<dp[n][ww];
}








Measured memory_bytes: 157184
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import bisect
#####################################
n=int(input())
A=INPUT()
A.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        ans+=bisect.bisect_left(A,A[i]+A[j],0,n)-1-j
print(ans)


Measured memory_bytes: 74384
fn rec(s: &Vec<usize>, a: usize, b: usize, i: usize) -> usize {
    if i == s.len() {
        return a + b;
    }
    rec(s, a, b * 10, i + 1) + rec(s, a + b, s[i], i + 1)
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let s: Vec<usize> = buf
        .trim()
        .chars()
        .map(|x| x.to_digit(10).unwrap() as usize)
        .collect();
    println!("{}", rec(&s, 0, 0, 0));
}


Measured memory_bytes: 4352
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
C = Counter(A)
D=dict()
sum_D =0
for key,val in C.items():
    r = val*(val-1)//2
    D[key] =r
    sum_D+=r

for a in A:
    cnt = C[a]
    gain= (cnt-1)*(cnt-2)//2
    less = D[a]
    print(sum_D - less + gain)


Measured memory_bytes: 96204
n=int(input())
c=input()
w=0
for i in range(n):
    if c[i]=="W":
        w+=1
w1=0
t=100
s=0
for i in range(n+1):
    r=n-i-(w-w1)
    if abs(w1-r)==1 and t!=0:
        t=1
        s=w1
    if w1==r:
        t=0
        s=w1
    if i!=n:
        if c[i]=="W":
            w1+=1
print(s+t)

Measured memory_bytes: 68028
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h> // sqrt
using namespace std;

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

Measured memory_bytes: 640
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        string n=System.Console.ReadLine();
        if(n.IndexOf('a')>=0 && n.IndexOf('b')>=0 && n.IndexOf('c')>=0)
            System.Console.WriteLine("Yes");
        else System.Console.WriteLine("No");
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        String cards = scn.next();

        while(!cards.equals("-")){
            int m = scn.nextInt();
            for(int i=0;i<m;i++){
                int h = scn.nextInt();
                String top = cards.substring(0,h);
                String bottom = cards.substring(h,cards.length());
                cards = bottom + top;
            }
            System.out.println(cards);
            cards = scn.next();
        }



    }

}


Measured memory_bytes: 26468
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int, D: int):
    while True:
        C -= B
        if C <= 0:
            return YES
        A -= D
        if A <= 0:
            return NO
    raise


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    print(solve(A, B, C, D))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
import java.io.*;

class Main {
	public static void main(String[] args){
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			
			while(true){
			String[] line = br.readLine().split(" ");
			int H = Integer.parseInt(line[0]);
			int W = Integer.parseInt(line[1]);
			
			if ( H == 0 && W == 0) break;
			for(int a = 1;a <= H;a++){
				for(int b = 1; b <= W;b++){
					if( a % 2 == 1){
						if(  b % 2 == 1) { 
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					} else {
						if( b % 2 == 1){
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
			}
		} catch(Exception e){
		}
	}
}
					

Measured memory_bytes: 35624
import java.io.BufferedReader
import java.util.*
import kotlin.math.max

fun main() = agc024b()

@OptIn(ExperimentalStdlibApi::class)
fun agc024b() = SimpleFastIOWithToken_agc024b().exec {
    val n = readInt()
    val pList = List(n) { readInt() - 1 }

    val valueToIndex = pList.withIndex().sortedBy { it.value }.map { it.index }.toIntArray()
    var maxRaiseStreak = 0
    var left = 0
    
    while (left in valueToIndex.indices){
        var right = left
        while (right+1 in valueToIndex.indices &&valueToIndex[right]< valueToIndex[right+1])right++
        maxRaiseStreak= max(maxRaiseStreak,right-left+1)
        left=right+1
    }
    
    val answer = n - maxRaiseStreak

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_agc024b(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readStringList(size: Int): List<String> = List(size) { readString() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readIntList(size: Int): List<Int> = List(size) { readInt() }
    fun readLong(): Long = java.lang.Long.valueOf(readString())
    fun readLongList(size: Int): List<Long> = List(size) { readLong() }
    inline fun <reified T> readArray(size: Int, init: () -> T) = Array(size) { init() }
    inline fun <T> readList(size: Int, init: () -> T) = List(size) { init() }

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = print(any.toString() + separator)

    fun exec(action: SimpleFastIOWithToken_agc024b.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()
    }.run { kotlin.io.print(sb) }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 70424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<60;
const ll Mod=998244353;

int main(){
  int i,j;
  ll n;
  cin>>n;
  vector<ll> v(303030,0);
  for(i=0;i<n;i++){
      int a;
      cin>>a;
      a--;
      v[a]++;
  }
  sort(v.begin(),v.end(),greater<int>());
  ll sum=0;
  for(i=0;i<303030;i++)  sum+=v[i];

  vector<int> psum(303030);
  vector<int> s(303030);
  for(i=0;i<303030;i++){
      psum[i]=sum;
      if(v[i]==0) s[i]=inf;
      else s[i]=sum/v[i];
      sum-=v[i];
  }
  
  int st=0;
  for(i=1;i<=n;i++){
    while(i-st-1>0&&(double)psum[st]/(i-st)>=(double)psum[st+1]/(i-st-1)) st++;
    cout<<psum[st]/(i-st)<<endl;
  }
}

Measured memory_bytes: 5632
// Problem : D - Remainder Reminder
// Contest : AtCoder - AtCoder Beginner Contest 090
// URL : https://atcoder.jp/contests/abc090/tasks/arc091_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;

void solve(){
	int n,k; cin >> n >> k;
	if(k == 0){
		cout << (int)n * n << endl;
		return;
	}
	int ans = 0;
	for(int b = k+1; b <= n; b++){
		ans += (int)n / b * (b-k);
		ans += (int)max(0LL, (n % b) - k + 1);
	}
	cout << ans << endl;
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}

Measured memory_bytes: 3660
using System;

    class Program
    {
        static void Main()
        {
            int[] matrixSize = TypeConverter.arrayStrToInt(Console.ReadLine().Split(' '));

            int[] sumCol = new int[matrixSize[1]];
            string writeLine = "";
            for (int row = 0; row < matrixSize[0]; row++)
            {
                string line = Console.ReadLine();
                int[] num = TypeConverter.arrayStrToInt(line.Split(' '));
                sumCol = sumCol.add(num);

                writeLine += line + " " + num.sum().ToString() + "\n";
            }
            writeLine += string.Join(" ", TypeConverter.arrayIntToStr(sumCol)) + " " + sumCol.sum().ToString();

            Console.WriteLine(writeLine);
        }
    }

    static class Extensions_intArray
    {
        public static int[] add(this int[] array, int[] x)
        {
            for (int i = 0; i < array.Length; i++)
            {
                array[i] += x[i];
            }
            return array;
        }

        public static int sum(this int[] array)
        {
            int sum = 0;
            for (int i = 0; i < array.Length; i++)
            {
                sum += array[i];
            }
            return sum;
        }
    }

    class TypeConverter
    {
        static public int[] arrayStrToInt(string[] str)
        {
            return Array.ConvertAll<string, int>(str,
                delegate(string value)
                {
                    return int.Parse(value);
                }
            );
        }

        static public string[] arrayIntToStr(int[] x)
        {
            return Array.ConvertAll<int, string>(x,
                delegate(int value)
                {
                    return value.ToString();
                }
            );
        }
    }

Measured memory_bytes: 6376
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    if(b-1<=n) {
        cout << (a*(b-1ll)/b) << endl;
    }
    else{
        cout << (a*n/b-a*(n/b)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	nextReader = newScanner()

	a := nextInt()
	b := nextInt()
	fmt.Printf("%d %d\n", a*b, 2*a+2*b)
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}



Measured memory_bytes: 1076
p = 1000000007
N = int(input())
T = [[] for _ in range(N)]
for _ in range(N - 1):
  (a, b) = (int(x) - 1 for x in input().split())
  T[a].append(b)
  T[b].append(a)
P = [-1] * N
P[0] = 0
Q = [0]
for i in range(N):
  q = Q[i]
  for adj in T[q]:
    if 0 <= P[adj]:
      continue
    P[adj] = q
    Q.append(adj)
ST = [[] for _ in range(N)]
for q in Q[N - 1:0:-1]:
  s = sum(ST[q]) + 1
  ST[P[q]].append(s)
  ST[q].append(N - s)
B = [1] * N
B[-1] = pow(1 << (N - 1), p - 2, p)
for i in range(N - 1, 0, -1):
  B[i - 1] = B[i] * 2 % p
H = [0] * N
ans = 0
for S in ST:
  ans += B[1] * ((1 - B[-1] - sum([(B[N - 1 - s] * (1 - B[s])) % p for s in S])) % p)
  ans %= p
print(ans)

Measured memory_bytes: 130172
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ts <- replicateM n getInt
    print $ foldl' lcm 1 ts

Measured memory_bytes: 508
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m;
int ans;

int main() {
	cin >> n >> m;
	if(n % m == 0) ans = 0;
	else ans = 1;
	cout << ans << endl;
}

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

int w, h;
int dx[][6] = {
		{ 0, 0, 1, -1, -1, -1 },//y&1==0
		{ 1, 1, 1, 0, -1, 0 }//y&1==1
};
int dy[] = { -1, 1, 0, -1, 0, 1 };
int pos[102][102];

void dfs(int x, int y){
	pos[x][y] = 2;
	bool flag = false;
	rep(i, 6){
		int nx = x + dx[y & 1][i], ny = y + dy[i];
		if (0 <= nx&&nx <= w + 1 && 0 <= ny&&ny <= h + 1 && !pos[nx][ny])
			dfs(nx, ny);
	}
}
int main(){
	int cnt = 0;
	scanf("%d%d", &w, &h);
	rep(i, h)
		rep(j, w)
			scanf("%d", &pos[j + 1][i + 1]);
	dfs(0, 0);
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			if (pos[j][i] != 1)continue;
			rep(t, 6){
				if (pos[j + dx[i & 1][t]][i + dy[t]] == 2)cnt++;
			}
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{

    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> b(M);

    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
    }

    int res = 0;
    for (int i = 0; i < M; i++)
    {
        UnionFind bridges(N);
        for (int j = 0; j < M; j++)
        {
            if (j != i)
            {
                bridges.unite(a[j]-1, b[j]-1);
            }
        }

        int rtn = bridges.root(0);
        for (int j = 1; j < N; j++)
        {
            if (rtn != bridges.root(j))
            {
                res += 1;
                break;
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

lst = []

lst.append(A*X + B*Y)
lst.append(C*2*max(X, Y))

if X > Y:
    a = C*2*Y + (X-Y)*A
else:
    a = C*2*X + (Y-X)*B
lst.append(a)

print(min(lst))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N;
    cin >> N;
    string S;
    cin >> S;
    int x = 0;
    int ans = 0;
    REP(i, N) {
        if (S[i] == 'I') {
            x++;
        }
        else {
            x--;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

ll dp[3010][3010], previ[3010][3010], prevj[3010][3010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s, t;
  cin >> s >> t;
  const ll n = s.size(), m = t.size();

  REP(i, n) REP(j, m) {
    if(s[i] == t[j]) {
      dp[i+1][j+1] = dp[i][j] + 1;
      previ[i+1][j+1] = i;
      prevj[i+1][j+1] = j;
    }
    else {
      dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      if(dp[i][j+1] < dp[i+1][j]) {
        previ[i+1][j+1] = i+1;
        prevj[i+1][j+1] = j;
      } else {
        previ[i+1][j+1] = i;
        prevj[i+1][j+1] = j+1;
      }
    }
  }

  string ans = "";
  ll nowi = n, nowj = m;
  while(nowi != 0 && nowj != 0) {
    ll pi = previ[nowi][nowj], pj = prevj[nowi][nowj];
    if(nowi-1 == pi && nowj-1 == pj) ans += s[pi];
    nowi = pi;
    nowj = pj;
  }
  reverse(ALL(ans));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 212352
#include <string>
#include <vector>
#include <iostream>
using namespace std;
string ds = "ENWS";
int dx[4] = { 0, -1, 0, 1 };
int dy[4] = { 1, 0, -1, 0 };
int H, W; string s[33]; bool flag[33][33];
int main() {
	while (cin >> W >> H, H | W) {
		for (int i = 0; i < H; i++) cin >> s[i];
		int ret = -1;
		for (int i = 1; i <= 180; i++) {
			for (int j = 0; j < H; j++) {
				for (int k = 0; k < W; k++) {
					flag[j][k] = false;
					int pd = ds.find(s[j][k]);
					if (pd == string::npos) continue;
					for (int l = 3; l < 7; l++) {
						int tx = j + dx[(pd + l) % 4], ty = k + dy[(pd + l) % 4];
						if (s[tx][ty] == '.' || s[tx][ty] == 'X') {
							s[j][k] = ds[(pd + l) % 4];
							break;
						}
					}
				}
			}
			for (int j = 0; j < H; j++) {
				for (int k = 0; k < W; k++) {
					if (s[j][k] == '.' || s[j][k] == 'X') {
						for (int l = 0; l < 4; l++) {
							int tx = j + dx[l], ty = k + dy[l];
							if (0 <= tx && tx < H && 0 <= ty && ty < W) {
								int pd = ds.find(s[tx][ty]);
								if (pd == string::npos || pd != (l + 2) % 4) continue;
								flag[tx][ty] = true;
								break;
							}
						}
					}
				}
			}
			for (int j = 0; j < H; j++) {
				for (int k = 0; k < W; k++) {
					if (flag[j][k]) {
						int pd = ds.find(s[j][k]);
						int tx = j + dx[pd], ty = k + dy[pd];
						if (s[tx][ty] == '.') swap(s[j][k], s[tx][ty]);
						else s[j][k] = '.';
					}
				}
			}
			int cnt = 0;
			for (int j = 0; j < H; j++) {
				for (int k = 0; k < W; k++) {
					if (ds.find(s[j][k]) != string::npos) cnt++;
				}
			}
			if (cnt == 0) {
				ret = i;
				break;
			}
		}
		if (ret == -1) cout << "NA" << endl;
		else cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	if (N >= 30){
	cout << "Yes" << "\n";
	} else {
	cout << "No" << "\n";

	}



	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
 
 
using namespace std;
int main() {
	int n;
	cin >> n;
 
	long a[3 * n];
 
	for (int i = 0; i < n * 3; i++) {
		cin >> a[i]; 
	}
 
	sort(a, a + (3 * n) );
 
	long long count = 0;
	for (int i = 0; i < n; i++) {
		count +=  a[3 * n  - 1 - (i * 2 + 1)] ;
	}
	cout << count << endl;
 
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main (void)
{
	int a,b,c;
	scanf("%d%d%d\n",&a,&b,&c);
	
	if(a<b && b<c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    ll A,B,C;
    cin >> A >> B >> C;
    ll ans = 0;
    while (A%2==0 && B%2==0 && C%2==0) {
        ll a = (B+C)/2;
        ll b = (A+C)/2;
        ll c= (A+B)/2;
        //cout << A csp B csp C << endl;
        ans++;
        A = a,B=b,C=c;
        if(ans > 100000000){
            cout << -1 << endl;
            return 0;
        }
        
    }
    
    
    cout << ans << endl;
    
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;

    if(S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(2)){
        cout << "Yes" << endl;
    }
    else if (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(1)){
        cout << "Yes" << endl;
    }
    else if (S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) != S.at(1)){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = []
b = []
for sig in ["S", "H", "C", "D"]:
    for num in range(1, 14):
        a.append([sig, num])
for i in range(n):
    p, q= input().split()
    q = int(q)
    b.append([p, q])
for i in range(13*4):
    if not (a[i] in b):
        print(*a[i])


Measured memory_bytes: 5604
import itertools

x = [int(input()) for i in range(5)]
y = list(itertools.permutations(x))
t = 130 * 5
for z in y:
   c = [z[i] if i==4 or z[i]%10==0 else int(z[i]/10+1)*10 for i in range(5)]
   tt = sum(c)
   t = min(t, tt)
print(t)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <numeric>

using namespace std;
typedef long long ll;

bool is_prime(ll n){
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++){
        if (n % i == 0 ) return false;
    }
    return true;
}

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

    if (2 * k - 1 <= n) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n=100000000;
  ll h,w,a,b;cin>>h>>w>>a>>b;
  ll ans[h][w];
  if(a==1&&b==1){
    cout<<"No"<<endl;
    return 0;
  }
  ll y=n/(a*b-1);
  for(ll i=0;i<h;i++)for(ll j=0;j<w;j++)ans[i][j]=y;
  for(ll i=a-1;i<h;i+=a)for(ll j=b-1;j<w;j+=b)ans[i][j]=-y*(a*b-1)-1;
  ll sum=0;
  for(ll i=0;i<h;i++)for(ll j=0;j<w;j++)sum+=ans[i][j];
  if(sum>0){
    cout<<"Yes"<<endl;
    for(ll i=0;i<h;i++){
      for(ll j=0;j<w;j++)cout<<ans[i][j]<<" ";
      cout<<endl;
    }
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4736