akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '[';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "");
    return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

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

    int n, m, q;
    cin >> n >> m >> q;
    vi as(q), bs(q), cs(q), ds(q);
    F0R (i, q)
        cin >> as[i] >> bs[i] >> cs[i] >> ds[i];
    F0R (i, q) {
        --as[i];
        --bs[i];
    }
    vi arr(n, m);
    auto calc = [&]() {
        int sum = 0;
        F0R (i, q) {
            if (arr[bs[i]] - arr[as[i]] == cs[i]) sum += ds[i];
        }
        return sum;
    };
    int best = 0;
    while (1) {
        dout << dvar(arr) << endl;
        ckmax(best, calc());
        int i = n - 1;
        bool repeat = true;
        while (repeat) {
            repeat = false;
            --arr[i];
            if (i > 0) {
                if (arr[i - 1] > arr[i]) {
                    arr[i] = m;
                    --i;
                    repeat = true;
                }
            } else {
                if (arr[i] == 0) {
                    cout << best << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3632
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = int(input())
S = "0" + input()

flag = False
cnt = 0
for i in range(1, N+1):
    c = S[i]
    if not flag and c == "#":
        flag = True
    elif c == "." and flag:
        cnt += 1

ans = cnt

# white
flag = False
cnt2 = 0
for i in range(1, N+1):
    c = S[i]
    if not flag and c == "#":
        flag = True
        
    if c == "#":
        cnt2 += 1
    elif c == "." and flag:
        cnt -= 1
        cnt += cnt2
        cnt2 = 0
        ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 41404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int T = scan.nextInt();

		int times = T /A;
		int ans = times * B;

		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

        String alpha = scanner.next();

        if (Character.isUpperCase(alpha.charAt(0))) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }
}


Measured memory_bytes: 26956
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let mut a = Vec::with_capacity(n);
    for _ in 0..n {
        let ai: usize = read!();
        a.push(ai);
    }

    // 考えうる整数列すべて
    let all = 3usize.pow(n as u32);

    // 積が奇数のもののみ
    let mut only_odd = 1;
    for &ai in &a {
        if ai % 2 == 0 {
            only_odd *= 2;
        }
    }
    
    println!("{}", all - only_odd);
}


Measured memory_bytes: 2112
import math

a, b = map(int, input().split())

def gcd(x, y):
  z = x % y
  if z == 0:
    return y
  else:
    return gcd(y, z)
  
def common_divisors(x, y):
  xd = make_divisors(x)
  xd.append(1)
  xd.append(x)
  yd = make_divisors(y)
  yd.append(1)
  yd.append(y)
  return set(xd).intersection(yd)

def make_divisors(n):
  divisors = [] 
  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n // i)
  return divisors

divisors = common_divisors(a, b)
divisors_set = frozenset(divisors)

res = []

for n in divisors:
  if n == 1 or n == 2 or n == 3:
    res.append(n)
  elif n % 2 == 0:
    continue
  else:
    dvs = set(make_divisors(n))
    if len(dvs) == 0 or not dvs <= divisors_set:
      res.append(n)

print("{}".format(len(res)))

Measured memory_bytes: 4712
#n=int(input())
l,r=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

if r-l>2019:
    print(0)
else:
    ans=2018
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans=min(ans,(i*j)%2019)
    print(ans)

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

int main()
{

  int n,k;
  int x[100];
  int dist=0;
  cin >> n >> k;

  for (int i = 0; i < n; i++)
  {
    cin >> x[i];
    // a
    if(x[i] < abs(x[i] -k)){
      dist+=x[i]*2;
    }
    // b
    else{
      dist+=abs(x[i] -k)*2;
    }
  }
  cout << dist << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		int[] arr = r.ria();
		String[] sArr = r.rsaml(arr[0]);
		StringBuilder sb = new StringBuilder();
		for(String line : sArr)
			sb.append(al(line)).append(al(line));
		print(sb.toString());
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}

Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 mypow(s64 x, s64 n)
{
    s64 ret = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            ret = ret * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

void comdiv(map<int, s64>& x, s64 y)
{
    map<int, s64> vy;
    for (int i = 2; i * i <= y; ++i)
    {
        s64 temp = 0;
        if (y % i == 0)
        {
            while (y % i == 0)
            {
                temp++;
                y /= i;
            }
            x[i] = MAX(x[i], temp);
        }
    }
    x[y] = MAX(x[y], 1);
}

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

    s64 N;
    s64 a;
    vs64 ainv;
    cin >> N;
    ainv.resize(N);
    map<int, s64> com;
    com[1] = 0;
    rep (i, N)
    {
        cin >> a;
        comdiv(com, a);
        ainv[i] = mypow(a, MOD - 2ULL);
    }

    s64 g = 1;
    for (auto mcom : com)
    {
        rep (i, mcom.second)
        {
            g *= mcom.first;
            g %= MOD;
        }
    }

    s64 ans = 0;
    rep (i, N)
    {
        ans += (g * ainv[i]) % MOD;
        ans %= MOD;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main implements Runnable {

    int ans, k;
    List<Integer>[] r;

    int dfs(int q, int p) {
        int h = 0;
        for (int w : r[q]) {
            h = Math.max(h, dfs(w, q) + 1);
        }
        if (h == k - 1 && p != 0) {
            ans++;
            h = -1;
        }
        return h;
    }

    void solve() throws IOException {
        int n = nextInt();
        k = nextInt();
        r = new List[n];
        for (int i = 0; i < n; i++) r[i] = new ArrayList<>();
        ans = 0;
        for (int i = 0; i < n; i++) {
            int q = nextInt();
            if (i != 0) r[q - 1].add(i); else if (q != 1) ans++;
        }
        dfs(0, 0);
        out.println(ans);
    }


    public static void main(String[] args) {
	    new Thread(null, new Main(), "name", 1 << 27).start();
    }

    @Override
    public void run() {
        try {
            solve();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        } finally {
            out.close();
        }
    }

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    StringTokenizer st;

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
}


Measured memory_bytes: 47336
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double degree = scanner.nextDouble();
 
        double S = 0.5*a*b*Math.sin(Math.PI*degree/180.0);
        double c = Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.PI*degree/180.0));
 
        System.out.printf("%.10f\n",S);
        System.out.printf("%.10f\n", a+b+c);
        System.out.printf("%.10f\n", 2*S/a);
    }
}


