akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdbool.h>

int main(void) {

	int n, num;
	bool cards[4][13] = { false };
	char mark;
	
	scanf("%d", &n);
	//scanf("%c %d\n", &mark, &num);
	
	for (int i = 0; i < n; i++) {
		scanf("%c", &mark);
		scanf("%c %d", &mark, &num);

		switch (mark) {
		case 'S':
			cards[0][num - 1] = true;
			break;
		case 'H':
			cards[1][num - 1] = true;
			break;
		case 'C':
			cards[2][num - 1] = true;
			break;
		case 'D':
			cards[3][num - 1] = true;
			break;
		}
	}

	for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 13; k++) {
			if (cards[j][k] == false) {
				switch (j) {
				case 0:
					printf("S %d\n", k + 1);
					break;
				case 1:
					printf("H %d\n", k + 1);
					break;
				case 2:
					printf("C %d\n", k + 1);
					break;
				case 3:
					printf("D %d\n", k + 1);
					break;
				}
			}
		}
	}

	return 0;
}




Measured memory_bytes: 2080
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;
const ull num = 1e18;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int x, y; cin >> x >> y;
	if (y & 1 || y <= x)
	{
		cout << "No";
		return 0;
	}
	int b = -((2 * x - y) / 2);
	if (b < 0 || b > x)
	{
		cout << "No";
		return 0;
	}
	int a = -((y - 4 * x) / 2);
	if (a < 0 || a > x || a + b != x)
	{
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3660
#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+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;
  k = min(k,(ll)100);
  rep(i,k){
    if(s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void){
    int a,b,c;
    int S=0;
    scanf("%d %d %d",&a,&b,&c);
    S = a+b+c;

    if(S>21){
        printf("bust\n");
    }else{
        printf("win\n");
    }

    return 0;

}

Measured memory_bytes: 128
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693
int compare(const void *a, const void *b){
  return (*(int *)a)- (*(int *)b);
} 

int main(){
  int n,k,ans=0;
  scanf("%d %d",&n,&k);
  int p[n];
  for(int i=0;i<n;i++)scanf("%d",&p[i]);
  qsort(p,n,sizeof(int),compare);
  for(int i=0;i<k;i++){
    ans += p[i];
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 1728
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i = 0; i < n1; i++) L[i] = A[left + i];
    for (i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for (k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r) {
    int i, j;
    struct Card t, x;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
    int q;
    if (p < r) {
        q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q + 1, r);
    }
}

int main() {
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n - 1);
    
    for (i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit) stable = 0;
    }
    
    if (stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for (i = 0; i < n; i++) {
        printf("%c %d\n", B[i].suit, B[i].value);
    }
    
    return 0;
}


Measured memory_bytes: 4044
sx,sy,tx,ty=map(int,input().split())
disx=tx-sx
disy=ty-sy
answer='U'*disy+'R'*disx+'D'*disy+'L'*(disx+1)+'U'*(disy+1)+'R'*(disx+1)+'D'+'R'+'D'*(disy+1)+'L'*(disx+1)+'U'
print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<ll>>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
void a(){

}

void b(){
    string s;cin >> s;
    string sf = s.substr(0,s.size()/2);
    string bsf = sf;
    reverse(bsf.begin(),bsf.end());
    string sb = s.substr((s.size()+1)/2);
    string bsb = sb;
    reverse(bsb.begin(),bsb.end());
    if(sf==bsf&&bsf==sb&&sb==bsb){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000 , mod = 1000000007;
#define PI 3.14159265
int dp[100005];
int a[102];
int n,k;
int solve(int rem)
{
    if(rem<0)
        return 1;
    if(dp[rem]!=-1)
        return dp[rem];
    int f = 0;
    for(int i=1;i<=n;i++)
    {
        f = f | solve(rem-a[i])^1;
    }
    return dp[rem] = f;
}
int main()
{
    fastio;
    cin>>n>>k;
    set_ar(dp,-1);
    for(int i=1;i<=n;i++)cin>>a[i];
    int flag = solve(k);
    if(flag)
        cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s,t[1000001];
int main(void){
    cin>>s;
    ll i=1;
    t[s]++;
    while(1){
        i++;
        if(s%2==0){
            s/=2;
            if(t[s]==1){cout<<i<<endl;return 0;}
            else t[s]++;
        }
        else{
            s=s*3+1;
            if(t[s]==1){cout<<i<<endl;return 0;}
            else t[s]++;
        }
    }
}


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

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int N;
	int a[100];
	int res = INF;
	cin >> N;
	REP(i, N){
		cin >> a[i];
	}
	FOR(i, -100, 101){
		int sum = 0;
		REP(j, N){
			sum += (a[j]-i)*(a[j]-i);
		}
		res = min(res, sum);
	}
	
	cout << res << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scr =new Scanner(System.in);
	
		String in = scr.next();
		String out = scr.next();
		
		String a = out.substring(0,out.length()-1);
	
		if(in.equals(a)&&in.length() != out.length()) {
			System.out.println("Yes");
		}else {
			System.out.println("No");	
		}
	
	}
}


Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
typedef long long ll;
const int N=0;
int n,k,x,t,a,b;
string s;
vector<int>v;
bool ispald(string s){
	int x = s.length();
	for(int i =0;i<x/2;i++){
		if(s[i] != s[x-i-1]){
			return false;
		}
	}
	return true;
}
int main(){

	cin >> s;
	n = s.length();
	if(ispald(s) && ispald(s.substr(0,n/2))&&ispald(s.substr((n+2)/2))){
		cout << "Yes";
	}else{
		cout <<"No";
	}
	return 0;
}

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

using namespace std;

void solve() {
    int n; cin >> n;
    multiset<uint32_t> st;
    for (int _ = 0; _ < n; _++) {
        uint32_t x; cin >> x;
        st.insert(x);
    }
    int cnt = 0;
    while (st.size() >= 2) {
        auto x = *st.rbegin();
        st.erase(--st.end());
        uint32_t pw = 1 << (32 - __builtin_clz(x));
        auto it = st.find(pw - x);
        if (it != st.end()) {
            cnt++;
            st.erase(it);
        }
    }
    cout << cnt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int m,n,i,j;
   cin>>m>>n;
   string b,a[m][n];
   for(i=0;i<m;i++)
   {
       cin>>b;
       for(j=0;j<n;j++)
       a[i][j]=b[j];
       
   }
   
 
   for(i=0;i<m+2;i++)
   {
       for(j=0;j<n+2;j++)
       {
           if(i==0 || i==m+1)
           cout<<'#';
           
            else if(j==0 || j==n+1)
           cout<<'#';
           else
           cout<<a[i-1][j-1];
           
       }
       cout<<""<<endl;
   }
}
           

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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int t;
  t=s.size();
  
  if(n<t){
    for(int i=0;i<n;i++)cout << s.at(i);
    cout << "..."<<endl;
    
  }else{
    cout << s <<endl;
  }
  
  
  
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;

int n,nex,cost;
int dis[100009],ans[100009];
vector<P>v[100009];

void SET(int x,int i){
  nex=v[x][i].first;
  cost=v[x][i].second;
}

void dfs1(int x,int pre){
  r(i,v[x].size()){
    SET(x,i);
    if(nex==pre)continue;
    dfs1(nex,x);
    SET(x,i);
    dis[x]=max(dis[x],dis[nex]+cost);
  }
}

void dfs2(int x,int d_pre,int pre){
  vector<P>child;
  child.push_back(P(0,-1));
  r(i,v[x].size()){
    SET(x,i);
    if(nex==pre)child.push_back(P(d_pre+cost,nex));
    else child.push_back(P(dis[nex]+cost,nex));
  }
  sort(child.begin(),child.end(),greater<P>());
  ans[x]=max(child[0].first,child[1].first);
  r(i,v[x].size()){
    SET(x,i);
    if(nex==pre)continue;
    dfs2(nex,child[nex==child[0].second].first,x);
  }
}

int main(){
  cin>>n;
  r(i,n-1){
    int s,t,w;
    scanf("%d%d%d",&s,&t,&w);
    v[s].push_back(P(t,w));
    v[t].push_back(P(s,w));
  }
  dfs1(0,-1);
  dfs2(0,0,-1);
  r(i,n)cout<<ans[i]<<endl;
}



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

int main() {
	int ans;
	vector<int> x(5);
	for (int i = 0; i < 5; i++)
		cin >> x[i];
	for (int i = 0; i < 5; i++) {
		if ( x[i] == 0) {
			ans = i;
			break;
		}
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

ll isSame(ll arr1[], ll arr2[], ll n)
{
    for(ll i=0;i<n;i++)
    {
        if(arr1[i]!=arr2[i])
        {
            return 0;
        }
    }
    return 1;
}


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

     ll arr1[n],arr2[n],i;
     for(i=0;i<n;i++)
     {
         cin>>arr1[i];
     }
     for(i=0;i<n;i++)
     {
         cin>>arr2[i];
     }

     ll arr[n];
     for(i=0;i<n;i++)
     {
         arr[i]=i+1;
     }
     ll k=0;
     ll a,b;

     do
     {
         k++;
         if(isSame(arr,arr1,n))
         {
             a=k;
         }
         if(isSame(arr,arr2,n))
         {
             b=k;
         }
     } while(next_permutation(arr,arr+n));

     ll ans = abs(a-b);
     cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

def solve(N, K, ab):
    ab.sort(key=lambda x: x[0])

    s = 0
    for x in ab:
        s += x[1]
        if s >= K:
            print(x[0])
            return


def main():
    N, K = map(int, input().split())
    ab = [ tuple(map(int, input().split())) for _ in range(N) ]
    solve(N, K, ab)

if __name__ == "__main__":
    main()

Measured memory_bytes: 18192
function main(input) {
    let [av,bw,t] = input.trim().split('\n')
    let [a,v] = av.split(' ').map(n => Number(n))
    let [b,w] = bw.split(' ').map(n => Number(n))

    const dist = Math.abs(a - b)
    const speed = v - w
    const is_catchable = (speed > 0) && (dist / speed <= Number(t))

    console.log(is_catchable ? 'YES' : 'NO')
}

main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

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

    int ans = (int)pow(n,3);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let s = scan.next_word();
    let t = scan.next_word();
    let mut ans = 0;
    for i in 0..s.len() {
        if s[i] != t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 2812
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)

main :: IO ()
main = do
    n <- readLn :: IO Int
    ds <- U.fromList <$> sort <$> r'
    print $ ds U.!(div n 2) - (ds U.! (div n 2 - 1))

Measured memory_bytes: 17788
N = int(input())
A = [0 for _ in range(N)]
for i in range(N-1):
  c, s, f = map(int, input().split())
  for j in range(i+1):
    if A[j] < s:
      A[j] = s + c
    else:
      d = (A[j] - s) // f
      if (A[j] - s) % f != 0:
        d += 1
      A[j] = s + f * d + c
for i in range(N):
  print(A[i])


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
#define ar array
int32_t main() 
{ 
	int n,d,a;
	cin>>n>>d>>a;
	ar<int,2> arr[n];
	for (int i = 0; i < n; ++i)
		cin>>arr[i][0]>>arr[i][1];
	int s=0;
	sort(arr,arr+n);
	int c[n+1]={0};
	for(int i=0,j=0;i<n;++i){
		while(j<n && arr[j][0]<=arr[i][0]+2*d)
			j++;
		j--;
		int b=(arr[i][1]-c[i]*a +a-1)/a;
		if(b<0)
			b=0;
		s+=b;
		c[i]+=b;
		c[j+1]-=b;
		c[i+1]+=c[i];
	}
	cout<<s;
} 


Measured memory_bytes: 4992
import java.util.Scanner;

class dice {
	int[] num = new int[6];
	dice(int[] d) {
		num = d;
	}
	public void an(int x,int y) {
		if(x==num[0]&&y==num[1]||x==num[1]&&y==num[5]||x==num[5]&&y==num[4]||x==num[4]&&y==num[0]) {
			System.out.println(num[2]);
		}else if(x==num[0]&&y==num[2]||x==num[2]&&y==num[5]||x==num[5]&&y==num[3]||x==num[3]&&y==num[0]) {
			System.out.println(num[4]);
		}else if(x==num[0]&&y==num[4]||x==num[4]&&y==num[5]||x==num[5]&&y==num[1]||x==num[1]&&y==num[0]) {
			System.out.println(num[3]);
		}else if(x==num[0]&&y==num[3]||x==num[3]&&y==num[5]||x==num[5]&&y==num[2]||x==num[2]&&y==num[0]) {
			System.out.println(num[1]);
		}else if(x==num[4]&&y==num[3]||x==num[3]&&y==num[1]||x==num[1]&&y==num[2]||x==num[2]&&y==num[4]) {
			System.out.println(num[0]);
		}else {
			System.out.println(num[5]);
			}
		}
	}

public class Main {

	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int a,b;
		int [] d=new int[6];
		for(int i=0;i<6;i++) {
			d[i]=sc.nextInt();
		}
		dice d1=new dice(d);
		int q=sc.nextInt();
		for(int i=0;i<q;i++) {
		a=sc.nextInt();
		b=sc.nextInt();
		d1.an(a,b);
		}
		sc.close();
	}
}




Measured memory_bytes: 26356
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        sc.nextLine();
        ArrayList<String> c = new ArrayList<String>();
        for (int i = 0; i < h; i++) {
            c.add(sc.nextLine());
        }

        String redLine = "";

        Set<Integer> hSet = new HashSet<Integer>();
        for (int i = 0; i < h; i++) {
            hSet.add(i);
        }
        Set<Integer> wSet = new HashSet<Integer>();
        for (int i = 0; i < w; i++) {
            wSet.add(i);
            redLine += "."; // in fact, this is white line;
        }

        Set<Set<Integer>> hPowSet = powerSet(hSet);
        Set<Set<Integer>> wPowSet = powerSet(wSet);

        int ans = 0;

        for (var hi : hPowSet) {
            for (var wi : wPowSet) {
                ArrayList<String> copy = new ArrayList<String>(c);
                for (var hii : hi) {
                    copy.set(hii, redLine);
                }
                for (var wii : wi) {
                    for (int j = 0; j < h; j++) {
                        StringBuilder builder = new StringBuilder(copy.get(j));
                        builder.setCharAt(wii, '.');
                        copy.set(j, builder.toString());
                    }
                }
                // count #
                int count = 0;
                for (var str : copy)
                    for (int j = 0; j < str.length(); j++)
                        if (str.charAt(j) == '#')
                            count += 1;

                if (count == k)
                    ans += 1;
            }
        }
        System.out.println(ans);
    }

    public static <T> Set<Set<T>> powerSet(Set<T> originalSet) {
        Set<Set<T>> sets = new HashSet<Set<T>>();
        if (originalSet.isEmpty()) {
            sets.add(new HashSet<T>());
            return sets;
        }
        List<T> list = new ArrayList<T>(originalSet);
        T head = list.get(0);
        Set<T> rest = new HashSet<T>(list.subList(1, list.size()));
        for (Set<T> set : powerSet(rest)) {
            Set<T> newSet = new HashSet<T>();
            newSet.add(head);
            newSet.addAll(set);
            sets.add(newSet);
            sets.add(set);
        }
        return sets;
    }
}

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

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split("");

		int white[] = new int[n + 1];
		int black[] = new int[n + 1];

		for (int i = 0; i < n + 1; i++) {
			if (i - 1 >= 0) {
				if (str[i - 1].equals("#"))
					black[i] = 1 + black[i - 1];
				else
					black[i] = black[i - 1];
			}
		}

		for (int i = n; i >= 0; i--) {
			if (i + 1 < n) {
				if (str[i + 1].equals("."))
					white[i] = 1 + white[i + 1];
				else
					white[i] = white[i + 1];
			}
		}

		int ans = Integer.MAX_VALUE;

		for (int i = 0; i < n + 1; i++) {
			ans = Math.min(ans, black[i] + white[i]);
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 51296
#144c
N = int(input())

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

    divisors.sort()
    return divisors

divisors_list = make_divisors(N)

if len(divisors_list)%2==0:
    print(divisors_list[int(len(divisors_list)/2)] + divisors_list[int(len(divisors_list)/2 -1)] -2)
else:
    print(divisors_list[int((len(divisors_list)-1)/2)] + divisors_list[int((len(divisors_list)-1)/2)] -2)

Measured memory_bytes: 3272
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var hw = IO.RSInt;
            var h = hw[0];
            var w = hw[1];
            var n = IO.RInt;
            var a = IO.RSInt;

            var all = new int[h * w];
            int idx = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < a[i]; j++)
                {
                    all[idx] = i + 1;
                    idx++;
                }
            }
            for (int i = 0; i < h; i++)
            {
                var row = new int[w];
                Array.Copy(all, w * i, row, 0, w);
                if (i % 2 == 1)
                    Array.Reverse(row);
                WriteLine(string.Join(' ', row)); ;
            }
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 20880
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

namespace {
    const int mo = 1e9 + 7;
    inline int add(int x) {return x >= mo ? x - mo : x;}
    inline int sub(int x) {return x < 0 ? x + mo : x;}
    inline int mul(int x, int y) {return (long long) x * y % mo;}
}
const int N = 302;
int dp[N][N][N], n, m;

inline void U(int &x, int y) {
    x = add(x + y);
}

int main(void) {
    read(n); read(m);
    dp[0][1][0] = 1;
    for (int step = 0; step < m; step++) {
	for (int co = 1; co <= n; co++) {
	    for (int lian = 0; lian <= n; lian++)
		if (dp[step][co][lian]) {
		    int other = n - co - lian;
		    // extend
		    U(dp[step + 1][co][lian + 1], mul(dp[step][co][lian], other));
		    // form circle
		    if (lian != 0) {
			U(dp[step + 1][co + lian][0], mul(dp[step][co][lian], co));
		    }
		    // do noting
		    if (lian == 0) {
			U(dp[step + 1][co][lian], mul(dp[step][co][lian], co));
		    } else {
			U(dp[step + 1][co][lian], mul(dp[step][co][lian], lian));
		    }
		}
	}
    }
    cout << dp[m][n][0] << "\n";
}


Measured memory_bytes: 105472
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    ll x,inicio=100,contador=0;
    cin >> x;
    while(x>inicio){
        inicio+=inicio/100;
        contador++;
    }
    cout << contador << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int t[n], x[n], y[n];
    rep(i, n) cin >> t[i] >> x[i] >> y[i];

    bool ok = true;
    rep(i, n) {
        int a = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        int b = t[i] - t[i - 1];
        if (i == 0) a = x[0] + y[0], b = t[0];
        if (a > b || a % 2 != b % 2) ok = false;
    }

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1408
import sys,math
INF = 2**31-1
N,Q = map(int,sys.stdin.readline().split())
COM = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(Q)) # multi line with multi param
i = 1
while i < N:
    i*=2
