akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;

const int M = 100100;

ll n, l, t;
ll x[M];
ll w[M];
ll p[M];
int ans[M];

ll norm(ll x) {
    x %= l;
    if (x < 0)
        x += l;
    return x;
}

void read() {
    cin >> n >> l >> t;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> w[i];
        if (w[i] == 2)
            w[i] = -1;
    }
}

void kill() {
    for (int i = 0; i < n; ++i) {
        p[i] = norm(x[i] + w[i] * t);
    }

    ll step = 0;
    int at = 0;
    for (int i = 0; i < n; ++i)
        if (w[i] == 1) {
            at = i;
            for (int j = 0; j < n; ++j)
                if (w[j] == -1) {
                    ll d = norm(x[j] - x[i]);
                    ll len = 2 * t - d;
                    if (len < 0)
                        continue;
                    step += (len + l - 1) / l;
                }
            break;
        }

    ll x = p[at];
    sort(p, p + n);
    int i = find(p, p + n, x) - p;
    int id = (at + step) % n;
    for (int j = 0; j < n; ++j) {
        ans[i] = id;
        id = (id + 1) % n;
        i = (i + 1) % n;
    }

    for (int i = 0; i < n; ++i)
        if (ans[i] == 0) {
            for (int j = 0; j < n; ++j)
                cout << p[(i + j) % n] << "\n";
            break;
        }
}

int main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  kill();

}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main() {
    ll N, M, V, P;
    cin >> N >> M >> V >> P;

    vector<ll> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];

    sort(a.begin(), a.end(), greater<ll>());
    int ans = P;
    ll total = a[P-1];
    for (int i = P; i < N; i++) {
        //cout << "i=" << i << endl;
        ll noo = i - (P - 1);
        if (N - noo >= V) {
            if (a[i] + M >= a[P - 1])
                ans++;
            //else
              //  break;
        }

        else {
            if (max(a[P-1],(total + M*(V - (N - noo)) + (noo - 1)) / noo) <= a[i] + M)
                ans++;
        }
        total += a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n;
	int i, j, k;
	long long int ans = 0;
	long long int *f;

	scanf("%d", &n);

	f = (long long int *)malloc(n * sizeof(long long int));

	for (i = 1; i <= n; i++)
	{
		for (j = i; j <= n; j+=i)
		{
			f[j]++;
		}
	}

	for (k = 1; k <= n; k++)
	{
		ans += k * f[k];
	}

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

	free(f);
	return 0;
}