Measured memory_bytes: 28140
#include <cstdio>
int coin[6] = { 1,5,10,50,100,500 };
int main() {
	int n, sum = 0;
	for (int i = 0; i < 6; i++) {
		scanf("%d", &n);
		sum += coin[i] * n;
	}
	printf("%d\n", sum >= 1000);
}

Measured memory_bytes: 1032
#include<stdio.h>
int main()
{
	int n,pm,pe,pj,i;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
		scanf("%d %d %d",&pm,&pe,&pj);
		if(pm==100||pe==100||pj==100){
			printf("A\n");
		}
		else if((pm+pe)/2>=90){
			printf("A\n");
		}
		else if((pm+pe+pj)/3>=80){
			printf("A\n");
		}
		else if((pm+pe+pj)/3>=70){
			printf("B\n");
		}
		else if((pm+pe+pj)/3>=50&&(pm>=80||pe>=80)){
			printf("B\n");
		}
		else{
			printf("C\n");
		}
		}
	}
	return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
#define max(a, b) ((a) < (b) ? (b) : (a))
string str="a";
int n;
void fun(char a)
{
    if(str.size() ==  n)
    {
        cout<<str<<endl;
        return;
    }
    
    for(char x  ='a';x<=a+1;x++)
    {
        str+=x;
        fun(max(x,a));
        str.erase(str.end()-1);
        
    }
    
    
}


int main()
{

cin>>n;
fun('a');
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    string s, t;
    cin >> s;
    rep(i, s.length()){
        if((i + 1) % 2 == 1)
            t += s[i];
    }
    cout << t << endl;
    return 0;
    
}

Measured memory_bytes: 512
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var s = Console.ReadLine();
		var s1 = s.Remove(s.Length / 2);
		var s2 = s.Substring(s1.Length + 1);
		Console.WriteLine(s1 == s2 && Enumerable.Range(0, s1.Length / 2).All(i => s1[i] == s1[s1.Length - 1 - i]) ? "Yes" : "No");
	}
}


