akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {

	ll n, k, cnt, ans = 0;
	string s;
	std::cin >> n >> k;
	std::cin >> s;
	map<ll, ll> x, y;

	bool flg = false;
	cnt = 0;
	rep(i, 0, n) {
		if (s[i] == '0' && !flg) {
			flg = true;
			cnt++;
			y[cnt] = i + 1;
		}
		else if (s[i] == '1' && flg) {
			flg = false;
			y[cnt] = i;
		}
		x[cnt] = i + 1;
	}

	if (cnt <= k) {
		outn(x[cnt]);
		return 0;
	}
	if (k > 0) {
		ans = x[k - 1];
	}
	repeq(i, k, cnt) {
		ans = max(ans, x[i] - y[i - k]);
	}
	outn(ans);
	return 0;
}


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

int main(){

    ll n;
    cin>>n;
    vector<pair<ll,ll> >v;
    ll A[n];
    ll B[n];
    for(ll i = 0; i < n; i++){
        cin>>A[i]>>B[i];
        v.push_back({A[i]+B[i],i});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    ll a1=0,a2=0;
    for(ll i = 0; i < n; i++){
        if(i%2 == 0){
            a1 += A[v[i].second];
        }else{
            a2 += B[v[i].second];
        }
    }
    cout<<(a1-a2);
    return 0;
}




//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);


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



int main() {
  string s;
  cin >> s;
  int n=s.size();
  vector<char> g;
  rep(i,n){
    if(s[i]=='B'){if(!g.empty())g.pop_back();}else{g.push_back(s[i]);}
  }
  int gg=g.size();
  rep(i,gg){
    cout << g[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    std::string a, b;
    std::cin>>a>>b;

    std::string ans;
    if(a.size() < b.size()){
        ans = "LESS";
    }else if(a.size() > b.size()){
        ans = "GREATER";
    }else{
        for(int i = 0;i < a.size();i++){
            if((int)a[i] < (int)b[i]){
                ans = "LESS";
                break;
            }else if((int)a[i] > (int)b[i]){
                ans = "GREATER";
                break;
            }else{
                ans = "EQUAL";
            }
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;
use std::collections::{HashSet, VecDeque};

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let m = scan.read::<usize>();
    let mut g = vec![vec![];n];
    let mut set = HashSet::new();
    let mut path = VecDeque::new();
    for i in 0..m {
        let a = scan.read::<usize>()-1;
        let b = scan.read::<usize>()-1;
        g[a].push(b);
        g[b].push(a);
        if i == 0 {
            path.push_front(a);
            path.push_back(b);
            set.insert(a);
            set.insert(b);
        }
    }
    loop {
        let mut is_ok = true;
        if let Some(&p) = g[*path.front().unwrap()].iter().find(|x| !set.contains(*x)) {
            path.push_front(p);
            set.insert(p);
            is_ok = false;
        }
        if let Some(&p) = g[*path.back().unwrap()].iter().find(|x| !set.contains(*x)) {
            path.push_back(p);
            set.insert(p);
            is_ok = false;
        }
        if is_ok {break;}
    }
    println!("{}", path.len());
    println!("{}", join(&path.iter().map(|x| *x + 1).collect::<Vec<_>>(), " "));
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 20732
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  long long a,b,c,k,res;
  cin >> a >> b >> c >> k;
  res=min(a,k);
  if(k>a){
    k-=a;
    if(k>b)
      res-=k-b;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<vector>
using namespace std;
#define loop(i,a,b) for(int i=a,i<b;i++)
#define rep(i,a) loop(i,0,a)
int main(){
  int n,p;
  while(cin>>n>>p,n||p){
    int wan=p;
    vector<int>in(n);
    int to=0;
    while(1){
      if(wan){
	wan--;
	in[to]++;
      }else{
	wan+=in[to];
	in[to]=0;
      }
      if(in[to]==p)break;
      to++;
      if(to==n)to=0;
    }
    cout<<to<<endl;
  }
}

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

int main() {
    int count;
    while (cin >> count && count > 0) {
        int cur;
        int sum = 0;
        int maxScore = 0;
        int minScore = 1001;
        for (int i = 0; i < count; i++) {
            cin >> cur;
            sum += cur;
            maxScore = max(maxScore, cur);
            minScore = min(minScore, cur);
        }
        cout << (sum - minScore - maxScore) / (count - 2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3004
while True:
    n, r = map(int, input().split())
    if n == 0:
        break
    card = list(range(n, 0, -1))
    for i in range(r):
        p, c = map(int, input().split())
        t = card[p-1:p+c-1]
        del(card[p-1:p+c-1])
        card[0:0] = t
    print(card[0])

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

int main(){
  int w,h,x,y,r;
  cin >>w>>h>>x>>y>>r;
  if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h)
     cout<<"Yes"<<endl;
     else 
       cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3100
N = gets.to_i
M = gets.to_i
point = Array.new(N){0}
target = gets.split.map(&:to_i)
lose = 0
M.times do |n|
	ans = gets.split.map(&:to_i)
	N.times do |i|
		if target[n] == ans[i]
			point[i]+=1
		else
			lose += 1
		end
	end
	point[target[n]-1] += lose
	lose = 0
end

point.each do |v|
	puts v
end

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

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009


using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

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

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

    cin >> i >> j >> k;

    swap(i,j);
    swap(i,k);

    cout << i << " " << j << " " << k << endl;


}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll K;
    string S;
    cin>>K>>S;
    if(S.size()<=K)cout<<S<<endl;
    else{
        rep(i,K){
            cout<<S[i];
        }
        cout<<"..."<<endl;
    }
}

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

int main(int argc, const char * argv[]) {
    string S, T, U;
    int A, B;
    cin >> S;
    cin >> T;
    cin >> A;
    cin >> B;
    cin >> U;
    if (S == U) {
        A -= 1;
    }
    if (T == U) {
        B -= 1;
    }
    
    std::cout << A << " " << B;
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,sum=0,i,j,dum;
    cin>>n>>m;
    priority_queue<ll>q;
    for(i=0;i<n;i++){
        cin>>j;
        q.push(j);
        sum+=j;
    }
    i=0;
    while(i<m){
        dum=q.top();
        sum-=dum;
        dum/=2;
        sum+=dum;
        q.pop();
        q.push(dum);
        i++;
        
    }
    
    cout<<sum;
 
  return 0;
    
}

Measured memory_bytes: 1400
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input= sc.nextLine();
        String[] inputStrArray = input.split(" ");
        int[] intputIntArray = new int[inputStrArray.length];
 
        for (int index = 0; index < intputIntArray.length; index++) {
            intputIntArray[index] = Integer.parseInt(inputStrArray[index]);
        }
        // 面積
        int squareSize = intputIntArray[0] * intputIntArray[1];
        // 周
        int squareLength = (intputIntArray[0] + intputIntArray[1]) * 2;
 
        System.out.println(squareSize + " " + squareLength );
 
    }
}


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

int main() {
    string o, e;
    cin >> o >> e;

    vector<char> v(o.size() + e.size());

    for (int i = 0, n = o.size(); i < n; i++)
        v.at(2 * i) = o.at(i);

    for (int i = 0, n = e.size(); i < n; i++)
        v.at(2 * i + 1) = e.at(i);
    
    string p(v.begin(), v.end());

    cout << p << endl;
}

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

int main() {
    int n;
    cin >> n;
    vvi a(n, vi(3));
    rep(i, n) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    vvi dp(n+1, vi(3));
    rep(i, n) {
        rep(j, 3) {
            rep(k, 3) {
                if(j == k) continue;
                dp[i+1][j] = max(dp[i][k] + a[i][j], dp[i+1][j]);
            }
        }
    }

    int ans=0;
    rep(i, 3) {
        ans = max(ans, dp[n][i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 11136
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1LL << 50


long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}



struct edge{int from,to;
            long long cost;};
std::vector<edge> edges;
long long d[1000];
int N,M;

bool shortest_path(int s, int t){ // t: destination
    REP(i, N) d[i] = INF;
    d[s] = 0;
    REP(i, 2*N){
        REP(j, M){
            edge e = edges[j];
            if(d[e.from]!=INF && d[e.to]>d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;

                if(i>=N-1 && e.to==t) return true;
            }
        }
    }
    return false;
}


int main(){
    cin >> N >> M;
    REP(i, M){
        int a,b; cin >> a >> b;
        long long c; cin >> c;
        edges.push_back(edge{a-1,b-1,-1LL*c});
    }


    if(shortest_path(0,N-1)){
        cout << "inf" << endl;
    } else {
        cout << -1*d[N-1] << endl;
    }


    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int n;
int l[201];
int ans=0;
int main()
{
	cin >> n;
	rep(i, 2*n)
	{
		cin >> l[i];
	}
	sort(l, l+(2*n));
	rep(i, n)
	{
		ans+=l[2*i];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    if ((B - A) == 1) {
        cout << "Borys" << endl;
        return 0;
    }

    while (true) {
        // Alice
        if (A + 1 < B) {
            ++A;
        }
        if ((B - A) == 1) {
            cout << "Alice" << endl;
            return 0;
        }

        if (A < B - 1) {
            --B;
        }
        if ((B - A) == 1) {
            cout << "Borys" << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3572
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
-- end of templete

type Point = (Int, Int)
type Line = (Point, Point)

f :: Line -> Point -> Int
f ((x1,y1),(x2,y2)) (x,y) = signum $ a*x + b*y + c
  where
    a = y2 - y1
    b = x1 - x2
    c = x2*y1 - x1*y2

inner :: Point -> Point -> Point -> Point -> Bool
inner t1 t2 t3 p = f1 p == f1 t1 && f2 p == f2 t2 && f3 p == f3 t3
  where
    f1 = f (t2,t3)
    f2 = f (t3,t1)
    f3 = f (t1,t2)

judge xs = func pk /= func ps
  where
    [p1,p2,p3,pk,ps] = map (apply2 (,)) $ splitRec 2 xs
    func = inner p1 p2 p3

main = do
    n <- getInt
    replicateM n $ do
        getInts >>= putStrLn . cond "OK" "NG" . judge
    return ()


Measured memory_bytes: 4556
#include<stdio.h>
int main(){
	int cards[5][14]={},j,m,i,n;
	char ch;
	scanf("%d", &n);
	for(i = 1;i <= n; i++){
		scanf(" %c %d",&ch,&m);
		if(ch== 'S'){
			cards[1][m]=m;
		}
		if(ch== 'H'){
			cards[2][m]=m;
		}
		if(ch=='C'){
			cards[3][m]=m;
		}
		if(ch=='D'){
			cards[4][m]=m;
		}
	}
	for(i = 1;i < 5; i++){
		for(j = 1;j < 14; j++){
			if(i==1 && cards[i][j]==0){
				printf("S %d\n",j);
			}
			if(i==2 && cards[i][j]==0){
				printf("H %d\n",j);
			}
			if(i==3 && cards[i][j]==0){
				printf("C %d\n",j);
			}
			if(i==4 && cards[i][j]==0){
				printf("D %d\n",j);
			}
		}
	}
}




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

int main() {
    int n, m;
    cin >> n >> m;
    int sp[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> sp[i][j];
        }
    }

    int total_row = 0;
    int total = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cout << sp[i][j] << ' ';
            total_row += sp[i][j];
        }
        cout << total_row << endl;
        total += total_row;
        total_row = 0;
    }

    int total_col = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            total_col += sp[j][i];
        }
        cout << total_col << ' ';
        total_col = 0;
    }
    cout << total << endl;
}


Measured memory_bytes: 3128
#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, k;
	cin >> n >> k;
	vector<ld> a(n);
	ld cur = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < k; ++i) {
		cur += 1.0 / a[i] * (a[i] * (a[i] + 1)) / 2;
	}
	ld answer = cur;
	for (int i = k; i < n; ++i) {
		cur += 1.0 / a[i] * (a[i] * (a[i] + 1)) / 2;
		cur -= 1.0 / a[i - k] * (a[i - k] * (a[i - k] + 1)) / 2;
		answer = max(answer, cur);
	}
	cout << answer << '\n';
	
	
 	return 0;
}


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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1,i,j;
   // cin>>t;
    while(t--)
    {
        int n,m,k,a,b,count=0,sum=0,maxi=0,mini=1e18;
        cin>>a>>b>>n;
        n=min(n,b-1);
        cout<<(n*a)/b-a*(n/b);
    }
}

Measured memory_bytes: 3652
r, c = map(int, input().split())

data = [list(map(int, input().split())) for i in range(r)]

for i in range(r):
    sum = 0
    for j in range(c):
        sum += data[i][j]
    data[i].append(sum)


data.append([])

for j in range(c+1):
    sum = 0
    for i in range(r):
        sum += data[i][j]
       # print(sum)
    data[r].append(sum)


for i in range(r+1):
    print(*data[i])


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

int calplanfrom(int day, int prev, int arr[][3], int memo[][3], int n)
{
    
    if (day == n)
    {
        return arr[day - 1][prev];
    }

    if(memo[day][prev]!=-1)
    {
        return memo[day][prev];
    }

    int ans = INT_MIN;
    for (int i = 0; i < 3; i++)
    {
        if (i != prev)
        {
            int cand = calplanfrom(day + 1, i, arr, memo, n);
            ans = max(ans, cand);
        }
    }
    memo[day][prev]=ans + arr[day - 1][prev];

    return memo[day][prev];
}

int main()
{
    //freopen("inp.txt", "r", stdin);
    int n;
    cin >> n;
    int arr[n][3];
    int memo[n][3];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> arr[i][j];
            memo[i][j] = -1;
        }
    }
    int call0, call1, call2;

    call0 = calplanfrom(1, 0, arr, memo, n);
    call1 = calplanfrom(1, 1, arr, memo, n);
    call2 = calplanfrom(1, 2, arr, memo, n);
    int finalans = max(call0, max(call1, call2));
    cout << finalans;
    return 0;
}

Measured memory_bytes: 15240
#include <iostream>

using namespace std;

int roundup(int d)
{
	int r = (d % 1000 > 0) ? 1 : 0;
	d /= 1000; d += r;
	return d * 1000;
}

int main()
{
	int debt = 100000;
	int n;
	cin >> n;
	
	for (int i=0; i<n; i++) {
		debt += (debt/20);
		debt = roundup(debt);
	}
	
	cout << debt << endl;
	
	return 0;
}

Measured memory_bytes: 2980
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i] >> B[i];
    }

    std::vector<int> C(N);
    for (int i = 0; i < N; i++) {
        C[i] = A[i] + B[i];
    }

    std::sort(C.rbegin(), C.rend());

    ll sum = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            sum += C[i];
        }
        sum -= B[i];
    }

    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力された文字列を、文字単位で昇順にソート
		String s = sc.next();
		char[] s_char = s.toCharArray();
		Arrays.sort(s_char);
		String s_asc = new String(s_char);
		
		// 入力された文字列を、文字単位で降順にソート
		String t = sc.next();
		char[] t_char = t.toCharArray();
		Arrays.sort(t_char);
		String t_asc = new String(t_char);
		String t_desc = new StringBuilder(t_asc).reverse().toString();
		
		if(s_asc.compareTo(t_desc) < 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.nextLine());
		
		switch(a % 10){
		    case 3 :
		        System.out.println("bon");
		        break;
		    
		    case 0 :
		        System.out.println("pon");
		        break;
		    
		    case 1 :
		        System.out.println("pon");
		        break;
		    
		    case 6 :
		        System.out.println("pon");
		        break;
		        
            case 8 :
                System.out.println("pon");
		        break;
		        
		    default : 
		        System.out.println("hon");
		}
		
    }
}

