akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

#define WIDTH 5
#define MAX_HEIGHT 10
#define CHAIN_SIZE 3
#define EXTINCT -1//?¶?????????????
#define EMPTY -2//???????????¨?????????

void down(int h,  int stones[MAX_HEIGHT][WIDTH]){

  for(int i=0;i<h;i++){
    for(int j=0;j<WIDTH;j++){
      if(stones[i][j] == EXTINCT){
	int c;
	for(c=i; c<h-1; c++){
	  if(stones[c+1][j] == EMPTY){
	    break;
	  }	  
	  stones[c][j] = stones[c+1][j];
	}

	while(c<h){
	  stones[c][j] = EMPTY;
	  c++;
	}
      }
      
      if(stones[i][j] == EXTINCT){
	//???????????¨???????????????????????????EXTINCT?????£????????????????????????
	i--;
      }
    }
  }
  
}

int main(){
  int h;
  int stones[MAX_HEIGHT][WIDTH];
  cin>>h;

  while(h != 0){
    int ans = 0;
    for(int i=h-1;i>=0;i--){
      for(int j=0;j<WIDTH;j++){
	cin>>stones[i][j];
      }
    }


    bool finish = false;

    while(!finish){
       
      bool chained = false;
      for(int i=0;i<h;i++){
	int s = 0;
	int e = 0;
	for(int j=0;j<WIDTH-1;j++){
	  if(stones[i][j]==stones[i][j+1] && stones[i][j]!=EXTINCT && stones[i][j]!=EMPTY){
	    e++;
	    if(e-s+1 >= CHAIN_SIZE){//3??\????????£?¶??????????
	      int num = stones[i][s];
	      int c = 0;
	      chained = true;
	      while(s<WIDTH && stones[i][s] == num){
		stones[i][s] = EXTINCT;
		s++;
		c++;
	      }
	      ans += c*num;
	      e=s;
	    }
	  }else{
	    s = j+1;
	    e = j+1;
	  }
	}
	
      }

      down(h,stones);
      
      if(!chained){
	finish = true;
      }
    }
    
    cout<<ans<<endl;
    cin>>h;
  }
  

  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
signed main() {
	int h, w;
	cin >> h >> w;
	if (h == 1 || w == 1)cout << 1 << endl;
	else cout << (h * w + 1) / 2 << endl;
	ggr
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int d[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&d[i]);
    }
    int count = 0;
    bool e[n];
    for(int i = 0; i < n; i++){
        e[i] = true;
    }
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(e[i] == true && e[j] == true && d[i] == d[j]){
                count++;
                e[j] = false;
            }
        }
    }
    printf("%d\n",n - count);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 3005;
const int MOD = 998244353;

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int n, s;
int a[N], store[N];
int cache[N][N];

int dp(int idx, int s)
{
	if(s < 0)
		return 0;
	if(s == 0)
		return store[idx];
	if(idx > n)
		return 0;
	int &ans = cache[idx][s];
	if(ans != -1)
		return ans;
	ans = 2 * dp(idx + 1, s) + dp(idx + 1, s - a[idx]);
	ans %= MOD;
	return ans;

}

int32_t main()
{
	memset(cache, -1, sizeof(cache));
	cin >> n >> s;
	for(int i = 0; i <= n + 2; i++)
		store[i] = pow(2, n + 1 - i, MOD);
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = dp(1, s);
	cout << ans;
	return 0;
}

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

using namespace std;

typedef long long ll;

const int N=100000;
int n,v[N+5];
int sol=0;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i+1];
    n+=2;
    for(int i=2;i<=n;i++)
        sol+=abs(v[i]-v[i-1]);
    for(int i=2;i<n;i++){
        cout<<sol-abs(v[i]-v[i-1])-abs(v[i+1]-v[i])+abs(v[i-1]-v[i+1])<<"\n";
    }
    return 0;
}
/**



**/


Measured memory_bytes: 1664
#!/usr/bin/env python3

n, k = map(int, input().split())
h = [0 for _ in range(n)]
for i in range(n):
    h[i] = int(input())

h = sorted(h)
ans = 1001001001
for i in range(n-k+1):
    ans = min(ans, h[i+k-1]-h[i])

print(ans)


Measured memory_bytes: 8284
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define ff first
#define ss second
#define int long long 
#define endl "\n"
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	

const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
int n ;

void solve(){
	ld r;
	cin >> r;
	ld ans;
	cout << fixed << setprecision(10);
	ans = 2* 22 * r / 7;
	cout << ans << endl;
}