Measured memory_bytes: 26576
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Union_Find_Tree{
	public:
	vi Par;
	Union_Find_Tree(int n){
		Par=vi(n);
		for(int i=0;i<n;i++) Par[i]=i;
	}
	int Find_Par(int x){
		if(Par[x]==x) return x;
		return Par[x]=Find_Par(Par[x]);
	}
	bool Unite(int x,int y){
		x=Find_Par(x);
		y=Find_Par(y);
		if(x==y) return 0;
		Par[x]=y;
		return 1;
	}
};

int n,q;
vi a;

int main(){
	while(1){
		cin>>n>>q;
		if(!n) break;
		a=vi(n+1);
		for(int i=2;i<=n;i++) cin>>a[i];
		vp p(q);
		vi b(n+1);
		Union_Find_Tree uft(n+1);
		ll res=0;
		for(int i=0;i<q;i++){
			char c;
			int v;
			cin>>c>>v;
			if(c=='Q') p[i]={0,v};
			else{
				p[i]={1,v};
				b[v]++;
			}
		}
		for(int i=2;i<=n;i++) if(!b[i]) uft.Unite(i,a[i]);
		for(int i=q-1;i>=0;i--){
			bool B=p[i].first;
			int v=p[i].second;
			if(B){
				b[v]--;
				if(v!=1&&!b[v]) uft.Unite(v,a[v]);
			}
			else res+=uft.Find_Par(v);
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 4792
#C問題
N, M=map(int, input().split())

s_list=[]
for i in range(M):
    s_list.append(list(map(int, input().split())))
    
bit_list =[]
for i in range(2**N):
    bit_list.append(bin(i)[2:].zfill(N))
p_list = list(map(int, input().split()))

delete_list = []
for i in range(M):
    count = 0
    for j in range(2**N):
        count = 0
        for k in range(s_list[i][0]):
            if int(bit_list[j][s_list[i][k+1]-1]) == 1:
                count +=1
        if count % 2 != p_list[i]:
            delete_list.append(bit_list[j])
bit_list =[i for i in bit_list if i not in delete_list]
print(len(bit_list))

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

void Main()
{
    string s;
    std::cin >>  s;

    if (s[0] == s[1] && s[1] == s[2])
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

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

int a[100005];
int l[100005], r[100005];
int main(){
 	int n;
 	cin>>n;
 	for(int i=1;i<=n;i++) cin>>a[i];
 	int gcd=0;
 	for(int i=1;i<=n;i++){
 	    l[i]=gcd;
 	    gcd=__gcd(gcd, a[i]);
 	}
 	gcd=0;
 	int mx=0;
 	for(int i=n;i>=1;i--){
 	    r[i]=gcd;
 	    mx=max(mx, __gcd(l[i], r[i]));
 	    gcd=__gcd(gcd, a[i]);
 	}
 	cout<<mx<<endl;
 }

Measured memory_bytes: 1408
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[0]*(n+1)
for i in range(n):
    s[i+1]=s[i]+p[i]
res=0
for i in range(n-k+1):
    res=max(res,s[i+k]-s[i])
print((res+k)/2)

Measured memory_bytes: 71920
N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])

honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    string s;
    cin>>s;
    
    int min_d = 1000000;
    REP(i,s.size()-2){
        min_d = min(min_d,abs(stoi(s.substr(i,3))-753));
    }

    cout<<min_d<<endl;

    return 0;
}

Measured memory_bytes: 256
// C - Traveling

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	string ans = "Yes";

	int t, x, y;
	int prev_t = 0, prev_x = 0, prev_y = 0;
	for (int i=0; i<N; i++) {
		cin >> t >> x >> y;
		if (t - prev_t < abs(x - prev_x) + abs(y - prev_y)) ans = "No";
		if (((t - prev_t) - (abs(x - prev_x) + abs(y - prev_y))) % 2 != 0) ans = "No";
		prev_t = t;
		prev_x = x;
		prev_y = y;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

# 入力
H, W = map(int, input().split())
S = [input() for _ in range(H)]

# Python3 では str 型の要素の書き換えはできない
# 答えを格納する二次元配列を別途用意する ('.' のところは 0)
result = [[0 if v == '.' else '#' for v in row] for row in S]

# 各マス (i, j) について順に処理
for i in range(H):
    for j in range(W):
        if S[i][j] != '.':
            continue
        for d in range(8):
            ni = i + dx[d]
            nj = j + dy[d]
            if ni < 0 or ni >= H or nj < 0 or nj >= W:
                continue
            if S[ni][nj] == '#':
                result[i][j] += 1

for row in result:
    print(*row, sep = '')

Measured memory_bytes: 9236
program aaa
implicit none

integer(16) :: k, i, j, l, left, right, mid, res
character(105) :: s
character(1) :: a

read*, s
read*, k

left=0
right=0
mid=0
res=0

l=len_trim(s)
s=trim(s)

if(s(1:1)==s(l:l)) then
a=s(1:1)
 do i=1,l
  if(a==s(i:i)) then
  left=left+1
  else
  exit
  end if
 end do
 do i=l,1,-1
  if(a==s(i:i)) then
  right=right+1
  else
  exit
  end if
 end do
 do i=1,left
 s(i:i)='#'
 end do
 do i=l,(l-right+1),-1
 s(i:i)='#'
 end do
end if

if(2*l==left+right) then
write(*,'(i0)') k*l/2
return
end if


do i=1,l
 if (s(i:i)/='#') then
  do j=i+1,l
   if(s(i:i)==s(j:j)) then
   mid=mid+1
   s(j:j)='#'
     if(s(i:i)/=s(j+1:j+1)) then
     mid=mid+1
     res=res+mid/2
     mid=0
     end if
   else
   exit
   end if
  end do
 end if
end do
res=res*k+((left+right)/2)*(k-1)+left/2+right/2
write(*,'(i0)') res

end program

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        System.out.println(help(a,K));
    }
    static String help(int[] a, int K){
        int n = a.length;
        int max = a[0];
        if(a[0]==K) return "POSSIBLE";
        int div = a[0];
        for(int i=1;i<n;i++){
            if(a[i]==K) return "POSSIBLE";
            max = Math.max(max,a[i]);
            div = gcd(div,a[i]);
        }
        if(max<K) return "IMPOSSIBLE";
        return (max-K)%div==0?"POSSIBLE":"IMPOSSIBLE";
    }
    static int gcd(int a, int b){
        if(a<b){
            int med = b;
            b=a;
            a=med;
        }
        while(a%b!=0){
            int s = a;
            a = b;
            b = s%a;
        }
        return b;
    }
}


