akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
/*#include <boost/multiprecision/cpp_int.hpp> 
using boost::multiprecision::cpp_int;*/
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int              long long int
#define pb              push_back
#define mp12            make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq1             priority_queue<int>
#define pqr1            priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000000
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fast()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

}
void file(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int modInv(int a,int b,int m)
{
    int res=1;
    a=a%m;
    while(b>0){
        if(b&1){
            res=(res*a)%m;
        }
        a=(a*a)%m;
        b=b>>1;
    }
    return res;
}


int p[1000006];
vi prime;
//int mrp[1000000];
void seive(){
    for(int i=2;i<1000006;i++) {
        if(p[i]){
            prime.pb(i);
            for(int j=i*i;j<=1000006;j=j+i){
                p[j]=0;
            }
        }
    }

}

int dp[100005];
int solve(int i,vector<int> g[]){
    if(dp[i]!=-1) return dp[i];
    int ma=0;
    for(auto x:g[i]){
        ma=max(ma,solve(x,g));
    }
    return dp[i]=1+ma;
}


int32_t main()
{
    // memset(prime,0,sizeof(prime));
    //memset(p,1,sizeof(p));   
    //seive();
    //file();
    fast();
    //int mo=1000000007;
    int n,m;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    vector<int> g[n+1];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
         ans=max(ans,solve(i,g));
    }
    cout<<ans-1;





    return 0;
    
    
}



Measured memory_bytes: 11820
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <stack>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int>>
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
 
ll maxll(ll a , ll b ){
    return a > b ? a : b;
}
 
ll minll(ll a , ll b){
    return a > b ? b : a;
}

// bool check(ll z){
//     ll temp = k;
//     // cout << z << endl;
//     f(i , 0 , n){
//         ll sub = (ll)z * a[i];
//         if (sub > b[i])
//         temp -= (sub -b[i]);
//         if (temp < 0){
//             return 0;
//         }
//     }
//         // cout << z << endl;
//     sol = z;
//         return 1;
// }


// To count Number of ones in a binary number
// int count_one(int x){
//     x = (x & (0x55555555)) + ((x >> 1) & (0x55555555));
//     x = (x & (0x33333333)) + ((x >> 2) & (0x33333333));
//     x = (x & (0x0f0f0f0f)) + ((x >> 4) & (0x0f0f0f0f));
//     x = (x & (0x00ff00ff)) + ((x >> 8) & (0x00ff00ff));
//     x = (x & (0x0000ffff)) + ((x >> 16) & (0x0000ffff));
//     // cout << x << endl;
//     return x;
// }

// int gcd (int a , int b){
//     return __gcd(a,b);
// }

// void print_vi(vi a){
//     for (int i: a){
//         cout << i << " " ;
//     }
//     cout << endl;
// }

// Best algo to find maximum sum subarray (contiguous)
// ll kadane (vl a){
//     ll curr = 0 , maxi = 0;
//     f(i , 0 , a.size()){
//         curr = max(a[i] , curr + a[i]);
//         maxi = max(maxi , curr);
//     }
//     return maxi;
// }

void solve(){
    
    ll n;
    cin >> n;
    vl a(n);
    ll temp = 0;
    f( i , 0 , n){
        cin >> a[i];
        temp ^= a[i];
    }
    ll ans ;
    f(i , 0 , n){
        ans= temp^a[i];
        cout << ans << " " ;
    }
    
    cout << endl;

}

 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 
 

    int t = 1;
    // cin >> t;
    
    while(t--){
        
        solve();
    }
}

Measured memory_bytes: 4788
from collections import deque


def main():
    n = int(input())
    tree = [[] for _ in range(n)]
    dist = [0 for _ in range(n)]
    for _ in range(n - 1):
        a, b, c = map(int, input().split())
        tree[a - 1].append([b - 1, c])
        tree[b - 1].append([a - 1, c])
    q, k = map(int, input().split())
    k -= 1
    s = deque([k])
    dist[k] = -1
    while s:
        now = s.pop()
        for t, d in tree[now]:
            if dist[t] == 0:
                dist[t] = dist[now] + d
                dist[t] += 1 if now == k else 0
                s.append(t)
    dist[k] = 0
    for _ in range(q):
        x, y = map(lambda x: int(x) - 1, input().split())
        print(dist[x] + dist[y])