int32_t main(){
	FAST;
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = ReadInts();
            var ans = 3;
            if (abc[0] == abc[1]) ans--;
            if (abc[0] == abc[2]) ans--;
            if (abc[1] == abc[2]) ans--;
            if (ans == 0) ans = 1;
            WriteLine(ans);
        }
       

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 11092
'use strict'

function main(s) {

  const N = Number(s);

  let mod = 1;
  let i = 1;

  while (i <= N) {
    mod = (mod * i) % 1000000007;
    i += 1;
  }

  console.log(mod);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9164
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()

using namespace std;

vector<int> v[100001];

int main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    repf(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
    }
    int st,t;
    cin>>st>>t;
    set<int> s[3];
    int d[3][n+1];
    memset(d,0,sizeof d);
    queue<pair<int,int>> q;
    q.push({st,0});
    d[0][st]=0;
    while(!q.empty())
    {
        int u=q.front().fi;
        int id=q.front().se;
        q.pop();
        for(auto it:v[u])
        {
            if(s[(id+1)%3].find(it)!=s[(id+1)%3].end()) continue;
            s[(id+1)%3].insert(it);
            d[(id+1)%3][it]=d[id][u]+1;
            q.push({it,(id+1)%3});
        }
    }
    if(!d[0][t]) cout<<-1<<endl;
    else cout<<d[0][t]/3<<endl;
}
 

Measured memory_bytes: 20992
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int h, w;
string a[200];
int dp[200][200][200][2];
int dp2[200][200][200][2];
int s[200][200];
int count(int i, int j, int k, int l){
	return s[j+1][l+1]-s[i][l+1]-s[j+1][k]+s[i][k];
}
int main()
{
	cin>>h>>w;
	for(int i=0; i<h; i++) cin>>a[i];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			s[i+1][j+1]=s[i+1][j]+s[i][j+1]-s[i][j]+(a[i][j]=='#');
		}
	}
	for(int i=0; i<h; i++){
		for(int j=i; j<h; j++){
			int l=w-1;
			for(int k=w-1; k>=0; k--){
				while(l>=k){
					int x=count(i, j, k, l);
					if(x!=0 && x!=(j-i+1)*(l-k+1)){
						l--;
					}else{
						break;
					}
				}
				dp[i][j][k][0]=l+1;
			}
		}
	}
	if(dp[0][h-1][0][0]==w){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0; i<w; i++){
		for(int j=i; j<w; j++){
			int l=h-1;
			for(int k=h-1; k>=0; k--){
				while(l>=k){
					int x=count(k, l, i, j);
					if(x!=0 && x!=(j-i+1)*(l-k+1)){
						l--;
					}else{
						break;
					}
				}
				dp2[i][j][k][0]=l+1;
			}
		}
	}
	for(int t=1; t<30; t++){
		auto check=[&](int i, int j, int k, int l){
			int l1=dp[i][j][k][(t&1)^1];
			if(l1>l) return true;
			if(dp[i][j][l1][(t&1)^1]>l) return true;
			int l2=dp2[k][l][i][(t&1)^1];
			if(l2>j) return true;
			if(dp2[k][l][l2][(t&1)^1]>j) return true;
			return false;
		};
		for(int i=0; i<h; i++){
			for(int j=i; j<h; j++){
				int l=w-1;
				for(int k=w-1; k>=0; k--){
					while(l>=k){
						if(check(i, j, k, l)) break;
						else l--;
					}
					dp[i][j][k][t&1]=l+1;
				}
			}
		}
		if(dp[0][h-1][0][t&1]==w){
			cout<<t<<endl; return 0;
		}
		for(int i=0; i<w; i++){
			for(int j=i; j<w; j++){
				int l=h-1;
				for(int k=h-1; k>=0; k--){
					while(l>=k){
						if(check(k, l, i, j)) break;
						else l--;
					}
					dp2[i][j][k][t&1]=l+1;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 118912
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>


typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

int main() {
	ll a, b;
	while (true) {
		a = b = -1;
		cin >> a >> b;
		if (a == -1 && b == -1) {
			break;
		}
		ll tmp = a + b;
		if (tmp == 0) {
			cout << 1 << endl;
			continue;
		}
		ll ans = 0;
		while (tmp > 0) {
			ans++;
			tmp /= 10;
		}
		cout << ans << endl;
		
	}
}



Measured memory_bytes: 2984
#include<stdio.h>
int main(){
     
    int a, i[1000]={}, b, c;
    char mozi[1001]={};
    for(a=0;a<10000;a++){
    scanf("%s", mozi);
        if(mozi[0]=='0'){break;}
        for(b=0;b<1001;b++){
             
            i[a]+=mozi[b]-'0';
            if(mozi[b+1]=='\0')break;
             
        }
    }
    for(c=0;c<a;c++){
        printf("%d\n",i[c]);
    }
    return 0;
}


Measured memory_bytes: 2132
import java.util.Arrays;
import java.util.Optional;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Point[] blues = new Point[n], reds = new Point[n];
			IntStream.range(0, n).forEach(i -> reds[i] = new Point(scanner.nextInt(), scanner.nextInt()));
			IntStream.range(0, n).forEach(i -> blues[i] = new Point(scanner.nextInt(), scanner.nextInt()));
			Arrays.sort(blues, (a, b) -> a.x - b.x);
			System.out.println(IntStream.range(0, n).map(i -> {
				Optional<Point> first = Arrays.stream(reds)
						.filter(point -> (!point.visited) && (point.x < blues[i].x) && (point.y < blues[i].y))
						.sorted((a, b) -> b.y - a.y).findFirst();
				if (first.isPresent()) {
					first.get().visited = true;
					return 1;
				} else {
					return 0;
				}
			}).sum());
		}
	}

	/**
	 * 点を表すクラス
	 */
	private static class Point {
		/** X座標 */
		int x;
		/** Y座標 */
		int y;
		/** すでにペアリングしているかどうか */
		boolean visited = false;

		/**
		 * コンストラクタ
		 * 
		 * @param x
		 * @param y
		 */
		Point(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}
	}
}


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

using namespace std;

int main() {
	int yes = 1;
	string s ="";
	cin >> s;
	for (int i=0; i<s.size() && yes; i++) {
		if (i%2==0) {
			if (s[i]!='R' && s[i]!='U' && s[i]!='D') yes = 0;
		}
		else {
			if (s[i]!='L' && s[i]!='U' && s[i]!='D') yes = 0;
		}
	}
	if (yes) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  int n;
  n = S.size();
  
  if(n <= K)
    cout << S << endl;
  
  else{
    S.erase(K);
    cout << S << "..." << endl;
  }
}


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k;
	vector<int> h(n);
	for (int i=0; i<n; i++) 
		cin>>h[i];
	sort(h.rbegin(),h.rend());
	long long ret=0; 
	for (int i=k; i<n; i++)
		ret+=h[i];
	cout<<ret<<endl;
	return 0;
}

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

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