Measured memory_bytes: 49772
#coding:utf-8

n, t = map(int, input().split(' '))

def check(n, t):
  if t % 1000 != 0:
    print(-1, -1, -1)
    return
  if t // 1000 - n < 0:
    print(-1, -1, -1)
    return
  p = t // 1000 - n
  for i in range(n + 1):
    for j in range(0, n - i + 1):
      if i * 9 + j * 4 == p:
        print(i, j, n - i - j)
        return
  print(-1, -1, -1)

check(n, t)

Measured memory_bytes: 3064
n,q = map(int,input().split())
tree = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(lambda x: int(x)-1, input().split())
    tree[a].append(b)
    tree[b].append(a)

w = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    w[p-1] += x

stack = [0]
flag = [False]*n

while stack:
    nex = stack.pop()
    flag[nex] = True
    for i in tree[nex]:
        if flag[i]:
            continue
        w[i] += w[nex]
        stack.append(i)

print(*w)

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

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

    int a;
    int ans = 0;
    rep(i,n) {
        cin >> a;
        if ((i+1) % 2 != 0 && a % 2 != 0) {
            ans++;
        }
    }

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

Measured memory_bytes: 3596
n,m=map(int,raw_input().split())
s=[0]*n
s[0]=1
w=[1]*n
for i in range(m):
    x,y=map(int,raw_input().split())
    if s[x-1]==1:
        s[y-1]=1
        w[x-1]-=1
        w[y-1]+=1
    else:
        w[x-1]-=1
        w[y-1]+=1

    if w[x-1]==0:
        s[x-1]=0
print s.count(1)

