akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#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)
#define ALL(c) (c).begin(), (c).end()

const double EPS = 1e-8;
const double INF = 1e12;

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

bool intersectSC(const L &s, const C &c) {
  if (abs(s[0]-c.p) < c.r && abs(s[1]-c.p) < c.r) return false; // ツ円ツづ個陳づ可禿シツづゥツづ個づ債古ーツ債キツづつキツづゥツつゥツつオツづ按つ「ツつゥツ。
  return distanceSP(s, c.p) <= c.r +EPS;
}

int main() {
  int n;
  while(cin >> n, n) {
    vector<C> v;
    REP(i,n) {
      double x,y,r;
      cin >> x >> y >> r;
      v.push_back(C(P(x,y),r));
    }
    int m;
    cin >> m;
    while(m--) {
      int tx,ty,sx,sy;
      cin >> tx >>ty >> sx >> sy;
      L l(P(tx,ty), P(sx,sy));
      bool danger = true;
      FOR(it, v) {
        if (intersectSC(l, *it)) {
          cout << "Safe" << endl;
          danger = false;
          break;
        }
      }
      if (danger) {
        cout << "Danger" << endl;
      }
    }
  }
}

Measured memory_bytes: 0
/* ex2_3 KitamoriFumiya */
#include <stdio.h>
 
int main(void){
 
	int length, white, black; // N,A,Rをint型の変数として宣言
	
	scanf("%d %d", &length, &white); // N,Aを入力
	black = length * length - white; // 黒色に塗るマスの数を計算
	printf("%d\n", black); // 黒色に塗るマスの数を出力
	
	return 0;
}

Measured memory_bytes: 128
n = int(input())
c = 0
for p in range(2, int(n**0.5)+1):
  e = 0
  while n%p == 0:
    n //= p
    e += 1
  i = 1
  while e >= i:
    e -= i
    c += 1
    i += 1
if n != 1:
  c += 1
print(c)

Measured memory_bytes: 63632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