inline bool test_bit(unsigned S, int i) {
    return (i >= 0) ? ((S >> i) & 1) : false;
}

int best_splits(
    const vector<vector<bool>>& choco,
    int H, int W, int K,
    unsigned S
) {
    vector<int> group(H);
    int current_group = 0;
    REP(y, H) {
        if (test_bit(S, y-1)) { current_group++; }
        group[y] = current_group;
    }
    int group_count = current_group + 1;
    vector<int> n_whites(group_count);

    int v_splits = 0;
    REP(x, W) {
        REP(y, H) if (choco[y][x]) {
            n_whites[group[y]]++;
        }
        bool should_split = any_of(ALL(n_whites), [K](int n) { return n > K; });
        if (should_split) {
            v_splits++;
            fill(ALL(n_whites), 0);
            REP(y, H) if (choco[y][x]) {
                n_whites[group[y]]++;
            }
            bool impossible = any_of(ALL(n_whites), [K](int n) { return n > K; });
            if (impossible) {
                return numeric_limits<int>::max();
            }
        }
    }

    return __builtin_popcount(S) + v_splits;
}

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);

    int H, W, K; cin >> H >> W >> K;
    vector<vector<bool>> choco(H, vector<bool>(W));
    REP(y, H) REP(x, W) {
        char s; cin >> s;
        choco[y][x] = s == '1';
    }

    int ans = numeric_limits<int>::max();
    for (unsigned S = 0; S < (unsigned)(1 << (H-1)); ++S) {
        int n_splits = best_splits(choco, H, W, K, S);
        ans = min(ans, n_splits);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3624
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

p = A[0]
rem = n-2
idx = 1
while rem > 0:
    p += A[idx]
    rem -= 1
    if rem == 0:
        break
    p += A[idx]
    rem -= 1
    idx += 1

print(p)


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

bool odd_dig(int i){
  string s = to_string(i);
  return ((s.size() % 2) ? true : false);
}
int main(){
  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++){
    if (odd_dig(i)) ans++;
  }
  cout << ans << endl;
}

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

struct union_find {
    vector<int> par;