Measured memory_bytes: 7300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 250;
int a[maxn];
long long c(int a,int b)
{
    int i;
    long long int sum=1;
    if(a<b)
        return 0;
    if(b<a-b)   //c(a,b)=c(a,a-b)  可以减少运算
        b=a-b;

    for(i=b+1;i<=a;i++)     //c(a,b)=a!/b!(a-b)! 再对此式约分
       sum*=i;

    for(i=1;i<=a-b;i++)
        sum/=i;

      return sum;
}
int main()
{
    int n,m;
    cin >> n >>m;
    cout <<c(n,2)+c(m,2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define PAUSE \
    int t;    \
    cin >> t
#define int long long
#define vi vector<long long>
#define mapii map<long long, int>
#define mapci map<char, int>
#define append(x) push_back(x)
#define tcase          \
    long long t;       \
    scanf("%lld", &t); \
    while (t--)
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int>>
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
// #define debug(x, y) cout << "case #" << x << " at itr #" << y << endl
// #define debug(x) cout << "case #" << x << endl
#define ff first
#define ss second
#define range(ini, x) for (int itr = ini; itr < x; itr++)
#define takearr(x)    \
    for (auto &i : x) \
    cin >> i
#define print(x)     \
    for (auto i : x) \
        cout << i << " ";
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define foreach(i, x) for (auto i : x)
#define double long double
#define setbitcount __builtin_popcount

// #define range(ini, x, step) for( int itr = ini, i < x; itr += step )
using namespace std;
// using namespace __gnu_pbds;
// template < class type > using oset=tree<type, null_type,less<type>, rb_tree_tag,tree_order_statistics_node_update>;
const int mmx = 2e5 + 1;
const int mnx = 1e4 + 1;
const int mmod = 1e9 + 7;

int dp[mmx];

int fx(vi &arr, int idx)
{
    int n = arr.size();

    if (idx >= n)
    {
        return dp[idx] = 0;
    }

    if (dp[idx] != -1)
    {
        return dp[idx];
    }

    if (idx + 2 < n)
    {
        return dp[idx] = min(abs(arr[idx] - arr[idx + 1]) + fx(arr, idx + 1), abs(arr[idx] - arr[idx + 2]) + fx(arr, idx + 2));
    }
    else if (idx + 1 < n)
    {
        return dp[idx] = abs(arr[idx] - arr[idx + 1]) + fx(arr, idx + 1);
    }

    return 0;
}

signed main()
{

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

    int tcases;
    // cin >> tcases;
    tcases = 1;

    for (int __case = 1; __case <= tcases; __case++)
    {
        //cout << "Case #" << __case << ":";
        /* Code */
        memset(dp, -1, sizeof(dp));
        int N;
        cin >> N;
        vi arr(N);
        takearr(arr);
        cout << fx(arr, 0) << endl;
    }

    return 0;
}


Measured memory_bytes: 9568
# -*- coding: utf-8 -*-
import sys
import copy

def main():
	N, M = map(int, input().split(" "))
	
	graph = []
	maps = [[9999999 for _ in range(N)] for _ in range(N)]
	for i in range(N):
		maps[i][i] = 0
	
	for _ in range(M):
		a, b, c = map(int, input().split(" "))
		a, b = a-1, b-1
		maps[a][b] = c
		maps[b][a] = c
	
	ans = 0
	org = copy.deepcopy(maps)
	for k in range(N):
		for i in range(N):
			for j in range(N):
				#if maps[i][j] == 9999999:
					#continue
				if i <= j:
					continue
				maps[i][j] = min(maps[i][j], maps[i][k] + maps[k][j])
				maps[j][i] = min(maps[i][j], maps[i][k] + maps[k][j])
			
	for i in range(N):
		for j in range(N):
			if i <= j:
				continue
			if org[i][j] == 9999999:
				continue
			if org[i][j] != maps[i][j]:
				ans += 1
		
	print(ans)
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3828
#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(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
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;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x, ll n, ll mod) {
	ll bit = 1;
	while (n) {
		if (n & 1)bit = bit * x % mod;
		x = x * x % mod;
		n /= 2;
	}
	return bit;
}
signed main() {
	ll n;
	cin >> n;
	for (int i = sqrt(n); i >= 1; i--) {
		if (n % i == 0) {
			cout << i + n / i - 2 << endl;
			ggr
		}
	}
	ggr
}

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

int main() {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    if(n == 1 && a == b) return puts("1"), 0;
    if(n < 2 || a > b) return puts("0"), 0;
    printf("%lld\n", 1ll + 1ll*(n-2)*(b-a));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, m;  scanf("%d %d", &n, &m);
  int ans[52] = {0};
  for(int i=0; i<m; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    ans[a]++, ans[b]++;
  }
  for(int i=1; i<=n; i++)
    printf("%d\n", ans[i]);

  return 0;
}


Measured memory_bytes: 128
package main

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

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const INF = 1000000000

type key struct {
	cost int
	open int
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()
	pattern := 1 << uint(n)
	keys := make([]key, m)
	for mi := 0; mi < m; mi++ {
		a, b := nextInt(), nextInt()
		open := 0
		for bi := 0; bi < b; bi++ {
			c := nextInt()
			open = open | (1 << uint(c-1))
		}
		keys[mi] = key{a, open}
	}

	dp := make([][]int, m+1)
	dp[0] = make([]int, pattern)
	// dp[0][0] = 0
	for pi := 1; pi < pattern; pi++ {
		dp[0][pi] = INF
	}

	for mi := 0; mi < m; mi++ {
		dp[mi+1] = make([]int, pattern)
		copy(dp[mi+1], dp[mi])
		for pi := 0; pi < pattern; pi++ {
			pnext := pi | keys[mi].open
			if dp[mi][pi]+keys[mi].cost < dp[mi+1][pnext] {
				dp[mi+1][pnext] = dp[mi][pi] + keys[mi].cost
			}
		}
	}

	switch {
	case dp[m][pattern-1] < INF:
		fmt.Println(dp[m][pattern-1])
	default:
		fmt.Println(-1)
	}
}


Measured memory_bytes: 33792
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]