Measured memory_bytes: 35560
N, K = map(int, input().split())

x = 1000000000000000000
if N < K:
  x = min(N, K - N)
elif N == K:
  x = 0
else:
  m = N//K
  x = min((N - m * K),((m + 1) * K - N))

print(x)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
//動画解説写し
struct Sieve{
  int n;
  vector<int>f,primes;
  Sieve(int n=1):n(n),f(n+1){
  /*  f[0]=f[1]=-1;
    for(long long i=2;i<=n;++i){
      if(f[i])continue;
      primes.push_back(i);
      f[i]=i;
      for(long long j=i*i;j<=n;j+=i){
        if(!f[j])f[j]=i;
      }
    }*/
  }
vector<pair<long long,int>>factor(long long x){
  vector<pair<long long,int>>res;
  for(long long i=2;i*i<=x;++i){
    int y=0;
    while(x%i==0){
      x/=i;
      ++y;
    }
    if(y!=0)res.emplace_back(x,y);
  }
  if(x!=1)res.emplace_back(x,1);
  return res;
}
};
int main(){
  long long n;
  cin>>n;
  Sieve s(1000005);
  auto fs=s.factor(n);
  int ans=0;
  for(auto p:fs){
    int x=p.second;
    int b=1;
    while(b<=x){
      x-=b;
      b++;
      ++ans;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7172
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	a, b, c, d := nextInt(), nextInt(), nextInt(), nextInt()

	for t := true; ; t = !t {
		if t {
			c -= b
			if c <= 0 {
				puts("Yes")
				break
			}
		} else {
			a -= d
			if a <= 0 {
				puts("No")
				break
			}
		}
	}
}


Measured memory_bytes: 1768
N, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if t[i] + T <= t[i + 1]:
        ans += T
    else:
        ans += t[i + 1] - t[i]
ans += T
print(ans)

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  int64 k;
  cin >> n >> k;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  int64 ans = 0;
  if (xs[0] > k) {
    ans += xs[0] - k;
    xs[0] = k;
  }
  for (int i = 0; i + 1 < n; i++) {
    if (xs[i] + xs[i + 1] > k) {
      int64 d = xs[i] + xs[i + 1] - k;
      xs[i + 1] -= d;
      ans += d;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;

bool binary_search(int n, int *arr, int x, int imin, int imax)
{
  if (imax < imin)
    return false;

  int imid = (imax + imin) / 2;
  if (arr[imid] > x)
  {
    return binary_search(n, arr, x, imin, imid - 1);
  }
  else if (arr[imid] < x)
  {
    return binary_search(n, arr, x, imid + 1, imax);
  }
  else
  {
    return true;
  }
}

int main()
{
  int n, q, ans = 0;

  cin >> n;
  int S[n];
  for (int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    S[i] = x;
  }

  cin >> q;
  for (int i = 0; i < q; i++)
  {
    int x;
    cin >> x;
    if (binary_search(n, S, x, 0, n - 1))
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3472
import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_rec(num):
    return reduce(lcm, num, 1)

N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())

ans = lcm_rec(T)
print(ans)

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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define push push_back
#define pop pop_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    // // 文字列と，差し引きのスコアを辞書で管理
    // map<string, int> scores;
    //
    // int N=in<int>();
    // rep(i, N) {
    //     string word = in<string>();
    //     if(scores.find(word) == scores.end()) {
    //         // 新出
    //         scores.insert(make_pair(word, 1))
    //     } else {
    //         // 既出
    //
    //     }
    // }

    // 雑にやっても多分いける
    string wordsN[100];
    int N=in<int>();
    rep(i, N) {
        wordsN[i] = in<string>();
    }

    string wordsM[100];
    int M=in<int>();
    rep(i, M) {
        wordsM[i] = in<string>();
    }

    int ans = 0;
    rep(i, N) {
        string target = wordsN[i];
        int count = 0;
        rep(j, N) {
            if(wordsN[j] == target)
                count++;
        }
        rep(j, M) {
            if(wordsM[j] == target)
                count--;
        }

        if(count > ans)
            ans = count;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
	int a, b, c;
  	cin >> a >> b >> c;
  	set<int> s;
  	s.insert(a), s.insert(b), s.insert(c);
  	if(s.size() == 2) cout << "Yes" << endl;
  	else cout << "No" << endl;
}	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
using ll = long long;

//const long long MOD = 998244353;
const long long MOD = 1000000007;

int main(){
    int H, W;
    std::cin >> H >> W;

    std::vector<std::string> a;
    for(int i=0; i<H; ++i){
        std::string b;
        std::cin >> b;
        a.push_back(b);
    }

    std::vector<std::vector<ll>> dp(H+1, std::vector<ll>(W+1, 0));
    dp[0][0] = 1;
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            if(a[i][j]=='#') continue;
            dp[i  ][j+1] += dp[i][j]%MOD;
            dp[i+1][j  ] += dp[i][j]%MOD;
        }
    }

    std::cout << dp[H-1][W-1]%MOD;
    return 0;
}


Measured memory_bytes: 9216
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int vnum;
vpint adj[500001];
int d[500001],color[500001];
void dijkstra(int s){
	priority_queue<pint> PQ;
	rep(i,vnum){
		d[i]=INF;
		color[i]=0;
	}
	d[s]=0;
	color[s]=1;
	PQ.push(mp(0,s));
	while(!PQ.empty()){
		pint f=PQ.top();
		PQ.pop();
		int u=f.second;
		color[u]=2;
		if(d[u]< -f.first) continue;
		rep(j,adj[u].size()){
			int v=adj[u][j].first;
			if(color[v]==2) continue;
			if(d[v]>d[u]+adj[u][j].second){
				d[v]=d[u]+adj[u][j].second;
				PQ.push(mp(-d[v],v));
				color[v]=1;
			}
		}
	}
}
int P[200001],Q[200001],c[200001];
vint stacomp[100001];
int main(){
	int N,M;
	map<pint,bool> alreadystacomp;
	vpint vindex;
	map<pint,int> rvindex;
	scan(N);scan(M);
	rep(i,M){
		scan(P[i]);scan(Q[i]);scan(c[i]);
		P[i]--;Q[i]--;c[i]--;
		if(alreadystacomp[mp(P[i],c[i])]==false){
			stacomp[P[i]].push_back(c[i]);
			alreadystacomp[mp(P[i],c[i])]=true;
			rvindex[mp(P[i],c[i])]=vindex.size();
			vindex.push_back(mp(P[i],c[i]));
		}
		if(alreadystacomp[mp(Q[i],c[i])]==false){
			stacomp[Q[i]].push_back(c[i]);
			alreadystacomp[mp(Q[i],c[i])]=true;
			rvindex[mp(Q[i],c[i])]=vindex.size();
			vindex.push_back(mp(Q[i],c[i]));
		}
		adj[rvindex[mp(P[i],c[i])]].push_back(mp(rvindex[mp(Q[i],c[i])],0));
		adj[rvindex[mp(Q[i],c[i])]].push_back(mp(rvindex[mp(P[i],c[i])],0));
	}
	rep(i,N){
		rvindex[mp(i,-1)]=vindex.size();
		vindex.push_back(mp(i,-1));
		rep(j,stacomp[i].size()){
			adj[rvindex[mp(i,stacomp[i][j])]].push_back(mp(rvindex[mp(i,-1)],0));
			adj[rvindex[mp(i,-1)]].push_back(mp(rvindex[mp(i,stacomp[i][j])],1));
		}
	}
	vnum=vindex.size();
	dijkstra(rvindex[mp(0,-1)]);
	if(d[rvindex[mp(N-1,-1)]]==INF) prin(-1);
	else prin(d[rvindex[mp(N-1,-1)]]);
	return 0;
}


Measured memory_bytes: 105708
#include <stdio.h> 
int main() 
{ 
int x,i,n; 
scanf("%d",&n); 
for(i=1; i<=n; i++) 
{ 
x = i; 
if(x %3 == 0) 
{ 
printf(" %d",i); 
} 
else if(x % 10 == 3) 
{ printf(" %d",i); 
} 
else 
{ 
while(x != 0) 
{ 
x /=10; 
if(x % 10 == 3) 
{ printf(" %d",i); 
break; 
} 
} 
} 
} 
printf("\n");
return 0; 
} 


Measured memory_bytes: 2064
#include<stdio.h>
#include<string.h>
int main(){
	int n,i,s,j,min;
	char a[100][100],b[100][130];
	memset(b,0,sizeof(b));
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
		s=strlen(a[i]);
		for(j=0;j<s;j++){
			b[i][a[i][j]]++;
		}
	}
	int flag=0;
	for(i='a';i<='z';i++){
		min=99999;
		for(j=0;j<n;j++){
			if(b[j][i]<min)
				min=b[j][i];
		}
		if(min!=0){
			flag=1;
			while(min--)
				printf("%c",i);
		}
	}
	if(flag!=1)
		printf("\n");
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;

namespace AtCoder
{
	public class Program
	{
		// ABC107-C
		static void Main(string[] args)
		{
			string[] vs = Console.ReadLine().Split();
			int N = int.Parse(vs[0]);
			int K = int.Parse(vs[1]);
			vs = Console.ReadLine().Split((string[])null, StringSplitOptions.RemoveEmptyEntries);
			int[] pos = new int[N];
			for (int i = 0; i < N; i++) {
				pos[i] = int.Parse(vs[i]);
			}

			int p1 = 0, p2 = p1 + (K - 1);
			long sum = 0;
			for (int i = p1; i < p2; i++) {
				sum += Math.Abs(pos[i + 1] - pos[i]);
			}
			long time = 0;
			while (p2 < N) {
				long tmp = Math.Min(Math.Abs(pos[p1]), Math.Abs(pos[p2])) + sum;
				if (time == 0 || time > tmp) {
					time = tmp;
				}
				if (p1 + 1 < N) {
					sum -= Math.Abs(pos[p1] - pos[p1 + 1]);
				}
				if (p2 + 1 < N) {
					sum += Math.Abs(pos[p2] - pos[p2 + 1]);
				}
				p1++;
				p2++;
			}
			Console.WriteLine(time);
		}
	}
}


Measured memory_bytes: 20320
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		if((s[3]==s[4]&&s[3]==s[5]||s[1]==s[4]&&s[1]==s[7]||s[0]==s[4]&&s[0]==s[8]||s[2]==s[4]&&s[2]==s[6])&&s[4]!='s')cout<<s[4];
		else if((s[0]==s[1]&&s[0]==s[2]||s[0]==s[3]&&s[0]==s[6])&&s[0]!='s')cout<<s[0];
		else if((s[2]==s[5]&&s[2]==s[8]||s[6]==s[7]&&s[6]==s[8])&&s[8]!='s')cout<<s[8];
		else cout<<'d';
		cout<<endl;
	}
}

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

int main(){
    using namespace std;
    unsigned long N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<vector<unsigned long>> dp(401, vector<unsigned long>(401, numeric_limits<unsigned long>::max()));
    dp[0][0] = 0;
    for(unsigned long i{0}, a, b, c; i < N; ++i){
        cin >> a >> b >> c;
        for(unsigned long j{401 - a}; j--;)for(unsigned long k{401 - b}; k--;)if(~dp[j][k])dp[j + a][k + b] = min(dp[j + a][k + b], dp[j][k] + c);
    }
    unsigned long ans{numeric_limits<unsigned long>::max()};
    for(unsigned long i{1}; i * Ma <= 400 && i * Mb <= 400; ++i)ans = min(ans, dp[i * Ma][i * Mb]);
    cout << static_cast<long>(ans) << endl;
    return 0;
}

Measured memory_bytes: 1536
class Dice:
    def __init__(self,my_label):
        self.top,self.front,self.right,self.left,self.back,self.bottom = [int(x) for x in my_label]

    def Roll(self,i):
        if i == 0:
            self.top, self.front, self.right, self.left, self.back, self.bottom = \
            self.right, self.front, self.bottom, self.top, self.back, self.left
        
        if i == 1:
            self.top, self.front, self.right, self.left, self.back, self.bottom = \
            self.left, self.front, self.top, self.bottom, self.back, self.right
        
        if i == 2:
            self.top, self.front, self.right, self.left, self.back, self.bottom = \
            self.back, self.top, self.right, self.left, self.bottom, self.front
            
        if i == 3:
            self.top, self.front, self.right, self.left, self.back, self.bottom = \
            self.front, self.bottom, self.right, self.left, self.top, self.back

    def Open(self):
        print(self.top)

def CheckData(data,top,front):
    for i in range(len(data)):
        if(data[i][0] == top and data[i][1] == front):
            print(data[i][2])
            break
            
def CheckDice(n,data):
    #同じ物が見つかったら偽にしてbreak
    
    isEqual = False
    
    for i in range(n):
        for j in range(i+1,n):
            if(data[i] == data[j]):
                isEqual = True
                break
    
    if(isEqual == True):
        print("No")
    else:
        print("Yes")
                
def MakeData(dice):
    num_data = 4 * 6 -1
    
    dataset = list()
    data = [dice.top, dice.front, dice.right]

    dataset.append(data)
    
    isOnly = True
    
    n = 0
    while 0 < num_data:
        n += 1
        if (n > 1000):
            break
            
        data = [dice.top, dice.front, dice.right]

        isOnly = True
        for i in range (len(dataset)):
            if(data == dataset[i]):
                isOnly = False
                break
        if isOnly == True:
            dataset.append(data)
            dataset.sort()
            num_data -= 1
        
        dice.Roll(int(random.random() * 4))
        
    
        
    return dataset

import random

n = int(input())

my_label = [0] * n
dice = [0] * n
data = [0] * n

for i in range(n):
    my_label = [int(x) for x in input().split(" ")]
    
    dice = Dice(my_label)
    data[i] = MakeData(dice)

CheckDice(n,data)


Measured memory_bytes: 8448
N = int(input())
mod = 10 ** 9 + 7

#10 ** N - 2 * (9 ** N) + (8 ** N)
ten = 1
nine = 1
eight = 1
for i in range(N):
  ten *= 10
  ten %= mod
  nine *= 9
  nine %= mod
  eight *= 8
  eight %= mod
  
ans = ten - 2 * nine + eight  
print(ans % mod)  



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

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

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

  int ans = 0;
  int tmp = 0;
  int length = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == tmp) {
      if (length > 0) {
        length++;
      } else {
        length = 2;
      }
    } else {
      if (length >= 2) {
        ans += length / 2;
      }
      length = 0;
    }
    tmp = A[i];
  }

  if (length >= 2) {
    ans += length / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def solve(n,A):
    if n==0:
        if A[0]==1:
            return 1
        return -1
    if A[0]!=0:
        return -1
    if A[-1]>pow(2,n):
        return -1
    Num=[0]*(n+1)
    Num[0]=1
    Num[-1]=A[-1]
    Cap=[0]*(n+1)
    Cap[0]=1
    for i in range(1,n+1):
        Cap[i]=Cap[i-1]*2-A[i]
    for i in range(1,n)[::-1]:
        min_num=(Num[i+1]+1)//2+A[i]
        max_num=Num[i+1]+A[i]
        if min_num>Cap[i-1]*2:
            return -1
        Num[i]=min(max_num,Cap[i-1]*2)
    if Num[1]>2 or Num[1]<1:
        return -1
    return sum(Num)

def main():
    n=int(input())
    A=tuple(map(int,input().split()))
    ans=solve(n,A)
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 702108
import java.util.*;

public class Main {
	public static void main(String[] args) {
		new Main().AOJ0555();
	}
	Scanner sc = new Scanner(System.in);	
	
	void AOJ0555(){
		String search  = sc.next();
		int n = sc.nextInt();
		String[] rings = new String[n];
		
		String input;
		for(int i = 0; i < n; i++){
			input = sc.next();
			rings[i] = input+input;
		}
		
		int result = 0;
		
		for(int i = 0; i < n; i++){
			if(rings[i].indexOf(search) != -1){
				result++;
			}
		}
		
		System.out.println(result);
		
		
	}
	
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

vector<ll> fact, inv;
void fact_inv(int n, ll mod = MOD) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

ll ncr(ll n, ll r, ll mod = MOD) {
	if (n < r || r < 0 || n < 0) return 0;
	return fact[n] * inv[r] % mod * inv[n - r] % mod;
}

int main() {
	fact_inv(2123456);
	
	int X, Y;
	cin >> X >> Y;
	
	ll ans = 0;
	if ((X + Y) % 3 == 0) {
		int cnt = (X + Y) / 3;
		ans = ncr(X - cnt + Y - cnt, X - cnt);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 33408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a;
  cin >> n >> a;
  vector<int>x(n);
  int i,j;
  for(i=0;i<n;i++){
    cin >> x[i];
    x[i]-=a;
  }
  vector<vector<long> >dp(n,vector<long>(100050,0));
  dp[0][50000+x[0]]=1;
  for(i=1;i<n;i++){
    for(j=100;j<100000;j++){
      dp[i][j+x[i]] = dp[i-1][j]+dp[i-1][j+x[i]];
    }
    dp[i][50000+x[i]]+=1;
  }
  cout<<dp[n-1][50000]<<endl;


}


Measured memory_bytes: 40192
#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
const unsigned int MOD = 1000000007;
int max_char=26;



int main()
    {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;

    while(t--)
    {
        ll n,m;
        cin>>n;
        if(n<30)
            cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}











Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
# 整数の入力
a = str(input())
b = 's'
c = 'es'
# スペース区切りの整数の入力
if a[-1] == 's':
    a = a+c
else:
    a = a+b
# 出力
print("{}".format(a))

Measured memory_bytes: 9024
#include <bits/stdc++.h>
//#include "definitions.cpp"
using namespace std;
typedef long long int ll;


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

    string s1 = "", s2 ="";
    for(int i = 0; i < a; i++)
        s1 += to_string(b);

    for(int i = 0; i < b; i++)
        s2 += to_string(a);

    if(s1 < s2)
        cout << s1;
    else
        cout << s2;

    //cout << "H";

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
for i in range(N):
    if A[i] <= B[i]:
        ans += A[i]
        B[i] -= A[i]
        A[i] = 0

        ans += min(A[i+1], B[i])
        A[i+1] = max(0, A[i+1] - B[i])
    else:
        ans += B[i]
        A[i] -= B[i]
print(ans)

Measured memory_bytes: 82148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//, a = sc.nextInt(),b=sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[n];
		//String s=sc.next(),t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<n;i++) {
			array[i]=sc.nextLong();
		}
		for(int j=0;j<30;j++) {
			for(int i=0;i<n;i++) {
				if(array[i]%2==0) {
					array[i]=array[i]/2;
				}else {
					System.out.println(j);
					System.exit(0);
				}
			}
		}
		//System.out.println(max);



	}
	public static int sample(int n) {
		return n;
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <set>
using ll = long long;
using namespace std;
#define INF 999999999

int main()
{
    int s;
    cin >> s;
    int ans = -1;
    int a = s;
    vector<int> b;
    b.push_back(s);
    for (int i = 2;; i++)
    {
        if (a % 2 == 0)
            a = a / 2;
        else
            a = 3 * a + 1;
        for (auto v : b)
        {
            if (a == v)
            {
                ans = i;
                break;
            }
        }
        if (ans != -1)
            break;
        b.push_back(a);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256