    union_find(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

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

    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    union_find tree(n);
    vector<pair<ll, ll>> bridge(m);
    for(int i = 0; i < m; i++){
        cin >> bridge[i].first >> bridge[i].second;
    }
    vector<ll> ans(m, 0);
    ans[0] = n * (n - 1) / 2;
    reverse(bridge.begin(), bridge.end());
    for (int i = 0; i < m-1; i++)
    {
        ans[i+1] = ans[i];
        ll x = bridge[i].first -1;
        ll y = bridge[i].second -1;
        ll xs = tree.size(x);
        ll ys = tree.size(y);
        if (tree.same(x, y) == false)
        {
            ans[i+1] -= xs * ys;
        }
        tree.unite(x,y);
    }

    reverse(ans.begin(), ans.end());
    for(int i = 0; i < m; i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int i,j,n,t,a[200000],sum=0,x,y;
cin>>n>>t;
for(i=0;i<n;i++){
  cin>>a[i];

  }
    for(j=1;j<n;j++){
       x=a[j]-a[j-1];
        if(x<=t){sum+=x;}
        else{sum+=t;}
       }
    sum+=t;
     cout<<sum<<endl;


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

ll N, Q;
string s;
char t[MAX*2], d[MAX*2];

//左から脱落するなら1を返す
ll LC(ll u) {
  for(ll i=0; i<Q; i++) {
    if(t[i]==s[u]) {
      if(d[i]=='L') u--;
      if(d[i]=='R') u++;
      
      if(u<0) return 1;
      if(u>=N) return 0;
    }
  }
  
  return 0;
}

//右から脱落するなら1を返す
ll RC(ll u) {
  for(ll i=0; i<Q; i++) {
    if(t[i]==s[u]) {
      if(d[i]=='L') u--;
      if(d[i]=='R') u++;
      
      if(u<0) return 0;
      if(u>=N) return 1;
    }
  }
  
  return 0;
}

int main(void) {
  cin >> N >> Q;
  cin >> s;
  ll i;
  
  for(i=0; i<Q; i++) {
    cin >> t[i] >> d[i];
  }
  
  ll lan=0, ran=0;
  
  ll l=0, r=N;
  while(l+1<r) {
    ll mid=(l+r)/2;
    if(LC(mid)) l=mid;
    else r=mid;
  }
  lan=l;
  
  l=0; r=N;
  while(l+1<r) {
    ll mid=(l+r)/2;
    if(RC(mid)) r=mid;
    else l=mid;
  }
  ran=r;
  
  pt(max(0, ran-lan-1));
  
}


Measured memory_bytes: 1028
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int n, k;
    scanf("%d %d\n", &n, &k);
    string s;
    getline(cin, s);
    if(s.at(k - 1) == 'A'){
        s.at(k - 1) = 'a';
    }else if(s.at(k - 1) == 'B'){
        s.at(k - 1) = 'b';
    }else{
        s.at(k - 1) = 'c';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mem(a, b) memset(a, b, sizeof(a))
#define INF 0X3f3f3f3f
const ll MAXN = 5000 + 7;
const ll MOD = 1e9 + 7;
//-------------------------------------------//
int main()
{
    int a,b,ans=0;
    scanf("%d %d",&a,&b);
    for(int i=1;i<=2;i++)
    {
    if(a>b)
    {
        ans+=a;
        a--;
    }
    else
    ans+=b;
    b--;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define mod 1000000007
int M(long long a, long long b, long long c)//a ^ b mod c
{
	int ans = 1;
	a = a % c;
	while (b != 0)
	{
		if (b & 1)
			ans = ans * a % c;
		a = a * a % c;
		b = b >> 1;
	}
	return ans;
}
char a[100005];
int main()
{
	int l,i,len;
	long long sum = 1,sum2=0;
	scanf("%s", a);
	len = strlen(a);
	for (i = 0; i < len; i++)
	{
		if (a[i] == '1')
		{
			sum2 = (sum2 + sum * M(3, len - i - 1, mod)) % mod;
			sum *= 2;
			sum %= mod;
		}
	}
	printf("%lld", (sum + sum2) % mod);
}

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

int main(){
    int a, b;
    cin >> a >> b;

    int ans;
    if (a >= 13){
        ans = b;
    }
    else if (a >= 6){
        ans = b / 2;
    }
    else{
        ans = 0;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1001001001;
int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> key;
    vector<int> a(M), b(M);
    for (int i = 0; i < M; i++) {
        cin >> a.at(i) >> b.at(i);
        int s = 0;
        for (int j = 0; j < b.at(i); j++) {
            int c;
            cin >> c;
            --c;
            s |= 1 << c;
        }
        key.emplace_back(s, a.at(i));
    }
    vector<int> dp(1 << N, INF);
    dp[0] = 0;
    for (int s = 0; s < 1 << N; s++) {
        for (int j = 0; j < M; j++) {
            int t    = s | key[j].first;
            int cost = dp[s] + key[j].second;
            dp[t]    = min(dp[t], cost);
        }
    }
    if (dp.back() == INF) {
        cout << -1 << endl;
    } else {
        cout << dp.back() << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)
int H,W,K;
string s[330];
int a[330][330];

int main(void)
{
    int c = 0;
    cin >> H >> W >> K;

    REP(i,H) {
        REP(j,W) a[i][j] == 0;
    }

    REP(i,H) {
        cin >> s[i];
        REP(j,W)  {
            if(s[i][j] == '#') {
                a[i][j] = ++c;
            }
        }
    }
/*
    REP(i,H) {
        REP(j,W) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
*/
    REP(i, H) {
        REP(j, W) {
            if(a[i][j]!=0) {
                for(int l=j-1;l>=0&&a[i][l]==0;l--) {
                    a[i][l] = a[i][j];
                }
            } else {
                if(j > 0) {
                    a[i][j] = a[i][j-1];
                }
            }
        }
//        REP(j,W) cout << a[i][j] << " " ;
//        cout << endl;
    }

    REP(j, W) {
        REP(i, H) {
            if(a[i][j]!=0) {
                for(int l = i - 1; l >=0 && a[l][j] == 0; l--) {
                    a[l][j] = a[i][j];
                }
            } else {
                if(i > 0) {
                    a[i][j] = a[i-1][j];
                }
            }

        }
    }

    REP(i,H) {
        REP(j,W) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }

}


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

int main()
{
  int n, num;
  long long int price, count;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<int> index;
    vector<long long int> sale(4000, 0);
    for (int i = 0; i < n; ++i) {
      cin >> num >> price >> count;
      sale[num] += price * count;
      if (find(index.begin(), index.end(), num) == index.end())
	index.push_back(num);
    }

    bool found = false;
    for (unsigned int i = 0; i < index.size(); ++i) {
      if (sale[index[i]] >= 1000000LL) {
	cout << index[i] << endl;
	found = true;
      }
    }
    if (!found)
      cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = (a + d - 1) / d;
    int y = (b + c - 1) / b;
    cout << (x >= y ? "Yes" : "No") << '\n';
    //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 3600
import java.util.Scanner;
import java.lang.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int sum;
		String s;
		while (true)
		{
			s = input.nextLine();
			if(s.length() == 1 && s.charAt(0) == '0')
				break;
			else
			{
				sum = 0;
				for(int i = 0; i < s.length(); i++)
				{
					sum += (int)(s.charAt(i)-'0');
				}
				System.out.println(sum);
			}
		}
	}
}

Measured memory_bytes: 26744
#include <stdio.h>
#include <string.h>

int main()
{
	int i,j;
	char str[20];
	scanf("%s",str);
	
	i = strlen(str);
	
	char str2[i];
	str2[i] = '\0';
	
	for(j=0;j<i;j++){
		printf("%c",str[i-j-1]);
	}
	printf("\n");
	
	
	return 0;
}

Measured memory_bytes: 524
n,k = map(int, input().split())
s = input()
lis=[]
z_cnt=0
o_cnt=0
for num in s:
    if num=="0":
        z_cnt+=1
        if o_cnt!=0:
            lis.append(o_cnt)
            o_cnt=0
    else:
        o_cnt+=1
        if z_cnt!=0:
            lis.append(z_cnt)
            z_cnt=0
if z_cnt!=0:
    lis.append(z_cnt)
if o_cnt!=0:
    lis.append(o_cnt)

first_zero = s[0]=="0"
if first_zero:
    ind=k*2
    low=-1
else:
    ind=1+k*2
    low=0
sm=0

if ind > len(lis):
    print(sum(lis))
    exit()
for i in range(ind):
    sm+=lis[i]
ans=sm
while True:
    if low ==-1:
        sm-=lis[0]
    else:
        sm-=lis[low+1]+lis[low]
    if ind+1>=len(lis):
        sm+=lis[ind]
    else:
        sm+=lis[ind]+lis[ind+1]
    if sm > ans:
        ans=sm
    ind+=2
    low+=2
    if ind+1>len(lis):
        break
print(ans)


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    string s;
    cin >> n >> s;

    vector<bool> seen(n, false);
    int right = 0;
    int left = 0;
    rep(i, n){
        if(s[i] == '('){
            bool found = false;
            for(int j = i+1; j < n; ++j){
                if(!seen[j] && s[j] == ')') {
                    found = true;
                    seen[j] = true;
                    break;
                }
            }
            if(!found) ++right;
        }

        else{
            bool found = false;
            for(int j = i-1; j >= 0; --j){
                if(!seen[j] && s[j] == '('){
                    found = true;
                    seen[j] = true;
                    break;
                }
            }
            if(!found) ++left;
        }
    }

    rep(_, left) cout << '(';
    cout << s;
    rep(_, right) cout << ')';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

template<class T>
struct union_find{
    int N;
    vector<int> par, rank;
    vector<T> sz;

    union_find(int N) : N(N), par(N + 1), rank(N + 1, 1), sz(N + 1, 1){
        for(int i = 0; i <= N; ++i) par[i] = i;
    }

    void init(int n, T s){sz[n] = s;}

    int find(int v){
        return (v == par[v] ? v : find(par[v]));
    }

    void unite(int x, int y, int t){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] > rank[y]){
            par[y] = x;
            sz[x] += sz[y];
        }else{
            par[x] = y;
            sz[y] += sz[x];
            if(rank[x] == rank[y]) rank[y]++;
        }
    }

    T get_sz(int x){
        return sz[find(x)];
    }
};

struct arc{
    int from, to, idx;
    ll Y;
    arc(int from, int to, int idx, ll Y) : from(from), to(to), idx(idx), Y(Y) {}

    bool operator < (const arc& e1) const {
        return Y < e1.Y;
    }
    bool operator > (const arc& e1) const {
        return Y > e1.Y;
    }
};

struct edge{
    int to, idx;
    ll Y;
};

int N, M;
ll X[100010];
bool ok[100010], used[100010];
vector<edge> G[100010];

void dfs(int v, ll Y){
    if(used[v]) return;
    used[v] = true;

    for(auto u : G[v]){
        if(u.Y > Y) continue;
        ok[u.idx] = true;
        dfs(u.to, Y);
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;

    union_find<ll> uf(N);
    for(int i = 1; i <= N; ++i){
        cin >> X[i];
        uf.init(i, X[i]);
    }

    vector<arc> as;
    for(int i = 1; i <= M; ++i){
        int A, B;
        ll Y;
        cin >> A >> B >> Y;
        as.emplace_back(arc{A, B, i, Y});
        G[A].emplace_back(edge{B, i, Y});
        G[B].emplace_back(edge{A, i, Y});
    }

    sort(as.begin(), as.end());
    vector<arc> mx;
    for(int i = 0; i < M; ++i){
        uf.unite(as[i].to, as[i].from, i);
        if(uf.get_sz(as[i].to) >= as[i].Y) mx.emplace_back(as[i]);
    }

    for(int i = (int)mx.size() - 1; i >= 0; --i){
        dfs(mx[i].to, mx[i].Y);
    }

    int ans = M;
    for(int i = 1; i <= M; ++i) ans -= ok[i]; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18732
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int n = readln.chomp.to!int;
    auto as = readln.chomp.split(" ").map!(to!int).array;
    int[int] count;
    foreach (a; as) {
        count[a] = count.get(a, 0) + 1;
    }
    auto cs = count.values();
    int r = 0;
    foreach (c; cs) {
        r += max(0, c - 1);
    }
    int eat = (r + 1) / 2 * 2;
    writeln(n - eat);
}


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

int main(int argc, char *argv[])
{
	int cubic;
	char str[256];
	fgets(str, 256, stdin);
	cubic = atoi(str);
	printf("%d\n", cubic*cubic*cubic);
	return 0;
}

Measured memory_bytes: 528
import java.util.*;

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

        int m = sc.nextInt();

        int x = sc.nextInt();

        int y = sc.nextInt();

        int max_x = -100;

        int min_y = 100;

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

            max_x = Math.max(max_x,sc.nextInt());

        }

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

            min_y = Math.min(min_y,sc.nextInt());

        }

        for(int i = x+1 ;i <= y;i++){

            if(max_x < i&&i <= min_y){
                System.out.println("No War");
                return;
            }

        }

        System.out.println("War");

    }
}

Measured memory_bytes: 23764
def d_alter_altar():
    N = int(input())
    C = input()

    left, right = 0, N - 1
    ans = 0
    while left < right:
        if C[left] == 'W' and C[right] == 'W':
            right -= 1
        elif C[left] == 'W' and C[right] == 'R':
            ans += 1
            left += 1
            right -= 1
        elif C[left] == 'R' and C[right] == 'W':
            left += 1
        elif C[left] == 'R' and C[right] == 'R':
            left += 1
    return ans

print(d_alter_altar())

Measured memory_bytes: 9372
# 孤立点

import numpy as np
import sys
buf = sys.stdin.buffer

H,W = map(int,buf.readline().split())
S = np.frombuffer(buf.read(H*(W+1)), dtype='S1').reshape((H,W+1))
S = S[:,:-1]

black = (S == b'#')
black_nbd = np.zeros((H,W), dtype=np.bool)

# 左
black_nbd[1:,:] |= black[:-1,:]
# 右
black_nbd[:-1,:] |= black[1:,:]
# 下
black_nbd[:,1:] |= black[:,:-1]
# 上
black_nbd[:,:-1] |= black[:,1:]

impossible = (black & ~black_nbd).any()
answer = 'Yes' if not impossible else 'No'
print(answer)

Measured memory_bytes: 12508
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 100000000000000003;
int ne[200001], he[100001];
char C[1200100];

ll num[500010];
int kazu[500010];
const int ma = (1 << 18) - 1;
int query(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2];
		n2 = n2 * 61 % 500009;
	}
	return 0;
}
void add(ll n, int b) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			kazu[n2] |= b;
			return;
		}
		n2 = n2 * 61 % 500009;
	}
	num[n2] = n + 1;
	kazu[n2] = b;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	fread(C, 1, 1200100, stdin);
	char* ci = C, c;
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';
	set<pair<int, char*>> ST;
	char* s[200001];
	rep1(i, N) {
		s[i] = ci;
		while (*ci++ >= '0');
		int n = ci - s[i] - 1;	
		if (n <= 100000) {
			ne[i] = he[n];
			he[n] = i;
		}
		else {
			ST.insert(mp(n, s[i]));
		}
	}

	ll kotae = 0;

	for (int M = 1; M <= 100000; M++) {
		for (int p = he[M]; p; p = ne[p]) {
			auto S = s[p];
			int k[26] = {};
			ll are = 0;
			for (int i = M - 1; i >= 1; i--) {
				int tmp = query(are);
				rep(j, 26) if ((tmp >> j & 1)) {
					k[j]++;
				}
				kotae += k[S[i] - 'a'];
				k[S[i] - 'a'] = 0;
				are = (are * 30 + S[i] - 'a' + 1) % mod;
			}

			kotae += k[S[0] - 'a'];
			k[S[0] - 'a'] = 0;

			add(are, 1 << (S[0] - 'a'));
		}
	}
	for (auto p : ST) {
		auto S = p.second;
		int k[26] = {};
		ll are = 0;
		for (int i = p.first - 1; i >= 1; i--) {
			int tmp = query(are);
			rep(j, 26) if ((tmp >> j & 1)) {
				k[j]++;
			}
			kotae += k[S[i] - 'a'];
			k[S[i] - 'a'] = 0;
			are = (are * 30 + S[i] - 'a' + 1) % mod;
		}

		kotae += k[S[0] - 'a'];
		k[S[0] - 'a'] = 0;

		add(are, 1 << (S[0] - 'a'));
	}
	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 12964
