akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,x) for(int i = 0; i < x; i++)
typedef long long ll;
using namespace std;

int main(){
    int h,w; cin >> h >> w;   
    vector<string> s(h);
    rep(i,h){
        cin >> s.at(i);
    }
    vector<vector<int>> l(h, vector<int>(w,0));
    vector<vector<int>> r(h, vector<int>(w,0));
    vector<vector<int>> d(h, vector<int>(w,0));
    vector<vector<int>> u(h, vector<int>(w,0));
    rep(i,h){
        rep(j,w){
            if(s[i][j] == '.'){
                if(i == 0) u[i][j] = 1;
                else u[i][j] = u[i-1][j] + 1;
                if( j == 0) l[i][j] = 1;
                else l[i][j] = l[i][j-1] + 1;
            }
            else{
                l[i][j] = 0; 
                r[i][j] = 0;
                u[i][j] = 0;
                d[i][j] = 0;
            }
        }
    
    }

    for(int i = h-1; i >= 0;i--){
        for(int j = w-1; j >= 0;j--){
            if(s[i][j] == '.'){
                if(i == h-1) d[i][j] = 1;
                else  d[i][j] = d[i+1][j] + 1;
                if( j == w-1) r[i][j] = 1;
                else r[i][j] = r[i][j+1] + 1;
            }
        }
    }

    vector<int> ans;
    rep(i,h){
        rep(j,w){
            ans.push_back(l[i][j] + r[i][j] + d[i][j] + u[i][j] -3);
            // cout << i << j << l[i][j] << r[i][j] << u[i][j] << d[i][j] <<endl;
        }
    }

    cout << *max_element(ans.begin(), ans.end()) << endl;
}

Measured memory_bytes: 84980
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS
    string s;
    cin>>s;
    int n= s.length();
    if(s[n-1]!='s')
        s+='s';
    else
        s+="es";
    cout<<s;
    return 0;
}

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

static const int N = 100;

