akhauriyash/Code-Regression huggingface dataset:
def Warshall_Floyd(edges,N):
  """頂点N個のグラフ上の隣接行列edges(空欄はinfとせよ)が与えられたとき, 
  2点間の最短距離距離を隣接行列で返す"""
  for k, i, j in itertools.product(range(N), range(N),range(N)):
    if edges[i][j]>edges[i][k]+edges[k][j]: return 1
  return 0
 
import sys
import itertools
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
if Warshall_Floyd(A,N):
  print(-1)
  sys.exit()
 
ans=0
for i, j in itertools.product(range(N),range(N)):
  need=1
  for k in range(N):
    if k!=i and k!=j and A[i][j]==A[i][k]+A[k][j]:
      need=0
      break
  if need:ans+=A[i][j]
print(ans//2)

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

int main()
{
    int n;
    cin>>n;
    string s,t;
    cin>>s;
  
    for(int i=0;i<s.size();i++)
    {
        char c;
        c= s[i] + n;
        
        if(c > 'Z')
        {
            c = c - 26;
        }
        t = t+ c;
    }
    
    cout<<t;
  
    return 0;
  }
      
      

Measured memory_bytes: 256
package main

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

const MAX_NODE = 25

type Node struct {
	id int
	parent int
	left int
	right int
}

func (n *Node) initNode() {
	n.id, n.parent, n.left, n.right = -1, -1, -1, -1
}

type Tree [MAX_NODE]*Node

func (t *Tree) initTree() {
	for i := range t {
		t[i] = new(Node)
		t[i].initNode()
	}
}

func (t *Tree) preorder(root int) {
	if root == -1 {
		return
	}
	var tmp *Node
	for i := 0; i < MAX_NODE; i++ {
		if t[i].id == root {
			tmp = t[i]
		}
	}
	fmt.Printf(" %d", root)
	t.preorder(tmp.left)
	t.preorder(tmp.right)
}

func (t *Tree) inorder(root int) {
	if root == -1 {
		return
	}
	var tmp *Node
	for i := 0; i < MAX_NODE; i++ {
		if t[i].id == root {
			tmp = t[i]
		}
	}
	t.inorder(tmp.left)
	fmt.Printf(" %d", root)
	t.inorder(tmp.right)
}

func (t *Tree) postorder(root int) {
	if root == -1 {
		return
	}
	var tmp *Node
	for i := 0; i < MAX_NODE; i++ {
		if t[i].id == root {
			tmp = t[i]
		}
	}
	t.postorder(tmp.left)
	t.postorder(tmp.right)
	fmt.Printf(" %d", root)
}

func main() {
	t := new(Tree)
	t.initTree()
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		data := strings.Fields(scanner.Text())
		t[i].id, _ = strconv.Atoi(data[0])
		t[i].left, _ = strconv.Atoi(data[1])
		t[i].right, _ = strconv.Atoi(data[2])
		if t[i].left != -1 {
			t[t[i].left].parent = t[i].id
		}
		if t[i].right != -1 {
			t[t[i].right].parent = t[i].id
		}
	}
	// for i := 0; i < n; i++ {
	// 	fmt.Printf("%+v\n", t[i])
	// }

	var root int
	for i := 0; i < n; i++ {
		if t[i].parent == -1 {
			root = i
		}
	}
	// fmt.Println(root)
	fmt.Println("Preorder")
	t.preorder(root)
	fmt.Printf("\nInorder\n")
	t.inorder(root)
	fmt.Printf("\nPostorder\n")
	t.postorder(root)
	fmt.Println()
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll h, w, a, b;
/******* define variable end *******/
int solve() {
	cin >> h >> w >> a >> b;
	REP(i, b){
		REP(j, a){
			cout << 0;
		}
		REP(j, w - a){
			cout << 1;
		}
		cout << endl;
	}
	REP(i, h-b){
		REP(j, a){
			cout << 1;
		}
		REP(j, w - a){
			cout << 0;
		}
		cout << endl;
	}
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

const int MODULO = 1e+9 + 7;

int main()
{

    int nbEnfant, nbBonbon;
    cin >> nbEnfant >> nbBonbon;

    int nbBonbonMax[nbEnfant];

    for(int i = 0; i < nbEnfant; i++) cin >> nbBonbonMax[i];

    int dp[nbEnfant][nbBonbon+1];

    for(int i = 0; i <= nbBonbon; i++) {
        dp[0][i] = 0;
        if(i <= nbBonbonMax[0]) {
            dp[0][i] = 1;
        }
    }

    for(int i = 1; i < nbEnfant; i++) {

        int debutFenetre = 0; //Inclus
        long long int total = 0;

        for(int j = 0; j <= nbBonbon; j++) {
            int taille = j - debutFenetre + 1;

            if(taille <= nbBonbonMax[i]+1) {
                total += dp[i-1][j];
            }
            else {
                total += dp[i-1][j];
                total -= dp[i-1][debutFenetre];
                debutFenetre++;
            }

            dp[i][j] = total % MODULO;
        }
    }

    /*for(int i = 0; i < nbEnfant; i++) {
        for(int j = 0; j <= nbBonbon; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

    cout << dp[nbEnfant-1][nbBonbon];




    return 0;
}


Measured memory_bytes: 39296
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <string>


using namespace std;
int main()
{
	long long i, j, k, a, b, c, d, A, B, X;

	cin >> A >> B >> X;

	a = A + B;

	if (a > X && A <= X) {
		cout << "YES";
	}

	else {
		cout << "NO";
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string s1 = Console.ReadLine();
        string s2 = Console.ReadLine();
        int[,] DP = new int[s1.Length+1,s2.Length+1];
        for(int i=0;i<=s2.Length;i++){
            DP[0,i] = i;
        }
        for(int i=1;i<=s1.Length;i++){
            for(int j=0;j<=s2.Length;j++){
                int min = DP[i-1,j] + 1;
                if(j > 0){
                    min = Math.Min(min,DP[i-1,j-1] + (s1[i-1] == s2[j-1] ? 0 : 1));
                    min = Math.Min(min,DP[i,j-1] + 1);
                }
                DP[i,j] = min;
            }
        }
        sb.Append(DP[s1.Length,s2.Length]+"\n");
    }
}

Measured memory_bytes: 13048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

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

    vector<vector<int>> s(M);

    rep(i,M){
        int k; cin >> k;
        rep(j, k){
            int sw; cin >> sw; sw--;
            s[i].emplace_back(sw);
        }
    }

    vector<int> p(M);
    rep(i,M) cin >> p[i];

    int ans = 0;
    for(int sw = 0; sw < (1 << N); sw++){
        bool on = true;
        for(int i = 0; i < M; i++){
            int cnt = 0;
            for(int k = 0; k < s[i].size(); k++){
                if(sw & (1 << s[i][k])) cnt++; 
            }
            if(cnt % 2 != p[i]) {
                on = false;
                break;
            }
        }
        if(on) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
def pow(x,n)
  if n == 0
    ""
  elsif n % 2 == 0
    pow((x+x), n/2)
  else
    x + pow(x, n-1)
  end
end


n,k,s = gets.chomp.split(" ").map(&:to_i);

ans = ""
if s > 1000000

  ans = pow("#{s} ",k) + pow("#{1} ",n-k)

else

  ans = pow("#{s} ",k) + pow("#{s+1} ",n-k)

end

print ans

Measured memory_bytes: 15740
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
const int N=3005;
int a,b,c,d,dp[N][N];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int i=a;i<=c;i++)
    {
        for(int j=b;j<=d;j++)
        {
            if(a!=i||b!=j) dp[i][j]=(i*dp[i][j-1]+j*dp[i-1][j]-(i-1)*(j-1)*dp[i-1][j-1]%mod+mod)%mod;
        }
    }
    cout<<dp[c][d];
}


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

int main() {

	string dance;

	cin >> dance;

	for (int i = 0; i < dance.length(); i++) {
		if (i % 2 == 0 && dance[i] == 'L') {
			cout << "No";
			return 0;
		}
		else if(i % 2 == 1 && dance[i] == 'R'){
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 15;

int n, m;
int e[MAX][MAX];

int d1[(1 << MAX)];
int d2[(1 << MAX)][MAX];

bool bit(int m, int i) {
	return (1 & (m >> i));
}

void init() {
	for (int mask = 0; mask < (1 << n); mask++) {
		fi(0, n - 1) {
			fj(i + 1, n - 1) {
				if (bit(mask, i) && bit(mask, j)) {
					d1[mask] += e[i][j];
				}
			}
		}
	}

	for (int mask = 0; mask < (1 << n); mask++) {
		fo(0, n - 1) {
			fi(0, n - 1) {
				if (bit(mask, i)) {
					d2[mask][o] += e[i][o];
				}
			}
		}
	}
}

int d[(1 << MAX)][MAX];
int const INF = 1e9 + 41;

int ans;
int sum;

int getbest(int comp, int path) {
	int res = 0;

	fi(0, n - 1) {
		if (bit(path, i)) {
			res = max(res, d2[comp][i]);
		}
	}
	
	res += d1[comp];
	return res;
}

void solve() {
	init();
	for (int mask = 0; mask < (1 << n); mask++) {
		fo(0, n - 1) {
			d[mask][o] = -INF;
		}
	}
	d[(1 << (n - 1)) - 1][n - 1] = 0;

	for (int mask = (1 << n) - 1; mask > 0; mask--) {
		fo(0, n - 1) {
			if (d[mask][o] < 0) continue;
			fi(0, n - 1) {
				if (e[i][o] && bit(mask, i)) {
					int nmask = (mask ^ (1 << i));
					d[nmask][i] = max(d[nmask][i], d[mask][o] + e[i][o]);
				}
			}
			int sm = mask;
			while (sm > 0) {
				int nmask = (mask ^ sm);
				int pathmask = ( ((1 << n) - 1) ^ mask);
				int bs = getbest(sm, pathmask);
				d[nmask][o] = max(d[nmask][o], d[mask][o] + bs);
				sm = ((sm - 1) & mask);
			}
		}
	}

	ans = sum - d[0][0];
	err("d = %d sum = %d\n", d[0][0], sum);
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d %d", &n, &m);
  fi(1, m) {
  	int x, y, w;
  	scanf("%d %d %d", &x, &y, &w);
  	x--;
  	y--;
  	e[x][y] = e[y][x] = w;
  	sum += w;
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 4224
from collections import deque

n, m = map(int, input().split())
g = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

q = deque([0])
d = [-1] * n
d[0] = 0
ans = [0] * n

print('Yes')
while q:
    p = q.popleft()
    for node in g[p]:
        if d[node] == -1:
            d[node] = d[p] + 1
            q.append(node)
        else:
            if d[node] + 1 == d[p]:
                ans[p] = node + 1
for i in range(1, n):
    print(ans[i])

Measured memory_bytes: 37776
def examA():
    AB = [I() for _ in range(2)]
    for i in range(1,4):
        if not i in AB:
            ans = i
            break
    print(ans)
    return

def examB():
    N = I()
    S,T = LSI()
    ans = ""
    for i in range(N):
        ans += S[i]+T[i]
    print(ans)
    return

def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examC():
    A, B = LI()
    ans = lcm(A,B)
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    ans = N; cur = 1
    for a in A:
        if cur==a:
            ans -=1
            cur +=1
    if ans==N:
        ans = -1
    print(ans)
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()


Measured memory_bytes: 72560
package main

import "fmt"

func main() {
	var card [4][13]int
	var n, number int
	var img, ans string

	fmt.Scan(&n)
	
	for i := 0; i < n; i ++ {
		fmt.Scan(&img, &number)

		if img == "S" {
			card[0][number - 1] = 1
		} else if img == "H" {
			card[1][number - 1] = 1
		} else if img == "C" {
			card[2][number - 1] = 1
		} else {
			card[3][number - 1] = 1
		}
	} 
		
	for i := 0; i < 4; i ++ {
		for j := 0; j < 13; j++ {
			if i == 0 {
				ans = "S %d\n"
			} else if i == 1 {
				ans = "H %d\n"
			} else if i == 2 {
				ans = "C %d\n"
			} else {
				ans = "D %d\n"
			}

			if card[i][j] == 0 {
				fmt.Printf(ans, j + 1)
			}
		}
	}

}


Measured memory_bytes: 1160
#include <stdio.h>
#define PI 3.141592653589793238462643383
int main()
{
    double r,area,circumference;
    scanf ("%lf",&r);
    area = PI*r*r;
    circumference = 2*PI*r;
    printf ("%lf %lf\n",area,circumference);


    return 0;
}


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


public class Main {
	private	static	BufferedReader	br = null;

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

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int		cnt  = parseCnt();
		int[]	ball = null;

		for (int n = 0; n < cnt; n++) {
			if ((ball = parseBall()) != null) {
				if (push(0, 0, 0, ball) == 0) {
					System.out.println("YES");
				}
				else {
					System.out.println("NO");
				}
			}
		}
	}

	private static int push(int n, int a, int b, int[] ball) {
		int	nStatus = 0;

		if (n < ball.length) {
			if (a < ball[n]) {
				nStatus = push(n + 1, ball[n], b, ball);
			}
			else if (b < ball[n]) {
				nStatus = push(n + 1, a, ball[n], ball);
			}
			else {
				nStatus = -1;
			}
		}
		
		return nStatus;
	}

	private static int parseCnt() {
		int		cnt   = 0;
		String	strIn = null;

		if ((strIn = parseStdin()) != null) {
			cnt = Integer.parseInt(strIn);
		}
		
		return cnt;
	}

	private static int[] parseBall() {
		int[]	ball  = null;
		String	strIn = null;

		if ((strIn = parseStdin()) != null) {
			String[]	aN = strIn.split(" ");
			ball = new int[10];
			for (int n = 0; n < 10; n++) {
				ball[n] = Integer.parseInt(aN[n]);
			}
		}
		
		return ball;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 16908
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int n,m,q,a[60],b[60],c[60],d[60],ans=0;
int keisan(int x[]){
    int k=0;
    REP(i,q){
        if(x[b[i]-1]-x[a[i]-1]==c[i]) k+=d[i];
    }
    return k;
}
void solve(int p,int x[]){
    if(p==0){
        for(int i=1;i<=m;i++){
            x[p]=i;
            solve(p+1,x);
        }
    }
    else if(p==n){
        ans=max(keisan(x),ans);
    }
    else{
        for(int i=x[p-1];i<=m;i++){
            x[p]=i;
            solve(p+1,x);
        }
    }
}
int main(){
    int x[11]={};
    cin>>n>>m>>q;
    REP(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
    solve(0,x);
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
import itertools
A=input()
for i in list(itertools.product(range(2),repeat=3)):
  c=''
  c+=A[0]
  bns=int(A[0])
  for j in range(3):
    if i[j]==0:
      bns+=int(A[j+1])
      c+='+'+A[j+1]
    else:
      bns-=int(A[j+1])
      c+='-'+A[j+1]
  if bns==7:
    print(c+'=7')
    exit()

Measured memory_bytes: 9084
#include <iostream>
#include <string>
using namespace std;
long m,a,r,c,h;
int main(void){
    int N;
    long long ans;
    cin>>N;
    string S[N];
    char s[N];
    for(int i=0;i<N;i++){
        cin>>S[i];
        s[i]=S[i][0];
        if(s[i]=='M'){
            m++;
        }
        if(s[i]=='A'){
            a++;
        }
        if(s[i]=='R'){
            r++;
        }
        if(s[i]=='C'){
            c++;
        }
        if(s[i]=='H'){
            h++;
        }
    }
    ans=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
    cout<<ans<<endl;
}


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

int main()
 {
   int N;
   cin>>N;
   if(N%10==3)
{
  cout<<"bon";
}
else if(N%10==0 || N%10==1 || N%10==6 || N%10==8)
  cout<<"pon";
else
cout<<"hon";
return 0;
 }


Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b[100];
    cin >> a;
    for(int i=0; i<a; i++){
        cin >> b[i];
    }
    for(int i=a-1; i>=0; i--){
        if(i!=a-1){
            cout << " ";
        }
        cout << b[i];
    }
    cout << endl;
}



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

int main(){
    vector<int> a(3);
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());

    if(a[0]==a[1]){
        if(a[0]!=a[2]){
            cout << "Yes" << endl;
            return 0;
        }
    }if(a[1]==a[2]){
        if(a[1]!=a[0]){
            cout << "Yes" << endl;
            return 0; 
        }
    }
    cout << "No" << endl;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> graph(n+1);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  vector<int> dist(n+1, -1);
  queue<int> que;
  dist[1] = 0;
  que.push(1);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(int nv : graph[v]){
      if(dist[nv] != -1) continue;
      dist[nv] = dist[v] +1;
      que.push(nv);
    }
  }
  //rep(i,n) cout << i+1 << ": " << dist[i+1] << endl;
  cout << "Yes" << endl;
  for(int i=2; i<=n; i++){
    for(int nv : graph[i]){
      if(dist[i] - dist[nv] == 1){
        cout << nv << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 10112
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val countMap = mutableMapOf<Char, Int>()
    val inf = 51
    for (c in 'a'..'z') {
        countMap[c] = inf
    }
    repeat(n) {
        val s = br.readLine()!!.toList()
        val charCount = elementCountMap(s)
        for (c in 'a'..'z') {
            countMap[c] = min(countMap[c]!!, charCount.getOrDefault(c, 0))
        }
    }
    for (c in 'a'..'z') {
        repeat(countMap[c]!!) {
            out.print(c)
        }
    }
    out.println()
}

/** O(n) */
fun <T>elementCountMap(list: List<T>): Map<T, Int> {
    val countMap = mutableMapOf<T, Int>()
    for (e in list) {
        countMap.merge(e, 1) { oldValue, value -> oldValue + value }
    }
    return countMap
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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



public class Main {
   public static void main(String[] args) throws IOException{
           final   Scanner scan = new Scanner(System.in);
           int n=scan.nextInt();
           System.out.println("0.000000 0.000000");
           koch(new double[]{0,0}, new double[]{100,0},n);
           System.out.println("100.000000 0.000000");
   }
   
   public static void koch(double[] p,double[] q,int n){
           double pi=Math.PI/3;
        if(n==0) return;
        double[] S={(2*p[0]+q[0])/3,(2*p[1]+q[1])/3};
        double[] T={(p[0]+2*q[0])/3,(p[1]+2*q[1])/3};
        double[] U={(T[0]-S[0])*Math.cos(pi)-(T[1]-S[1])*Math.sin(pi)+S[0],(T[0]-S[0])*Math.sin(pi)+(T[1]-S[1])*Math.cos(pi)+S[1]};

        koch(p.clone(),S.clone(),n-1);
    System.out.println(S[0]+" "+S[1]);
        koch(S.clone(),U.clone(),n-1);
        System.out.println(U[0]+" "+U[1]);
        koch(U.clone(),T.clone(),n-1);
        System.out.println(T[0]+" "+T[1]);
        koch(T.clone(),q.clone(),n-1);   
   }
}

Measured memory_bytes: 31996
H=int(input())
W=int(input())
N=int(input())

if H>W:
  if N%H==0:
    print(int(N/H))
  else:
    print(int(N/H)+1)
else:
  if N%W==0:
    print(int(N/W))
  else:
    print(int(N/W)+1)

Measured memory_bytes: 3060
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define pb push_back
#define F first
#define S second
using namespace std;
using ll =long long;
const ll maxn=1e5+5,inf=1e18+18;
ll n,m,t;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	for(int i=0;i<=4;i++){
		cin>>n;
		if(!n)m=i+1;
	}
	cout<<m;
}


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

int main()
{
    int K;
    cin >> K;
    string S;
    cin >> S;
    if(S.size() <= K) cout << S << endl;
    else{
        cout << (S.substr(0, K) + string("...")) << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    string s; cin >> s;

    int n = s.size();

    string snew = "";

    for(int i=0; i<n-1; i++){
        if(s[i] == 'B' && s[i+1] == 'C'){
            snew += 'D';
            i++;
        }
        else{
            snew += s[i];
        }
    }

    int cnttemp = 0;
    long long cnttotal = 0;
    for(int i=0; i<n-1; i++){
        if(snew[i] == 'A'){
            cnttemp++;
        }
        else if(snew[i] == 'D'){
            cnttotal += cnttemp;
        }
        else{
            cnttemp = 0;
        }
    }

    cout << cnttotal;

    return 0;
}

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

using namespace std;
int n;
const int maxn = 3e5+5;
int sum[maxn];
int fuck[maxn];
int main()
{
    scanf("%d", &n);
    memset(sum,0,sizeof(sum));
    memset(fuck,0,sizeof(fuck));
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        sum[x]++;
        fuck[sum[x]]++;
    }
    for(int i=1;i<=n;i++)
        fuck[i]+=fuck[i-1];
    int now = n;
    for(int i=1;i<=n;i++){
        while(fuck[now]<i*now){
            now--;
        }
        printf("%d\n", now);
    }
    return 0;
}


Measured memory_bytes: 3200
import Control.Applicative ((<$>), (<*>))
import Control.Monad (unless, when, forM_)
import Data.Vector.Unboxed.Mutable (IOVector)
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  tbl <- VM.replicate 1000001 0 :: IO (IOVector Int)
  VM.write tbl 1 1
  forM_ [1 .. 500000] $ \i -> do
    x <- VM.read tbl i
    when (x > 0) $ do
      when (2 * i <= 1000000) $ VM.write tbl (2 * i) 1
      when (3 * i <= 1000000) $ VM.write tbl (3 * i) 1
      when (5 * i <= 1000000) $ VM.write tbl (5 * i) 1
  forM_ [1 .. 1000000] $ \i -> do
    x <- VM.read tbl i
    y <- VM.read tbl (i-1)
    VM.write tbl i (x + y)
  solve tbl

solve :: IOVector Int -> IO ()
solve tbl = do
  (m:rs) <- map read <$> words <$> getLine
  unless (m == 0) $ do
    let n = head rs
    (-) <$> VM.read tbl n <*> VM.read tbl (m-1) >>= print
    solve tbl



Measured memory_bytes: 20404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int l, r;
	ll ans = LINF;

	cin >> l >> r;

	if (r - l > 2019)ans = 0;
	else {
		rep(i, r - l + 1)rep(j, r - l + 1) {
			ll ii = l + i;
			ll jj = l + j;
			if (ii >= jj)continue;
			ans = min(ans,(ii * jj) % 2019);
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
/*
       _________
      /         \
     /  _     _  \
    /   0     0   \
   |       ||     |
   |              | => HI
    \     -----   /
     \           /
      \_ _ _ _ _/
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T = 1;
	for(int t = 1; t <= T; t++){
		int n;
		cin >> n;
		if(n >= 400 and n <= 599){
			cout << "8";
		}else if(n >= 600 and n <= 799){
			cout << "7";
		}else if(n >= 800 and n <= 999){
			cout << "6";
		}else if(n >= 1000 and n <= 1199){
			cout << "5";
		}else if(n >= 1200 and n <= 1399){
			cout << "4";
		}else if(n >= 1400 and n <= 1599){
			cout << "3";
		}else if(n >= 1600  and n <= 1799){
			cout << "2";
		}else{
			cout << "1";
		}
	}
}




Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int main() {
	
	string s,t,u;
	cin >> s;
	t = s.substr(0, 2);
	u = s.substr(2, 2);

	if (stoi(t) > 12 || stoi(t) == 0) {

		if (stoi(u) > 12 || stoi(u) == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << "YYMM" << endl;
		}

		return 0;

	}
	else {

		if (stoi(u) > 12) {
			cout << "MMYY" << endl;
		}
		else if(stoi(u) != 0){
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
		return 0;
	}




}

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

ll n, k, res = 0;
vector<ll> a;
ll f(ll x){
    ll ret = 0;
    for(int i = 0; i < n; ++i){
        ret += a[i]/x + (a[i]%x > 0);
    }
    return ret - n;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    a.assign(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll l = 1, r = 2e9;
    while(l <= r){
        ll m = l + (r - l)/2;
        if(f(m) <= k){
            res = m;
            r = m - 1;
        }
        else{
            l = m + 1;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 4788
import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        int[] table = new int[100002];
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            if (a > 0) table[a - 1]++;
            table[a]++;
            table[a + 1]++;
        }
        int max = 0;
        for (int i = 0; i < table.length; i++) {
            if (table[i] > max) {
                max = table[i];
            }
        }
        System.out.println(max);
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 40588
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    cout << n + n*n + n*n*n;

    return 0;
}


Measured memory_bytes: 3652
def main():
    n = int(input())
    d = set()
    for _ in range(n):
        op, s = input().split()
        if op == 'insert':
            d.add(s)
        else:
            if s in d:
                print('yes')
            else:
                print('no')

if __name__ == '__main__':
    main()


Measured memory_bytes: 30992
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int N, D;
    cin >> N >> D;
    int X[N][D];
    for (int n = 0; n < N; ++n) {
        for (int d = 0; d < D; ++d) {
            cin >> X[n][d];
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i != j) {
                int sum = 0;
                for (int d = 0; d < D; ++d) sum += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]);
                double s = sqrt(sum);
                ans += ceil(s) == floor(s) ? 1 : 0;
            }
        }
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	string N;
	cin >> N;
	if (N[0] == '9' || N[1] == '9')cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int ans[4];
  for(int i=0;i<4;i++) ans[i]=0;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    if(s=="AC") ans[0]++;
    if(s=="WA") ans[1]++;
    if(s=="TLE") ans[2]++;
    if(s=="RE") ans[3]++;
  }
  cout<<"AC x "<<ans[0]<<endl;
  cout<<"WA x "<<ans[1]<<endl;
  cout<<"TLE x "<<ans[2]<<endl;
  cout<<"RE x "<<ans[3]<<endl;
  
  return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=pow(10,9)+7;
#define ff(i,n) for(i=0;i<n;i++)
#define gg1(n1) cin>>n1;
#define gg(n1,n2) cin>>n1>>n2;
#define gg3(n1,n2,n3) cin>>n1>>n2>>n3;
#define hh(n) cout<<n<<endl;
#define t top
#define p push
#define pb push_back
#define mp make_pair
ll dp[100][100001];
int main()
{
  ll h,w,i,j;
  cin>>h>>w;
  char grid[h][w];
  for(i=0;i<h;i++)
     for(j=0;j<w;j++)
        cin>>grid[i][j];
  ll dp[h][w];
  for(i=0;i<h;i++)
     for(j=0;j<w;j++)
        dp[i][j]=0;
  if(grid[0][0]!='#')
     dp[0][0]=1;
  else 
     dp[0][0]=0;
  for(i=0;i<h;i++)
   { 
    for(j=0;j<w;j++)
     {
        if(i==0&&j==0)
          continue;
        if(grid[i][j]=='#')
          dp[i][j]=0;
        else{     
                
        ll max=0;
        if(j-1>=0&&grid[i][j-1]!='#')
           max=(max%bg+dp[i][j-1]%bg)%bg;
        if(i-1>=0&&grid[-1][j]!='#')
           max=(max%bg+dp[i-1][j]%bg)%bg;
           dp[i][j]=max;}      
     }
   }
   cout<<dp[h-1][w-1]<<endl;
  return 0;
}

Measured memory_bytes: 9088
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		PriorityQueue<Integer> b = new PriorityQueue<Integer>();
		int max = 0; int count = 0;

		for(int i = 0; i < n; i++) {
			max = Math.max(max, sc.nextInt());
			b.add(-1*sc.nextInt());
		}

		while(h > 0) {
			if(!b.isEmpty() && -1*b.peek() > max) {
				h  += b.poll();
				count++;
			}else {
				double h_ = h;
				double max_ = max;
				count += Math.ceil(h_/max_);
				break;
			}
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 67212
# coding: utf-8
# Your code here!
n=int(input())
a = [int(i) for i in input().split()]
import sys
sys.setrecursionlimit(10**7)

ko = [0]*4
for i in a:
    ko[i] += 1

dp = [[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)]

cc=ko[1]+ko[2]+ko[3]
ccc=ko[2]+ko[3]
for k in range(ko[3]+1):
    for j in range(ccc+1-k):
        for i in range(cc+1-k-j):
            t=i+j+k
#            print(i,j,k)
            if i != 0:
                dp[i][j][k] += (dp[i-1][j][k] + n/t)*i/t
            if j != 0 and i < n:
                dp[i][j][k] += (dp[i+1][j-1][k] + n/t)*j/t
            if k != 0 and j < n:
                dp[i][j][k] += (dp[i][j+1][k-1] + n/t)*k/t
#print(dp)
print(dp[ko[1]][ko[2]][ko[3]])


Measured memory_bytes: 254344
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	s := SScan(n)
	d := make(map[[2]int]struct{})
	edges := make([][]int, n)
	for i, v := range s {
		for j, r := range v {
			if string(r) == "1" {
				edges[i] = append(edges[i], j)
				d[[2]int{i, j}] = struct{}{}
			}
		}
	}
	ans := -1
	for i := 0; i < n; i++ {
		q := []int{i}
		g := make([]int, n)
		for j, _ := range g {
			g[j] = -1
		}
		g[i] = 1
		for len(q) != 0 {
			x := q[0]
			q = q[1:]
			for _, v := range edges[x] {
				if g[v] == -1 {
					g[v] = g[x] + 1
					q = append(q, v)
				}
			}
		}
		f := true
		for j, v := range g {
			for k, w := range g {
				if abs(v-w) != 1 {
					if _, ok := d[[2]int{j, k}]; ok {
						f = false
					}
				}
			}
		}
		if f {
			ans = larger(ans, max(g))
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6116
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  string S;
  VB used(26, false);

  cin >> S;
  REP(i, SZ(S)) {
    if (used[static_cast<int>(S[i] - 'a')]) {
      cout << "no" << endl;
      return 0;
    } else {
      used[static_cast<int>(S[i] - 'a')] = true;
    }
  }

  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

int main() {
  ll n, q;
  cin >> n >> q;
  ll ans = (n - 2) * (n - 2);
  ll miteiYokoIdxMax = n - 1;
  ll miteiTateIdxMax = n - 1;
  vector<ll> yokoWhiteCnt(n, n - 2), tateWhiteCnt(n, n - 2);

  REP(i, q) {
    ll type, x;
    cin >> type >> x;
    if (type == 1) {
      if (x <= miteiYokoIdxMax) {
        ll flip = yokoWhiteCnt[miteiYokoIdxMax];
        ans -= flip;
        FOR(i, x, miteiYokoIdxMax + 1) { yokoWhiteCnt[i] = flip; }
        miteiYokoIdxMax = x - 1;
        yokoWhiteCnt[miteiYokoIdxMax] = yokoWhiteCnt[x];
        tateWhiteCnt[miteiTateIdxMax] = (x - 1) - 1;
      } else {
        ans -= yokoWhiteCnt[x];
      }
    } else {
      if (x <= miteiTateIdxMax) {
        ll flip = tateWhiteCnt[miteiTateIdxMax];
        ans -= flip;
        FOR(i, x, miteiTateIdxMax + 1) { tateWhiteCnt[i] = flip; }
        miteiTateIdxMax = x - 1;
        tateWhiteCnt[miteiTateIdxMax] = tateWhiteCnt[x];
        yokoWhiteCnt[miteiYokoIdxMax] = (x - 1) - 1;
      } else {
        ans -= tateWhiteCnt[x];
      }
    }
    // DUMP(ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  ll b;
  cin>>b;
  if(a*b%2==0){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  return 0;
}



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

int H, W, S;
//?????????
int dp1[32][32][33][33];    //????????°
int dp2[32][32][33][33];    //?????????
bool done[32][32][33][33];
int field[33][33];

int area(int t, int l, int b, int r){
    return field[b][r] - field[t][r] - field[b][l] + field[t][l];
}

void dfs(int t,int l, int b, int r){
    if(done[t][l][b][r]) return;
    
    int split = 1;
    int res = S-(area(0, 0, H, W)-area(t, l, b, r));
    
    for(int h=t+1; h<b; h++){
        if(area(t, l, h, r) >= area(0, 0, H, W)-S && area(h, l, b, r) >= area(0, 0, H, W)-S){
            dfs(t, l, h, r);
            dfs(h, l, b, r);
            if(dp1[t][l][h][r] + dp1[h][l][b][r] > split){
                split = dp1[t][l][h][r] + dp1[h][l][b][r];
                res = min(dp2[t][l][h][r], dp2[h][l][b][r]);
            }else if(dp1[t][l][h][r] + dp1[h][l][b][r] == split){
                res = max(res, min(dp2[t][l][h][r], dp2[h][l][b][r]));
            }
        }
    }
    for(int w=l+1; w<r; w++){
        if(area(t, l, b, w) >= area(0, 0, H, W)-S && area(t, w, b, r) >= area(0, 0, H, W)-S){
            dfs(t, l, b, w);
            dfs(t, w, b, r);
            if(dp1[t][l][b][w] + dp1[t][w][b][r] > split){
                split = dp1[t][l][b][w] + dp1[t][w][b][r];
                res = min(dp2[t][l][b][w], dp2[t][w][b][r]);
            }else if(dp1[t][l][b][w] + dp1[t][w][b][r] == split){
                res = max(res, min(dp2[t][l][b][w], dp2[t][w][b][r]));
            }
        }
    }
    done[t][l][b][r] = true;
    dp1[t][l][b][r] = split;
    dp2[t][l][b][r] = res;
}

int main(){
    while(cin >> H >> W >> S, H|W|S){
        memset(field, 0, sizeof(field));
        memset(dp1, -1, sizeof(dp1));
        memset(dp2, -1, sizeof(dp2));
        memset(done, 0, sizeof(done));
        
        for(int i=1; i<=H; i++)
            for(int j=1; j<=W; j++)
                cin >> field[i][j];
        
        for(int i=0; i<H; i++)
            for(int j=0; j<=W; j++)
                field[i+1][j] += field[i][j];
        for(int i=0; i<W; i++)
            for(int j=0; j<=H; j++)
                field[j][i+1] += field[j][i];
        
        dfs(0, 0, H, W);
        
        cout << dp1[0][0][H][W] << " " << dp2[0][0][H][W] << endl;
    }
    return 0;
}

Measured memory_bytes: 12820
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
MOD = 10**9+7
ans = 0
fact = [1] * N
for i in range(1, N):
    fact[i] = fact[i-1] * i % MOD
for k in range(N-K+1):
    p = fact[N-k-1] * pow(fact[N-K-k], MOD-2, MOD) % MOD
    ans -= A[k] * p % MOD
    ans += A[N-k-1] * p % MOD
    ans %= MOD
print(ans * pow(fact[K-1], MOD-2, MOD) % MOD)

Measured memory_bytes: 14416
#include <string>
#include <iomanip>
#include <iostream>

using namespace std;

/** Problem0040 : Affine Chipher **/
int main()
{
	string tmp, str;
	int n;
	
	cin >> n;
	cin.ignore();
	for (int i=0; i<n; i++) {
		getline(cin, tmp);
		string tt = tmp;
		for (int alpha=0; alpha<1000; alpha++) {
			for (int beta=0; beta<26; beta++) {
				for (int j=0; j<tt.length(); j++)
					if (tt[j]!=' ') tt[j] = 'a'+((tmp[j]-'a')*alpha+beta)%26;
				if (tt.find("that")!=-1 || tt.find("this")!=-1) {
					cout << tt << endl;
					goto end;
				}
			}
		}
	end: ;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, W;
	cin >> N >> W;

	vector<Int> w(N);
	vector<Int> v(N);

	for (Int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}

	vector<vector<Int>> dp(N + 10, vector<Int>(W + 10));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j <= W; j++) {
			if (j - w[i] >= 0) {
				dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i + 1][j]);
			}
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	cout << dp[N][W] << "\n";

}

Measured memory_bytes: 87296