akhauriyash/Code-Regression huggingface dataset:
class Dice
 
  def initialize( given_ary )
    @ary = given_ary
  end
 
  def topface( val )
    4.times do
      self.roll( "E" )
      if self.top == val
        return
      end
    end
    3.times do
      self.roll( "N" )
      if self.top == val
        return
      end
    end
  end
 
  def frontface( val )
    4.times do
      tmp = @ary[1]
      @ary[1] = @ary[2]
      @ary[2] = @ary[4]
      @ary[4] = @ary[3]
      @ary[3] = tmp
      if @ary[1] == val
        return
      end
    end
  end
 
  def checkall( givendice )
    4.times do
      self.roll( "E" )
      4.times do
        tmp = @ary[1]
        @ary[1] = @ary[2]
        @ary[2] = @ary[4]
        @ary[4] = @ary[3]
        @ary[3] = tmp
        if identical( givendice )
          return true
        end
      end
    end
    3.times do
      self.roll( "N" )
      4.times do
        tmp = @ary[1]
        @ary[1] = @ary[2]
        @ary[2] = @ary[4]
        @ary[4] = @ary[3]
        @ary[3] = tmp
        if identical( givendice )
          return true
        end
      end
    end
    return false
  end
 
  def roll( direction )
    case direction.downcase
    when "e"
      tmp = @ary[0]
      @ary[0] = @ary[3]
      @ary[3] = @ary[5]
      @ary[5] = @ary[2]
      @ary[2] = tmp
    when "w"
      tmp = @ary[0]
      @ary[0] = @ary[2]
      @ary[2] = @ary[5]
      @ary[5] = @ary[3]
      @ary[3] = tmp
    when "s"
      tmp = @ary[0]
      @ary[0] = @ary[4]
      @ary[4] = @ary[5]
      @ary[5] = @ary[1]
      @ary[1] = tmp
    when "n"
      tmp = @ary[0]
      @ary[0] = @ary[1]
      @ary[1] = @ary[5]
      @ary[5] = @ary[4]
      @ary[4] = tmp
    end
  end
 
  def top
    @ary[ 0 ]
  end
 
  def front
    @ary[ 5 ]
  end
 
  def right
    @ary[ 2 ]
  end
 
  def vals
    @ary
  end
 
  def compare( givendice )
    4.times do
      self.roll( "E" )
      if identical( givendice )
        return true
      end
    end
    3.times do
      self.roll( "N" )
      if identical( givendice )
        return true
      end
      4.times do
      self.roll( "E" )
      if identical( givendice )
        return true
      end
    end
 
    end
    false
 
  end
 
  def identical( givendice )
    @ary.zip( givendice.vals ).map{ | x, y | ( x - y ).abs }.inject(:+) == 0
  end
 
end
 
 
dice1 = Dice.new( gets.split.map(&:to_i) )
dice2 = Dice.new( gets.split.map(&:to_i) )
puts ( dice1.checkall( dice2 ) )? "Yes": "No"

Measured memory_bytes: 8784
#include <iostream>
#include <vector>
using namespace std;
const int mod = 1e9+7;

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; ++i) cin >> S[i];
  vector< vector<int> > dp(H,vector<int>(W,0));
  dp[0][0] = 1;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(i < H-1 and S[i+1][j] != '#')
        dp[i+1][j] += dp[i][j], dp[i+1][j] %= mod;
      if(j < W-1 and S[i][j+1] != '#')
        dp[i][j+1] += dp[i][j], dp[i][j+1] %= mod;
    }
  }
  cout << dp[H-1][W-1] << endl;
}


Measured memory_bytes: 5248
import itertools

N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
  x[i],y[i]=map(int,input().split())

l=[i for i in range(N)]
dis=0
cnt=0
for v in itertools.permutations(l):
  #print(v)
  cnt+=1
  for i in range(1,N):
    dis+=((x[v[i]]-x[v[i-1]])**2+(y[v[i]]-y[v[i-1]])**2)**0.5

print(dis/cnt)

Measured memory_bytes: 40940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

const int N=5005;
const int inf=2000000001; 

struct Per{
	int h,p,s;
}a[N];
int n,ans;
int dp[N][N];

bool cmp(Per a,Per b){
	return a.s<b.s;
}