a=1
b=10**5
for i in range(m):
    if l[i][0]>=a:
        a=l[i][0]
    if l[i][1]<=b:
        b=l[i][1]

print(max(0,b-a+1))

Measured memory_bytes: 27332
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 1; i <= n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
#define MP make_pair
#define FI first
#define SE second
#define VI vector<int>
#define CLR(x) memset(x, 0, sizeof(x))
#define SZ(x) (x.size())
#ifdef QWERTIER
#define err(x) cerr<<x<<endl;
#else
#define err(x)
#endif

typedef long long LL;

int n, a[100010];
LL b[100010];
LL sum, sum2;
bool check() {
  if (sum % (n*(LL)(n+1)/2) != 0)
    return false;
  LL times = sum / (n*(LL)(n+1)/2);
  LL rem = times;
  FOR (i, n) {
    int dec;
    if (i > 1)
      dec = a[i] - a[i-1];
    else
      dec = a[i] - a[n];
    b[i] = dec;
    b[i] -= times;
    //printf("%I64d\n", b[i]);
    if (b[i] % n != 0)
      return false;
    LL t = 0;
    if (b[i] < 0) {
      t = -b[i] / n;
      b[i] += t * n;
      rem -= t;
    } else if (b[i] > 0) {
      return false;
    }
    if (rem < 0)
      return false;
  }
  if (rem != 0)
    return false;
  return true;
}
int main() {
#ifdef QWERTIER
  freopen("in.txt", "r", stdin);
#endif
  scanf("%d", &n);
  FOR (i, n) {
    scanf("%d", &a[i]);
    sum += a[i];
    if (i > 1)
      sum2 += a[i] - a[i-1];
  }
  sum2 += a[1] - a[n];
  puts(check()?"YES":"NO");
  return 0;
}


Measured memory_bytes: 1408
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var s = o.a(1);
  var l = s.length;
  var ans = 0, w = 0;
  for(var i = l-1; i >= 0; i--){
    if(s[i] === "W")w++;
    else ans += w;
  }
  return ans;
}

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