if __name__ == '__main__':
    main()



Measured memory_bytes: 51056
s = int(input())

def f(n):
    if n%2==0:
        return int(n/2)
    else:
        return int(3*n+1)

a=[s]
for i in range(10000000):
    a_last = f(a[i])
    if a_last in a:
        print(i+2)
        break
    a.append(a_last)


Measured memory_bytes: 9172
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var s = sc.next();
		sc.close();

		var max = 0;
		var count = 0;
		for (var i = 0; i < s.length(); i++) {
			if (s.substring(i, i + 1).equals("R")) {
				count++;
				max = Math.max(max, count);
			} else {
				count = 0;
			}

		}

		System.out.println(max);
	}
}


Measured memory_bytes: 35524
#include<bits/stdc++.h>
using namespace std;
int ans(int x,int y,int a[7]){
    if((a[4]==x&&a[2]==y)||(a[2]==x&&a[3]==y)||(a[3]==x&&a[5]==y)||(a[5]==x&&a[4]==y)) return a[1];
    if((a[1]==x&&a[4]==y)||(a[4]==x&&a[6]==y)||(a[6]==x&&a[3]==y)||(a[3]==x&&a[1]==y)) return a[2];
    if((a[1]==x&&a[2]==y)||(a[2]==x&&a[6]==y)||(a[6]==x&&a[5]==y)||(a[5]==x&&a[1]==y)) return a[3];
    if((a[2]==x&&a[1]==y)||(a[1]==x&&a[5]==y)||(a[5]==x&&a[6]==y)||(a[6]==x&&a[2]==y)) return a[4];
    if((a[1]==x&&a[3]==y)||(a[3]==x&&a[6]==y)||(a[6]==x&&a[4]==y)||(a[4]==x&&a[1]==y)) return a[5];
    if((a[2]==x&&a[4]==y)||(a[4]==x&&a[5]==y)||(a[5]==x&&a[3]==y)||(a[3]==x&&a[2]==y)) return a[6];
}
int main(){
    int a[7];
    for(int i=1;i<7;i++){
        cin>>a[i];
    }
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        cout<<ans(x,y,a)<<endl;
    }
}


Measured memory_bytes: 3096
#include <iostream>