int main(){
	int i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++){
		scanf("%d%d",&a[i].h,&a[i].p);
		a[i].s=a[i].h+a[i].p;
	}
	sort(a+1,a+1+n,cmp);
	for (i=0;i<=n;i++)
		for (j=0;j<=n;j++) dp[i][j]=inf;
	dp[0][0]=0;
	for (i=1;i<=n;i++)
		for (j=0;j<=i;j++){
			dp[i][j]=dp[i-1][j];
			if (j){
				if (dp[i-1][j-1]<=a[i].h)
				dp[i][j]=min(dp[i][j],dp[i-1][j-1]+a[i].p);
			}
		}
	for (i=1;i<=n;i++)
		if (dp[n][i]<inf) ans=i;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 98048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,x,y;
    cin>>a>>b>>x;
    y=(b/x)-(a/x);
    if(a%x==0)
        y++;
    cout<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


LL mod = 998244353;
LL n, m, k;

LL pow2(LL a, LL b) {
    LL ans = 1;
    while(b > 0) {
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

class Inverse{
    public:
        vector<LL> inv;
        int sz;
    Inverse(int _sz = 0){
        sz = max(1, _sz);
        inv = vector<LL>(sz + 1);
        inv[1] = 1;
        for(int i = 2; i <= sz; i++) {
            inv[i] = inv[mod % i] * (mod - mod / i) % mod;
        }
    }
    LL get(LL x) {
        if(x <= sz) return inv[x];
        else return pow2(x, mod - 2);
    }
};

class Combination{
    //mode=1: pre cal c[n][m]
    //mode=2: pre cal fac[] invfac[] => fac[n] * invfac[m] * invfac[n - m]
    public:
        Combination(int _mode, int _sz): mode(_mode), sz(_sz){
            if(mode == 1) {
                c = vector<vector<LL>>(sz + 1, vector<LL>(sz + 1, 0));
                c[0][0] = 1;
                for(int i = 1; i <= sz; i++) {
                    c[i][0] = c[i][i] = 1;
                    for(int j = 1; j < i; j++) {
                        c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
                    }
                }
            }
            else {
                Inverse inv(sz);
                fac = vector<LL>(sz + 1);
                invfac = vector<LL>(sz + 1);
                fac[0] = invfac[0] = 1;
                for(int i = 1; i <= sz; i++) {
                    fac[i] = fac[i - 1] * i % mod;
                    invfac[i] = invfac[i - 1] * inv.get(i) % mod;
                }
            }
        }
        LL get(int n, int m){
            assert(m <= n && n <= sz);
            if(mode == 1) return c[n][m];
            else return fac[n] * invfac[m] % mod * invfac[n - m] % mod;
        }

        int mode, sz;
        vector<vector<LL>> c;
        vector<LL> fac, invfac;
};


int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  cin >> n >> m >> k;

  LL ans = pow2(m, n);  
  Combination c(2, 200005);

  for (int i = k + 1; i < n; i++) {
    ans -= c.get(n - 1, i) * pow2(m - 1, n - i - 1) % mod * m;
    ans = (ans % mod + mod) % mod;
  }

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

Measured memory_bytes: 8008
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		Integer n = sc.nextInt();

		Long min = 1000001L;
		Long max = -1000001L;
		Long sum = 0L;

		for (Integer i = 0; i < n; i++) {
			Long a = sc.nextLong();

			if (a < min) {
				min = a;
			}

			if (a > max) {
				max = a;
			}

			sum += a;

		}

		System.out.print(min);
		System.out.print(" ");
		System.out.print(max);
		System.out.print(" ");
		System.out.println(sum);

	}
}


