akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int inf=1000000007;
signed main(){
  int a,b,c;cin>>a>>b>>c;
  int res=inf;
  int x,y;cin>>x>>y;
  res=a*x+b*y;
  if(x>y){
    int buf=c*2*y+a*(x-y);
    res=min(buf,res);
  }
  else{
    int buf=c*2*x+b*(y-x);
    res=min(res,buf);
  }
  res=min(res,c*2*max(x,y));
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int    main( void )
{
    int N, maisu;
    
    scanf("%d",&N);
    
    maisu=N/2;
    if(N%2!=0){
    printf("%d", maisu+1);
    }else{
        printf("%d", maisu);
    }
    return 0;
}


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

const int N = 1e5 + 10;

vector <int> G[N];
int rec[N], color[N], ver[N], d[N], c[N];

void dfs(int x, int dist, int col){
	if (!color[x]) color[x] = col;
	if (~rec[x] && dist <= rec[x]) return;
	rec[x] = dist;
	if (dist == 0) return;
	for (int i = 0; i < G[x].size(); i++) dfs(G[x][i], dist - 1, col);
}

int main(){
	int n, m, q, u, v;
	scanf("%d %d",&n,&m);
	for (int i = 1; i <= m; i++){
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	memset(rec, -1, sizeof(rec));
	memset(color, 0, sizeof(color));
	scanf("%d",&q);
	for (int i = 1; i <= q; i++) scanf("%d %d %d",&ver[i],&d[i],&c[i]);
	for (int i = q; i >= 1; i--) dfs(ver[i], d[i], c[i]);
	for (int i = 1; i <= n; i++) printf("%d\n", color[i]);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> num(N);

  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    num.at(A.at(i) - 1) = i + 1;
  }
  
  for(int i = 0; i < N; i++){
    cout << num.at(i) << ' ';
  }
  
  cout << endl;

  return 0;
}


Measured memory_bytes: 1664
main(a,b,c){
	for(;~scanf("%d%d%d",&a,&b,&c);){
		int cnt=0,i;
		for(i=1;i<=10;i++){
			if(i==a||i==b||i==c)	continue;
			if(a+b+i<=20)	cnt++;
		}
		puts(cnt>=4?"YES":"NO");
	}
	exit(0);
}

Measured memory_bytes: 0
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<usize> = get_vec();
    let h : usize = v[0];
    let _w : usize = v[1];
    let mut im : Vec<String> = Vec::new();
    for _i in 0..h {
        let s : String = get_one();
        im.push(s);
    }

    for s in im {
        println!("{}", s);
        println!("{}", s);
    }
}