int main(int argc, char *argv[]) {
  long long a, b, v, w, t;
  std::cin >> a >> v >> b >> w >> t;
  bool ans = (v * t - w * t) >= std::abs(b - a);
  std::cout << (ans ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 3132
def is_prime(x):
  if x == 2: return 1
  if x % 2 == 0: return 0
  for i in range(3, int(x ** 0.5) + 1, 2):
    if x % i == 0: return 0
  return 1

c = 0
for _ in range(int(input())):
  c += is_prime(int(input()))
print(c)


Measured memory_bytes: 5672
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, f, t) for(int i=(int)(f); i<(int)(t); i++)
#define RFOR(i, f, t) for(int i=(int)(f); i>(int)(t); i--)
using namespace std;
using ll = long long;
#define MOD 1000000007
#define MOD2 998244353
constexpr int INFINT = (1 << 30) - 1;       // 1.07x10^ 9
constexpr int INFINT_LIM = (1LL << 31) - 1; // 2.15x10^ 9
constexpr ll INFLL = 1LL << 60;             // 1.15x10^18
typedef pair<ll, ll> P;
template<class T> inline T chmax(T& a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

/*ナップサック*/
/*制約w小さい、価値v大きい*/
/*dp[v] vの価値を達成できる最小の重さ*/

/*def*/
ll dp[101000];
ll n, w;
ll wi, vi;

int main() {
/*input*/
    cin >> n >> w;

    dp[0] = 0;
    for (int i = 1; i <= 100000; i++){
        dp[i] = INFLL;
    }

/*maindp*/
    int ret = 0;
    FOR(i, 0, n){
        cin >> wi >> vi;
        for (int j = 100000; j >= 0; j--){
            if (j-vi >= 0){
                chmin(dp[j], dp[j-vi] + wi);
                if (dp[j] <=w)
                    chmax(ret, j);
            }
        }
    }

/*output*/
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 4388
#標準入力
str3 = input()
str3 = str3.lower()
try:
    while True:
        str1 = input()
        str1 = str1.lower()
        str3 += str1
except EOFError:
    pass

#英語を数字に変換して繰り返し処理をし、文字数をカウントして出力する
finally:
    for num in range(ord("a"),ord("a") + 26):
        str2 = chr(num)
        num2 = str3.count(str2)
        print(str2 + " : " + str(num2))


Measured memory_bytes: 5556
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int c = Integer.parseInt(scan.next());
        if(a <= b && b <= c){
            System.out.println(a+" "+b+" "+c);
            return;
        }
        if(a <= c && c <= b){
            System.out.println(a+" "+c+" "+b);
            return;
        }
        if(b <= a && a <= c){
            System.out.println(b+" "+a+" "+c);
            return;
        }
        if(b <= c && c <= a){
            System.out.println(b+" "+c+" "+a);
            return;
        }
        if(c <= a && a <= b){
            System.out.println(a+" "+a+" "+b);
            return;
        }
        if(c <= b && b <= a)
            System.out.println(c+" "+b+" "+a);{
            return;
        }
    }
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s, t;
  cin >> s >> t;

  bool ans = true;
  array<char, 256> r1, r2;
  r1.fill('\0');
  r2.fill('\0');

  // S_i == S_j ならば T_i == T_j
  // T_i == T_j ならば S_i == S_j
  for (int i = 0; i < s.size(); i++) {
    char s_ch = s[i], t_ch = t[i];
    if (r1[s_ch] != '\0' && r1[s_ch] != t_ch) {
      ans = false;
      break;
    }

    if (r2[t_ch] != '\0' && r2[t_ch] != s_ch) {
      ans = false;
      break;
    }

    if (r1[s_ch] == '\0') {
      r1[s_ch] = t_ch;
    }

    if (r2[t_ch] == '\0') {
      r2[t_ch] = s_ch;
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';

  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007; 
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

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

char maze[50][51];
int h, w;
int sx = 0, sy = 0;
int gx; int gy;

int d[50][50];

int bfs() {
	queue<P>que;
	rep(i, h)rep(j, w)d[i][j] = INF;
	que.push(P(sx, sy));
	d[sx][sy] = 0;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		if (p.first == gx && p.second == gy)break;
		rep(i, 4) {
			int nx = p.first + dx[i]; int ny = p.second + dy[i];
			if (0 <= nx && nx < h && 0 <= ny && ny < w&&d[nx][ny] == INF&&maze[nx][ny]!='#') {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gx][gy];
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> h >> w;
	rep(i, h)rep(j, w)cin >> maze[i][j];
	gx = h - 1, gy = w - 1;
	int ans = bfs();
	if (ans == INF) {
		cout << -1 << endl; return 0;
	}
	else {
		int tmp = 0;
		rep(i, h)rep(j, w) {
			if (maze[i][j] == '#') {
				tmp++;
			}
		}
		ans++;
		cout << h*w-ans-tmp << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
   int main(){
   int n,l;cin>>n>>l;
   int a[n];
   for(int i=0;i<n;i++)cin>>a[i];
   sort(a,a+n);
   int sum=0,p=0;
   for(int i=0;i<n;i++){
       if(p<l){
       sum+=a[i];
       p++;
       }
   }
   cout<<sum<<endl;
   
  }
   

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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 T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    double a,b; cin >> a >> b;
    out(a/b);

    return 0;
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<int, int>> e;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (i + j == (n + 1 - n % 2)) continue;
            e.push_back({i, j});
        }
    }
    cout << e.size() << "\n";
    for (auto p : e) {
        cout << p.first << " " << p.second << "\n";
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{

    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//----------------------------------------------------------------

int main()
{
    ll n, k;
    cin >> n >> k;
    set<ll> g;
    ll a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        g.insert(a);
    }
    ll cnt = 0;
    ll size = g.size();
    while (size > k)
    {
        cnt += size / k;
        size = size % k + size / k;
    }
    cout << cnt + 1 << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n, a[1000], b[1000], c[1000], ans=0, i, pre=-1;
   cin >> n;
   for(i=0;i<n;i++){
       cin >> a[i];
       a[i]--;
   }
   for(i=0;i<n;i++){
       cin >> b[i];
   }
   for(i=0;i<n-1;i++){
       cin >> c[i];
   }
   for(i=0;i<n;i++){
       ans+=b[a[i]];
       if(pre==a[i]-1) ans+=c[a[i]-1];
       pre=a[i];
   }
   cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>

using std::max;
using std::min;
using std::cerr;
using std::endl;

inline void read(int &x)
{
    int s = 0, w = 1;
    char c = getchar();
    while(!isdigit(c)){if(c == '-')w = -1; c = getchar();}
    while(isdigit(c)){s = (s << 3) + (s << 1) + c - '0', c = getchar();}
    x = s * w;
}

typedef long long ll;
#define rg register int

const int N = 20;

char s[N];
int cnt, n;

int main()
{
    scanf("%s", s + 1);
    n = strlen(s + 1);
    for (rg i = 1; i <= n; i++)
        cnt += (s[i] == 'o');
    cnt += 15 - n;
    puts(cnt >= 8 ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

vector<int> ans(10001);

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int n; cin >> n;
    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                int res = x*x + y*y + z*z + x*y + y*z + z*x;
                if (res <= n) { ans[res]++; }
            }
        }
    }
    rep(i,n) {
        cout << ans[i+1] << '\n';
    }

    return 0;
}


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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i <= b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n, y;
	cin >> n >> y;
	int f=-1, s=-1, t=-1, z;
	REP(i, 0, n){
		REP(j, 0, n-i){
			z = n -i -j;
			if(i*10000+j*5000+z*1000 == y){
				f = i;
				s = j;
				t = z;
				break;
			}
			else if(i*10000+j*5000+z*1000 > y) break;
		}
		if(f != -1) break;
	}
			
	cout << f << " " << s << " " << t;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    if(a == b){
        cout << 2 * a;
    }
    else if(a > b){
        cout << 2 * a - 1 << endl;
    }else{
        cout << 2 * b - 1 << endl;
    }
    
}



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

int main() {
    int D,T,S;

    cin >> D >> T >> S;

    if (D > T*S){
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	for(int i=0; i<200; ++i){
		c -= b;
		if(c<=0){
			cout << "Yes"  << endl;
			break;
		}
		a -= d;
		if(a<=0){
			cout << "No" << endl;
			break;
		}
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }

bool isPall(string s) {
    int n=s.size();
    string p;
    p=s;
    reverse(p.begin(),p.end());
    if(s==p) return true;
    return false;
}
bool isPalli1(string s) {
    int n=s.size();
    int i=0,j=((n-1)/2)-1;
    while(i<(n-1)/2 && j>0) {
        if(s[i]!=s[j]) {
            return false;
        }
        ++i;
        --j;
    }
    return true;
}
bool isPalli2(string s) {
    int n=s.size();
    int i=(n+1)/2,j=n-1;
    while(i<n&&j>=i) {
        if(s[i]!=s[j]) {
            return false;
        }
        ++i;
        --j;
    }
    return true;
}
int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    string s;
    cin>>s;


    (isPall(s)&&isPalli1&&isPalli2(s))?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    int N, K;
    cin >> N >> K;
    
    ll ans = K;
    REP(i,N-1) ans *= K - 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
     n = int(input())
     p = list(map(int, input().split()))

     min_p = p[0]
     ans = 1
     for i in range(1, n):
          if p[i] <= min_p:
               ans += 1
               min_p = p[i]
     
     print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 24744
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  vector<vector<pair<ll, ll>>> dp(s.length(), vector<pair<ll, ll>>(2, {0, 0}));
  if (s[0] == 'g') {
    dp[0][0] = {0, 1};
    dp[0][1] = {0, 1};
  } else {
    dp[0][0] = {-1, 1};
    dp[0][1] = {-1, 1};
  }
  for (int i = 1; i < s.size(); i++) {
    int g_v_0 = dp[i - 1][0].first;
    int stock_0 = dp[i - 1][0].second;
    int g_v_1 = dp[i - 1][1].first;
    int stock_1 = dp[i - 1][1].second;
    int score_0 = (s[i] == 'g') ? 0 : -1;
    if (g_v_0 < g_v_1) {
      dp[i][0] = {g_v_1 + score_0, stock_1 + 1};
    } else {
      dp[i][0] = {g_v_0 + score_0, stock_0 + 1};
    }
    ll cand0 = -INF, cand1 = -INF;
    int score_1 = (s[i] == 'g') ? 1 : 0;
    if (0 < stock_0) cand0 = g_v_0 + score_1;
    if (0 < stock_1) cand1 = g_v_1 + score_1;
    if (cand0 < cand1) {
      dp[i][1] = {cand1, stock_1 - 1};
    } else if (cand1 < cand0) {
      dp[i][1] = {cand0, stock_0 - 1};
    } else if (cand1 == cand0) {
      dp[i][1] = {cand0, max(stock_1 - 1, stock_0 - 1)};
    } else {
      dp[i][1] = dp[i][0];
    }
  }
  cout << max(dp[s.size() - 1][0].first, dp[s.size() - 1][1].first) << endl;
  return 0;
}

Measured memory_bytes: 10332
# include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
typedef long long LL;
const int maxn = 23000000;
short dig[maxn+1];
inline void add(int &x, int y)
{
    x+=y;
    if(x>=mod) x-=mod;
}
int qmod(LL a, int b)
{
    LL res = 1;
    for(;b;b>>=1)
    {
        if(b&1) res=res*a%mod;
        a=a*a%mod;
    }
    return (int)res;
}
int main()
{
    for(int i=1; i<=maxn; ++i) dig[i] = dig[i/10]+1;
    int n, ans=0;
    scanf("%d",&n);
    for(int i=1, j=1, s=0; i<1e7; ++i)
    {
        while(s<n) s+=dig[j],++j;
        if(s==n) add(ans, 1);
        s -= dig[i];
    }
    for(int i=1; i<=n/8; ++i)
    {
        if(n%i==0) add(ans, ((qmod(10,n/i)-qmod(10,n/i-1)-i+1)%mod+mod)%mod);
        else add(ans, 1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 45312
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
	string s;
	cin >> s;
	if((s.at(0) == s.at(1) && s.at(0) == s.at(2))
		||(s.at(1) == s.at(2) && s.at(1) == s.at(3))){
		cout << "Yes" << endl;
	}else cout << "No" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> like(M + 1, 0);
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      like[A]++;
    }
  }
  int res = 0;
  for (int i = 0; i <= M; i++)
    if (like[i] == N) res++;
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
#define G a.insert(A+B);a.insert(B+A);
using namespace std;
string s;
int n;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		set<string>a;
		for(int i=1;i<s.size();i++)
		{
			string A=s.substr(0,i),B=s.substr(i);
			G
			reverse(B.begin(),B.end());
			G
			reverse(A.begin(),A.end());
			G
			reverse(B.begin(),B.end());
			G
		}
		cout<<a.size()<<endl;
	}
}




Measured memory_bytes: 3244
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    long ans = 0;
    for(int i = 0; i < N; i++){
      long n = Long.parseLong(sc.next());
      if(i == 0){
        ans = n;
      }else{
        ans = ans^n;
      }
    }

    System.out.println(ans == 0 ? "Yes" : "No");
  }
}

Measured memory_bytes: 44752
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string s; cin >> s;
    int a,b;
    a=0;b=0;
    bool f=false;
    for(int i=0;i<s.size();i++){
        if(!f && s[i]=='A'){
            a=i;f=true;
        }
        if(f && s[i]=='Z'){
            b=i;
        }
    }
    cout << b-a+1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#define f first
#define s second
#define INF (1<<29)
using namespace std;

typedef pair<int,int> P;

int h,w,s,u[34][34];
P memo[34][34][34][34];

P rec(int x1,int y1,int x2,int y2){
	
	if(memo[x1][y1][x2][y2]!=P(0,INF))return memo[x1][y1][x2][y2];
	
	if(u[h-1][w-1]-(u[y2-1][x2-1]-u[y2-1][x1-1]-u[y1-1][x2-1]+u[y1-1][x1-1])>s)return P(0,INF);
	
	P res=P(1,s-(u[h-1][w-1]-(u[y2-1][x2-1]-u[y2-1][x1-1]-u[y1-1][x2-1]+u[y1-1][x1-1])));
	
	for(int i=x1+1;i<x2;i++){
		P a=rec(x1,y1,i,y2);
		P b=rec(i,y1,x2,y2);
		res=max(res,P(a.f+b.f,min(a.s,b.s)));
	}
	
	for(int i=y1+1;i<y2;i++){
		P a=rec(x1,y1,x2,i);
		P b=rec(x1,i,x2,y2);
		res=max(res,P(a.f+b.f,min(a.s,b.s)));
	}
	
	return memo[x1][y1][x2][y2]=res;
}

int main(void){
	
	while(cin >> h >> w >> s,h|w|s){
		
		for(int i=0;i<34;i++)
			for(int j=0;j<34;j++)
				for(int k=0;k<34;k++)
					for(int l=0;l<34;l++)
						memo[i][j][k][l]=P(0,INF);
		
		fill(u[0],u[33],0);
		h++,w++;
		
		for(int i=1;i<h;i++){
			for(int j=1;j<w;j++){
				cin >> u[i][j];
			}
		}
		
		for(int i=1;i<h;i++){
			for(int j=1;j<w;j++){
				u[i][j]+=u[i-1][j]+u[i][j-1]-u[i-1][j-1];
			}
		}
		
		P ans=rec(1,1,w,h);
		cout << ans.f << " " << ans.s << endl;
	}
	return 0;
}

Measured memory_bytes: 11616
#include<stdio.h>
#define N 101


typedef struct
{
  int  d,f,k,color;
}Depth;

int  B[N][N],n,cnt=0;
Depth D[N];

void DFS(int);
void Print();


int main()
{
  int i,j,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)B[i][j] = 0;
  }
  for(i=0;i<n;i++)
  {
    D[i].d = 0;
    D[i].color = 0;
    scanf("%d%d",&u,&D[i].k);
    u--;
    for(j=0;j<D[i].k;j++)
    {
      scanf("%d",&v);
      v--;
      B[u][v] = 1;
    }
  }

  Print();

  return 0;
}