int main(){
  int n,p[N + 1],m[N + 1][N + 1];
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> p[i - 1] >> p[i];
  }

  for(int i = 1;i <= n;i++) m[i][i] =0;
  for(int l = 2;l <= n;l++){
    for(int i = 1;i <= n - l + 1;i++){
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      for(int k = i;k <= j - 1;k++){
	m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }

  cout << m[1][n] << endl;

  return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

int main() {
  int N;
  cin >> N;
  int ni = N / 100;
  if (100 * ni + 10 * ni + ni < N) {
    ni++;
  }
  cout << ni << ni << ni << endl;
}


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

int main() {
	int N; cin >> N;
	if (N % 2) {
		cout << N * (N - 1) / 2 - N / 2 << endl;
		for (int i = 1; i < N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (i + j != N) {
					cout << i << ' ' << j << endl;
				}
			}
		}
	}
	else {
		cout << N * (N - 1) / 2 - N / 2 << endl;
		for (int i = 1; i < N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (i + j != N + 1) {
					cout << i << ' ' << j << endl;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	n := nextInt()
	a := []int{}
	for i := 0; i < n; i++ {
		a = append(a, nextInt())
	}
	j := 1
	for i := 0; i < n; i++ {
		j = a[j-1]
		if j == 2 {
			fmt.Println(i + 1)
			return
		}
	}
	fmt.Println(-1)
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
 
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
int main(){
	string s;
	cin>>s;
	int a=0,b=0,c=0;

	for (int i = 0; i < s.size(); ++i){
		if(s[i]=='a')a++;
		if(s[i]=='b')b++;
		if(s[i]=='c')c++;
	}

	if(max(a,max(b,c))-min(a,min(b,c))<=1){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}

Measured memory_bytes: 512
H,W = map(int,input().split())
h = 0
w = 0
flag = 0
ans = 0
counter = 0
L = []
for i in range(H) :
    l = input()
    counter += l.count("#")
    L.append(l)

while flag == 0 :
    if h == (H-1) and w == (W-1) :
        ans = 1
        flag = 1
    else :
        if w == (W-1) :
            if L[h+1][w] == "#" :
                h += 1
            else :
                flag = 1
        elif h == (H-1) :
            if L[h][w+1] == "#" :
                w += 1
            else :
                flag = 1
        else :
            if L[h+1][w] == "#" and L[h][w+1] == "#" :
                flag = 1
            else :
                if L[h+1][w] == "#" :
                    h += 1
                elif L[h][w+1] == "#" :
                    w += 1
                else :
                    flag = 1
                
if ans == 1 and ((H+W-1) == counter) :
    print("Possible")
else :
    print("Impossible")


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

#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(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);


int main(){
  faster();
  int n,k,dig=1;
  cin >> n >> k;
  while(n/k){
    n /= k;
    dig++;
  }
  cout << dig;
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



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

bool solve(string s) {
    for(int i = 0; i < s.size(); i++) {
        if(i % 2) {
            if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) return false;
        } else {
            if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) return false;
        }
    }

    return true;
}

int main() {

    string s;
    cin >> s;

    if(solve(s)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int H, W; 
    scanf("%d%d", &H, &W);
    int grid[H][W];
    char tmp[W];
    int black1[H];
    int black2[W];
    for(int i = 0; i < H; i++){
        black1[i] = 0;
        scanf("%s", tmp);
        for(int j = 0; j < W; j++){
            if(i == 0) black2[j] = 0;
            grid[i][j] = (tmp[j] == '#') ? 1 : 0;
            black1[i] += grid[i][j];
            black2[j] += grid[i][j];
        }
    }

    for(int i = 0; i < H; i++){
        if(black1[i] == 0) continue;
        for(int j = 0; j < W; j++){
            if(black2[j] == 0) continue;
            printf("%c", grid[i][j] ? '#' : '.');
        }
        printf("\n");
    }

    return 0; 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int S[2000][2000];
int cnt_eh[2000][2000];
int cnt_ev[2000][2000];
int cnt_v[2000][2000];

int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            char s;
            cin >> s;
            S[i][j] = s-'0';
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            if(i == 0){
                if(j == 0){
                    cnt_v[i][j] = S[i][j];
                    cnt_eh[i][j] = 0;
                    cnt_ev[i][j] = 0;
                }else{
                    cnt_v[i][j] = cnt_v[i][j-1]+S[i][j];
                    cnt_eh[i][j] = cnt_eh[i][j-1];
                    cnt_ev[i][j] = 0;
                    if(S[i][j-1] == 1 && S[i][j] == 1) cnt_eh[i][j]++;
                }
            }else{
                if(j == 0){
                    cnt_v[i][j] = cnt_v[i-1][j]+S[i][j];
                    cnt_eh[i][j] = 0;
                    cnt_ev[i][j] = cnt_ev[i-1][j];
                    if(S[i][j] == 1 && S[i-1][j] == 1) cnt_ev[i][j] += 1;
                }else{
                    cnt_v[i][j] = cnt_v[i-1][j]+cnt_v[i][j-1]+S[i][j]-cnt_v[i-1][j-1];
                    cnt_eh[i][j] = cnt_eh[i][j-1]+cnt_eh[i-1][j]-cnt_eh[i-1][j-1];
                    cnt_ev[i][j] = cnt_ev[i-1][j]+cnt_ev[i][j-1]-cnt_ev[i-1][j-1];
                    if(S[i-1][j] == 1 && S[i][j] == 1) cnt_ev[i][j]++;
                    if(S[i][j-1] == 1 && S[i][j] == 1) cnt_eh[i][j]++;
                }
            }
        }
    }
    for(int i = 0; i < Q; i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int e, v;
        x1--;x2--;y1--;y2--;
        e = cnt_ev[x2][y2]+cnt_eh[x2][y2]-cnt_ev[x1][y2]-cnt_eh[x2][y1];
        v = cnt_v[x2][y2];
        if(x1 != 0){
            v -= cnt_v[x1-1][y2];
            e -= cnt_eh[x1-1][y2];
        }
        if(y1 != 0){
            v -= cnt_v[x2][y1-1];
            e -= cnt_ev[x2][y1-1];
        }
        if(x1 != 0 && y1 != 0){
            v += cnt_v[x1-1][y1-1];
            e += (cnt_eh[x1-1][y1] + cnt_ev[x1][y1-1]);
        }
        cout << v-e << '\n';
    }
}

Measured memory_bytes: 64256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        bool ok = true;
        for(int j = 2; j*j <= a; j++) {
            if(a%j == 0) {
                ok = false;
            }
        }
        if(ok) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3108
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = mutableMapOf<Int, Int>()

    repeat(n) {
        val a = readLine()!!.toInt()
        aa[a] = aa[a]?.plus(1) ?: 1
    }

    println(aa.count { it.value % 2 == 1 })
}

Measured memory_bytes: 47948
#include <iostream>

using namespace std;

int main(){
    int n, d;

    cin >> n >> d;

    int i = 0;
    int total = 0;
    bool flag = true;
    while(flag){
        total += d * 2 + 1; // 5 10
        i++;
        if (total >= n){
            flag = false;
        }
    }

    cout << i << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> k;
    vector<ll> a(n, 0);
    for(i = 0; i < k; i++) {
        ll d;
        cin >> d;
        for(j = 0; j < d; j++) {
            cin >> m;
            a[m-1]++;
        }
    }
    ll ret = 0;
    for(i = 0; i < n; i++) {
        if(a[i] == 0) ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3628
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll x, ans;
main() {
  file("threesum");
  ios;
  cin >> x;
  ll cur = 100;
  while (cur < x) {
    ++ans;
//    cur = cur * 101 / 100;
    cur += cur / 100;
  }
  cout << ans;
  return 0;
}
/**
x - 101
y - 100
x * 100 / 101
*/


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


void bubbleSort(int numbers[], int array_size)
{
  int i, j, temp;

  for (i = 0; i < (array_size - 1); i++) {
    for (j = (array_size - 1); j > i; j--) {
      if (numbers[j-1] > numbers[j]) {
        temp = numbers[j-1];
        numbers[j-1] = numbers[j];
        numbers[j] = temp;
      }
    }
  }
}

int main(){
  int  A[3];
  cin>>A[0]>>A[1]>>A[2];
  bubbleSort(A,3);
  cout<<A[0]+A[1];
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int L[100050], P[100050];

int main() {
  int N = in();
  for (int i = 0; i < N; ++i) {
    int a = in();
    P[i] = __builtin_popcount(a) == 1 ? 0 : 1;
    L[i] = 0;
    while (a > 1) {
      if (__builtin_popcount(a) == 1) {
        a /= 2;
      } else {
        while (__builtin_popcount(a) > 1) {
          a -= a & -a;
        }
      }
      ++L[i];
    }
  }

  int res = 0;
  int ps = 0;
  for (int i = 0; i < N; ++i) {
    if (ps < L[i]) {
      res += L[i] - ps;
      ps = L[i];
    } else if (ps > L[i]) {
      ps = L[i];
      if (P[i] == 1) {
        --ps;
      }
    } else if (P[i] == 1) {
      --ps;
    }
  }

  printf("%d\n", res);

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int n,m,x,y,dp[5][10010];

int main()
{
	int i;
	cin>>n>>m>>x>>y;
	if(n<=m) cout<<x*n;
	else cout<<m*x+y*(n-m);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define p_b push_back
#define pll pair < ll , ll >
#define lt(v) v[v.size()-1]
#define fori(n) for( int i = 0; i < n; i++)
#define s second
#define f first
using namespace std;
ll M = 1000000007;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    if(n%1000==0)
    {
        cout << 0;
    }
    else
    {
        cout << 1000-(n%1000);
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
//#include <ext/numeric>


using namespace std;
//using namespace __gnu_cxx;

const int MAXN = (int)1e5 + 5;
vector<int> adjList[MAXN];
bool vis[MAXN];

void dfs(int u) {
    vis[u] = 1;
    for (int v : adjList[u]) {
        if (!vis[v])
            dfs(v);
    }
}


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        adjList[x].push_back(y);
        adjList[y].push_back(x);
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            ++ans;
            dfs(i);
        }
    }

    cout << ans << '\n';




    return 0;
}

Measured memory_bytes: 12180
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> A;
  set<string> ss;
  
  REP(i, A) {
    string tmp;
    cin >> tmp;
    ss.insert(tmp);
  }


  return ss.size();
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 19256
// E - Almost Everywhere Zero
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
string N;
int K;
int lt = 0, eq = 1;//lt: <, eq: =
int dp[100+1][2][4+1];// digit DP, [|N|+1: 1 origin][lt|eq][k:0~3]

int main(){
	cin>>N>>K;
	int dn = N.size();
	dp[0][eq][0] = 1;
	rp(i,0,dn){
		int di = N[i] - '0';
		rp(k,0,K+1){
			dp[i+1][lt][k] = dp[i][lt][k] * 1 + dp[i][eq][k] * (di?1:0);
			if(k) dp[i+1][lt][k] += dp[i][lt][k-1] * 9 + dp[i][eq][k-1] * max(0,di-1);
			if(dp[i][eq][k]) dp[i+1][eq][k+(di>0)] = 1;
		}
	}
	cout<< dp[dn][lt][K] + dp[dn][eq][K] <<endl;
}

Measured memory_bytes: 256
def gcd(a, b):
    q = a % b
    if q == 0:
        return b
    else:
        return gcd(b,q)
    
n = int(input())
li = list(map(int, input().split()))
ans = li[0]

for i in range(n-1):
    ans = gcd(ans, li[i+1])

print(ans)

Measured memory_bytes: 14252
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int n;
		List<Integer> iary = new ArrayList<>();
		Scanner stdIn = new Scanner(System.in);
		n = stdIn.nextInt();

		for (int i = 0; i < n; i++) {
			iary.add(stdIn.nextInt());
		}

		for (int i = n-1; i >= 0; i--) {
			System.out.print(iary.get(i));
			if(i == 0) {
				break;
			}
			System.out.print(" ");
		}
		System.out.println();
	}

}

Measured memory_bytes: 26216
import java.io.PrintWriter;
import java.util.*;


public class Main{

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		double r=in.nextDouble();
		out.printf("%f %f ",r*r*Math.PI,2*r*Math.PI);
		out.flush();
	}

}



Measured memory_bytes: 28256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
int isB(char c){
  return (c=='a'||c=='i'||c=='u'||c=='e'||c=='o');
};
int isS(char c){
  return (c=='k'||c=='s'||c=='t'||c=='n'||c=='h'||
	  c=='m'||c=='y'||c=='r'||c=='w'||
	  c=='g'||c=='z'||c=='d'||c=='b'||
	  c=='p');
}
int isM(char c){
  return (c=='k'||c=='s'||c=='t'||c=='h'||c=='p'||c=='$');
}
int is1(char c){
  return isB(c);
}
int is2(char b,char c){
  return isS(b)&&isB(c);
}
int is3(char a,char b,char c){
  return !(a=='y'||a=='w')&&(b=='y')&&isB(c);
}
int is4(char b,char c){
  return (b==c)&&isS(c)&&!(c=='n'||c=='y'||c=='w');
}
int is5(char b,char c){
  return (b=='n')&&(c=='\''||c=='$'||isS(c));
}

int isIU(char c){
  return (c=='i'||c=='u');
}
int isAO(char c){
  return (c=='a'||c=='o');
}

signed main(){
  string s;
  while(cin>>s,s!="#"){
    int n=s.size();
    s+="$$$$$$";
    string ans;
    int isD=0,isE=0;
    auto cyc=[&]{isD=isE;isE=0;};
    const int DBG = 0;
    for(int i=0;i<n;){
      if(DBG) cout<<" ";
      if(is1(s[i])){
	cyc();
	if(DBG) cout<<s[i];
	ans+=s[i];
	i+=1;
	continue;
      }
      if(is2(s[i],s[i+1])){
	cyc();
	if(DBG) cout<<s[i]<<s[i+1];
	ans+=s[i];
	int x=0;
	if(!isD&&!isE&&isIU(s[i+1])&&isM(s[i])&&isM(s[i+2])&&
	   ((is2(s[i+2],s[i+3]))||
	    (is3(s[i+2],s[i+3],s[i+4]))||
	    (s[i+2]=='$')||
	    (is4(s[i+2],s[i+3])))){
	  isE=1;
	  if(DBG) cout<<"()";
	  x=1;
	  ans+=string("(")+s[i+1]+string(")");
	}
	if(!isD&&!isE&&isAO(s[i+1])&&isM(s[i])&&isM(s[i+2])&&
	   (((s[i+1]==s[i+3])&&is2(s[i+2],s[i+3]))||
	    ((s[i+1]==s[i+4])&&is3(s[i+2],s[i+3],s[i+4])))){
	  isE=1;
	  if(DBG) cout<<"()";
	  x=1;
	  ans+=string("(")+s[i+1]+string(")");
	}
	if(!x) ans+=s[i+1];
	i+=2;
	continue;
      }
      if(is3(s[i],s[i+1],s[i+2])){
	cyc();
	if(DBG) cout<<s[i]<<s[i+1];
	ans+=s[i];
	ans+=s[i+1];
	int x=0;
	if(!isD&&!isE&&isIU(s[i+2])&&isM(s[i])&&isM(s[i+3])&&
	   (is2(s[i+3],s[i+4])||
	    is3(s[i+3],s[i+4],s[i+5])||
	    (s[i+3]=='$')||
	    (is4(s[i+3],s[i+4])))){
	  isE=1;
	  if(DBG) cout<<"()";
	  x=1;
	  ans+=string("(")+s[i+2]+string(")");
	}
	if(!isD&&!isE&&isAO(s[i+2])&&isM(s[i])&&isM(s[i+3])&&
	   (((s[i+2]==s[i+4])&&is2(s[i+3],s[i+4]))||
	    ((s[i+2]==s[i+5])&&is3(s[i+3],s[i+4],s[i+5])))){
	  isE=1;
	  if(DBG) cout<<"()";
	  x=1;
	  ans+=string("(")+s[i+2]+string(")");
	}
	if(!x) ans+=s[i+2];
	i+=3;
	continue;
      }
      
      if(is4(s[i],s[i+1])){
	if(DBG) cout<<s[i];
	ans+=s[i];
	i+=1;
	continue;
      }
      if(is5(s[i],s[i+1])){
	if(DBG) cout<<s[i];
	ans+=s[i];
	if(s[i+1]=='\'')ans+=s[i+1],i+=2;
	else i+=1;
	continue;
      }
    }
    if(DBG) cout<<endl;
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3192
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int x,n;
    cin>>x>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int ans;
    int dis=100000;
    for(int now=-1;now<=101;now++){
        bool f=true;
        for(int i=0;i<n;i++){
            if(now==a[i]) f=false;
        }
        if(f && abs(now-x)<dis){
            dis=abs(now-x);
            ans=now;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3632
/*
 *  Author : Jun_SH
 *  Solution for ABC 146 E
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int maxn=2e5+10;
int a[maxn];
int s[maxn]={};
map<int,int>mp;
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        s[i]=s[i-1]+a[i];
    }
    int ans=0;
    for(int i=0;i<min(n+1,k-1);++i){
        ans+=mp[(s[i]-i)%k];
        mp[(s[i]-i)%k]++;
    }
    int r=k-1,l=0;
    for(;r<=n;){
//        cout<<r<<" "<<mp[(s[r]-r)%k]<<endl;
        ans+=mp[(s[r]-r)%k];
        mp[(s[r]-r)%k]++;
        mp[(s[l]-l)%k]--;
        r++;
        l++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 15872
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

vvi adj(2e5); vi vis(2e5);

void dfs (int cur)
{
    vis[cur] = 1;
    for (int i : adj[cur]) if(!vis[i]) dfs(i);
}
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //start from here

    readb(n, m)
    int x, y, z;

    fori (i, 1, m)
    {
        cin >> x >> y >> z;
        adj[x].pb(y); adj[y].pb(x);
    }

    int ans = 0;

    fori (i, 1, n)
    {
        if(!vis[i]) dfs(i), ans++;
    }

    print(ans)

    return 0;
}


Measured memory_bytes: 15488
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    vector<P> v;
    double a, b;
    while(~scanf("%lf,%lf", &a, &b)) v.pb(P(a,b));
    double ans = 0;
    double x, y, z;
    P init = v[0];
    rep(i,2,v.size()) {
        x = sqrt(norm(v[i] - init));
        y = sqrt(norm(v[i-1] - init));
        z = sqrt(norm(v[i] - v[i-1]));

        double s = (x + y + z) / 2;
        ans += sqrt(s * (s-x) * (s-y) * (s-z));
    }

    printf("%.8f\n",ans);
    return 0;
}

Measured memory_bytes: 1256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x.abs()
    } else {
        gcd(y, x % y)
    }
}

pub fn divisors(x: i64) -> Vec<i64> {
    let mut ds = vec![];
    for d in 1.. {
        if d * d > x {
            break;
        }

        if x % d == 0 {
            ds.push(d);

            if x % (x / d) == 0 {
                ds.push(x / d);
            }
        }
    }
    ds.sort();
    ds.dedup();
    ds
}

fn main() {
    // 約数を列挙する解法

    let N = read!(usize);
    let A = read![[i64]];

    let max_g = divisors(A[0])
        .into_iter()
        .chain(divisors(A[1]))
        .filter(|g| {
            let count = A.iter().filter(|&&a| a % g == 0).count();
            count >= N - 1
        })
        .max()
        .unwrap();

    println!("{}", max_g)
}


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

#define STONE_NUM 2000001

int main(void){
    int k;
    int x;
    int min,max,lange;

    scanf("%d" "%d",&k,&x);
    min = x-k+1;
    max = x+k;

    for(lange=min;lange<max;lange++){
        printf("%d",lange);
        if (lange!=max-1)
        {
            printf(" ");
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a1,a2,a3,a4;
  cin >> N;
  a1 = N % 10;
  a2 = (N % 100 - a1)/10;
  a3 = (N % 1000 - N % 100)/100;
  a4 = (N - N % 1000)/1000;
  
  if (((a1 == a2)&&(a2 == a3))||((a2 == a3)&&(a3 == a4))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

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

		// 1行目個数、2行目の複数の数字を配列に格納
		//   3
		//   1 2 3
		int N = Integer.parseInt(br.readLine());
		int[] ii0 = new int[N+1];
		ii0[0]=0;
		for(int i = 1; i < N+1; i++){
			ii0[i] = Integer.parseInt(br.readLine());
		}
		

		int i=1;
		int count=0;
		while(i != 2){
			i = ii0[i];
			count += 1;
			if(count > N+1) { System.out.println(-1); return; }
		}
		


		System.out.println(count); return;
	}
	//-----------------------------------------------------------------
	// Debug.Print
	static void dp(String s) {
		System.out.println(s);
	}
	static void dp(StringBuilder s) { dp(s.toString()); }
	static void dp(int i) { dp(String.valueOf(i)); }
	static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	// 入力値確認：リスト
	static void checkInput(List l) { System.out.println(l); }
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、float型
	//   ＜使い方＞
	//     float[] f = new float[N];
	//     checkInput(f);
	static void checkInput(float[] i1) {
		StringBuilder sb = new StringBuilder();
		for(float i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、int型
	//   ＜使い方＞
	//     int[] c = new int[N];
	//     checkInput(c);
	static void checkInput(int[] i1) {
		StringBuilder sb = new StringBuilder();
		for(int i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(long[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(long[] i1: i2){
			for(long i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}


Measured memory_bytes: 34604
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for(int i=0;i<w;i++){
                values[i] = i+1;
            }
            for(int i=0;i<n;i++){
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0])-1;
                int b = Integer.parseInt(ab[1])-1;
                int work = values[a];
                values[a] = values[b];
                values[b] = work;
            }
            for(int i=0;i<values.length;i++){
                System.out.println(values[i]);
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
string s[8];
int d[6] = {-3, -2, -1, 1, 2, 3};

void dfs(int y, int x) {
  s[y][x] = '0';
  for (int i = 0; i < 6; i++) {
    int ny = y + d[i], nx = x;
    if (ny >= 0 && ny < 8 && s[ny][nx] == '1') {
      dfs(ny, nx);
    }
  }
  for (int i = 0; i < 6; i++) {
    int ny = y, nx = x + d[i];
    if (nx >= 0 && nx < 8 && s[ny][nx] == '1') {
      dfs(ny, nx);
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    int X, Y;
    for (int j = 0; j < 8; j++) {
      cin >> s[j];
    }
    cin >> X >> Y;
    X--, Y--;
    dfs(Y, X);
    cout << "Data " << i + 1 << ":" << endl;
    for (int j = 0; j < 8; j++) {
      cout << s[j] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3008
#include<iostream>
#include<math.h>
#include<cstring>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include <vector>
#include<iomanip>
#include<queue>
#include<string>
#include<bitset>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
typedef long long ll;
using namespace std;

const int N = 200;
const ll INF = (1LL << 62) - 1;
ll dist[N][N];
vector <int> rr;

int main()
{
    int n, m, r;
    cin >> n >> m >> r;
    for (int i = 0; i < r; ++i) {
        int k;
        cin >> k;
        --k;
        rr.push_back(k);
    }
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
        {
            dist[i][j] = INF;
            if( i == j) dist[i][j] = 0LL;
        }
    sort(rr.begin(), rr.end());
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
         dist[b][a] = dist[a][b] = min(dist[a][b], c * 1LL);
    }
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            for (int z = 0; z < n; ++z) {
                dist[j][z] = min(dist[j][i] + dist[i][z] , dist[j][z] );
            }
    ll ans = INF;
    do
    {
        ll cur = 0LL;
        for(int i = 0; i < r - 1; i++)
        {
            cur+= dist[rr[i]][rr[i+1]];
        }
        ans = min(ans , cur);
    } while(next_permutation(rr.begin(), rr.end()));
    cout << ans <<'\n';
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();

    vl x(n);
    rep(i, n) {
        if(s[i] == 'A') {
            x[i] = 1;
        }
        else {
            x[i] = 2;
        }
    }

    vl y(m);
    rep(i, m) {
        if(t[i] == 'A') {
            y[i] = 1;
        }
        else {
            y[i] = 2;
        }
    }

    vl ruiX(n+1);
    rep(i, n) {
        ruiX[i+1] = ruiX[i] + x[i];
    }

    vl ruiY(m+1);
    rep(i, m) {
        ruiY[i+1] = ruiY[i] + y[i];
    }

    /*cout << "\n";
    rep(i, n+1) {
        cout << ruiX[i] << " ";
    }

    cout << "\n";
    rep(i, m+1) {
        cout << ruiY[i] << " ";
    }*/

    ll q;
    cin >> q;

    vl ans(q);
    rep(i, q) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;  c--;
        if( (ruiX[b] - ruiX[a])%3 == (ruiY[d] - ruiY[c])%3 ) {
            ans[i] = 1;
        }
    } 
    
    rep(i, q) {
        if(ans[i]) {
            out("YES");
        }   
        else {
            out("NO");
        }
    }
    
    re0;
}

Measured memory_bytes: 4864
p x y = (x+y) `mod` (10^9+7)
h (a,b,c) (d,e,f) = (a`p`d,b`p`e,c`p`f)
g n (x,y,z) 'A' = (x`p`n,y,z)
g n (x,y,z) 'B' = (x,y`p`x,z)
g n (x,y,z) 'C' = (x,y,z`p`y)
f _ (_,_,x) [] = x 
f n t ('?':s) = f (p 0 $ n*3) (g n t 'A' `h` g n t 'B' `h` g n t 'C') s
f n t (c:s) = f n (g n t c) s
main = do
  s <- getLine
  print $ f 1 (0,0,0) s

Measured memory_bytes: 8956
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long x;
    while (cin >> x) {
        long long a = 100;
        int ans = 0;
        while (a < x) {
            a = a * 1.01;
            ans++;
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
// #define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;
using namespace __gnu_pbds;

// typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=3000006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // compute();
    // Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        ll n,x,i;
        cin>>n;
        vector<ll>a(n);
        rep(i,0,n-1) cin>>a[i];
        ll ans=0;
        rep(i,1,n-1)
        {
          if(a[i-1]>a[i])
          {
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
          }
        }
        cout<<ans;

    }

    return 0;
}

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

int main(){

int N, K;
cin >> N >> K;

vector<int>l(N);
for(int i = 0; i < N; i++){ 
     cin >> l[i];
}

sort(l.begin(), l.end());
reverse(l.begin(), l.end());

int sum = 0;
for(int i = 0; i < K; i++){ 
     sum += l[i];
}

cout << sum << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n; cin >> n;
  vl c(n);
  rep(i, n) cin >> c[i];
  sort(all(c));

  vl two(n+1,1);
  rep(i,n) two[i+1] = (two[i]*2)%MOD;

  ll ans = 0;
  rep(i,n) {
    int l = i, r = n-i-1;
    ll now = two[r];
    if(r != 0) now = (now + two[r-1]*r)%MOD;
    now = (two[l]*now)%MOD;
    now = (now * c[i]);

    ans = (ans + now)%MOD;
  }

  ans = (ans * two[n])%MOD;

  cout << ans << endl;
}

Measured memory_bytes: 3328
N = int(input())
W = []
S = []
for _ in range(N):
    x,y = [int(hoge) for hoge in input().split()]
    wa = x+y
    sa = x-y
    W.append(wa)
    S.append(sa)
T = max(W)- min(W)
Y = max(S)- min(S)
print(max(T,Y))

Measured memory_bytes: 97496
def solve():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input()) // 50
    cnt = 0

    for i in range(a + 1):
        for j in range(b + 1):
            for k in range(c + 1):
                if 10 * i + 2 * j + k == x:
                    cnt += 1

    print(cnt)
solve()

Measured memory_bytes: 3060