Measured memory_bytes: 42520
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main()
{
    ll n,m;
    ll d[9]={2,5,5,4,5,6,3,7,6};
    cin >> n >> m;
    vector<pll> a(m);
    rep(i,m){
        cin >> a[i].fi;
        a[i].se=d[a[i].fi-1];
    }
    sort(a.rbegin(),a.rend());
    vector<ll> dp(n+1,-1);
    dp[0]=0;
    rep(i,n+1){
        if(dp[i]!=-1){
            rep(j,m){
                if(i+a[j].se<=n){
                    dp[i+a[j].se]=max(dp[i+a[j].se],dp[i]+1);
                }
            }
        }
    }
    ll match=n,remain=dp[n];
    string ans="";
    while(match>0){
        rep(i,m){
            if(match>=a[i].se && dp[match-a[i].se]==remain-1){
                match-=a[i].se;
                remain--;
                string c=to_string(a[i].fi);
                ans+=c;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 384
n = int(input())

L = list(map(int,input().split()))

ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if L[i]==L[j] or L[j]==L[k] or L[i]==L[k]:
        continue
      if L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[k]+L[j]>L[i]:
        ans+=1

print(ans)

Measured memory_bytes: 9104
function read() {
  return require('fs')
    .readFileSync('/dev/stdin', 'utf8')
    .trim()
    .replace(/\n/g, ' ')
    .split(' ');
}

const inputs = read().map(token => +token);
const K = inputs[1];
const H = inputs.slice(2);
console.log(H.filter(h => h >= K).length);

Measured memory_bytes: 29004
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

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

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

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

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

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

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

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	r := readInt()
	g := readInt()
	println(2*g - r)
}


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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n,m;
    cin >> n >> m;
    vector<pair<pair<ll,ll>, ll>> x(m);
    for (ll i = 0; i < m; i++){
        cin >> x[i].first.first >> x[i].first.second;
        x[i].second = i;
    }

    sort(x.begin(), x.end());

    ll c = 1;
    x[0].first.second = 1;

    for (ll i = 1; i < m; i++){
        if (x[i].first.first == x[i-1].first.first){
            c++;
        }
        else{
            c = 1;
        }
        x[i].first.second = c;
    }

    /*for (ll i = 0; i < m; i++){
        cout << x[i].first.first << " " << x[i].first.second << " " <<  x[i].second << endl;
    }*/

    vector<pair<ll,string>> y(m);
    for (ll i = 0; i < m; i++){
        y[i].first = x[i].second;
        string s = to_string(x[i].first.first);
        rep(j,(6-s.size())){
            y[i].second.push_back('0');
        }
        rep(j,s.size()){
            y[i].second.push_back(s[j]);
        }

        string t = to_string(x[i].first.second);
        rep(j,(6-t.size())){
            y[i].second.push_back('0');
        }
        rep(j,t.size()){
            y[i].second.push_back(t[j]);
        }

    }

    sort(y.begin(), y.end());

    for (ll i = 0; i < m; i++){
        cout << y[i].second << endl;
    }

}

Measured memory_bytes: 9528
ys, xs = map(int, input().split())
mas = []
for y in range(ys):
    mas.append(list(input()))
import numpy as np
mas_new = []
mas = np.array(mas)

for ma in mas:
    if (ma == '.').sum() != xs:
        mas_new.append(ma.tolist())
        
mas = np.array(mas_new).T

mas_new = []

for ma in mas:
    if (ma == '.').sum() != mas.shape[1]:
        mas_new.append(ma.tolist())
    
mas = np.array(mas_new).T
mas = mas.tolist()
for ma in mas:
    print(''.join(ma))

Measured memory_bytes: 12448
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	n = int(input().strip())
	s = [[0] * 2 for _ in range(n)]
	for i in range(n):
		s[i][0], s[i][1] = map(int, input().strip().split())
	s2 = sorted(s, key=itemgetter(1))
	t = 0
	for item in s2:
		t += item[0]
		if t > item[1]:
			print('No')
			return
	print('Yes')

if __name__ == '__main__':
	main()


Measured memory_bytes: 70764
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
const int INF = 1e6;
const int MAX = 1e5+10;
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define vi vector<int>
#define vli vector<lli>
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define print(a) cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define sortvec(a) sort(a.begin(),a.end())
#define pdd pair<lli,lli>
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1;x = x % mod; while (y > 0){if (y & 1) res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	} 
	return -1;
}
template <typename T>
void printvec(vector<T> inp){
	for(int i=0;i<inp.size();i++){
		cout<<inp[i]<<" ";
	}
	cout<<endl;
}
template <typename T>
T ceildiv(T x, T y){
	return 1 + ((x - 1) / y);
}
bool pd(string s1,string s2){
	string temp=s1;
	reverse(temp.begin(),temp.end());
	if(temp==s2) return true;
	return false;
	
}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b && a!=c)||(b==c && b!=a)||(a==c && a!=b)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}
 
 

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

誰の子にもなっていない頂点は、根

１人の子になっている頂点は、それが親

２人以上の子になっている頂点は親が不明
親の候補の個数を記憶

根から、幅優先探索でたどっていく

親が不明の頂点についたらそこで止まる。探索はしない
（早くついたということはそれはショートカットルートだった）
親の候補の個数を減らす
１だったらそれが本当の親