#include <iostream>
#include <numeric>

inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int cnt[1000001];

int main(){
  int n = read();
  int num = read();
  int g = num;
  int ex = (n-1)/8;
  cnt[num] = 1;

  for(int i=0;i<ex;i++){
    int num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
    num = read();
    g = std::gcd(g, num);
    cnt[num]++;
  }

  for(int i=0;i<(n-1)%8;i++){
    int num = read();
    g = std::gcd(g, num);
    cnt[num]++;
  }
  if(n - cnt[1] > 80000){
    if(g==1) printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
  }

  if(g!=1){
    printf("not coprime\n");
    return 0;
  }

  int use[1000001];
  int max_S = 0;
  for(int i=2;i<=1000000;i++){
    if(use[i]==-1) continue;
    int S = 0;
    for(int j=i;j<=1000000;j+=i) {
      S += cnt[j];
      use[j] = -1;
    }
    if(max_S<S) max_S = S;
  }
  if(max_S<2) printf("pairwise coprime\n");
  else printf("setwise coprime\n");
}


Measured memory_bytes: 11452
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll A, B, C, K;

	cin >> A >> B >> C >> K;

	if (K % 2 == 1) cout << B - A << endl;
	else cout << A - B << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
In = [map(int, input().split()) for _ in range(N)]