Measured memory_bytes: 79596
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
int main(){
    ll T;
    cin >> T;
    for(ll query = 0; query < T; query++){
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        if(A < B || B > D){
            cout << "No";
        }else if(C >= B){
            cout << "Yes";
        }else{
            ll g = gcd(B, D);
            if(B - g + A % g <= C) cout << "Yes";
            else cout << "No";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<cstdlib>
#include<unordered_set>
#include<algorithm>
#include<chrono>
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
//~ #define ii pair	<long long ,long 	long >
#define i64ii pair< long long, pair<int,int> >
#define i64i pair<long long , int >
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define ii pair<int, int > 
#define iii pair<int, ii >	
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;

typedef long long ll;	
typedef vector< int> vi;
typedef long double ld;

typedef unsigned long long ull;
		
typedef  pair <ii, ii > iiii;
typedef vector < ii > vii;

const int MAX = 2100;
const int maxn = 1e6 + 100;




int n,  k, a[maxn];

int main () {
 //~ in
 scanf("%d %d", &k, &n);
 
 
 
 
 for(int i = 0 ;i < n;i++) {
  scanf("%d", &a[i]);
 }
 
 a[n] = k + a[0];
 int g = 0;
 for(int i = 1 ;i <= n;i++) {
  int gap = a[i] -a[i-1];
  g = max ( gap, g );
 }
  
 
 printf("%d\n", k- g);
 
 
 return 0;
}


Measured memory_bytes: 1024
N, W = map(int, input().split())
w_v = [list(map(int, input().split())) for i in range(N)]

w = [w_v[i][0] for i in range(N)]
v = [w_v[i][1] for i in range(N)]

#dp[i+1][j]:i番目までの品物で価値がj以上となるときの重さの総和の最小値
INF = float('inf')
dp = [[INF for j in range(max(v)*N+1)] for i in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for j in range(max(v)*N+1):
        if j >= v[i]:
            dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i])
        else:
            dp[i+1][j] = dp[i][j]

res = 0
for j in range(max(v)*N+1):
    if dp[N][j] <= W:
        res = j
print(res)

Measured memory_bytes: 318648
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int cnt = 0;
        for(int x = 1; x * x <= i; x++) {
            for(int y = 1; y * y + x * x + x * y <= i; y++) {
                int temp = i - x * x - y * y - x * y;
                
                int d = (x + y) * (x + y) + 4 * 1 * temp;
                int t = sqrt(d);
                if(t * t == d) {
                    int num = t - (x + y);
                    if(num > 0 && num % 2 == 0) {
                        // trace(temp, i, x, y, num, t, d);
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3592
n, k = map(int, input().split())
d = list(map(int, input().split()))
all_num = [i for i in range(10)]
not_d = list(set(all_num) - set(d))
not_d_str = [str(i) for i in not_d]
ans = []
for i in range(n, 10 * n):
    if set(list(str(i))).issubset(set(not_d_str)) and i >= n:
        print(i)
        exit()


Measured memory_bytes: 3064
S = input()
#dp[i][four] =: i + 1番目まで見たとき,照合したケツがfourとなるものの総数
dp = [[0 for _ in range(4)] for _ in range(len(S)+1 )]
dp[0][0] = 1
mod = 10**9 + 7
for i in range(len(S)):
    if S[i] == 'A' or S[i] == '?':
        dp[i+1][1] += dp[i][0] 
        for k in range(4): dp[i+1][k] += dp[i][k]
    if S[i] == 'B' or S[i] == '?':
        dp[i+1][2] += dp[i][1]
        for k in range(4): dp[i+1][k] += dp[i][k]
    if S[i] == 'C' or S[i] == '?':
        dp[i+1][3] += dp[i][2]
        for k in range(4): dp[i+1][k] += dp[i][k]
    for k in range(4): dp[i+1][k] %= mod
print(dp[len(S)][3])


Measured memory_bytes: 57180
#include<stdio.h>

int main(void)
{
  int a,b,c,temp;
  scanf("%d",&a);
   scanf("%d",&b);
    scanf("%d",&c);
    if(a>b)
      {temp=a;
    a=b;
    b=temp;
      }
     if(b>c)
      {temp=b;
    b=c;
    c=temp;
      }
      if(a>b)
      {temp=a;
    a=b;
    b=temp;
      }
      printf("%d %d %d\n",a,b,c);
      return 0;
}

Measured memory_bytes: 596
// https://beta.atcoder.jp/contests/abc060

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;

i64 sum_v[4][100 + 1];

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(4 6
2 1
3 4
4 10
3 4
)");
#endif
    int N, W;
    in >> N >> W;

    vector<i64> v[4];
    i64 wi, vi, w1;
    for (int i = 0; i < N; ++i) {
        in >> wi >> vi;
        if (i == 0) w1 = wi;
        v[wi - w1].push_back(vi);
    }

    for (int i = 0; i < 4; ++i) {
        sort(v[i].begin(), v[i].end(), greater<>());
        for (int j = 1; j <= v[i].size(); ++j) {
            sum_v[i][j] += v[i][j - 1] + sum_v[i][j - 1];
        }
    }

    i64 ans = 0;
    for (int a = 0; a <= v[0].size(); ++a) {
        for (int b = 0; b <= v[1].size(); ++b) {
            for (int c = 0; c <= v[2].size(); ++c) {
                for (int d = 0; d <= v[3].size(); ++d) {
                    i64 w_k = (w1 + 0) * a + (w1 + 1) * b + (w1 + 2) * c + (w1 + 3) * d;
                    if (W < w_k) continue;
                    i64 v_k = sum_v[0][a] + sum_v[1][b] + sum_v[2][c] + sum_v[3][d];
                    ans = max(ans, v_k);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read();
int n;
int f[4003], sum[4003], sn[4003], cnt[4003];
char s[4003];

vector<int> e[4003];
void add(int f, int t) { e[f].push_back(t), e[t].push_back(f); }

void dfs(int u, int fa) {
    cnt[u] = s[u] == '1', sum[u] = sn[u] = 0;
    for (int i = 0, v; i < e[u].size(); ++i)
        if ((v = e[u][i]) != fa) {
            dfs(v, u), sum[u] += sum[v] + cnt[v], cnt[u] += cnt[v];
            sum[v] + cnt[v] > sum[sn[u]] + cnt[sn[u]] ? sn[u] = v : 0;
        }
    int v = sn[u], x = sum[v] + cnt[v] - f[v];
    f[u] = (x << 1) <= sum[u] - f[v] ? sum[u] - (sum[u] & 1)
                                     : (sum[u] - f[v] - x << 1) + f[v];
}

int main() {
    n = read(), scanf("%s", s + 1);
    for (int i = 1; i < n; ++i) add(read(), read());
    int tres = 100000000;
    for (int i = 1; i <= n; ++i)
        dfs(i, 0), f[i] == sum[i] ? tres = min(tres, sum[i]) : 0;
    printf("%d\n", tres >= 10000000 ? -1 : tres / 2);
    return 0;
}
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    return x * f;
}

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

int main() {
  using Graph= vector<vector<int>>;

  int N,M;
  cin >> N >> M;

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  Graph gph(N);
  int buf1,buf2;
  for(int j=0; j<M; j++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed

    gph.at(buf1).emplace_back(buf2);
    gph.at(buf2).emplace_back(buf1);
  }

  int ans= 0;
  for(int i=0; i<N; i++){
    bool is_good= true;
    for(auto v:gph.at(i)){
      if(data.at(i) <= data.at(v)){
        is_good= false;
        break;
      }
    }
    if(is_good){ ans++; }
  }

  cout << ans << endl;
}

Measured memory_bytes: 8804
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int sum, ave, n, x, y, i, j, k;
    String str;
    char[] ch;

    sum = 0; ave = 0; n = 0;
    for(;sc.hasNext();){
      str = sc.next();
      ch = new char[str.length()];
      for(j = 0;j < str.length();j++)ch[j] = str.charAt(j);
      x = 0; y = 0; k = 0;

      for(j = 0;j < str.length();j++){
        if(ch[j] == ','){
          x = readint(ch, 0, j);
          k = ++j; break;
        }
      }
      y = readint(ch, k, str.length());

      sum += x * y; ave += y; n++;
    }

    out.println(sum); out.println((int)(0.5 + ((double)ave / (double)n)));

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int readint(char[] ch, int l, int r){
    int i, d, res;
    d = 1; res = 0;
    for(i = r - 1;i >= l;i--){
      res += d * (int)(ch[i] - '0');
      d *= 10;
    }
    return res;
  }
}

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

using namespace std;
typedef long long LL;
int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
const int N = 250001, K = 401;
const int mod = 1e9 + 7;
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(int x) {
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int jc[K], inv[K], a[N];
int pre[K], f[N][K], g[N][K];

int pow_mod(int a, int k) {
	int ans = 1;
	while(k) {
		if(k & 1) ans = (LL)ans * a % mod;
		a = (LL)a * a % mod, k /= 2;
	} return ans;
}

int add(int x, int y) {
	x += y;
	return x >= mod ? x - mod : x;
}

int dec(int x, int y) {
	x -= y;
	return x < 0 ? x + mod : x;
}

int main() {
	int n = read(), k = read(), m = read();
	for(int i = 1; i <= m; i++) a[i] = read();
	jc[0] = 1; for(int i = 1; i <= k; i++) jc[i] = (LL)jc[i - 1] * i % mod;
	inv[k] = pow_mod(jc[k], mod - 2); for(int i = k; i >= 1; i--) inv[i - 1] = (LL)inv[i] * i % mod;
	int ans = (LL)pow_mod(k, n - m) * (n - m + 1) % mod;
	bool bk1 = 0, bk2 = 0;
	for(int i = 1; i <= m - k + 1; i++) {
		bool gg = 0;
		memset(pre, 0, sizeof(pre));
		for(int j = 1; j <= k; j++) {
			int x = i + j - 1;
			if(pre[a[x]]) {gg = 1; break;}
			pre[a[x]] = 1;
		} if(!gg) {bk1 = 1; break;}
	} memset(pre, 0, sizeof(pre));
	for(int i = 1; i <= m; i++) {
		if(pre[a[i]]) bk2 = 1;
		pre[a[i]] = 1;
	} if(bk1);
	else if(!bk2){
		f[0][0] = 1;
		for(int i = 1; i <= n; i++) {
			for(int j = _min(k - 1, i); j >= 1; j--) {
				f[i][j] = add(f[i - 1][j], (LL)dec(f[i - 1][j - 1], f[i - 1][j]) * (k - (j - 1)) % mod);
				g[i][j] = add(g[i - 1][j], (LL)dec(g[i - 1][j - 1], g[i - 1][j]) * (k - (j - 1)) % mod);
				if(j >= m) g[i][j] = add(g[i][j], f[i][j]);
			} for(int j = k - 1; j >= 1; j--) f[i][j - 1] = add(f[i][j], f[i][j - 1]), g[i][j - 1] = add(g[i][j], g[i][j - 1]);
		} ans = dec(ans, (LL)g[n][0] * inv[k] % mod * jc[k - m] % mod);
	} else {
		int st, ed;
		memset(pre, 0, sizeof(pre));
		for(st = 1; st <= m; st++) {
			if(pre[a[st]]) break;
			pre[a[st]] = 1;
		} memset(pre, 0, sizeof(pre));
		for(ed = 1; ed <= m; ed++) {
			if(pre[a[m - ed + 1]]) break;
			pre[a[m - ed + 1]] = 1;
		} st--, ed--;
		for(int i = 0; i <= st; i++) f[0][i] = 1;
		for(int i = 0; i <= ed; i++) g[0][i] = 1;
		for(int i = 1; i <= n; i++) {
			for(int j = k - 1; j >= 1; j--) {
				f[i][j] = add(f[i - 1][j], (LL)dec(f[i - 1][j - 1], f[i - 1][j]) * (k - (j - 1)) % mod);
				g[i][j] = add(g[i - 1][j], (LL)dec(g[i - 1][j - 1], g[i - 1][j]) * (k - (j - 1)) % mod);
			} for(int j = k - 1; j >= 1; j--) f[i][j - 1] = add(f[i][j], f[i][j - 1]), g[i][j - 1] = add(g[i][j], g[i][j - 1]);
		} for(int i = 0; i <= n - m; i++) ans = dec(ans, (LL)f[i][0] * g[n - m - i][0] % mod);
	} put(ans), puts("");
	return 0;
}


Measured memory_bytes: 82304
n = int(input())
lis = {}
X =""
for a in range(1,5):
    for b in range(1,4):
        for c in range(1,11):
            fn = lambda A,B,C,D : lis.setdefault(f"{str(A)} {str(B)} {str(C)}",int(D))
            fn(a,b,c,0)
for x in range(n):
    b, f, r, v = map(int, input().split())
    lis[f"{str(b)} {str(f)} {str(r)}"] += v
for a in range(1,5):
    for b in range(1,4):
        for c in range(1,11):
            X += " " + str(lis[f"{str(a)} {str(b)} {str(c)}"])
        print(X)
        X = ""
    if a == 4:
        break
    print("#"*20)




Measured memory_bytes: 5620
#include <iostream>

using namespace std;

int main()
{
    string s[] = {"Sunny","Cloudy","Rainy"};
    string input;
    cin >> input;
    if(input == s[0]){
      cout << s[1] << endl;
    }else if( input== s[1]){
      cout << s[2] << endl;
    }else {
      cout << s[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// 20151014
// ??????????????§??????. ?£??????§??????????????¨?????¬???????£??????????????????¶????????\???.




#include<stdio.h>
#include<string.h>



int main() {
  int i;
  int count;;
  char st[200]; // 20 ????????¨




  /* ?????????????????? */
  fgets(st, sizeof(st), stdin);




  /*???????????????????????¨??? */
  for (i = strlen(st) - 2; i >= 0; i --) { // -2 ???, ???????????? `\0` ??¨ ???????????? `\n` ?????????
    printf("%c", st[i]);
  }
  printf("\n");




  /* ?????? */
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
 
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define INF 1000000000000000
 
 
int main()
{
  SPEED;
    ll h,w,n;
    cin>>h>>w>>n;
    vector<pll> height,width;
    ll a[h+1]={0},b[w+1]={0};
    ll i,j,k;
    map<pll,ll> m;
    for(i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        m[{x,y}]=1;
        a[x]++;
        b[y]++;
    }
    for(i=1;i<h+1;i++)height.pb({a[i],i});
    for(i=1;i<w+1;i++)width.pb({b[i],i});
    sort(height.begin(),height.end());
    reverse(height.begin(),height.end());
    sort(width.begin(),width.end());
    reverse(width.begin(),width.end());
    //cout<<width.size()<<" "<<height.size()<<endl;
    //for(i=0;i<height.size();i++)cout<<height[i].ff<<" "<<height[i].ss<<endl;
     //for(i=0;i<width.size();i++)cout<<width[i].ff<<" "<<width[i].ss<<endl;
    if(m[{height[0].ss,width[0].ss}]!=1)
    {
        cout<<height[0].ff+width[0].ff;
    }
    else
    {
       for(i=1;i<(ll)height.size();i++)
       {
           if(height[0].ff==height[i].ff && m[{height[i].ss,width[0].ss}]!=1)
           {
               cout<<height[0].ff+width[0].ff;return 0;
           }
       }
        for(i=1;i<(ll)width.size();i++)
       {
           if(width[0].ff==width[i].ff && m[{height[0].ss,width[i].ss}]!=1)
           {
               cout<<height[0].ff+width[0].ff;return 0;
           }
       }
        cout<<height[0].ff+width[0].ff-1;
       
    }
}

Measured memory_bytes: 43680
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<assert.h>

#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)>(b))?(b):(a)

typedef long long ll;
typedef unsigned long long ull;

int main(void)
{
    char s[4];
    scanf("%s", s);

    if (s[0] == '7' || s[1] == '7' || s[2] == '7')
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}

Measured memory_bytes: 1736
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <array>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <map>
using namespace std;

int main()
{
	string str;
	cin >> str;

	if (str == "SUN")
		cout << "7";
	else if (str == "SAT")
		cout << "1";
	else if (str == "FRI")
		cout << "2";
	else if (str == "THU")
		cout << "3";
	else if (str == "WED")
		cout << "4";
	else if (str == "TUE")
		cout << "5";
	else if (str == "MON")
		cout << "6";
}

Measured memory_bytes: 3552
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, q = MI()
    e = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = MI1()
        e[a].append(b)
        e[b].append(a)

    point = [0]*n
    for _ in range(q):
        p, x = MI()
        p -= 1
        point[p] += x

    # print(point)

    def dfs(v, v_pre=-1, pp=0):
        # ans = pp + point[v]
        # print(v)
        point[v] += pp
        for nv in e[v]:
            if nv == v_pre: continue
            dfs(nv, v, point[v])

    dfs(0)
    printlist(point, ' ')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 284104
#include <stdio.h>

int main(void)
{
	int n;
	while (scanf("%d", &n) != EOF) {
		int digit = 512, binary[10], idx = 9, last = -1;
		   for (; digit > 0; digit /= 2) {
			   if (n - digit >= 0) { if (last < 0) last = idx; binary[idx--] = 1; n -= digit;}
			   else				binary[idx--] = 0;
		   }
	
		   for (idx = 0, digit = 1; idx < 10; idx++, digit *= 2) {
			   if (binary[idx] == 1) {
				   printf("%d", binary[idx] * digit);
				   idx == last ? putchar('\n') : putchar(' ');
			   }
		   }
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long
    #define int long long 
    #define ull unsigned long long 
    #define ld long double
    #define sb __builtin_popcount
    #define vi vector<int>
    #define vc vector<char>
    #define ii pair<int, int>
    #define pq priority_queue<ii, vector<ii>, greater<ii>>
    #define vii vector<ii>
    #define sz(a) int((a).size())
    #define f(a, b) for (int i = a; i < b; i++)
    #define fr(a, b) for (int i = a - 1; i >= b; i--)
    #define tr(x, m) for (auto x : m)
    #define in(a, b) (b.find(a) != string::npos)
    #define minin(a) *min_element(all(a))
    #define maxin(a) *max_element(all(a))
    #define X first
    #define Y second
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define rall(v) reverse(v.begin(), v.end())
    #define unq(v) v.erase(unique(all(v)), v.end())
    #define el "\n"
    #define mx3(a, b, c) max(max(a, b), c)
    #define mn3(a, b, c) min(min(a, b), c)
    #define S(v) accumulate(all(v), (ll)0)
    #define SP(n) cout.precision(n)
    const ld PI = atan(1.0) * 4.0;
    const ll MOD = 1e9 + 7;
    const ll INF = 1e18;
    const ld EPS = 0.0000001;
    const ll MD = 998244353;
    
    int32_t main() {
        fio;
        SP(10);
        int k;
        cin>>k;
        int a,b;
        cin>>a>>b;
        for(int i=a;i<=b;i++){
            if(i%k==0){
                cout<<"OK"<<el;
                return 0;
            }
        }
         cout<<"NG"<<el;
        return 0;
    }


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
// #include <string>
// #include <queue>
// #include <cmath>
// #include <set>
// #include <map>
// #include <iomanip>
// #include <list>
// #include <cassert>

#define MOD 1000000007
// #define INF 1000000001
#define S 100001

using namespace std;
typedef unsigned long long ull;
// typedef long long ll;

void p_() {
    cout << "\n";
}
template<class Head, class... Body>
void p_(Head head, Body... body) {
    cout << head << ",";
    p_(body...);
}


int main(int argc, char const *argv[]) {
    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(), greater<int>());
    int ans = 0;
    for (int i = 0; i < K; ++i) {
        ans += l[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

struct UnionFind {
	vector< int > data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return (false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k) {
		if (data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k) {
		return (-data[find(k)]);
	}
};

int main() {

	LL n, m; cin >> n >> m;

	vector<LL> a(m);
	vector<LL> b(m);

	LL ans = (n)*(n - 1) / 2;

	for (int i = m-1; i >=0; i--) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}

	UnionFind uf(n);

	vector<LL> ret;

	for (int i = 0; i < m; i++) {
		
		ret.push_back(ans);

		if (uf.find(a[i]) != uf.find(b[i])) {
			LL sa = uf.size(a[i]);
			LL sb = uf.size(b[i]);
			LL tmp = sa * sb;
			ans -= tmp;
		}
		
		uf.unite(a[i], b[i]);

		
	}

	for (int i = m-1; i >=0; i--) {
		cout << ret[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4212
import java.util.*;

public class Main {
	public static void main(String[] args) {
      Scanner sc =new Scanner(System.in);
      int AB = sc.nextInt();
      int BC = sc.nextInt();
      int CA = sc.nextInt();
      int max = Math.max(Math.max(AB,CA),Math.max(CA,BC));
      int min = Math.min(Math.min(AB,CA),Math.min(CA,BC));
      int middle = AB + BC + CA -max - min;
      System.out.println(min * middle / 2); 
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include<string>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include <cctype>
#include <cstdio>
#define endl '\n'
#define Bedoazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

const long long N = 1e5 + 5;


int main() {

    Bedoazim

    long long n, k, arr[N];

    cin >> n >> k;

    for (int i = 0; i< n; i++) {

        cin >> arr[i];

    }
    long long min = 1e18;

    sort(arr, arr + n);

    for (int i = 0; i <= n - k; i++) {


        if (arr[i + (k-1)] - arr[i] < min) {

            min = arr[i + (k-1)] - arr[i];
        }

    }

    cout << min;

}

Measured memory_bytes: 1024
#include <iostream>
#define Nfor(N) for(int i=0;i<N;i++)
using namespace std;
typedef long long ll;

const int mod = 1000000007;

int pow(int a, int b){
  	int ret = 1;
  	Nfor(b) ret=(1LL*ret*a)%mod;
  	return ret;
}

int main(){
  	int N;
  	cin >> N;
  	ll ans = pow(10, N);
  	ans -= 2LL * pow(9, N);
  	ans += 1LL * pow(8, N);
  	ans%=mod;
  	if(ans<0) ans+=mod;
  	cout << ans << endl;
}


Measured memory_bytes: 3572
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println((1..n).map {
        var x = sc.nextInt()
        var count = 0
        while (x > 0 && x % 2 == 0) {
            x /= 2
            count++
        }
        count
    }.sum())
}

Measured memory_bytes: 39164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  vector<vector<int>>A(N+1);
  vector<int>B(M);
  vector<int>C(M);
  for(int i=0;i<M;i++){
    cin>>B[i]>>C[i];
    A[B[i]].push_back(C[i]);
  }
  for(int i=0;i<=N;i++)sort(A[i].begin(),A[i].end());
  for(int i=0;i<M;i++){
    int a=B[i];
    int b=lower_bound(A[a].begin(),A[a].end(),C[i])-A[a].begin()+1;
    cout<<a/100000<<(a/10000)%10<<(a/1000)%10<<(a/100)%10<<(a/10)%10<<a%10<<b/100000<<(b/10000)%10<<(b/1000)%10<<(b/100)%10<<(b/10)%10<<b%10<<endl;
  }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    vector<int> a(3);
    
    for(int i = 0; i < 3; i++)
    {
        cin>>a[i];
    }
    sort(all(a));
    cout<<a[0]+a[1]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int n, b, f, r, v;
    int buildings[4][3][10];
 
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                buildings[i][j][k] = 0;
            }
        }
    }
 
     
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> b >> f >> r >> v;
        buildings[b-1][f-1][r-1] += v;
    }
 
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                cout << " " << buildings[i][j][k];
            }
            cout << endl;
        }
        if(i!=3){
            cout << "####################" << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 1160
def main():
    import sys
    input = sys.stdin.readline

    H, W, D = map(int, input().split())
    B = [0] * (H * W)

    C = [None] * (H * W)
    for r in range(H):
        for c, cell in enumerate(int(x) - 1 for x in input().split()):
            C[cell] = r, c

    for x in range(D, H * W):
        L, R = x - D, x
        lr, lc = C[L]
        rr, rc = C[R]
        B[R] = B[L] + abs(rr - lr) + abs(rc - lc)

    ans = []
    Q = int(input())
    for _ in range(Q):
        L, R = (int(x) - 1 for x in input().split())
        ans.append(B[R] - B[L])

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 19988
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_9x9(void) {

	int A, B; cin >> A >> B;
	
	if (A > 9 || B > 9) cout << -1 << flush;
	else				cout << A * B << flush;
	return;
}

void B_81(void) {

	int N; cin >> N;

	for (int loop = 9; loop > 0; loop--) {
		if (N % loop == 0) {
			N /= loop;
			break;
		}
	}
	cout << ((N <= 9) ? "Yes" : "No") << flush;
	return;
}

void C_Walk_on_Multiplication_Table(void) {

	long long N; cin >> N;
	int center = (int)pow(N, 0.5);

	for (int loop = center; loop > 0; loop--) {
		if (N % loop == 0) {
			cout << loop + N / loop - 2 << flush;
			return;
		}
	}
	for (int loop = center; loop <= N; loop++) {
		if (N % loop == 0) {
			cout << loop + N / loop - 2 << flush;
			return;
		}
	}
	return;
}

int main(void) {

	//A_9x9();
	//B_81();
	C_Walk_on_Multiplication_Table();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n,a,b;
   cin>>n>>a>>b;
   int count=0;
   for(int i=1;i<n+1;i++){
      int sum=0;
      int s=i;
      do{
         sum+=s%10;
         s=s/10;
      }while(s!=0);
     if(a<=sum && sum<=b) count+=i;  
   }
   cout<<count;
   


   
   return 0;
}

Measured memory_bytes: 256
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, x = ns()
    a = na()

    ans = 0

    for i in range(1, n):
        tmp = a[i - 1] + a[i]
        if tmp > x:
            a[i] = max(0, a[i] - (tmp - x))
            ans += tmp - x

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24100
import fractions
A,B,C,D = map(int,input().split())
#(B-B以下のCorDの倍数)-(A-1-A-1以下のCorDの倍数)
l = C*D//fractions.gcd(C,D)
x = B-(B//C+B//D-B//l)
y = (A-1)-((A-1)//C+(A-1)//D-(A-1)//l)
print(x-y)

Measured memory_bytes: 10496
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[][] c = new char[3][3];
    for (int i = 0; i < 3; i++) {
      String s = sc.next();
      for (int j = 0; j < 3; j++) {
        c[i][j] = s.charAt(j);
      }
    }
    
    System.out.println(""+c[0][0]+c[1][1]+c[2][2]);
  }
}

Measured memory_bytes: 21716
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

map <pii,int> mp; 
map <int,int> r,c; 

inline void solve(){ 
    int h,w,t,rr=0,cc=0; cin>>h>>w>>t; 
    for (int i=0;i<t;i++){ 
        int a,b; 
        cin>>a>>b; 
        r[a]++; c[b]++; 
        rr = max(rr,r[a]);
        cc = max(cc,c[b]);
        mp[{a,b}] = 1; 
    } 
    int ans = rr+cc-1 ; 
    vector <int> row,col;
    for (auto &it: r)
        if (it.ss==rr) row.pb(it.ff);
    for (auto &it: c)
        if (it.ss==cc) col.pb(it.ff);
    for (int i=0;i<sz(row);i++){
        bool ok=false;
        for (int j=0;j<sz(col);j++){
            if (!mp[{row[i],col[j]}]){
                ans = rr + cc;
                ok=true;
                break;
            }
        }
        if (ok) break;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 67908
#include <stdio.h>
#include <stdlib.h>
#define N 100000

int compare(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int power(int a, int b)
{
    if (b == 0)
        return 1;
    else
        return a * power(a, b - 1) % 1000000007;
}

int main()
{
    int n, i;
    int flag = 1;
    int a[N];
    scanf("%d\n", &n);
    for (i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), compare);
    if (n % 2 == 0)
        for (i = 0; i < n / 2; i++)
        {
            if (a[2 * i] == 2 * i + 1 && a[2 * i + 1] == 2 * i + 1)
                continue;
            else
            {
                flag = 0;
                break;
            }
        }
    else
        for (i = 0; i < (n + 1) / 2; i++)
        {
            if (i == 0)
            {
                if (a[i] == 0)
                    continue;
            }
            else if (a[2 * i - 1] == 2 * i && a[2 * i] == 2 * i)
                continue;
            else
            {
                flag = 0;
                break;
            }
        }
    if (flag)
    {
        if (n % 2)
            printf("%d\n", power(2, (n - 1) / 2));
        else
            printf("%d\n", power(2, n / 2));
    }
    else
        printf("0\n");
}

Measured memory_bytes: 1396
#include<iostream>
#include<string>
using namespace std;
string a,b;
int main()
{
	int s=1001;
	cin>>a>>b;
	int l1=a.size(),l2=b.size();
	int i=0;
	while(i<l1-l2+1)
	{
		int sum=0;
		int i1=i;
		for(int j=0;j<l2;j++)
		{
			if(a[i1]!=b[j])
				sum++;
			i1++;	
		}
		s=min(s,sum);
		i++;
	}
	cout<<s<<endl;
	return 0;		
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

bool isPrime(int n) {
    bool flag = true;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            flag = false;
            break;
        }
    }
    return flag;
}

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

    repd(i, X, 1e6) {
        if (isPrime(i)) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 5002

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}
  private:
    bool first;
    string separator;
};

template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}


int main(){
FAST_READ;
ll n;
cin>>n;
if(n%n==0 && n%2==0)cout<<n<<endl;
else cout<<n*2<<endl;




return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;

const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};

int main(){
	//ios_base::sync_with_stdio(false);
	int H, W, ans=0;
	string S[100];

	cin >> H >> W;
	rep(i,H) cin >> S[i];

	int block = 0;
	rep(i,H) rep(j,W) if( S[i][j] == '#' ) block++;

	queue<pii> que;
	que.emplace(0,0);
	int d[105][105]={};
	d[0][0] = 1;
	while( que.size() ){
		int x = que.front().X;
		int y = que.front().Y;
		que.pop();
		rep(k,4){
			int nx = x + vx[k];
			int ny = y + vy[k];
			if( nx >= 0 && nx < W && ny >= 0 && ny < H &&
					S[ny][nx] != '#' && d[nx][ny] == 0 ){
				d[nx][ny] = d[x][y] + 1;
				que.emplace(nx, ny);
			}
		}
	}

	if( d[W-1][H-1] == 0 ){
		cout << -1 << endl;
		return 0;
	}

	ans = H * W - d[W-1][H-1] - block;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//#if !defined(YCM) && 1
//#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx")
////#pragma GCC optimize ("O3")
////#pragma GCC target ("sse4")
//#include <stdio.h>
//#endif
#include <unistd.h>
//#pragma GCC diagnostic ignored "-Wunused-result"
//#pragma GCC diagnostic ignored "-Wunused-function"
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define clr(a) memset(a,0,sizeof(a))
#define clr_(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
#define pii pair<int,int>
#define eps 1e-9
#define inf INT_MAX
#define pi acos(-1.0)
#define ff first
#define ss second
#define INF (ll)1e18
#define m_p make_pair
#define all(v) v.begin(),v.end()
int fx[]={0,0,-1,1,-1,1,1,-1};
int fy[]={1,-1,0,0,1,1,-1,-1};
ll lcm(ll a,ll b){return (a/__gcd(a,b))*b;}
ll bigmod(ll a,ll p,ll mod){ll ans=1;while(p){if(p&1)ans=ans*a%mod;a=a*a%mod;p>>=1;}return ans;}
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0){ll y=power(x,n/2);return y*y;}else return x*power(x,n-1);}

#ifdef shaft
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
const int N=(int)1e6+5;
const int mod=(int)1e9+7;
int n;
int arr[5][110];
int dp[5][110];
int call(int i, int j){
    if(i == 1 && j == n-1)
        return arr[i][j];
    int &res = dp[i][j];
    if(res != -1)
        return res;
    res = 0;
    int p1 = 0, p2 = 0;
    if(i+1 <= 1)
        p1 = call(i+1, j)+arr[i][j];
    if(j+1 < n)
        p2 = call(i,j+1)+arr[i][j];
    res = max(p1,p2);
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(100); cout.tie(nullptr); cin.tie(nullptr);
    #ifdef shaft
        freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif ///shaft
    cin >> n;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++)
            cin >> arr[i][j];
    }
    clr_(dp);
    int res = call(0,0);
    cout << res << endl;
    return 0;
}





Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
public class Main {





public static void main(String[] args)
{
	Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	if(a+b>=24) {
		System.out.println(-24+(a+b));
	}else {
		System.out.println(a+b);
	}

	

}

}




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

int main(int argc, char **argv)
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	std::cout << string(dy, 'U') << string(dx, 'R');

	std::cout << string(dy, 'D') << string(dx, 'L');

	cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';

	cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U' << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int main(){
  ll n;cin>>n;
  std::vector<ll> a(n+1);rep(i,n)cin>>a[i];
  ll ans=0,num=0;
  rep(i,n){
    if(a[i+1]==a[i]){
      num++;
    }else{
      num++;
      ans+=num/2;
      num=0;
    }
  }
  cout<<ans<<endl;
}










Measured memory_bytes: 256