void solve()
{
	int n;
	while (cin >> n, n)
	{
		vector<int> p(n);
		vector<int> joint(n - 1);
		long long int sum = 0;
		for (int i = 0; i < n; ++i)
		{
			cin >> p[i];
			sum += p[i];
		}
		for (int i = 0; i < n - 1; ++i)
		{
			cin >> joint[i];
			sum += joint[i];
		}
		long long int ret = sum;
		sort(joint.begin(), joint.end());
		for (int i = 0; i < n - 1; ++i)
		{
			sum -= joint[i];
			ret = max(ret, sum * (i + 2));
		}
		cout << ret << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1532
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N;
  string s;
  scanln(N);
  scanln(s);
  N.iota.count!(
    i => s[i..min($, i+3)] == "ABC"
  ).writeln;
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

string s, t;

int main(){
    
    cin >> s >> t;

    for(int i=0;i<s.size();i++){
        if(s[i] == t[i]){

        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3636
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

typedef struct node_st {
	int key;
	struct node_st *left, *right;
} node_t;

node_t *root;

node_t *node_new(int x) {
	node_t *new = malloc(sizeof(node_t));
	if (new == NULL) exit(1);
	new->key = x;
	new->left = new->right = NULL;
	return new;
}

node_t *insert(node_t *nd, int x) {
	if (!nd) return node_new(x);
	if (x < nd->key) nd->left = insert(nd->left, x);
	else if (nd->key < x) nd->right = insert(nd->right, x);
	return nd;
}

enum {
	PREORDER,
	INORDER,
};

void print_tree(node_t *nd, int order) {
	if (!nd) return;
	if (order == PREORDER) printf(" %d", nd->key);
	print_tree(nd->left, order);
	if (order == INORDER) printf(" %d", nd->key);
	print_tree(nd->right, order);
}

int main(int argc, char **argv)
{
	int i, n, x;
	char cmd[128];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", cmd);
		if (!strcmp("insert", cmd)) {
			scanf("%d", &x);
			root = insert(root, x);
		} else if (!strcmp("print", cmd)) {
			print_tree(root, INORDER);
			puts("");
			print_tree(root, PREORDER);
			puts("");
		}
	}

	return 0;
}

Measured memory_bytes: 16232
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  tmp = input.shift();
  A = parseInt(tmp.split(" ")[0]);
  B = parseInt(tmp.split(" ")[1]);
  M = parseInt(tmp.split(" ")[2]);
  refArg = input
    .shift()
    .split(" ")
    .map(v => parseInt(v));
  eleArg = input
    .shift()
    .split(" ")
    .map(v => parseInt(v));
  ken = input;
  refMin = Math.min.apply(null, refArg);
  eleMin = Math.min.apply(null, eleArg);
  defaultMin = refMin + eleMin;
  min = defaultMin;
  // 重複削除
  input.forEach(t => {
    tm = t.split(" ").map(v => parseInt(v));
    x = tm[0];
    y = tm[1];
    c = tm[2];
    raw = refArg[x-1] + eleArg[y-1] - c;
    if (min > raw ) {
      min = raw;
    }
  });
  console.log(min);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 53812
#include<stdio.h>
int main(void){
	char ball='A',b,c;
	while(scanf("%c,%c",&b,&c)!=EOF){
		if(ball==b)ball=c;
		else if(ball==c)ball=b;
	//printf("%c\n",ball);
	}
	printf("%c\n",ball);
	return 0;
}

Measured memory_bytes: 544
#include <stdio.h>
int main() {
    int W,H,x,y,r;
    scanf ("%d",&W);
    scanf ("%d",&H);
    scanf ("%d",&x);
    scanf ("%d",&y);
    scanf ("%d",&r);
    if (2*r > W || 2*r > H) {
        printf("No\n");
    }
    else if (x >= r && x <= W - r) {
        if (y >= r && y <= H - r) {
            printf ("Yes\n");
        }
        else {
            printf ("No\n");
        }
    }
    else {
        printf ("No\n");
    }
}


Measured memory_bytes: 2140
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int[] a = new int[n];
		int[] sz = new int[n];
		for (int i = 0; i < n; ++i) {
			if (s.charAt(i) == '1') {
				a[i] = 1;
			} else {
				a[i] = 0;
			}
		}
		for (int i = 0; i < n; ++i) {
			if (a[i] == 1) {
				++sz[i];
				if (i > 0)
					sz[i] += sz[i - 1];
			}
		}

		int[] dp = new int[n];
		for (int i = 2; i < n; ++i) {
			dp[i] = dp[i - 1];
			if (a[i] == 0)
				continue;
			if (a[i - 1] == 0 && a[i - 2] == 1) {
				for (int d = 0; d < 3 && sz[i - 2] - d > 0; ++d) {
					dp[i] = Math.max(dp[i],
							(sz[i - 2] - d) + (i - 2 - (sz[i - 2] - d) >= 0 ? dp[i - 2 - (sz[i - 2] - d)] : 0));
				}
			}
			if (i - sz[i] - 1 >= 0 && a[i - sz[i] - 1] == 1) {
				dp[i] = Math.max(dp[i], sz[i] + (i - 2 - sz[i] >= 0 ? dp[i - sz[i] - 2] : 0));
			}
		}
		System.out.println(dp[n - 1]);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 36192
n, k = (int(x) for x in input().split())
h = [0] + [int(x) for x in input().split()]
dp = [float('inf')] * (n + 1)
dp[1] = 0
for i in range(2, n + 1):
    for j in range(1, k + 1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
print(dp[n])

Measured memory_bytes: 56288
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){

  int N;
  int count;
  double ans;
  scanf("%d", &N);

  if(N%2==0){
    count=N/2;
  }else{
    count=1+N/2;
  }
  // printf("count=%d\n",count);
  ans=(double)count/N;

  printf("%.10lf\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if(n>12)
	{
		cout<<m<<endl;
		
	}
	else if(n>5)
	{
		cout<<m/2<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 256
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/



/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    ll n;
    cin>>n;
    cout<<(ld)2*((ld)22/7)*n;newl;
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 8484
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    LL N,M;
    cin>>M>>N;
    LL ans;
    if(M>=N/2)ans=N/2;
    else{
        ans=M;
        N-=2*M;
        ans+=N/4;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
inputlist = [input() for i in range(4)]

n = 0

A,B,C= inputlist[0],inputlist[1],inputlist[2]

for i in range(int(A)+1):

    X = inputlist[3] 

    X = int(X) - i*500

    for j in range(int(B)+1):

        X = X - j*100

        for k in range(int(C)+1):
            
            X = X -k*50

            if X == 0:
                n += 1
            X= X + k*50

        X = X + j*100

    X = X + i*500

print(n)

Measured memory_bytes: 9124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = Integer.parseInt(br.readLine());
		String ans = "Yes";
		String[] nums = br.readLine().split(" ");
		Cube firstCube = new Cube(nums);

		for (int i = 1; i < count; i++) {
			String[] str = br.readLine().split(" ");
			Cube comparedCube = new Cube(str);
			if (firstCube.trace(firstCube, comparedCube) == true) {
				ans = "No";
				break;
			}
		}
		System.out.println(ans);
	}
}

class Cube {
	String top;
	String center;
	String back;
	String bottom;
	
	String right;
	String left;
	String temp;

	Cube(String[] nums) throws IOException {
		this.top = nums[0];
		this.center = nums[1];
		this.right = nums[2];
		this.left = nums[3];
		this.back = nums[4];
		this.bottom = nums[5];
	}

	void south() {
		temp = this.top;
		this.top = this.back;
		this.back = this.bottom;
		this.bottom = this.center;
		this.center = temp;
	}

	void north() {
		temp = this.top;
		this.top = this.center;
		this.center = this.bottom;
		this.bottom = this.back;
		this.back = temp;
	}

	void east() {
		temp = this.top;
		this.top = this.left;
		this.left = this.bottom;
		this.bottom = this.right;
		this.right = temp;
	}

	void west() {
		temp = this.top;
		this.top = this.right;
		this.right = this.bottom;
		this.bottom = this.left;
		this.left = temp;
	}

	void roll(char[] act) {
		for (int i = 0; i < act.length; i++) {
			switch (act[i]) {
			case 'S':
				south();
				break;
			case 'N':
				north();
				break;
			case 'E':
				east();
				break;
			case 'W':
				west();
				break;
			}
		}
	}

	void turnRight() {
		temp = this.center;
		this.center = this.left;
		this.left = this.back;
		this.back = this.right;
		this.right = temp;
	}

	void search(BufferedReader br) throws IOException {

		String[] numList = br.readLine().split(" ");
		for (int i = 0; i < 6; i++) {
			if (i == 3) {
				this.east();
			}
			if (numList[1].equals(this.center)) {
				break;
			} else {
				this.north();
			}
		}
		while (true)
			if (numList[0].equals(this.top)) {
				break;
			} else {
				this.west();
			}
		System.out.println(right);
	}

	void setUpside(int top, Cube cube) throws IOException {

		for (int i = 0; i < 7; i++) {
			if (cube.top.equals(top)) {
				break;
			}
			if (i == 3) {
				cube.east();

			}
			cube.north();
		}
	}

	boolean trace(Cube cube01, Cube cube02) {

		boolean ans = false;

		for (int i = 0; i < 8; i++) {
			cube02.north();
			// System.out.print("???");
			if (cube02.top.equals(cube01.top)) {
				for (int j = 0; j < 5; j++) {
					cube02.turnRight();
					if (cube02.right.equals(cube01.right) && cube02.center.equals(cube01.center)
							&& cube02.left.equals(cube01.left) && cube02.back.equals(cube01.back)
							&& cube02.bottom.equals(cube01.bottom)) {
						ans = true;
					}
				}
			}
			if (i == 3) {
				cube02.east();
				// System.out.print("?\?");
			}
		}
		return ans;
	}
}

Measured memory_bytes: 24352
a = [input() for i in range(3)]
k = []
i = 0
while len(a[0]) >= 0 and len(a[1]) >= 0 and len(a[2]) >= 0:
  if k == []:
    k.append(a[0][0])
    a[0] = a[0].replace(a[0][0],'',1)
    
  elif k[i-1] == 'a':
    try:
      k.append(a[0][0])
      a[0] = a[0].replace(a[0][0],'',1) 
    except:
        print('A')
        break
  elif k[i-1] == 'b':
    try:
      k.append(a[1][0])
      a[1] = a[1].replace(a[1][0],'',1) 
    except:
        print('B')
        break
  elif k[i-1] == 'c':
    try:
      k.append(a[2][0])
      a[2] = a[2].replace(a[2][0],'',1) 
    except:
        print('C')
        break
  i += 1

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
aa=[]
for i in a:
  aa.append(i)
  aa.append(i)
g=aa.pop(0)
ans=0
#print(aa)
for i in range(n-1):
  ans+=aa[i]
print(ans)

Measured memory_bytes: 31448
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
int n, q, x, ans ;
string str;
set<int> l;
set<int> r;
#define INF (1<<29)

int seg[1<<20];
int all[1<<20];

void add(int l, int r, int val, int bottom = 0, int top = 1 << 19, int p = 1){
	if(r <= bottom || top <= l)return;
	if(l <= bottom && top <= r){
		all[p] += val;
		return;
	}
	int mid = (top + bottom) / 2;
	add(l, r, val, bottom, mid, p*2);
	add(l, r, val, mid, top, p*2+1);
	seg[p] = min(seg[p*2] + all[p*2], seg[p*2+1] + all[p*2+1]);
}

int minval(int l, int r, int bottom = 0, int top = 1 << 19, int p = 1){
	if(r <= bottom || top <= l)return INF;
	if(l <= bottom && top <= r)return seg[p] + all[p];
	int mid = (top + bottom) / 2;
	return all[p] + min(minval(l, r, bottom, mid, p * 2),
											minval(l, r, mid, top, p * 2 + 1));
}



int solve(int x){
	int l = 0, rr = n;
	while(rr - l > 1){
		int mid = (l + rr) / 2;
		int tmp = *r.lower_bound(mid);
		if(minval(mid, n) < 2)l = mid;
		else rr = mid;
	}
	return rr;
}

int main(){
	cin >> n >> q;
	cin >> str;
	for(int i = 0;i < str.size();i++){
		if(str[i] == '('){
			add(i,n, 1);
			l.insert(i);
		}
		if(str[i] == ')'){
			add(i,n, -1);
			r.insert(i);
		}
	}
	while(q--){
		cin >> x;x--;
		if(str[x] == '('){
			str[x] = ')';
			l.erase(x);
			r.insert(x);
			add(x,n,-2);
			ans = *r.begin();
			r.erase(ans);
			l.insert(ans);
			add(ans, n, 2);
			str[ans] = '(';
		}
		else{
			l.insert(x);
			r.erase(x);
			str[x] = '(';
			add(x, n, 2);
			ans = solve(x);
			l.erase(ans);
			r.insert(ans);
			add(ans,n, -2);
			str[ans] = ')';
		}
		ans++;
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 20800
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> S(M);
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i] >> S[i];
  }

  vector<int> se(N, 0);
  vector<int> pe(N, 0);
  for (int i = 0; i < M; i++) {
    if (S[i] == "WA" && se[p[i] - 1] == 0) {
      pe[p[i] - 1]++;
    }
    if (S[i] == "AC") {
      se[p[i] - 1] = 1;
    }
  }

  int pes = 0;
  for (int i = 0; i < N; i++) {
    if (se[i]) pes += pe[i];
  }
  cout << accumulate(se.begin(), se.end(), 0) << " " << pes << endl;
  return 0;
}


Measured memory_bytes: 6912
#include<iostream>
#include<cstdio>
#include<string>
#include<cfloat>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
const int mod = 1e9+7;
const int INFINT = INT_MAX/2;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int start = 'a';
    bool flag = true;
    REP(i, 26){
        char c = start + i;
        vector<int> x(N, -1);
        REP(j, N){
            if(S[j] == c) x[j] = 1;
        }
        vector<int> S(N+1);
        REP(j, N+1){
            if(j==0) S[j] = 0;
            else S[j] = S[j-1] + x[j-1];
        }
        int maxDiff = -INFINT;
        int res1, res2;
        int minNum = S[0];
        int minId = 0;
        for (int j=1;j<N+1;j++){
            if(minId < j-1 && S[j] - minNum >= maxDiff){
                maxDiff = S[j] - minNum;
                res1 = minId;
                res2 = j;
            }
            if(S[j] < minNum){
                minNum = S[j];
                minId = j;
            }
        }
        if(maxDiff > 0){
            cout << res1+1 << " " << res2 << endl;
            flag = false;
            break;
        }
    }
    if(flag){
        cout << -1 << " " << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
}
int a[4]={0,1,0,-1};
int b[4]={1,0,-1,0};
int d[114][114];
char c[114][114];
signed main(){
	ic(h) ic(w)
	rep(0,i,h)rep(0,j,w)cin>>c[i][j];
	queue<P>que;
	rep(0,i,h)rep(0,j,w)d[i][j]=inf;
	d[0][0]=0;
	que.push(P(0,0));
	while(que.size()){
		P p=que.front(); que.pop();
		if(p.first==h-1&&p.second==w-1)break;
		rep(0,i,4){
			int ny=p.first+a[i],nx=p.second+b[i];
			if(0<=ny&&ny<h&&0<=nx&&nx<w&&d[ny][nx]==inf&&c[ny][nx]!='#'){
				que.push(P(ny,nx));
				d[ny][nx]=d[p.first][p.second]+1;
			}
		}
	}
	int ans=0;
	rep(0,i,h)rep(0,j,w)if(c[i][j]!='#')ans++;
	if(d[h-1][w-1]>h*w){
		c(-1)
		return 0;
	}	
	c(ans-d[h-1][w-1]-1)
}			


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val r = sc.nextInt()
    val g = sc.nextInt()
    val b = sc.nextInt()
    println(problem064a(r, g, b))
}

fun problem064a(r: Int, g: Int, b: Int): String {
    return if ((r.toString() + g + b).toInt() % 4 == 0) "YES" else "NO"
}

Measured memory_bytes: 29348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll n,k,ch[100010],cnt;
vector<ll>a[100010];
void dep(ll now){
	if(now!=cnt&&a[now].size()==1){
		return;
	}
	for(ll i=0;i<a[now].size();i++){
		ll next=a[now][i];
		if(ch[next]!=-1){
			continue;
		}
		ch[next]=0;
		dep(next);
	}
}
int main() {
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		ch[i]=-1;
	}
	for(ll i=0;i<k;i++){
		ll x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for(ll i=0;i<n;i++){
		if(ch[i]==0){
			continue;
		}
		ch[i]=1;
		cnt=i;
		dep(i);
	}
	cnt=0;
	for(ll i=0;i<n;i++){
		cnt+=ch[i];
	}
	cout << cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
int main(){
  int S,h,m,s;
  scanf("%d",&S);
  h = S / 3600;
  m = (S - 3600 * h) / 60;
  s = S - 3600 * h - 60 * m;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 592
#include<map>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int T;
    cin >> T;
    map<string, int> mp;
    while (T--) {
        int t;
        cin >> t;
        if (t==0) {
            string s;int a;
            cin >> s >> a;
            mp[s] = a;
        } else if (t==1) {
            string s;
            cin >> s;
            if (mp.find(s)==mp.end()) cout << 0 << endl;
            else cout << mp[s] << endl;
        } else if (t==2) {
            string s;
            cin >> s;
            mp.erase(s);
        } else {
            string l, r;
            cin >> l >> r;
            auto it = mp.lower_bound(l);
            auto it1 = mp.upper_bound(r);
            for (; it !=it1; it++) cout << it->first << " " << it->second <<endl;
        }
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,t;
  cin >> n >> t;
  vector<P> v(n);
  rep(i,n)cin >> v[i].first >> v[i].second;
  sort(ALL(v));
  vector<vector<int>> dp(3010,vector<int>(3010,-1e7));
  dp[0][0] = 0;
  rep(i,n)rep(j,t+1){
    dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
    if(j == t || dp[i][j] < 0)continue;
    dp[i+1][min(t*1ll,j+v[i].first)] = max(dp[i+1][min(t*1ll,j+v[i].first)],dp[i][j]+v[i].second);
  }
  int res = 0;
  rep(i,3010)res = max(res,dp[n][i]);
  cout << res << endl;




  return 0;
}

Measured memory_bytes: 38876
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <bitset>
#include <memory>

class Tree {
	std::vector<std::vector<int>> parent, nodes;
	std::vector<int> depth;
	int move_up_to(int v, int step) const {
		if (step == 0) return v; 
		auto i = 0;
		for (; ((1 << i) & step) == 0; ++i) {}
		return move_up_to(parent[v][i], step - (1 << i));
	}
public:
	Tree(const std::vector<std::vector<int>>& _nodes): parent(_nodes.size()), nodes(_nodes), depth(_nodes.size(), -1) {
		std::stack<int> stack; stack.push(0); depth[0] = 0;
		while (!stack.empty()) {
			const auto top = stack.top(); stack.pop();
			for (const auto c : _nodes[top]) if (depth[c] == -1) {
				depth[c] = depth[top] + 1;
				stack.push(c);
				parent[c].push_back(top);
				while (parent[parent[c].back()].size() >= parent[c].size()) {
					parent[c].push_back(parent[parent[c].back()][parent[c].size() - 1]);
				}
			}
		}
		for (auto i = 0; i < nodes.size(); ++i) {
			nodes[i].erase(std::remove_if(nodes[i].begin(), nodes[i].end(), [i, this](int j) {return depth[i] > depth[j]; }), nodes[i].end());
		}
	};
	int lca(int u, int v) const {
		if (depth[u] > depth[v]) std::swap(u, v);
		if (depth[u] < depth[v]) v = move_up_to(v, depth[v] - depth[u]);
		if (u == v) return u;
		int i = 0;
		while (i + 1 < parent[v].size() && parent[v][i + 1] != parent[u][i + 1]) ++i;
		return lca(parent[v][i], parent[u][i]);
	}
	const std::vector<int>& children(int v) const {
		return nodes[v];
	}
	int size() const {
		return nodes.size();
	}
	int root() const {
		return 0;
	}
};
int main() {
	int n; std::cin >> n;
	std::vector<std::vector<int>> nodes(n);
	for (auto& node : nodes) {
		int k; std::cin >> k;
		node = std::vector<int>(k);
		for (auto& c : node) std::cin >> c;
	}
	Tree tree(nodes);
	int q; std::cin >> q;
	for (auto i = 0; i < q; ++i) {
		int u, v; std::cin >> u >> v;
		std::cout << tree.lca(u, v) << std::endl;
	}
}



Measured memory_bytes: 26644
l;
main(k){
  float f,h;
  char d[][4]={"AAA","AA","A","B","C","D","E","NA"};
  for(;~scanf("%f%f",&f,&h);printf("%s\n",d[k<l?l:k]))
    k=f<35.5?0:f<37.5?1:f<40?2:f<43?3:f<50?4:f<55?5:f<70?6:7,l=h<71?0:h<77?1:h<83?2:h<89?3:h<105?4:h<116?5:h<148?6:7;
}

Measured memory_bytes: 0
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
#include<tuple>
#include<stack>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

const ll MOD_CONST = 1000000007;
//const ll MOD_CONST = 998244353;


//const int INF = 1000000000;
const ll INF = 1000000000000000000;



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

	int r = 0;
	int l = 1000;
	
	int mid = (r + l) / 2;

	bool canConsist = false;

	while (r != mid) {
		int num = (mid * (mid - 1)) / 2;
		if (num == n) {
			canConsist =true;
			break;
		}

		if (num > n) {
			l = mid;
		}
		else {
			r = mid;
		}
		mid = (r + l) / 2;
	}
	
	if (canConsist) {
		cout << "Yes" << endl;
		vector<set<int>> s(mid);
		int cnt = 1;
		for (int i = 0; i < mid; i++) {
			for (int j = i+1; j < mid; j++) {
				s[i].insert(cnt);
				s[j].insert(cnt);
				cnt++;
			}
		}

		cout << mid << endl;
		for (int i = 0; i < mid; i++) {
			cout << s[i].size() << " ";
			for (auto it = s[i].begin(); it != s[i].end(); it++) {
				cout << *it << " ";
			}
			cout << endl;
		}
		
	}
	else {

		cout << "No" << endl;
	}

}



Measured memory_bytes: 10752
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    map<int, int> mp_odd;
    map<int, int> mp_even;
    rep(i, n) {
        int a;
        cin >> a;
        if ( i&1 ) {
            ++mp_odd[a];
        }
        else {
            ++mp_even[a];
        }
    }
    int max_odd_num = 0;
    int max_odd = 0;
    int second_max_odd_num = 0;
    int second_max_odd = 0;

    int max_even_num = 0;
    int max_even = 0;
    int second_max_even_num = 0;
    int second_max_even = 0;

    for ( auto m : mp_odd ) {
        if ( m.second > max_odd ) {
            second_max_odd_num = max_odd_num;
            second_max_odd = max_odd;
            max_odd = m.second;
            max_odd_num = m.first;
        }
        else if ( m.second > second_max_odd ) {
            second_max_odd = m.second;
            second_max_odd_num = m.first;
        }
    }

    for ( auto m : mp_even ) {
        if ( m.second > max_even ) {
            second_max_even_num = max_even_num;
            second_max_even = max_even;
            max_even = m.second;
            max_even_num = m.first;
        }
        else if ( m.second > second_max_even ) {
            second_max_even = m.second;
            second_max_even_num = m.first;
        }
    }

    if ( max_odd_num != max_even_num ) {
        cout << n - max_odd - max_even << endl;
    }
    else {
        cout << min(n - max_odd - second_max_even, n - second_max_odd - max_even) << endl;
    }

    return 0;
}


Measured memory_bytes: 4992
while(1):
	count = input()
	if(count == 0):
		break
	else:
		a, b = 0, 0

		for i in range(count):
			l = map(int, raw_input().split())
			if(l[0]>l[1]):
				a += l[0]
				a += l[1]
			elif(l[0]<l[1]):
				b += l[0]
				b += l[1]
			else:
				a += l[0]
				b += l[1]

		print a,b

Measured memory_bytes: 6560
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N,K;
  cin >> N >> K;
  int sum = 0;
  
  for(int i = 0 ; i < N ; i++){
    
    int x;
    cin >> x;
    
    if(K-x < x){
      sum += 2*(K-x);
    }else{
      sum += 2*x;
    }
    if(i == N-1){
      cout << sum << endl;
    }
  }
}
      
      
      
      
      
      
      
      
    
    
    
    
    
    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        
        char words[] = new char[s1.length()];
        for(int i = 0; i < s1.length(); i++){
            words[i] = s1.charAt(i);
        }
        
        boolean match = false;
        for(int i = 0; i < s1.length(); i++){
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        }
        
        if(match){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    bool judge=true;
    while(s.size()!=0){
        ll k=0;
        ll n=s.size();

        if(n>=5){
            if(s.substr(n-5)=="erase"||s.substr(n-5)=="dream"){
                k++;
                s.erase(n-5);
            }
        }
        if(n>=6){
            if(s.substr(n-6)=="eraser"){
                k++;
                s.erase(n-6);
            }
        }
        if(n>=7){
            if(s.substr(n-7)=="dreamer"){
                k++;
                s.erase(n-7);
            }
        }
        if(k==0){
            judge=false;
            break;
        }
    }
    if(judge) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main() {
  int N,K,sum=0;
  cin >> N >> K;
  vector<int> v(N);
  for(int i=0; i<N; i++) {
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0; i<K; i++) {
    sum+=v[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
n, m = map(int, raw_input().split(' '))

dist_sum = [0] * n
for x in xrange(n - 1):
    d = int(raw_input())
    dist_sum[x + 1] = dist_sum[x] + d

ans = 0
cur = 0

for x in xrange(m):
    k = int(raw_input())
    ans += abs(dist_sum[cur + k] - dist_sum[cur])
    ans %= 10 ** 5
    cur += k

print ans

Measured memory_bytes: 7380
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int x,n;
    cin>>x>>n;
    vector<bool> p(101,false);
    p[0]=true;
    rep(i,n){
        int tmp;
        cin>>tmp;
        p[tmp]=true;
    }
    if(n==0){
        cout<<x;return 0;
    }
    for(int i=0; i<=100;i++){
        if(x-i>0){
            if(!p[x-i]){
                cout<<x-i<<endl;
                return 0;
            }
        } else {
            cout<<x-i;
            return 0;
        }
        if(x+i<=100){
            if(!p[x+i]){
                cout<<x+i<<endl;
                return 0;
            }
        } else {
            cout << x+i;
            return 0;
        }
    }



    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>

using namespace std;

char ConvertChar(char c) {
    if (c == '1') {
        return '9';
    } else if (c == '9') {
        return '1';
    }
    return c;
}

string MapString(string s, char (*func_ptr)(char)) {
    string result_s = "";
    
    for (const char& c : s) {
        result_s += func_ptr(c);
    }

    return result_s;
}

int main() {
    string n;

    string ans;

    cin >> n;

    ans = MapString(n, ConvertChar);

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	#define all(c) c.begin(),c.end()
	#define init(c) memset(c,0,sizeof c)
	#define S second
	#define F first
	typedef long long ll;

	typedef pair<int,int> pii;
	typedef pair<ll,ll> pll;
	typedef vector<int> vi;
	typedef vector<ll> vl;
	const int N=20000005;
	int n,k,x,t,a,b,m;
	string s;
	vi v;
	double PI = 3.14159;
	int main(){

		cin >> n;
		printf("%0.9f\n",2*PI*n );

		
		return 0;
	}

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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define let const auto
#define USE1(T) template <typename T>
#define USE2(T, U) template <typename T, typename U>
#define I_ inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

USE1(T) using duo = std::pair<T, T>;
USE1(T) using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE2(T,U) I_ bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U) I_ bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int) I_ T in(){T x;std::cin>>x;return x;}
USE1(T=int) I_ vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T) I_ void pr(T&x){std::cout<<x<<'\n';}
USE2(T,...Ts) I_ void pr(T&x,Ts&&...xs){std::cout<<x<<' ';pr(std::forward<Ts>(xs)...);}
I_ int re(){int x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
I_ void wr(int x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

int bkt[0x100];
signed main() {
  auto s = in<string>();
  for (char c : s)
    bkt[c] = 1;
  if ((bkt['N'] ^ bkt['S']) or (bkt['W'] ^ bkt['E'])) {
    pr("No");
  } else {
    pr("Yes");
  }
  return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p, m, y;
string s, t;
ld w;
ll a, b;

ll c[11][11];

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s >> t;

	reverse(all(s));
	reverse(all(t));

	n = s.length();m = t.length();

	for(ll i=0;i<=n-m;i++) {
		ll ok = 1;
		ll j=0;
		for(;j<m;j++) {
			if(s[i+j] != t[j] && s[i+j] != '?') {
				ok = 0;
				break;
			}
		}
		if(ok) {
			for(ll j=0;j<m;j++) s[i+j]=t[j];
			for(ll j=0;j<n;j++) {
				if(s[j] == '?') s[j] = 'a';
			}
			reverse(all(s));
			cout<<s;
			return;
		}
	}

	cout<<"UNRESTORABLE\n";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) 0 and 0
#endif
#define rout(i) (cout << i << '\n', 0)
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
template<typename T, typename S>
inline istream& operator >> (istream &in, const pair<T, S> &a){
	return in >> a.first >> a.second;
}
template<typename T, typename S>
inline ostream& operator << (ostream &ou, const pair<T, S> &b){
	return ou << b.first << ' ' << b.second;
}
const ul maxn = 200001;
const ul maxk = 30;
ul k;
ul res;
ul n;
ul a[maxn], b[maxn], c[maxn], cnt[maxk];	
// #define mo(i, j) ((i) & ((2u<<(j))-1u))
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(ul i = 0u;i < n;++i)cin >> a[i];
	for(ul i = 0u;i < n;++i)cin >> b[i];
	k = __lg(max(*max_element(a,a+n), *max_element(b,b+n)))+2u;
	for(ul i = 0u;i < n;++i)for(ul j = 0u;j < k;++j)cnt[j] += (b[i]>>j) & 1u;
	for(ul i = 0u, x;i < k;++i){
		x = 0u;
		for(ul j = 0u;j < n;++j)c[j] = b[j]&((2u<<i)-1u);
		sort(c, c+n);
		ul q, w, e;
		for(ul j = 0u;j < n;++j){
			q = c+n - lower_bound(c,c+n, (1u<<i) - (a[j]&((1u<<i)-1u))) - cnt[i];
			e = c+n - (lower_bound(c,c+n, (2u<<i) - (a[j]&((1u<<i)-1u))));
			w = cnt[i]-e;
			x ^= q ^ w;
			if((a[j]>>i)&1u){
				x ^= n;
			}
		}
		res ^= (x&1u) << i;
	}
	cout << res << '\n';
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N;
    cin >> N;
    V v(N);
    vector<string> s(N);
    string t;
    rep(i, N){
        cin >> s[i] >> v[i];
    }
    cin >> t;
    ll ans = -1;
    rep(i, N){
        if(ans >= 0){
            ans += v[i];
        }
        else if(s[i] == t)ans = 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,cnt=0;
	cin >> a;
	for(int i=1;i<=9;i++){
		if(a%i==0 && a/i<=9 && a/i>=1)
			cnt++;
	}
	if(cnt>0) cout << "Yes" << endl;
	else if(cnt==0) cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }
struct stu{
    int num;
    int hight;
};
bool cmp(stu a,stu b){
    return a.hight > b.hight;
}
signed main() {
    int n;
    cin >> n;
    vector<int> num;
    int sum = 0;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        sum += tmp;
        num.push_back(tmp);
    }
    int ans = INF;
    vector<int>::iterator min = min_element(num.begin(),num.end());
    vector<int>::iterator max = max_element(num.begin(),num.end());
    size_t index_min = distance(num.begin(),min);
    size_t index_max = distance(num.begin(),max);
    for(int i=num[index_min];i<=num[index_max];i++){
        int tmp = 0;
        for(int j=0;j<n;j++){
            tmp += pow((i - num[j]),2);
        }
        if(ans > tmp) ans = tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
import itertools
n, m = [int(i) for i in input().split()]
A = np.zeros((m, n), dtype = int)
for i in range(m):
    tmp = [int(i) for i in input().split()]
    for j in range(1, len(tmp)):
        A[i][tmp[j]-1] = 1
p = np.array([int(i) for i in input().split()])
ans = 0

lst = list(itertools.product([0,1], repeat = n))
for i in range(len(lst)):
    tmp = np.remainder(np.dot(A, np.array(lst[i])), 2)
    if np.array_equal(tmp, p):
        ans += 1
print(ans)

Measured memory_bytes: 12436
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, x, r;
    cin >> n;
    vector<vector<int>> range;
    for(int i = 0; i < n; i++) {
        cin >> x >> r;
        range.push_back({x-r, x+r-1});
    }
    sort(range.begin(), range.end(), [](vector<int>& a, vector<int>& b){
        if (a[0] == b[0]) return a[1] > b[1];
        return a[0] < b[0];
    });
    int ans = 1;
    int so_far = range[0][1];
    for(int i = 1; i < n; i++) {
        if (range[i][0] > so_far) {
            ans += 1;
            so_far = range[i][1];
        } else {
            so_far = min(so_far, range[i][1]);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 6836