s = (0, 0)
t = 0
success = True

for move in In:
    before_x, before_y = s
    tn, after_x, after_y = move

    dist_xy = abs(after_x - before_x) + abs(after_y - before_y)
    walk = tn - t

    if walk < dist_xy:
        success *= False
        break

    if walk % 2 == 0 and dist_xy % 2 != 0:
        success *= False
        break
    elif walk % 2 != 0 and dist_xy % 2 == 0:
        success *= False
        break

    s = (after_x, after_y)
    t = tn

print("Yes" if success else "No")

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

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int a[3],d;
    cin >> a[0] >> a[1] >> a[2] >> d;
    sort(a,a+3);
    cout << a[0]+a[1]+a[2]*pow(2,d) << "\n";
}

Measured memory_bytes: 4192
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double ans;
    double ax, ay, bx, by;
    ax = a * cos((h / 12 + m / 720) * 2 * 3.1415926535898);
    ay = a * sin((h / 12 + m / 720) * 2 * 3.1415926535898);
    bx = b * cos((m / 60) * 2 * 3.1415926535898);
    by = b * sin((m / 60) * 2 * 3.1415926535898);
    ans = sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
    printf("%0.10lf",ans);
    return 0;
}

Measured memory_bytes: 4032
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        System.out.print(s);
        System.out.println(s.charAt(s.length() - 1) == 's' ? "es" : "s");
    }

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