int main(){
    using namespace std;
    unsigned long N, Q;
    cin >> N >> Q;
    vector<unsigned long> c(N);
    for(auto&& i : c){
        cin >> i;
        --i;
    }
    vector<tuple<unsigned long, unsigned long, unsigned long>> queries(Q);
    {
        unsigned long cnt{0};
        for(auto&& [i, l, r] : queries){
            cin >> l >> r;
            --l;
            i = cnt++;
        }
    }
    constexpr unsigned long B{2000};
    sort(begin(queries), end(queries), [&B](const auto& lhs, const auto& rhs){
        const auto& [i, li, ri] = lhs;
        const auto& [j, lj, rj] = rhs;
        return li / B == lj / B ? (li / B) & 1 ? ri > rj : ri < rj : li < lj;
    });
    unsigned long nl{0}, nr{0}, now{0};
    vector<unsigned long> cnt(N), ans(Q);
    for(const auto& [i, l, r] : queries){
        while(nr < r)now += !cnt[c[nr++]]++;
        while(nr > r)now -= !--cnt[c[--nr]];
        while(nl < l)now -= !--cnt[c[nl++]];
        while(nl > l)now += !cnt[c[--nl]]++;
        ans[i] = now;
    }
    for(const auto& i : ans)cout << i << endl;
    return 0;
}

Measured memory_bytes: 27152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),M = in();
    int mina = 1,maxa = N;
    REP(i,M){
        chmax(mina,in());
        chmin(maxa,in());
    }
    cout << max(0,maxa-mina+1) << "\n";
}

Measured memory_bytes: 256
def main():
    X = int(input())

    def is_ok(mid):
        if X <= mid*(mid+1)//2:
            return True
        else:
            return False

    def binary_search_meguru():
        ng = -1
        ok = 10**9 + 1
        while abs(ok - ng) > 1:
            mid = ng + (ok - ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    print(binary_search_meguru())


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	LL N, T;
	cin >> N >> T;

	LL sum = 0;
	vector<LL> t(N);
	IN(t);

	LL prev = -LINF;
	bool f = false;
	LL start = -INF;
	LL end = -INF;
	for (int i = 0; i < N; ++i) {
		if (f == false) {
			f = true;
		}
		else {
			if (t[i] < end) {
				sum += t[i] - start;
			}
			else {
				sum += T;
			}
		}
		start = t[i];
		end = t[i] + T;
	}
	if (f) {
		sum += T;
	}
	cout << sum << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

int main()
{
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  
  int ans = max(max(A1, A2), A3) - min(min(A1, A2), A3);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	/*
	int Wi, Hi, xi, yi;
	cin >> Wi >> Hi >> xi >> yi;
	double W = (double)Wi, H = (double)Hi, x = (double)xi, y = (double)yi;
	*/
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	double rect = (W * H) / 2;
	bool isTwo = false;
	if (x == W / 2 && y == H / 2) isTwo = true;

	printf("%f %d\n",rect,(isTwo ? 1 : 0));

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for(auto it = v.begin();it != v.end();it++) 
		min = std::min(min,*it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}


Measured memory_bytes: 504
n,q=map(int, input().split( ))
S=[[] for i in range(n)]
for i in range(q):
    c,*a=map(int,input().split( ))
    if c==0:
        S[a[0]].append(a[1])
    elif c==1:
        if len(S[a[0]])>0:
            print(S[a[0]][-1])
        else:
            pass
    elif c==2:
        if len(S[a[0]])>0:
            S[a[0]].pop()
        else:
            pass



Measured memory_bytes: 13440
#include<stdio.h>
#define INF 1000000
void warshall_floyd(void);
int min(int,int);

int graph[10][10],n;

int main(void){
  int a,b,c,i,j,sum[10],ans1,ans2;

  while(scanf("%d",&n),n){

    for(i=0;i<10;i++)sum[i]=0;
    ans1=INF;

    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	graph[i][j]=INF;
      }
      graph[i][i]=0;
    }
    
    for(i=0;i<n;i++){
      scanf("%d %d %d",&a,&b,&c);
      graph[a][b]=graph[b][a]=c;
    }
    warshall_floyd();

    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	if(graph[i][j]<INF)sum[i]+=graph[i][j];
      }
    }

    for(i=0;i<10;i++){
      if(ans1>sum[i] && sum[i]>0){
	ans1=sum[i];
	ans2=i;
      }
    }
    printf("%d %d\n",ans2,ans1);
  }

  return 0;
}

void warshall_floyd(void){
  int i,j,k;

  for(k=0;k<10;k++)
    for(i=0;i<10;i++)
      for(j=0;j<10;j++)
	graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
}