N = i
MAX_N = 1 << math.ceil(math.log2(N)) #17
SEG = [INF]*(2*MAX_N-1)

def update(k,a):#0 indexed
    k += N-1
    SEG[k] = a
    while k > 0:
        k = (k-1)//2
        SEG[k] = min(SEG[k*2+1],SEG[k*2+2])

def find(a,b,i=0,l=0,r=N):#0 indexed
    if r <= a or  b <= l:
        return INF
    if a <= l and r <= b:
        return SEG[i]
    vl = find(a,b,2*i+1,l,(r+l)//2)
    vr = find(a,b,2*i+2,(r+l)//2,r)
    return min(vl,vr)

for com,x,y in COM:
    if com == 0:
        update(x,y)
    else:
        print(find(x,y+1))



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

long long MOD = 1000000007;
long long dp[100010];
long long ok[100010];

int main() {
  int N, M; cin >> N >> M;
  for (int i = 0; i < 100010; i++) ok[i] = true;
  for (int i = 0; i < M; i++) {
    int a; cin >> a;
    ok[a] = false;
  }
  for (int i = 0; i < 100010; i++) dp[i] = 0;

  dp[0] = 1;

  for (int now = 0; now <= N; now++) {
    if (ok[now+1]) {
      dp[now+1] += dp[now];
      dp[now+1] %= MOD;
    }
    if (ok[now+2]) {
      dp[now+2] += dp[now];
      dp[now+2] %= MOD;
    }
  }

  cout << dp[N] << endl;
  return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, W; std::cin >> n >> W;
  map<int, ll> dp;
  vi w(n), v(n);
  rep(i, n) {
    std::cin >> w[i] >> v[i];
  }
  dp[0] = 0;
  rep(i, n) {
    map<int, ll> tmp;
    for (auto &p : dp) {
      if (p.fi+w[i] <= W) tmp[p.fi+w[i]] = p.se+v[i];
    }
    for (auto &p : tmp) chmax(dp[p.fi], p.se);
  }
  ll ans = 0;
  for (auto &p : dp) chmax(ans, p.se);
  std::cout << ans << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}


int main(){
    char c;
    cin >> c;
    c++;
    cout << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)

int main() {
	int x, y;
	cin >> x >> y;
	if (( y-2*x) % 2 == 0 && (y-2*x) >= 0 && (4*x)-y >= 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
// Type alias
using ll=long long;
using ld=double;
 
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;
 
using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;
 
// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();
 
// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl
 
#define ALL(a) a.begin(),a.end()
 
// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
 
 
void solve(){
  int n;
  cin >> n;
  int res = (n / 500) * 1000 + n % 500 / 5 * 5;
  cout << res << endl;
}
 
int main(){
  // FastIO
  //ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}





















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

long long i,j,k,n,m,s,t,z,w,a[10001];

int main()
{
    cin>>n>>z>>w;
    for (i=1;i<=n;i++) cin>>a[i];
    if (n==1) cout<<abs(a[1]-w)<<endl;
    else cout<<max(abs(a[n]-w),abs(a[n-1]-a[n]))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n, m, s, c, x[4] = {-1, -1, -1, -1};
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &s, &c);
    if (s == 1 && c == 0 && n > 1) {
      printf("-1\n");
      return 0;
    } else if (x[s] == -1) {
      x[s] = c;
    } else if (x[s] != c) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (x[i] == -1 && i == 1 && n > 1) {
      printf("1");
    } else if (x[i] == -1) {
      printf("0");
    } else {
      printf("%d", x[i]);
    }
  }
  printf("\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,n;
    int i,j;
    n=0;
    cin >> t;
    string alt;
    cin >> alt;
    i=0;
    j=t-1;
    while(i<j){
        if(alt[i]=='W'){
            if(alt[j]=='R'){
                n++;
                i++;
                j--;
            }
            else j--;
        }
        else i++;
            
    }
    cout << n;
    return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
	int a, b;
	cin >> a >> b;
	cout << a*b << endl;

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 3636
def cshift(w):
    r = ""
    for c in w:
        if c == 'z':
            r += 'a'
        elif c == '.':
            r += '.'
        else:
            r += chr(ord(c)+1)
    return r
while True:
    try:
        sent = input()
    except EOFError:
        break
    
    words = sent.split()
    while ("the" not in words) and ("this" not in words) and ("that" not in words):
        for i, w in enumerate(words):
            words[i] = cshift(w)
    print(" ".join(words))

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);

//int dxy[5] = {0, 1, 0, -1, 0};
// assign

signed main()
{
    Int(n);
    Int(m);

    while (n && m) {
        vi h(n), w(m);
        map<int, int> s;
        rep(i, n) {
            cin >> h[i];
        }
        rep(i, n) {
            int tmp = h[i];
            if (s.find(tmp) != s.end()) {
                int sec = s.find(tmp)->second + 1;
                s.erase(tmp);
                s.insert(mp(tmp, sec));
            } else {
                s.insert(mp(tmp, 1));
            }
            for (int j = i+1; j < n; j++) {
                tmp += h[j];
                if (s.find(tmp) != s.end()) {
                    int sec = s.find(tmp)->second + 1;
                    s.erase(tmp);
                    s.insert(mp(tmp, sec));
                } else {
                    s.insert(mp(tmp, 1));
                }
            }
        }
        rep(i, m) {
            cin >> w[i];
        }
        int ret = 0;
        rep(i, m) {
            int tmp = w[i];
            if (s.find(tmp) != s.end()) {
                ret += s.find(tmp)->second;
            }
            for (int j = i+1; j < m; j++) {
                tmp += w[j];
                if (s.find(tmp) != s.end()) {
                    ret += s.find(tmp)->second;
                }
            }
        }
        cout << ret << endl;
        cin >> n >> m;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, a[5];

int main(int argc, char **argv) {
	cin >> n;
	REP(i, 5) cin >> a[i];
	ll res = 0;
	REP(i, 5) res = max(res + 1, i + (n+a[i]-1)/a[i]);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>> Z(3, vector<int>(3,0));
  vector<vector<int>> X(3, vector<int>(3,0));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      int a;
      cin >>a;
      Z[i][j]=a;
    }
  }
  int N;
  cin >>N;
  for(int i=0; i<N; i++){
    int x;
    cin >>x;
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(Z[j][k]==x){
          X[j][k]=1;
          break;
        }
      }
    }
  }
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      if(X[i][j]==0)
        break;
      if(j==2){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      if(X[j][i]==0)
        break;
      if(j==2){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  for(int i=0; i<3; i++){
    if(X[i][i]==0)
      break;
    if(i==2){
        cout<<"Yes"<<endl;
        return 0;
    }
  }
  for(int i=0; i<3; i++){
    if(X[2-i][i]==0)
      break;
    if(i==2){
        cout<<"Yes"<<endl;
        return 0;  
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M, C int
	fmt.Scan(&N, &M, &C)
	var B []int
	for i := 0; i < M; i++ {
		var b int
		fmt.Scan(&b)
		B = append(B, b)
	}
	ans := 0
	for i := 0; i < N; i++ {
		score := 0
		for j := 0; j < M; j++ {
			var a int
			fmt.Scan(&a)
			score += B[j] * a
		}
		score += C
		if score > 0 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <cmath>
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int ans = 0;
    for(int i=0; i<n; i++){
        if(x>=a[i] and i<n-1){
            ans += 1;
            x -= a[i];
        }else if(x==a[i] and i==n-1){
            ans += 1;
            x -= a[i];
        }
    }
    cout << ans;
}

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

const int MOD = 1e9+7;

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

long long inv(int i){
    return power(i, MOD-2);
}

int main(){
    long long sum = 1;
    int a = 0, b = 0;
    int x, y; cin >> x >> y;
    if((x+y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    while (x != 2*y && 2*x != y)
    {
        x-=3;
        y-=3;
        a++;
        b++;
        if (x < 0 || y < 0)
        {
            cout << 0 << endl;
            return 0;
        }
        
    }
    if (2*x == y)
    {
        a += x;
    }
    else if (x == 2*y)
    {
        b += y;
    }
    for (int i = 1; i <= b; i++)
    {
        sum *= (a+i);
        sum %= MOD;
        sum *= inv(i);
        sum %= MOD;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = b[a[0] - 1]
for i in range(1, n):
    ans += b[a[i] - 1]
    if a[i] - a[i - 1] == 1:
        ans += c[a[i - 1] - 1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
class Dice {
 public:
  int dice[6];
  int label[6];
  int tmp;
  void init() {
	for(int i = 0; i < 6; ++i) {
	  dice[i] = label[i];
	}
  }

  void move(char ch) {
	if(ch == 'N') {
	  moveN();
	}
	else if(ch == 'E') {
	  moveE();
	}
	else if(ch == 'S') {
	  moveS();
	}
	else {
	  moveW();
	}
  }
  
  void moveN() {
	tmp = dice[0];
	dice[0] = dice[1];
	dice[1] = dice[5];
	dice[5] = dice[4];
	dice[4] = tmp;
  }
  void moveS() {
	tmp = dice[0];
	dice[0] = dice[4];
	dice[4] = dice[5];
	dice[5] = dice[1];
	dice[1] = tmp;
  }
  void moveE() {
	tmp = dice[0];
	dice[0] = dice[3];
	dice[3] = dice[5];
	dice[5] = dice[2];
	dice[2] = tmp;
  }
  void moveW() {
	tmp = dice[0];
	dice[0] = dice[2];
	dice[2] = dice[5];
	dice[5] = dice[3];
	dice[3] = tmp;
  }
};
/*
void print(Dice d1) {
    for(int i = 0; i < 6; ++i) {
	  cout << "i:" << i << endl;
	  cout << "\tdice:" << d1.dice[i] << endl;
	}
}
*/
int main() {
  Dice d1;
  char ch;
  
  for(int i = 0; i < 6; ++i) {
	cin >> d1.label[i];
  }
  d1.init();

  while(cin >> ch) {
	d1.move(ch);
	//	print(d1);
  }
  cout << d1.dice[0] << endl;

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    double ans = 0;
    for (int i = 0; i < n; i++)
    {
        double x;
        string u;
        cin >> x >> u;
        if(u=="BTC")
        {
            ans += (x * 380000);
        }
        else
        {
            ans += (x);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> B(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
  	cin >> B[i];
  }
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  for(int i = 0; i < K; i++){
  	sum += B[i];
  }
  cout << sum << endl;
}

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

immutable long mod = 10^^9 + 7;

void main() {
    int n;
    scan(n);

    auto ps = sieveEratos(n + 1);
    auto cnt = new int[](n + 1);

    foreach (m ; 2 .. n + 1) {
        foreach (pi ; ps) {
            if (pi*pi > m) break;
            while (m % pi == 0) {
                cnt[pi]++;
                m /= pi;
            }
        }

        if (m > 1) cnt[m]++;
    }

    long ans = 1;

    foreach (cnti ; cnt) {
        (ans *= (cnti + 1)) %= mod;
    }

    writeln(ans);
}

int[] sieveEratos(int N) {
    auto s = new bool[](N);
    s[] = 1;
    s[0] = s[1] = 0;

    for (int p = 2; p*p < N; p++) {
        if (s[p]) {
            for (int q = p*p; q < N; q += p) {
                s[q] = 0;
            }
        }
    }

    return iota(N).filter!(i => s[i]).array;
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    string n;
    cin >> n;

    if(n[n.size()-1] == '3') cout << "bon" << endl ;
    else if(n[n.size()-1] == '0' || n[n.size()-1] == '1' || n[n.size()-1] == '6' || n[n.size()-1] == '8') cout << "pon" << endl ;
    else  cout << "hon" << endl;

    return 0;
}

Measured memory_bytes: 3632