void DFS(int u)
{
  int i;
  D[u].color = 1;
  D[u].d = ++cnt;
  for(i=0;i<n;i++)
  {
    if(B[u][i] == 0) continue;
    if(D[i].color == 0)DFS(i);
  }
  D[u].color = 2;
  D[u].f = ++cnt;
}

void Print()
{
  int i;
  for(i=0;i<n;i++)if(D[i].color == 0)DFS(i);
  for(i=0;i<n;i++)
  {
    printf("%d %d %d\n",i+1,D[i].d,D[i].f);
  }
}



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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> bamboo_length(n);
    rep(i, n) cin >> bamboo_length[i];

    int ans = 1000000000;
    rep(bit, pow(4, n)) {
        llong tmp_bit = bit;
        list<int> com;
        while (1) {
            com.push_back(tmp_bit % 4);
            tmp_bit /= 4;
            if (tmp_bit < 4) {
                com.push_back(tmp_bit);
                break;
            }
        }

        if (com.size() < n) {
            int needed_add_0 = com.size();
            for (int i = 0; i < n - needed_add_0; ++i) {
                com.push_back(0);
            }
        }

        int len_a = 0, len_b = 0, len_c = 0;
        int cnt_a = 0, cnt_b = 0, cnt_c = 0;
        int i = 0;
        stl_rep(itr, com) {
            if (*itr == 0) len_a += bamboo_length[i], ++cnt_a;
            if (*itr == 1) len_b += bamboo_length[i], ++cnt_b;
            if (*itr == 2) len_c += bamboo_length[i], ++cnt_c;
            ++i;
        }
        if (len_a == 0 || len_b == 0 || len_c == 0) continue;
        ans = min(ans, abs(a - len_a) + abs(b - len_b) + abs(c - len_c) + 10 * (cnt_a - 1 + cnt_b - 1 + cnt_c - 1));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int H,W,h,w;
  cin>>H>>W;
  cin>>h>>w;
  cout<<H*W-h*W-w*H+w*h<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

int main(void){
    ll n,h; cin >> n >> h;
    vector<ll>a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    int cnt=0,max_a=a[0];
    for(int i=0;i<n;i++){
        if(b[i] <= max_a || h <= 0) break;
        h -= b[i];
        cnt++;
    }
    cnt += max(0,int(h+max_a-1)/max_a);
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextInt();
		long w = sc.nextInt();
		sc.close();

		if (h % 3 == 0 || w % 3 == 0) {
			System.out.println(0);
			return;
		}
		long ans = Math.min(h, w);
		for (int i = 1; i < h; i++) {
			long a = w * i;
			long b = w / 2 * (h - i);
			long v = Math.abs(a - b);
			if (w % 2 == 1) {
				long c = (w / 2 + 1) * (h - i);
				v = Math.max(v, Math.abs(a - c));
			}
			ans = Math.min(ans, v);
		}
		for (int i = 1; i < w; i++) {
			long a = h * i;
			long b = h / 2 * (w - i);
			long v = Math.abs(a - b);
			if (h % 2 == 1) {
				long c = (h / 2 + 1) * (w - i);
				v = Math.max(v, Math.abs(a - c));
			}
			ans = Math.min(ans, v);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22100
#include<cstdio>
#include<cstring>
using namespace std;
int num[205];
int main(){
    int n;
    memset(num,0,sizeof(num));
    for(int i=1;i<205;i++)
    for(int j=1;j<=i;j++)
    if(i%j==0&&j%2) num[i]++;
    scanf("%d",&n);
    int res=0;
    for(int i=1;i<=n;i++)
    if(num[i]==8) res++;
    printf("%d\n",res);
}

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

int main() {

   string s;
   cin>>s;
   
   int ct=0;
   int ct1=0;
   for(int i=0;i<s.length();++i){
       if(s[i]=='+')
          ct++;
          else
          ct1++;
   }
   cout<<ct-ct1;
   
   
   
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
   int w, n, i, a, b, tmp;
   scanf("%d %d", &w, &n);
   int R[w];

   for(i=0; i<w; i++){
      R[i] = i+1;
   }

   for(i=0; i<n; i++){
      scanf("%d,%d", &a, &b);
      tmp = R[a-1];
      R[a-1] = R[b-1];
      R[b-1] = tmp;
   }

   for(i=0; i<w; i++){
      printf("%d\n", R[i]);
   }

   return 0;
}

Measured memory_bytes: 1688
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int rest = x - z;
        int num = rest / (y + z);
        System.out.println(num);
    }
}

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

int main(){
    vector<vector<bool>> grid(100, vector<bool>(100, true));
    for (int i = 50; i < 100; i++){
        for (int j = 0; j < 100; j++) grid[i][j] = false;
    }
    int a, b;
    cin >> a >> b;
    a--; b--;
    for (int i = 0; i < b; i++){
        grid[2 * i / 100 * 2][(2 * i) % 100] = false;
    }
    for (int i = 0; i < a; i++){
        grid[99 - 2 * i / 100 * 2][(2 * i) % 100] = true;
    }
    cout << "100 100" << endl;
    for (int i = 0; i < 100; i++){
        for (int j = 0; j < 100; j++){
            if (grid[i][j]) cout << ".";
            else cout << "#";
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double pi = acos(-1);
const double EPS = 1e-10;

vi solve(int i,int j,vii ans){
  vi res(i);
  if (j == 0) {
    REP(k,i) res[k] = k+1;
    return res;
  } else {
    for (int k = 0; k < i; k++) {
      if(k < j){
        res[k] = ans[k][j-1];
      }else if(k == j){
        res[k] = ans[j-1].back() + 1;
      }else{
        res[k] = res[k-1] + 1;
      }
    }
    return res;
  }
}

int main(){
  int n;
  cin >> n;
  bool flag = false;
  int i = 1;
  for (; i*(i+1)/2 <= n; i++) {
    if (i*(i+1)/2 == n) {
      flag =true;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
    cout << i+1 << endl;
    vii ans;
    REP(j,i+1){
      cout << i;
      ans.pb(solve(i,j,ans));
      REP(k,i){
        cout << " " << ans[j][k];
      }
      cout << endl;
    }
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using Graph = vector<VE>;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k; cin >> n >> k;
	VE h(n); rep(i, n)cin >> h[i];
	sort(ALLR(h));
	rep(i, min(n,k))h[i] = 0;
	int ans = 0;
	rep(i, n) {
		ans += h[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>


int main(void){
    int n;
    std::cin >> n;

    std::vector<int> h(n);
    for(int i = 0; i < n; i++){
        std::cin >> h.at(i);
    }

    int pre = -99;
    for(int i = 0; i < n; i++){
        if(pre < h.at(i)){
            pre = h.at(i) - 1;
        }
        else if(pre <= h.at(i)){
            pre = h.at(i);
        }
        else{
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 640
import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
o=0
h=0
u=list(itertools.permutations(range(1,n+1)))
for i in range(len(u)):
    if u[i]==p:
        h=i
for i in range(len(u)):
    if u[i]==q:
        o=i
print(abs(h-o))


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

#define MOD 1000000007

int main(){
    string s;cin>>s;
    long long ans=0;
    int n=s.size(),cnt=0;
    vector<long long>a(n+1),b(n+1);
    a[0]=1;b[0]=1;
    for(int i=1;i<n+1;++i){
        a[i]=a[i-1]*3%MOD;
        b[i]=b[i-1]*2%MOD;
    }
    for(int i=0;i<n;++i){
        if(s[i]=='1'){
            cnt++;
            ans+=b[cnt-1]*a[n-i-1]%MOD;
            ans%=MOD;
        }
    }
    ans+=b[cnt];
    ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 2048
#include<stdio.h>

int main(void) 
{
	int n, total, yen;
	int x, y, z;
	int *px, *py, *pz;
	int i, j, k;
	int exitFrag = 0;

	x = y = z = -1;

	px = &x;
	py = &y;
	pz = &z;

	scanf("%d %d", &n, &total);

	for (i = 0; i <= n; i++)
	{
		for ( j = 0; j <= n - i ; j++)
		{
			k = n - i - j;
			yen = 10000 * k + 5000 * j + 1000 * i;
			if (yen == total)
			{
				*px = k;
				*py = j;
				*pz = i;
				exitFrag = 1;
			}

			if (exitFrag) break;
		}
		if (exitFrag) break;
	}
	
	
	printf("%d %d %d", x, y, z);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int tmp=0;
		while(true){
			int x=sc.nextInt(),y=sc.nextInt();
			if(x==0&&y==0) break;
			if(x>y){
				tmp=x;
				x=y;
				y=tmp;
			}
			System.out.println(x+" "+y);
		}
	}
}


Measured memory_bytes: 35572
import java.util.*;
 
class  Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n;
		String a;
		int b = 0;
		int[][]kard = new int[4][13];//たて４ S,H,C,D用横 13 1?１３の配列準備
		String []mark = {"S","H","C","D"};
		n = sc.nextInt();
		for(int i=0; i<n; i++){ 
			a = sc.next();
			b = sc.nextInt();
			for(int d=0; d<4; d++){
				if(mark[d].equals(a))
				kard[d][b-1]++;
			}
		}
		for(int c=0; c<4; c++){
			for(int d=0; d<13; d++){
				if( kard[c][d]==0) 
				System.out.println(mark[c]+" "+(d+1)); 
			}
		}
	}
}

Measured memory_bytes: 18048