int min(int x,int y){
  return x<y?x:y;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

long long n, x, cur = 0;
vector<vector<long long>> tests;

long long check(long long k){

    long long complete = k / x;
    long long other = k - complete * x;
    long long cursum = 0, best = 0;

    if(complete >= n)
        return cur + 1;

    for(int i = 0; i < complete; ++i)
        cursum += tests[i][0];

    best = max(best, cursum);

    for(int i = 0; i < n; ++i){
        if(i < complete){
            best = max(best, tests[complete][0] + (cursum - tests[i][0]) + tests[i][3] * other - tests[i][1] * (tests[i][3] - tests[i][2]));
            best = max(best, tests[complete][0] + (cursum - tests[i][0]) + tests[i][2] * other);
        } else {
            best = max(best, cursum + tests[i][3] * other - tests[i][1] * (tests[i][3] - tests[i][2]));
            best = max(best, cursum + tests[i][2] * other);
        }
    }
    //cout << best << endl;
    return best;

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    // D = A - B
    // Di = Ci * (Ai - Bi)

    // If Di is useful (Ai > Bi) then set Ci to Ui
    // otherwise it is set to Li

    long long b, l ,u; cin >> n >> x;

    for(int i = 0; i < n; ++i){
        cin >> b >> l >> u;
        cur += b * l;
        tests.push_back({(x - b) * u + b * l, b, l, u});
    }

    sort(tests.begin(), tests.end(), greater<vector<long long>>());

    long long mid, lef = -1, rig = 1e17;
    for(;lef < rig - 1;){
        mid = lef + rig >> 1;
        if(check(mid) >= cur)
            rig = mid;
        else
            lef = mid;
    }

    cout << rig << "\n";

    return 0;

}


Measured memory_bytes: 9648
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
/*
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
*/

using namespace std;


string suffle(string s,int h){
    string prm=s;
    for (int i = 0; i < s.size();i++){
        if(i<s.size()-h)
            s[i] = prm[h+i];
        else
            s[i] = prm[h - s.size() + i];
    }
        return s;
}

int main()
{
    string ans;
    int m;
    int h;

    while (cin>>ans)
    {
        if (ans[0] == '-')
            break;
        cin >> m;
        for (int i = 0; i < m;i++){
            cin >> h;
            ans = suffle(ans, h);
        }
        cout << ans << endl;
    }
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int main() {
    string s,t;
    cin>>s>>t;
    vvi pl(26,vi(0));
    for (int i=0;i<int(s.size());i++){
        int num=s[i]-'a';
        pl[num].push_back(i);
    }
    ll ans=0;
    ll now=0;
    ll c=0;
    int b=1;
    for (int i=0;i<int(t.size());i++){
        int num=t[i]-'a';
        if (pl[num].size()==0){
            b=0;
            break;
        }
        else{
            int num1=pl[num].size();
            if (pl[num][num1-1]<now){
                now=pl[num][0]+1;
                c+=1;
            }
            else{
                auto index=lower_bound(all(pl[num]),now)-pl[num].begin();
                now=pl[num][index]+1;
            }
        }
    }
    ll ss=ll(s.size());
    if (b==0){
        cout<<-1<<endl;
    }
    else{
        unsigned long long c1=c;
        unsigned long long sss=ss;
        unsigned long long now1=now;
        cout<<c1*sss+now1<<endl;
    }

    return 0;
}


Measured memory_bytes: 1216
S = input()

S_set = set(S)
if len(S_set) % 2 == 0:
    if S_set == set() or S_set == set(['N', 'S']) or S_set == set(['E', 'W']) or S_set == set(['N', 'S', 'E', 'W']):
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

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

	set<string> valid = { "hi", "hihi", "hihihi", "hihihihi", "hihihihihi" };
	string c;

	cin >> c;
	if ( valid.count(c) )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<string>
#include<vector>
#include<cctype>
#include<cmath>
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

int main(){
    map<string, int> snum;
    vector<string> vecstr;
    int N;
    cin >> N;
    string tmp;
    int mcnt = 0;
    while(cin>>tmp){
        vecstr.push_back(tmp);
        snum[tmp]++;
        if(snum[tmp]>mcnt)
            mcnt = snum[tmp];
    }
    sort(vecstr.begin(), vecstr.end());
    for(auto s:vecstr){
        if(snum[s]==mcnt){
            cout << s << endl;
            snum[s]--;
        }
    }

    return 0;
}

Measured memory_bytes: 26736