Measured memory_bytes: 35560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

#define ALL(V) (V).begin(),(V).end()

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

int main() {
    int n,m,p;
    cin >> n >> m;
    string s;
    vector<int> penalty(n,0);
    vector<bool> ac(n,false);

    for (int i=0;i<m;i++){
        cin >> p >> s;
        if (s == "AC") {
            ac[p-1] = true;
        } else if (s == "WA") {
            if (!ac[p-1]) {
                penalty[p-1]++;
            }
        }
    }
    int acs=0, ps=0;
    for (int i=0;i<n;i++) {
        if (ac[i]) {
            acs++;
            ps += penalty[i];
        }
    }
    
    cout << acs << " " << ps << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N, A, B; cin >> N >> A >> B;
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        int n = 0;
        int x = i;
        while(x) {
            n += x % 10;
            x /= 10;
        }
        if(n >= A && n <= B) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3440
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <string>

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  int dp[200000];
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    if((S[i-1] == 'A') && (S[i] == 'C')) dp[i] = dp[i-1] + 1;
    else dp[i] = dp[i-1];
  }
  while(Q--){
    int l, r;
    cin >> l >> r;
    cout << dp[r-1] - dp[l-1] << endl;
  }
  return 0;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int64_t> stairs(n + 2);
  stairs[1] = 1;

  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    stairs[x + 1] = -1;
  }

  for (int i = 2; i < n + 2; i++) {
    if (stairs[i] < 0) continue;
    if (stairs[i - 1] > 0) stairs[i] += stairs[i - 1];
    if (stairs[i - 2] > 0) stairs[i] += stairs[i - 2];
    stairs[i] %= 1'000'000'007;
  }
  cout << stairs[n + 1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    cout << n*n*n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int max(int a, int b){return a>b?a:b;}

int arr[3][101], farr[3][101];

int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1; i <= 2; i++){
		for(int j = 1; j <= n; j++){
		scanf("%d", &arr[i][j]);
		}
	}
	int m = 0;
	for(int i = 1; i <= 2; i++){
		for(int j = 1; j <= n; j++){
			farr[i][j] = max(farr[i-1][j], farr[i][j-1]) + arr[i][j];
			m = max(farr[i][j], m);
			//printf("%d ",farr[i][j]);
		}//puts("");
	}
	printf("%d",m);
}

Measured memory_bytes: 128
macro_rules! get_tuple {
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };

    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get_tuple!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c, d) = get_tuple!(usize, usize, usize, usize);

    let taka = (a - 1) / d;
    let aoki = (c - 1) / b;

    if taka >= aoki {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2048
#include <cstdint>
#include <iostream>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

} // namespace null_null

#include <string>

namespace null_null {

void main_() {
  std::string S;
  std::cin>>S;

  for(usize i=0;i<S.size();i++){
    if(((i+1)%2==1 && S[i]=='L')||((i+1)%2==0 && S[i]=='R')){
      std::cout<<"No"<<std::endl;
      return;
    }
  }

  std::cout<<"Yes"<<std::endl;
  return;
}

} // namespace null_null

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  null_null::main_();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  int d[n+1];
  mem(d);
  rep(i,n) {
    d[i+1]+=d[i];
    if(s[i]=='#') d[i+1]++;
  }
  int c=0,ans=MAX;
  rrep(i,n) {
    ans=min(ans,d[i]+c);
    if(s[i]=='.') c++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1300