*/

class Node{
	Node parent;
	Node[] kids;
	Node[] parents;
	long count;
	long id;
	this(long id){
		this.id = id;
	}
}

class X{
	Node from;
	Node to;
	this(Node from, Node to){
		this.from = from, this.to = to;
	}
}

void main(){
	long n = read.to!long;
	long m = read.to!long;
	
	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i);
	
	foreach(i; 0 .. n - 1 + m){
		long a = read.to!long - 1;
		long b = read.to!long - 1;
		
		nodes[a].kids ~= nodes[b];
		nodes[b].parents ~= nodes[a];
	}
	
	Node root;
	foreach(nd; nodes){
		if(nd.parents.length == 0) nd.parent = null, root = nd;
		else nd.count = nd.parents.length;
	}
	
	X[] queue;
	long ix = 0;
	foreach(nd; root.kids) queue ~= new X(root, nd);
	while(ix < queue.length){
		X x = queue[ix];
		if(x.to.count == 1){
			x.to.parent = x.from;
			foreach(nd; x.to.kids) queue ~= new X(x.to, nd);
		}
		else x.to.count -= 1;
		
		ix += 1;
	}
	
	foreach(nd; nodes){
		if(nd.parent) writeln(nd.parent.id + 1);
		else writeln(0);
	}
}


Measured memory_bytes: 31356
#include <stdio.h>