Measured memory_bytes: 4352
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

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

        int sum = 0;

        for (int i=0; i<2; i++) {
            if (a > b) {
                sum += a;
                a--;
            } else {
                sum += b;
                b--;
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define INT long long int
using namespace std;
INT n;
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin>>s;
    for(int i = 0 ; i < s.size()-1 ; i++ )
        if( s[i] == 'A' and s[i+1] == 'C' ) return cout<<"Yes"<<endl, 0;
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int Lw,Lh,h,w;
  cin >> Lh >> Lw >> h >> w;
  int ans = Lh * Lw - h * Lw - w * Lh + h * w;
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = 10**13

n, K = [int(item) for item in input().split()]
h = [0] + [int(item) for item in input().split()]

# dp[i][j][k] i:till ith, j:skipped j, k: previous index
dp = [[[INF] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
for i, item in enumerate(h):
    if i == 0:
        dp[0][0][0] = 0
        continue
    for j in range(n-1, -1, -1):
        for k in range(n-1, -1, -1):
            if dp[i-1][j][k] == INF:
                continue
            # skip
            dp[i][j+1][k] = min(dp[i][j+1][k], dp[i-1][j][k])
            # use
            dp[i][j][i] = min(dp[i][j][i], dp[i-1][j][k] + max(0, h[i] - h[k]))
            
ans = INF
for j in range(n+1):
    ans = min(ans, dp[n][K][j])

print(ans)

Measured memory_bytes: 256136
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003;

int n, m;
int a[N];
LL ans, sum;
map <int, int> p;
bool st[N];

int main()
{
	//File("");
	n = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi(), ++p[a[i]];
	for (int i = 1; i <= n; i+=1)
	{
	    if (!st[a[i]])
	    {
	        st[a[i]] = true;
	        ans += 1ll * p[a[i]] * (p[a[i]] - 1) / 2;
	    }
	}
	for (int i = 1; i <= n; i+=1)
	{
	    sum = ans;
	    printf("%lld\n", ans - (p[a[i]] - 1));
	}
	return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;


int main(){
    ll n;
    cin >> n;
    if(n==0){
        cout << 'a' << endl;
        return 0;
    }
    vector<char> name;
    int initial;
    while (n > 0)
    {
        initial = n % 26;
        if(initial==0)
            initial = 26;
        name.push_back('a' + initial-1);
        if(n<=26) n = 0;
        else {
            n /= 26;
            if(initial==26)
                n -= 1;
        }
        }
    for (int i = name.size() - 1; i >= 0; i--){
        cout << name[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	bool c = false,f = false;
	string s;
	cin >> s;
	int n = s.length();

	for(int i=0;i<n;i++){
		if(!c){
			if(s[i] == 'C') c = true;
		}
		else if(!f){
			if(s[i] == 'F') f = true;
		}
	}

	if(f){
		cout << "Yes";
	}
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	N := float64(nextInt())
	for i := 0.0; i <= 50000; i++ {
		if math.Trunc(i*1.08) == N {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(":(")
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

ll GCD(ll x, ll y);

int main() {

    ll N;

    cin >> N;

    ll x;
    cin >> x;
    ll ans = x;

    rep(i, N - 1) {
        cin >> x;
        ans = GCD(ans, x);
        if (ans == 1) {
            break;
        }
    }

    cout << ans;

    return 0;
}
ll GCD(ll x, ll y) {
    ll a, b, r, gcd;
    a = max(x, y);
    b = min(x, y);
    r = 1;
    while (r != 0) {
        r = a % b;
        if (r == 0) {
            gcd = b;
        }
        a = b;
        b = r;
    }
    return gcd;
}

Measured memory_bytes: 3604
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            try:
                if isCLKWISE(phU) : break
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            try:
                if isCLKWISE(phL) : break
            except IndexError : break
      
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(y) for y in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

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

int main() {
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A, A + 3);
  if(A[0] == 5 && A[1] == 5 && A[2] == 7) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


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


  ll c = a+b;
  c /= 2;

  if(abs(a-c) == abs(b-c)) cout << c << endl;
  else                     cout << "IMPOSSIBLE" << endl;


  return 0;
}



Measured memory_bytes: 256
def e
  return H if S[H-1]!=S[H]
  (1...H).each do |i|
    return N-(H-i) unless S[H-1-i]==S[H] && S[H]==S[H+i]
  end
  N
end

def o
  (1..H).each do |i|
    return N-(H-i+1) unless S[H-i]==S[H] && S[H]==S[H+i]
  end
  N
end

S=gets.chop.chars
N=S.size
H=N/2
p N.odd? ? o : e


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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k-a<=0){
        cout << k << endl;
        return 0;
    }
    if(k-a-b<=0){
        cout << a <<endl;
        return 0;
    }
    else{
        cout << a - (k-a-b) << endl;
        return 0;
    }
}



Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
    int a, b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '?') break;
        if(op == '+') cout << (int)(a + b) << endl;
        if(op == '-') cout << (int)(a - b) << endl;
        if(op == '*') cout << (int)(a * b) << endl;
        if(op == '/') cout << (int)(a / b) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3100
def partition(array, head, tail)
	x = array[tail]
	i = head - 1
	(head...tail).each do |j|
		if array[j] <= x
			i = i + 1
			array[i], array[j] = array[j], array[i]
		end
	end
	array[i + 1], array[tail] = array[tail], array[i + 1]
	i + 1
end

array_size = STDIN.gets.to_i
array = STDIN.gets.split[0...array_size].map(&:to_i)
index = partition(array, 0, array_size - 1)
array[index] = sprintf("[%d]", array[index])
puts array.join(" ")

Measured memory_bytes: 21664
import sys
x,n = map(int,input().split())
if n==0:
  print(x)
  sys.exit()

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

for i in range(150):
  if x-i not in p:
    print(x-i)
    break
  if x+i not in p:
    print(x+i)
    break

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

int main(){
    unsigned long L, A, B, M;
    cin >> L >> A >> B >> M;
    auto modpow = [&M](auto n, unsigned long b = 1){
        unsigned long ret = b, p = 10;
        while(n){
            if(n & 1)(ret *= p) %= M;
            (p *= p) %= M;
            n >>= 1;
        }
        return ret;
    };
    cout << [impl = [&M, &modpow](auto f, auto L, auto A, auto B) -> pair<unsigned long, unsigned long> {
        if(to_string(A).size() < to_string(A + (L - 1) * B).size()){
            auto a = f(f, L / 2, A, B), b = f(f, (L + 1) / 2, A + B * (L / 2), B);
            return {a.first + b.first, (modpow(b.first, a.second) + b.second) % M};
        }
        unsigned long ret = 0, len = to_string(A).size(), N = L, R = modpow(len);
        A %= M;
        B %= M;
        while(N){
            if(N & 1){
                ((ret *= R) += A) %= M;
                (A += B) %= M;
            }
            ((A *= R + 1) += B) %= M;
            (B *= 2 * (R + 1)) %= M;
            (R *= R) %= M;
            N >>= 1;
        }
        return {len * L, ret};
    }](auto L, auto A, auto B){return impl(impl, L, A, B).second;}(L, A, B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char c[100][101];
    int h,w,i,j;
    scanf("%d%d",&h,&w);
    for(i=0;i<h;i++)scanf("%s",c[i]);
    for(i=0;i<h;i++)for(j=0;j<2;j++)puts(c[i]);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    String today = sc.next();
    String tomorrow = null;
    switch (today) {
	case "Sunny":
		tomorrow = "Cloudy";
		break;
	case "Cloudy":
		tomorrow = "Rainy";
		break;
	case "Rainy":
		tomorrow = "Sunny";
		break;
    }
    
    System.out.println(tomorrow);
    
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N) cin >> C[i];

    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));

    ll ans = 0;

    vector<ll> B_choice(N);
    REP(i, N) {
        auto itr_c = upper_bound(C.begin(), C.end(), B[i]);
        if(itr_c == C.end()) continue;
        B_choice[i] = N - (itr_c - C.begin());
    }

    FORR(i, N-2, 0) B_choice[i] += B_choice[i+1]; 

    REP(i, N) {
        int a = A[i];
        auto itr_b = upper_bound(B.begin(), B.end(), a);
        ans += B_choice[itr_b - B.begin()];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{


	public static void SelectionSort(int[] array){
		int len=array.length;
		int cnt=0;
		int min;
		int swap;
		for(int i=0;i<len-1;i++){
			min=i;
			for(int j=i+1;j<len;j++){
			if(array[min]>array[j])min=j;
			}
			if(min!=i){
				cnt++;
				swap=array[i];array[i]=array[min];array[min]=swap;

		}

		}

		//??\????????????
		for(int i=0;i<len;i++){
		System.out.print(array[i]);
		if(i!=len-1)System.out.print(" ");}

		System.out.println();
		System.out.println(cnt);
	}

	public static void main(String[] args){

		int n;

		Scanner scan=new Scanner(System.in);
		n=scan.nextInt();
		int[] box=new int[n];

		for(int i=0;i<n;i++){
		box[i]=scan.nextInt();
		}

		SelectionSort(box);

		scan.close();

	}

}

Measured memory_bytes: 25984
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<vector>
#include<queue>
#include<map>
#include<ctime>
using namespace std;

typedef long long ll;
const int MAX=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int d[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{-1,1},{1,-1},{1,1}};

void solve(int n,char s[64][64]){
    int cnt[64][26]={0};
    for(int i=0;i<n;i++){
        for(int j=0;s[i][j];j++){
            char k=s[i][j];
            cnt[i][k-'a']++;
        }
    }
    for(int i=0;i<26;i++){
        int m=cnt[0][i];
        for(int j=1;j<n;j++){
            m=min(m,cnt[j][i]);
        }
        while(m--){
            printf("%c",i+'a');
        }
    }
    putchar('\n');
}

int main(){
    int n;
    char s[64][64];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
    }
    solve(n,s);
    return 0;
}


Measured memory_bytes: 3156
//subset sum problem

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> h(n);
    for (int i = 0; i <n ; ++i) {
        cin>>h[i];
    }
    ll dp[n];
    dp[0]=0;
    for (int i = 1; i <n ; ++i) {
        dp[i]=1e9+7;
        for (int j = 1; j <=2 ; ++j) {
            if(i-j>=0){
                dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 4756
N = int(input())
Flag = 0
TmpNum = 0
Count = 0
Data = [[0 for i in range(2)]  for j in range(N)]

for i in range(N):
    TmpS = input()
    Num = i
    if Num == 0:
        Data[i][0] = TmpS
        Data[i][1] = 1
        Count += 1
    else:
        Flag = 0
        for i2 in range(Num):
            if TmpS == Data[i2][0]:
                Flag = 1
                TmpNum = i2
                break
        
        if Flag == 1:
            Data[TmpNum][1] += 1
        else:
            Data[Count][0] = TmpS
            Data[Count][1] = 1
            Count += 1

M = int(input())
for i in range(M):
    TmpS = input()
    for i2 in range(Count):
        if TmpS == Data[i2][0]:
            Data[i2][1] -= 1
            break

Data = sorted(Data, key=lambda x: x[1],  reverse=True) 

Ans = Data[0][1]
if Ans < 0:
    Ans = 0

print(Ans)
    
            



Measured memory_bytes: 3064
using System;
namespace DS
{
    class Program
    {
        static void Main(string[] args)
        {
           
            string[] nk =  Console.ReadLine().ToString().Split(' ');
          	int n = Convert.ToInt32(nk[0]);
         	int k = Convert.ToInt32(nk[1]);
            string[] nums = Console.ReadLine().ToString().Split(' ');
            int[] stones = new int[n];
            for (int i = 0; i < n; i++)
                stones[i] = Convert.ToInt32(nums[i]);
           int[] cost = new int[n];
            cost[0] = 0;
            cost[1] = Math.Abs(stones[1] - stones[0]);
            for(int i=2;i<n;i++)
            {
                cost[i] = int.MaxValue;
                for(int j=1;j<=k && i-j>=0;j++)
                {
                    cost[i] = Math.Min(cost[i - j] + Math.Abs(stones[i] - stones[i - j]), cost[i]);
                }
            }
            
            Console.WriteLine(cost[n-1]);
        }
    }
}

Measured memory_bytes: 18656
a,b=gets.split.map &:to_i
c=[*?A..?Z]
d=[]
a.times do
  d<< gets.chomp.split
end
a.times do |i|
  b.times do |j|
    if d[i][j]=="snuke"
      puts c[j]+(i+1).to_s
    end
  end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	for (int a = 1; a < 10; ++a) {
		for (int b = 1; b < 10; ++b) {
			if (a * b == n) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;


int main() {
 itn N;
  in(N);
  vl t(N),x(N),y(N);
  bool f=true;
  rep(i,N) in(t[i]>>x[i]>>y[i]);
  if(N==1){
   if(x[0]+y[0]>t[0] || (x[0]+y[0])%2 != t[0]%2) out("No");
    else out("Yes");
    return 0;
  }
  rep(i,N-1){
    if(i==0){
      if(x[i]+y[i]>t[i]) f = false;
      else if((x[i]+y[i]) %2 != t[i]%2) f = false;
    }
    else{
    if((abs(x[i+1]-x[i])+abs(y[i+1]-y[i]))>t[i+1]-t[i]) f = false;
   else  if((abs(x[i+1]-x[i])+abs(y[i+1]-y[i]))%2 !=(t[i+1]-t[i])%2) f =false;
  }
  }
  if (f) out("Yes");
  else out("No");
}


Measured memory_bytes: 2688
// ※※※ 解答不能 ※※※
// snuke氏.
// https://atcoder.jp/contests/aising2020/submissions/15209244
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;

// Fermat's little theorem から, 大きな冪乗の計算を行う.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL mPow(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a *= a;
        a %= MOD;
        b >>= 1;
    }
    return t % MOD;
}

// 組み合わせ(nCk)計算用(mod版).
// @param n: 対象となる要素の個数.
// @param k: 選択する要素の個数.
// @return: 組み合わせ(nCk)の計算結果.
LL combination(int n, int k){
    LL a = 1, b = 1;
    rep(i, k){
        a = a * (LL)(n - i) % MOD;
        b = b * (LL)(i + 1) % MOD;
    }
    return a * mPow(b, MOD - 2) % MOD;
}

int main(){
    int T;
    scanf("%d", &T);
    rep(i, T){
        int N;
        scanf("%d", &N);
        N -= 5;
        LL ans = 0;
        rep(o, 12){
            int M = N - o;
            if(M < 0 || M % 2 != 0) continue;
            ans += combination(M / 2 + 15, 15) * combination(11, o);
            ans %= MOD;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3792
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int n; string s;
int main() {
	cin >> n >> s;
	int w = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '.') {
			w++;
		}
	}
	int ans = w;
	for (int i = 0; i < n; i++) {
		if (s[i] == '.') {
			w--;
		}
		else {
			w++;
		}
		ans = min(w, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto edges = new long[][](N);
	foreach (i; 0..M)
	{
		auto a = RD-1;
		auto b = RD-1;
		edges[a] ~= b;
	}

	long[] search(long pos)
	{
		long[] open = [pos];
		auto prev = new long[](N);
		prev[] = -1;
		while (!open.empty)
		{
			auto from = open.front; open.popFront;
			foreach (to; edges[from])
			{
				if (prev[to] == -1)
				{
					prev[to] = from;
					if (to == pos) return prev;
					open ~= to;
				}
			}
		}
		return [];
	}

	long[][] ans;
	foreach (i; 0..N)
	{
		auto r = search(i);
		if (!r.empty)
		{
			long[] tmp;
			auto pos = r[i];
			tmp~= i+1;
			while (true)
			{
				debug writeln(i, " ", pos+1);
				tmp ~= pos+1;
				pos = r[pos];
				if (pos == i) break;
			}
			ans ~= tmp;
		}
	}

	if (ans.empty)
		writeln(-1);
	else
	{
		ans.sort!"a.length < b.length"();
		writeln(ans[0].length);
		foreach (e; ans[0])
			writeln(e);
	}
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 12540
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        String s = sc.next();
        sc.close();

        // 主処理
        boolean judge = s.matches("^[0-9]{" + a + "}-[0-9]{" + b + "}");
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23636
#include<stdio.h>

int main(void)
{
  int a;
  int b[4];
  int i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
  while(scanf("%d", &a)!=EOF)
    {
      n = 0;
      for(j = 9; j >= 0; j--){
        for(k = 9; k >= 0; k--){
          for(l = 9; l >= 0; l--){
            for(m = 9; m >= 0; m--){
              if(j + k + l + m == a)
                n++;
            }
          }
	}
      } 
      printf("%d\n", n);
    }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int n = s.length();
	int k = t.length();
	int st=-1;
	for(int i=0;i<=n-k;i++)
	{
		bool flag=true;
		for(int j=0;j<k;j++)
		{
			if(s[i+j]!=t[j] && s[i+j]!='?'){
				flag=false;
				break;
			}
		}
		if(flag==true)
			st=i;

	}
	if(st==-1)
		cout<<"UNRESTORABLE\n";
	else
	{
		for(int i=st;i<st+k;i++)
			s[i]=t[i-st];
		for(int i=0;i<n;i++)
		{
			if(s[i]=='?')
				s[i]='a';
		}
		cout<<s<<"\n";
	}
}

Measured memory_bytes: 3608
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int w=0,b=0;
    rep(i,n){
        w += (s[i] == 'W');
        b += (s[i] == 'B');
    }
    if(w == 0 || b == 0){
        cout << 0 << '\n';
        return 0;
    }
    int cnt = 0;
    int minv = INF;
    char tmp = 'X';
    reps(i,n-1){
        if(s[i-1] != s[i]){
            ++cnt;
        }
    }
    minv = min(cnt,minv);
    cnt = 0;
    tmp = 'X';
    for(int i = n-1;i >= 0;--i){
        if(s[i] != s[i-1]){
            ++cnt;
        }
    }
    cout << min(minv,cnt) << '\n';
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <queue>
 
using namespace std;
typedef long long int64;
 
const int P = 998244353;
const int MAXN = 3011;
int dp[MAXN];
int n, s, ans;
 
inline int add(int x, int y) { x += y; x -= x >= P ? P : 0; return x; }
inline int mul(int x, int y) { return 1ll * x * y % P; }
inline void incr(int& x,int y) { x = add(x, y); }
 
int main(void)
{
	cin >> n >> s;
	for (int i = 1;i <= n; ++i)
	{
		int v;
		cin >> v;
		for (int j = s - v; j >= 0; --j)
			incr(dp[j + v], dp[j]);
		incr(dp[v], i);
		incr(ans, dp[s]);
	}
	cout << ans << '\n';
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    /* 座席　（中央×後）*/
    //資料の説明通りにやってみたつもりです

    int n;
    cin >> n;
    vector<vector<int>> vc(n, vector<int>());

    REP(i, n) {
        int u, k, e;
        cin >> u >> k;

        REP(j, k) {
            cin >> e;
            vc.at(u-1).push_back(e-1);
        }
    }

    vector<vector<int>> A(n, vector<int> (n, 0));

    REP(i, n) {
        REP(j, vc.at(i).size()) {
            A.at(i).at(vc[i][j]) = 1;
        }
    }

    REP(i, n) {
        REP(j, n) {
            cout << A.at(i).at(j);
            if (j != n-1)   cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3148
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define INF 1e18
#define N 1000100
typedef pair<ll,ll> pll;
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%MOD;
    if(b&1)
        ans=(a*ans)%MOD;
    return ans;
}
ll inv(ll a)
{
    return power(a,MOD-2,MOD);
}
//code begins



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

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    while(t--)
    {
        ll h,n;cin>>h>>n;
        ll s=0;
        for(ll i=0;i<n;i++)
        {
            ll x;cin>>x;
            s+=x;
        }
        if(h-s<=0)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
}


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<string, int>
#define fi				first
#define se				second

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 100;

bool G[MAX_N][MAX_N];

signed main() {
	string s; cin >> s;
	s[3] = '8';

	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,tot,a[105];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		tot+=a[i];
	}
	sort(a+1,a+n+1);
	if(a[n-m+1]*m*4<tot)
		puts("No");
	else
		puts("Yes");
    return 0;
}

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

void Main() {
  int N, M;
  cin >> N >> M;

  int A[M];
  for (int i = 0; i < M; i++) {
    cin >> A[i];
  }

  long long sum = 0;
  for (int i = 0; i < M; i++) {
    sum += A[i];
  }

  if (N - sum < 0) cout << -1 << endl;
  else cout << N - sum << endl;
}

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	int p = 0;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		scanf("%d", &a);
		int use = min(a, p);
		ans += use;
		a -= use;
		ans += a / 2;
		a %= 2;
		p = a;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc048/tasks/arc064_a
N, x = read_ints()
A = read_ints()

# 前処理ですべてx以下にしてから
# 漸化式 a[i+1] <= x-a[i]を満たすようにa[i+1]を決定していく(等号が成り立つときが一番いい)
# 右からやったり左からやったときに結果って変わらないのかな...?(大丈夫、無駄に多く減らすことはない)

# 前処理
ans = 0
for i in range(N):
    ans += max(A[i] - x, 0)
    A[i] = min(A[i], x)

# 漸化式を解く
for i in range(N - 1):
    new = x - A[i]
    if A[i + 1] <= new:
        continue  # もともと条件は満たされている
    ans += A[i + 1] - new
    A[i + 1] = new  # x>=A[i]なので大丈夫
print(ans)


Measured memory_bytes: 59632
Ss = {}
Ss["A"] = input()
Ss["B"] = input()
Ss["C"] = input()

p = "A"
while True:
    if len(Ss[p]) == 0:
        ans = p
        break
    ch = Ss[p][0]
    Ss[p] = Ss[p][1:]
    p = ch.upper()

print(ans)


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

int main() {
  int N;
  int A[200];

  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];

  int res = 0;
  while (true) {
    bool exist_odd = false;
    for (int i = 0; i < N; ++i) {
      if (A[i] % 2 != 0) exist_odd = true;
    }
    if (exist_odd) break;
    for (int i = 0; i < N; ++i) {
      A[i] /= 2;
    }
    ++res;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
n = int(raw_input())
a = [[0] * (n + 1) for _ in range(n + 1)]
m = -10000 * 100 * 100

for i in range(n):
    b = map(int, raw_input().split())
    for j in range(n):
        aa = 0
        for k in range(j, n):
            aa += b[k]
            a[j][k] = max(a[j][k], 0) + aa
            m = max(m, a[j][k])
print m

Measured memory_bytes: 4484
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    ll N, x;
    cin >> N >> x;

    ll a[N], c[N];
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        c[i] = a[i];
        ans += a[i];
    }

    for (ll t = 1; t < N; ++t) {
        ll cost = t * x;
        for (int i = 0; i < N; ++i) {
            c[i] = min(c[i], a[(i + N - t) % N]);
            cost += c[i];
        }
        ans = min(ans, cost);
    }

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


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int D;
    scanf("%d",&D);
    if(D==22)
    {
        printf("Christmas Eve Eve Eve\n");
    }
    else if(D==23)
    {
        printf("Christmas Eve Eve\n");
    }
    else if(D==24)
    {
        printf("Christmas Eve\n");
    }
    else if(D==25)
    {
        printf("Christmas\n");
    }
    return 0;
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> sum(n << 1 | 1, 0);
  for (int i = 0; i < n << 1; ++i) {
    sum[i + 1] = sum[i] + (s[i] == 'a' ? 1 : -1);
  }
  int last = 0;
  vector<string> all;
  function<string(int, int)> get = [&](int l, int r) {
    vector<int> a, b;
    for (int i = l; i < r; ++i) {
      if (s[i] == 'a') {
        a.push_back(i);
      } else {
        b.push_back(i);
      }
    }
    vector<bool> choose(r - l, false);
    if (a[0] < b[0]) {
      int last = -1;
      for (int i = 0; i < r - l >> 1; ++i) {
        if (a[i] > last) {
          choose[a[i] - l] = choose[b[i] - l] = true;
          last = b[i];
        }
      }
      string result = "";
      for (int i = 0; i < r - l; ++i) {
        if (choose[i]) {
          result += s[i + l];
        }
      }
      return result;
    } else {
      string result = "";
      for (int i = (r - l >> 1) - 1; ~i; --i) {
        choose[a[i] - l] = choose[b[i] - l] = true;
        string current = "";
        for (int j = 0; j < r - l; ++j) {
          if (choose[j]) {
            current += s[j + l];
          }
        }
        result = max(result, current);
      }
      return result;
    }
  };
  for (int i = 1; i <= n << 1; ++i) {
    if (!sum[i]) {
      all.push_back(get(last, i));
      last = i;
    }
  }
  vector<string> dp(all.size() + 1, "");
  for (int i = all.size() - 1; ~i; --i) {
    dp[i] = max(dp[i + 1], all[i] + dp[i + 1]);
  }
  cout << dp[0] << endl;
  return 0;
}


Measured memory_bytes: 10752
# 入力は以下の形式で標準入力から与えられる。
# s
# t
# 英小文字のみからなる文字列 s, t が与えられます。 
s = gets.chomp
t = gets.chomp

# あなたは、s の文字を並べ替え、文字列 s′ を作ります。 
# また、t の文字を並べ替え、文字列 t′ を作ります。 
s_d = s.split("").sort.join
t_d = t.split("").sort.reverse.join

# このとき、辞書順で s′ < t′ となるようにできるか判定してください。

# 辞書順で s′ < t′ となるようにできるならば Yes を、
# できないならば No を出力せよ。
if s_d < t_d
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 3836
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = input().rstrip()
    N = len(S)
    cnt_a = 0
    cnt_b = 0
    for i in range(N):
        if i%2 == 0 and S[i] == '0':
            cnt_a += 1
        elif i%2 == 1 and S[i] == '1':
            cnt_a += 1
        elif i%2 == 0 and S[i] == '1':
            cnt_b += 1
        elif i%2 == 1 and S[i] == '0':
            cnt_b += 1
    print(min(cnt_a,cnt_b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll n;
  cin >> n;
  ll k[1000001];
  ll ans=0;
  rep(i,1000001)k[i]=0;
  rep(i,1000001){
    if(i<2)continue;
    while(n%i==0){
      n/=i;
      k[i]++;
    }
  }
  if(n>1)ans++;
  rep(i,1000001){
    int u=k[i];
    int cnt=1;
    while(cnt<=u){
      ans++;
      u-=cnt;
      cnt++;
    }
  }
  cout << ans << endl;
}  


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

double dp[3005][3005];

int main() {
    int n;
    cin >> n;
    vector<double> p(n);
    rep(i, n) {
        cin >> p[i];
    }
    SPC(10);
    dp[1][1] = p[0];
    dp[1][0] = 1 - p[0];
    repeat(i, 1, n) {
        rep(j, n) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        }
    }
    double ans = 0;
    rep(i, n / 2 + 1) {
        ans += dp[n][n - i];
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 70656
#include <stdio.h>
#include <stdlib.h>

int main(){
	char n[10];
	int i,m = 0;
	
	scanf("%s",n);
	
	for(i = 0;i < 10;i++){
		if(n[i] == '\0') break;
		m += n[i] - '0';
	}
	
	printf("%s",atoi(n) % m == 0 ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 128
from heapq import*
import sys
input=sys.stdin.readline
 
def DIJKSTRA(point,d):
    cost      = [1e18]*(n+1)
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost

n=int(input())
d=[[]for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])

q,k=map(int,input().split())
y=DIJKSTRA(k,d)
 
for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])


Measured memory_bytes: 52520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N[4];
  cin >> N[0] >> N[1] >> N[2] >> N[3];
  sort(N,N+4);
  if(N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9){
  	cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    
    int N;
    cin >> N;
    cout << "ABC" << N << endl;
    
    return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch){
    if( ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

// 文字列から数値へ変換してkeyを生成する
long long getKey(char str[]){
    long long sum = 0, p=1,i;
    for(i=0; i<strlen(str); i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + (key % (M-1));}

int find(char str[]){
    long long key,i,h;
    key = getKey(str);

    for(i=0;;i++){
        h = (h1(key) + i*h2(key)) % M;
        if(strcmp(H[h],str) == 0) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key,i,h;
    key = getKey(str);
    for(i=0;;i++){
        h = (h1(key) + i*h2(key)) % M;
        if(strcmp(H[h],str) == 0) return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h],str);
            return 0;
        }
    }
}

int main(){
    int i,n,h;
    char str[L],com[9];
    for(i=0; i<M; i++) H[i][0] = '\0';
    scanf("%d",&n);
    for(i=0; i<n;i++){
        scanf("%s %s",com,str);

        if(com[0] == 'i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16976