int main()
{
    int n,p[200000],i,j,ans = 0,min = 200001;
    scanf("%d",&n);

    for (i = 0; i < n; i++)
    {
        scanf("%d",&p[i]);
    }

    for (i = 0; i < n; i++)
    {
        if(min > p[i])
        {
            ans++;
            min = p[i];
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
struct UnionFind {
vector<int> d;
UnionFind(int n):d(n,-1){}
int root(int x){
    if(d[x] <0) return x;
    return d[x] = root(d[x]);
}
bool unite(int x,int y){
    x = root(x),y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
}
int size(int x) {return -d[root(x)];}
bool same(int x,int y){return root(x) == root(y);}
};
int seen[110000];
signed main(){
    int n,m;cin >>n >> m;
    UnionFind uf(n);
    rep(i,m){
        int x,y,z;cin >> x >> y >> z;
        x--;y--;
        uf.unite(x,y);

    }
    int ans = 0;
    rep(i,n){
        auto hoge = uf.root(i);
        if(seen[hoge] == 0)ans++;
        seen[hoge] = 1;
    }
    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 212
#define LL long long
int T,n;LL a[N];char sc[N];
struct LB{
	LL b[63];bool hv;
	inline LB(){memset(b,0,sizeof(b));hv=0;}
	inline LL& operator[](const int &x){return b[x];}
	inline LL operator[](const int &x)const{return b[x];}
	inline bool Ins(LL x){for(LL i=60;i>=0;i--)if(x&(1ll<<i)){if(!b[i]){b[i]=x;return true;}x^=b[i];}return false;}
	inline bool can(LL x){for(LL i=60;i>=0;i--)if(x&(1ll<<i)){if(!b[i])return true;x^=b[i];}return false;}
	inline void cls(){memset(b,0,sizeof(b));hv=0;}
}b,c;
inline LB Cap(const LB &A,const LB &B)
{
	LB C(A),I(A),ans;int i,j;LL x,v;ans.hv=A.hv&&B.hv;
	for(i=0;i<=60;i++)if(x=B[i])for(v=0,j=i;j>=0;j--)if(x&(1ull<<j)){if(!C[j]){C[j]=x;I[j]=v;break;}x^=C[j];v^=I[j];if(!x){ans[i]=v;break;}}return ans;
}
inline LB Xor(LB b,LL v){c.cls();for(LL i=60;i>=0;i--)if(b.b[i]){if(b.b[i]!=v)c.Ins(b.b[i]^v);}if(b.hv)c.Ins(v);if(!b.can(v))c.hv=1;return Cap(b,c);}
int main(){
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);int i;for(i=1;i<=n;i++)scanf("%lld",&a[i]);
		scanf("%s",sc+1);b.cls();b.hv=1;
		for(i=n;i>=1;i--)if(sc[i]=='0')b.Ins(a[i]);else b=Xor(b,a[i]);
		printf("%d\n",!b.hv);
	}return 0;
}

Measured memory_bytes: 3104
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
//#include <windows.h>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VVC = vector<VC>;
using VS = vector<string>;
using VVS = vector<VS>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
const int INF = 2e9;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  queue<string> q;
  REP2(i, 1, 10) q.push(to_string(i));
  string ans;
  REP(i, k)
  {
    ans = q.front(); q.pop();
    LL tail = stoll(ans) % 10;
    if (tail != 0) q.push(ans + to_string(tail-1));
    q.push(ans + to_string(tail));
    if (tail != 9) q.push(ans + to_string(tail+1));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 10752
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws Exception{
		FScanner sc=new FScanner();
		String[] t=sc.readStringL("");
		int l=t.length;
		if(l%2==0){
			for(int i=0; i<l; i++){
				System.out.print(t[i]);
			}
		}else{
			for(int i=l-1; i>=0; i--){
				System.out.print(t[i]);
			}
		}
		System.out.println("");
	}
	
	static int lcm(int a, int b){
		return a*b/gcd(a,b);
	}
	
	static int gcd(int a, int b){
		int c=0;
		if(a<b){
			int t=a;
			a=b;
			b=t;
		}
		while(b!=0){
			c=a%b;
			a=b;
			b=c;
		}
		return a;
	}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(long[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		BufferedReader read=null;
		StringTokenizer tok=null;
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			String buf=sc.nextLine();
			return Integer.parseInt(buf);
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);

  int ans = 1;
  while (ans << 1 <= n) ans <<= 1;

  cout << ans << endl;

  return 0;
}

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

int main(){
  int N,M; cin>>N>>M;
  vector<pair<int,int>>between(M);
  for(int i=0;i<M;i++) cin>>between.at(i).second>>between.at(i).first;
  
  sort(between.begin(),between.end());
  
  int loc=1;
  int res=0;
  
  for(int i=0;i<M;i++){
    if(loc<=between.at(i).second){
      res++;
      loc=between.at(i).first;
    }
  }
  
  cout<<res;
}

Measured memory_bytes: 1024
from heapq import heappush, heappop, heapify
N = int(input())
As = list(map(int, input().split()))

q = As[:N]
heapify(q)
S = sum(q)
firstHalfSum = [S]
for i in range(N, 2*N):
    a = As[i]
    S += a
    heappush(q, a)
    S -= heappop(q)
    firstHalfSum.append(S)

q = [-a for a in As[2*N:]]
heapify(q)
S = sum(q)
secondHalfSum = [S]
for i in range(2*N-1, N-1, -1):
    a = -As[i]
    S += a
    heappush(q, a)
    S -= heappop(q)
    secondHalfSum.append(S)
secondHalfSum.reverse()

ans = max([f + s for f, s in zip(firstHalfSum, secondHalfSum)])
print(ans)


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

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vector<ll> v(n);
  ll sum = 0;
  REP(i,n) {
    int a,b;
    cin>>a>>b;
    v[i] += a+b;
    sum += a;
  }
  sort(ALL(v), greater<ll>());
  REP(i,n) {
    if ((i%2) == 1) {
      sum -= v[i];
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;
int main(void){ 
    int i=0,j;
    int hairetu[10000];
    while(1){
        cin>>hairetu[i];
        if(hairetu[i]==0){
            break;
        }
        i++;
    }
    for(j=0;j<i;j++){
        cout<<"Case "<< j+1<<": " <<hairetu[j]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3028
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> ps(a); cin >> ps;
    vector<int> qs(b); cin >> qs;
    vector<int> rs(c); cin >> rs;
    sort(ps.rbegin(), ps.rend());
    sort(qs.rbegin(), qs.rend());
    sort(rs.rbegin(), rs.rend());
    ps.push_back(-M);
    qs.push_back(-M);
    rs.push_back(-M);
    int total = x + y;
    int ip = 0, iq = 0, ir = 0;
    ll ans = 0;
    while(total){
        int p = x ? ps[ip] : -M,
            q = y ? qs[iq] : -M,
            r = rs[ir];
        if(p >= q && p >= r){
            x--;
            ans += p;
            ip++;
        }else if(q >= p && q >= r){
            y--;
            ans += q;
            iq++;
        }else if(r >= p && r >= q){
            ans += r;
            ir++;
        }
        total--;
    }
    cout << ans << '\n';
}


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

int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int count=0;
    if(abs(a-b)<=d) count++;
    if(abs(b-c)<=d) count++;
    if(abs(a-c)<=d) {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(count==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [i64;n]
    }

    let mut exist_zero = false;
    let mut min_abs = std::i64::MAX;
    let mut abs_total = 0;

    let mut minus_count = 0;
    for i in 0..n {
        if a[i] < 0 {
            minus_count += 1;
        } else if a[i] == 0 {
            exist_zero = true;
        }

        let abs = a[i].abs();
        min_abs = cmp::min(min_abs, abs);
        abs_total += abs;
    }

    //println!("{} {} {}", abs_total, min_abs, exist_zero);

    if exist_zero {
        println!("{}", abs_total);
    } else {
        if minus_count % 2 == 1 {
            println!("{}", abs_total - 2 * min_abs);
        } else {
            println!("{}", abs_total);
        }
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2272
#include<stdio.h>
#include<algorithm>
using namespace std;
int UF[2100];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
int l[2100];
int r[2100];
int dp[1100][1100];
int rev[1100][1100];
char in[20];
int used[1100];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a+b+c){
		int n=b+c;
		for(int i=0;i<n*2;i++)UF[i]=-1;
		for(int i=0;i<a;i++){
			int p,q;
			scanf("%d%d%s",&p,&q,in);
			p--;q--;
			if(in[0]=='y'){UNION(p*2,q*2);UNION(p*2+1,q*2+1);}
			else {UNION(p*2+1,q*2);UNION(p*2,q*2+1);}
		}
		for(int i=0;i<2100;i++)l[i]=r[i]=0;
		for(int i=0;i<n;i++){
			int t=FIND(i*2);
			if(t%2==0)l[t/2]++;
			else r[t/2]++;
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=0;
		dp[0][0]=1;
		for(int i=0;i<n;i++){
			if(!l[i]&&!r[i]){
				for(int j=0;j<=n;j++){dp[i+1][j]=dp[i][j];rev[i+1][j]=-1;}
			}else{
				for(int j=0;j<=n;j++){
					if(!dp[i][j])continue;
					dp[i+1][j+l[i]]=min(dp[i+1][j+l[i]]+dp[i][j],2);
					rev[i+1][j+l[i]]=1;
					dp[i+1][j+r[i]]=min(dp[i+1][j+r[i]]+dp[i][j],2);
					rev[i+1][j+r[i]]=2;
				}
			}
		}
		if(dp[n][b]!=1)printf("no\n");
		else{
			for(int i=0;i<n;i++)used[i]=0;
			int at=b;
			for(int i=n;i>0;i--){
				if(rev[i][at]==1){
					used[i-1]=1;
					at-=l[i-1];
				}else if(rev[i][at]==2){
					used[i-1]=2;
					at-=r[i-1];
				}
			}
			for(int i=0;i<n;i++){
				int t=FIND(i*2);
				if(t%2&&used[t/2]==2)printf("%d\n",i+1);
				if(t%2==0&&used[t/2]==1)printf("%d\n",i+1);
			}
			printf("end\n");
		}
	}
}

Measured memory_bytes: 7120
from math import sin as sin
from math import cos as cos
from math import pi as pi
from math import sqrt as sqrt

A,B,H,M = map(int, input().split())

dm = - pi/30*M + pi/2

dh = - (pi/6*H +  M*(pi/6/60)) + pi/2

xA = A*cos(dh)
yA = A*sin(dh)
xB = B*cos(dm)
yB = B*sin(dm)

print(sqrt( (xA-xB)**2 + (yA-yB)**2 ))

Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d = 0;
  cin >> a >> b >> c;
  for (int i = a; i <= b; i++) {
    if (c % i == 0) {
      d += 1;
    }
  }
  cout << d << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int D,E;
	cin >> D;
	cin >> E;
	while (D!=0||E!=0) {
		double r_min;
		for (int i = 0; i < (D+1); i++) {
			int x = i;
			int y = D - x;
			double cost = sqrt((std::pow(x,2.0))+(std::pow(y,2.0))) - E;
			cost = std::abs(cost);

			if (i == 0) {
				r_min = cost;
			}else if (cost < r_min) {
				r_min = cost;
			}
		}
		cout << std::setprecision(12);
		cout << r_min << endl;
		cin >> D;
		cin >> E;
	}
	return 0;
}

Measured memory_bytes: 3200
n,k = map(int,input().split())
a = list(map(int,input().split()))
plus = []
minus = []
zero = 0
for i in range(n):
    if a[i] < 0:
        minus.append(-a[i])
    elif a[i] > 0:
        plus.append(a[i])
    else:
        zero += 1
plus.sort()
minus.sort()
p = len(plus)
m = len(minus)
am = p*m
ap = p*(p-1)//2 + m*(m-1)//2
az = n*(n-1)//2 - am - ap
# print(plus,minus)

def binary_search_func(ok, ng, f):
    while(abs(ok - ng) > 1):
        med = (ok + ng) // 2
        if(f(med) == True):
            ok = med
        else:
            ng = med
    return ok

if k <= am:
    def c(x):# ~-xはk個以上あるか？
        res = p*m
        v = 0
        for i in minus[::-1]:
            kk = (x+i-1)//i
            # x以下のやつを引いていく
            while v < p and plus[v] < kk:
                v += 1
            res -= v
        return res >= k

    ok = 0
    ng = 10**18
    ans = -(binary_search_func(ok, ng, c))
    
elif k <= am + az:
    ans = 0

else:
    k -= am + az
    def c(x):# 1~xはk個以上あるか？
        res = 0
        vm = m-1
        for i,ai in enumerate(minus):
            kkm = x//ai
            while vm and minus[vm] > kkm:
                vm -= 1
            if vm > i:
                res += vm - i
        vp = p-1
        for i,ai in enumerate(plus):
            kkp = x//ai
            while vp and plus[vp] > kkp:
                vp -= 1
            if vp > i:
                res += vp - i
        return res >= k
    
    ok = 10**18
    ng = 0
    ans = binary_search_func(ok, ng, c)

print(ans)

Measured memory_bytes: 112436
#include <iostream>
#include <vector>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int ans = 10000, temp = 0;
    rep(i, s.size()) {
        if(s.size()-i < t.size()) continue;
        rep(j, t.size()) {
            if(s[i+j] != t[j]) temp++;
        }
        chmin(ans, temp);
        temp = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
nums = [[] for i in range(N)]
for i in range(N):
    t, d = map(int, input().split())
    t -= 1
    nums[t].append(d)
maxs = []
rest = []
for i in range(N):
    nums[i].sort(reverse=True)
    if len(nums[i]) > 0:
        maxs.append(nums[i][0])
        for n in nums[i][1:]:
            rest.append(n)
        #rest = rest + nums[i][1:]
maxs.sort(reverse=True)
if len(maxs) > K:
    maxs = maxs[:K]
    for n in maxs[K:]:
        rest.append(n)
    #rest = rest + maxs[K:]
rest.sort(reverse=True)
other = []
idx = 0
while len(maxs)+len(other) < K:
    other.append(rest[idx])
    idx += 1
rest = rest[idx:]

types = len(maxs)
#print(maxs)
#print(rest)
for i,r in enumerate(rest):
    diff = types*types - pow(types-1, 2)
    if diff < r-maxs[len(maxs)-1-i]:
        maxs[len(maxs)-1-i] = r
        types -= 1
    else:
        break
ans = types*types
for num in maxs:
    ans += num
for num in other:
    ans += num
print(ans)


Measured memory_bytes: 58544
import sys
from heapq import heapify, heappop, heappush
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

k = int(input())
a = [int(i) for i in range(1, 10)]

heapify(a)
while len(a):
    tmp = heappop(a)
    keta = len(str(tmp))
    one = tmp % 10
    k -= 1
    # -1,0,+1の範囲で末尾につけてqueueに入れる
    if one != 0: heappush(a, tmp * 10 + one - 1)
    heappush(a, tmp * 10 + one)
    if one != 9: heappush(a, tmp * 10 + one + 1)
    if k == 0:
        print(tmp)
        exit()


Measured memory_bytes: 18668
n=int(input())
AC=0
WA=0
TLE=0
RE=0
for n in range(n):
    s=input()
    if s=='AC':
        AC+=1
    elif s=='WA':
        WA+=1
    elif s=='TLE':
        TLE+=1
    else:
        RE+=1
print('AC x ',AC)
print('WA x ',WA)
print('TLE x ',TLE)
print('RE x ',RE)

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

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

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

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

	a -= k;
	if(a < 0)
	{
		b += a;
		a = 0;
	}
	if(b < 0) b = 0;

	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


ll deg[100010];
//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える
	int id[100010];//適宜変える
}G;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
G g;
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
		deg[x]++;
		deg[y]++;
	}
	g.vcnt=n;
	g.ecnt=2*m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

int f(int v1,int v2){
	int cnt=0;//結合の数
	rep(i,0,4){
		int pre=v1;
		int t=g.e[g.id[v1]+i].g;
		while(t!=v1&&t!=v2){
			if(g.e[g.id[t]].g!=pre){
				pre=t;
				t=g.e[g.id[t]].g;
			}else{
				pre=t;
				t=g.e[g.id[t]+1].g;
			}
		}
		if(t==v2)cnt++;
	}
	return cnt==2;
}

int main(){
	readgraph();
	
	int flag=0;
	rep(i,0,g.vcnt){
		if(deg[i]%2){
			puts("No");
			return 0;
		}
		if(deg[i]==4)flag++;
		if(deg[i]>=6)flag=3;
	}
	
	if(flag>=3)puts("Yes");
	else if(flag<=1)puts("No");
	else {
		//4重結合か、2重結合か判定
		int v1=-1,v2=-1;
		rep(i,0,g.vcnt){
			if(deg[i]==4){
				if(v1==-1)v1=i;
				else{
					v2=i;
					puts(f(v1,v2)?"Yes":"No");
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 7420
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n=int(input())
    s=list(input())
    for i in range(n+3):
        s.append("A")
    rr=0
    rg=0
    rb=0
    for i in range(n):
        if s[i]=="R":
            s[i]=-1
            rr+=1
        elif s[i]=="G":
            s[i]=1
            rg+=1
        elif s[i]=="B":
            s[i]=0
            rb+=1
    total=0
    for i in range(n-1):
        for j in range(i+1,n):
            if s[i]!=s[j]:
                if s[j*2-i]==(-1)*(s[i]+s[j]):
                    total-=1
    total+=rr*rg*rb


    print(total)



if __name__ == "__main__":

    main()

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

#define endl '\n'
#define int ll
typedef long long ll;

int dp[3] = {}, dp_new[3] = {};

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

    int N;
    cin >> N;

    int a, b, c;
    for (int i = 0; i < N; i++) {
        cin >> a >> b >> c;

        dp_new[0] = max(dp[1] + b, dp[2] + c);
        dp_new[1] = max(dp[0] + a, dp[2] + c);
        dp_new[2] = max(dp[0] + a, dp[1] + b);
        dp[0] = dp_new[0];
        dp[1] = dp_new[1];
        dp[2] = dp_new[2];
    }

    cout << max(max(dp[0], dp[1]), dp[2]);

    return 0;
}

Measured memory_bytes: 256
n, k, q = [int(i) for i in input().split()]
points = [0 for i in range(n)]
for i in range(q):
    a = int(input())
    points[a - 1] += 1
points = [k + p - q for p in points]
for p in points:
    print('Yes' if p > 0 else 'No') 

Measured memory_bytes: 7864
#include <bits/stdc++.h>
using namespace std;
int main()
{
	const long long mod = 1000000007;
//	const long long plus = (10^100)%mod;
	long long N,K;
	cin >> N >> K;
	long long ans = 0;
	int j;

	for(int i = K; i <= N+1; i++){
		if(i <= (N+1)/2)
			j = i;
		else
			j = N+1-i;
		ans = ((N - (j-1))*j + 1 + ans)%mod;
		
	}

	cout << ans;

	cin >> j;

	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
    
    int n;
    
    cin >> n;
    
    int numbers[n];
    
    for(int j=0; j<n; j+=1){
        cin >> numbers[j];
    }
    
    for(int i=(n-1); i>=0; i= i-1){

        cout << numbers[i];
        if(i!=0){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3104
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
  int N, M;
  scanf("%d %d", &N, &M);
  static int a[5001][5001];
  for (int i = 0; i < M; i++) {
    int A, B, X;
    scanf("%d %d %d", &A, &B, &X);
    a[A][B] = X+1;
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= i; j++) {
      a[i][j] = max(a[i][j], a[i-1][j] - 1);
      a[i][j] = max(a[i][j], a[i-1][j-1] - 1);
      if (a[i][j] > 0) {
        ++ans;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

char c[2][3];

int main(){
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 3; j++){
            if(c[i][j] != c[1 - i][2 - j]){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int a, b;

int main() {
	cin >> a >> b;
	if (a > b)swap(a, b);
	for (int i = 0; i < b; i++)cout << a;
	cout << endl;
}

Measured memory_bytes: 256