akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
	string input;
	while(cin >> input){
		int joi = 0, ioi = 0;
		for(int i=0; i < input.size(); i++){
			if(input.substr(i, 3) == "JOI") joi++;
			else if(input.substr(i, 3) == "IOI") ioi++;
		}
		cout << joi << endl << ioi << endl;
	}
}

Measured memory_bytes: 1212
using System;
using System.Linq;

namespace ARC068D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(aa => int.Parse(aa)).ToArray();

            bool[] ans = new bool[100000];
            int count = 0;
            foreach (int ai in a)
            {
                if (ans[ai])
                {
                    continue;
                }

                ans[ai] = true;
                count++;
            }

            Console.WriteLine(count - (count + 1 ) % 2 );
        }
    }
}

Measured memory_bytes: 20192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class39
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long ans = I[1] / I[2] - ((I[0]-1)>-1?(I[0]-1)/I[2]:0);
            if (I[0] == 0) ans += 1;
            Console.WriteLine(ans);
        }
        
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
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 = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
ll mods = 1000000007;

ll modpow(ll k, ll n){
    ll ans = 1;
    while(n>0){
        if(n&1) ans = (ans * k) % mods;
        k = (k * k) % mods;
        n >>= 1;
    }
    return ans;
}

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

    int n,a,b;
    cin >> n >> a >> b;
    ll ans=modpow(2,n)-1,u=1,d=1;
    
    rep(i,max(a,b)){
        u = (u * (n-i)) % mods;
        d = (d * (i+1)) % mods;
        if(i==min(a,b)-1 || i==max(a,b)-1) ans = (ans-(u*modpow(d,mods-2))%mods+mods)%mods;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            bool[] isHonest = Reader.ReadLine().Split(' ').Select(a=>a[0]=='H').ToArray();

            bool ans = !(isHonest[0]^isHonest[1]);
            Console.WriteLine(ans?"H":"D");
        }

        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"


H D



";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 13396
/* ex5_4
   moka223711 */

#include <stdio.h>
#define SIZE 11

int main(void){
    char input;
    int count = 0, ans = 0;
    while((input = getchar()) != EOF){ // EOF = End Of File ファイルの終端に入っている文字、stdio.h内で定義されている
        if(input=='A'||input=='C'||input=='G'||input=='T')count++; // 受け取った入力が'A'、'C'、'G'、'T'のいずれかであればcountをインクリメント
        else{ // そうでなければcountとansの大小関係を比較して、大きければansにcountを代入し、その後countを0にする
            if(count > ans)ans = count;
            count = 0;
        }
    }
    if(ans == 0){ // 文字列がすべてAGCTだったとき
        ans = count;
    }
    printf("%d\n", ans); // ansを出力
    return 0;
}


Measured memory_bytes: 1604
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    char N;
    cin >> N;

    if (N<='Z') cout << 'A';
    else cout << 'a';
    
    return 0;
}


Measured memory_bytes: 3012
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int decode(string s) {
	int ret = 0;
	int tmp = 1;
	for (int i = 0; i < s.size(); i++) {
		switch (s[i]) {
		case 'm':
			ret += tmp * 1000;
			tmp = 1;
			break;
		case 'c':
			ret += tmp * 100;
			tmp = 1;
			break;
		case 'x':
			ret += tmp * 10;
			tmp = 1;
			break;
		case 'i':
			ret += tmp;
			tmp = 1;
			break;
		default:
			tmp = s[i] - '0';
			break;
		}
	}
	return ret;
}

string encode(int a) {
	string ret = "";
	if (a / 1000) {
		if (a / 1000 >= 2)ret += (char)(a / 1000 + '0');
		ret += "m";
	}
	a %= 1000;
	if (a / 100) {
		if (a / 100 >= 2)ret += (char)(a / 100 + '0');
		ret += "c";
	}
	a %= 100;
	if (a / 10) {
		if (a / 10 >= 2)ret += (char)(a / 10 + '0');
		ret += "x";
	}
	a %= 10;
	if (a) {
		if (a >= 2)ret += (char)(a + '0');
		ret += "i";
	}
	return ret;
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		string s, t; cin >> s >> t;
		int a = decode(s);
		int b = decode(t);
		cout << encode(a + b) << endl;
	}
	return 0;
}

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

int h, m;

int main() {
	cin >> h >> m;
	if(h <= m) return cout << 1, 0;
	if(h % m == 0) return cout << h / m, 0;
	cout << h / m + 1;
	return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]

point = [[] for _ in range(N)]

for x in range(N):
    point[x] = K
    
for y in A:
    point[y-1] = point[y-1] + 1

def result(p):
    return p-Q
    
B = list(map(result, point))

for z in B:
    print("Yes") if z>0 else print("No")

Measured memory_bytes: 14432
#include <iostream>
#include <cstdio>
#include <queue>
#include <utility>
using namespace std;

typedef pair<double, int> P;

int main(){
    priority_queue< P > que[4];
    int i,j,n;
    double t;
    for(i=0;i<3;i++){
        for(j=0;j<8;j++){
            cin>>n>>t;
            que[i].push( P(-t, n) );
        }
    }
    for(i=0;i<3;i++){
        for(j=0;j<2;j++){
            P tmp = que[i].top();
            que[i].pop();
            printf("%d %.2lf\n",tmp.second,-tmp.first);
        }
        while( !que[i].empty() ){
            que[3].push( que[i].top() );
            que[i].pop();
        }
    }
    for(i=0;i<2;i++){
        P tmp = que[3].top();
        que[3].pop();
        printf("%d %.2lf\n",tmp.second,-tmp.first);
    }
    return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;


int main(){
   string S; cin >> S;
   vector<int> N(4);
   rep(i, 0, 4) N[i] = S[i] - '0';

   for(int tmp = 0; tmp < 1 << 3; tmp++){
      bitset<3> s(tmp);
      int sum = 0;
      rep(i, 0, 3){
         if(s.test(i)){
            sum += N[i+1];
         }else{
            sum -= N[i+1];
         }
      }
      sum += N[0];
      if(sum == 7){
         cout << S[0];
         rep(i, 0, 3){
            cout << (s.test(i) ? '+' : '-') << S[i+1];
         }
         cout << "=7" << endl;
         return 0;
      }
   }
}

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

int main() {
	
	//vector<int> a(n);  sort(a.begin(),a.end());
	//cout << "test" << endl;

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	//string ans="YES";


	int n;
	cin >> n;
	
	vector<pair<string,int>> a(n),b(n);
	rep(i,n) {
		cin >> a[i].first >> a[i].second;
		a[i].second=100-a[i].second;
		b[i]=a[i];
	}
	
	sort(a.begin(),a.end());
	
	rep(i,n){
		rep(j,n){
			if(a[i]==b[j]) cout << j+1 << "\n";
		}
	}
	
	
	
	
	//cout << ans << "\n";
	
	
	return 0;

    }

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	freopen("D.in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
#define C second
#define M first
const int N = 1e5 + 100;
int vis[N];
void inp(){
	deque<P> q;
	int k;scanf("%d",&k);
	q.push_back(P(1,1));
	while(!q.empty()){
		P p = q.front();q.pop_front();
		if(vis[p.M])continue;
		vis[p.M] =1;
		if(p.M == 0){
			printf("%d\n",p.C);
			return;
		}
		q.push_front(P((p.M*10)%k,p.C));
		q.push_back(P((p.M+1)%k,p.C+1));
	}
}
//D.cc by xsthunder at Sat Nov 11 09:46:51 2017


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    int x; std::cin >> x;
    int res;
    if(x < 600) res = 8;
    else if(x < 800) res = 7;
    else if(x < 1000) res = 6;
    else if(x < 1200) res = 5;
    else if(x < 1400) res = 4;
    else if(x < 1600) res = 3;
    else if(x < 1800) res = 2;
    else res = 1;
    std::cout << res << '\n';
    
    return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <utility>
#include <stack>
#include <list>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    int N, num;
    cin >> N;
    list<pair<int, int>> nums;
    for (int i = 0; i < N; i++) {
        cin >> num;
        nums.push_front(make_pair(num, i+1-num));
    }

    stack<int> seq;
    bool impossible =  false;
    for (int i = 0; i < N; i++) {
        list<pair<int, int>>::iterator iter, erase;
        bool find = false;
        for (iter = nums.begin(); iter != nums.end(); iter++) {
            if (find) {
                (*iter).second++;
            } else if ((*iter).second == i) {
                find = true;
                erase = iter;
            }
        }
        if (find) {
            seq.push((*erase).first);
            nums.erase(erase);
        } else {
            impossible = true;
            break;
        }
    }

    if (impossible)
        cout << -1;
    else {
        while (seq.size() != 0) {
            int n = seq.top(); seq.pop();
            cout << n << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mu=1000000007;
int n,m,a[1005][1005],dp[1005][1005];
char s[1005];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%s",s+1);
		for (int j=1;j<=m;j++) a[i][j]=(s[j]=='.');
	}
	dp[0][1]=1;
	for(int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			if (!a[i][j]) continue;
			dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mu;
		}
	printf("%d\n",dp[n][m]); 
}

Measured memory_bytes: 8064
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>


using namespace std;
typedef long long LL;

int main(void) {
	int a, b;

	cin >> a >> b;

	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a * b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;

	}

	return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int a, b, q;
    cin >> a >> b >> q;
    vector <ll> s(a), t(b);
    for (int i = 0; i < a; i++) cin >> s[i];
    for (int i = 0; i < b; i++) cin >> t[i];

    for (int i = 0; i < q; i++) {
        ll x;
        cin >> x;
        
        int left_s, right_s, left_t, right_t;
        right_s = lower_bound(ALL(s), x) - s.begin();
        left_s = right_s - 1;
        right_t = lower_bound(ALL(t), x) - t.begin();
        left_t = right_t - 1; 

        //cout << left_s << " " << right_s << " " << left_t << " " << right_t << endl;
        ll ans = inf;
        // right right
        if (right_s < a and right_t < b) chmin(ans, max(s[right_s], t[right_t]) - x);
        // left left
        if (left_s >= 0 and left_t >= 0) chmin(ans, x - min(s[left_s], t[left_t]));
        // right left
        if (right_s < a and left_t >= 0) {
            ans = min({ans, (s[right_s] - x) * 2 + x - t[left_t], (x - t[left_t]) * 2 + s[right_s] - x});
        }
        // left right
        if (left_s >= 0 and right_t < b) {
            ans = min({ans, (x - s[left_s]) * 2 + t[right_t] - x, (t[right_t] - x) * 2 + x - s[left_s]});
        }
        cout << ans << endl;
    }
    return 0;
}



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

int main(){
    int N;
    cin >> N;
    int digit = to_string(N).size();

    int arr[3] = {3, 5, 7};
    int ans = 0;
    for(int d=3; d<=digit; d++){
        int patterns = 1;
        for(int i=0; i<d; i++) patterns *= 3;

        for(int _trits=0; _trits<patterns; _trits++){
            int trits = _trits;
            bitset<3> use;
            int sum = 0;
            for(int i=0; i<d; i++){
                sum = sum*10 + arr[trits % 3];
                use[trits % 3] = true;
                trits /= 3;
            }
            if(use.all() && sum <= N) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
num = gets.chomp
inputs = gets.chomp.split(' ').map(&:to_i)
result = []
ans = 0

inputs.each_with_index do | input, idx |
  if idx != 0
    if input < result[idx - 1]
      result << result[idx - 1]
    else
      result << input
    end
  else
    result << input
  end
end

result.each_with_index do | r, idx |
  ans += r - inputs[idx]
end

puts ans


Measured memory_bytes: 32036
k = int(input())
sum = 0


import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


for a in range(k):
    for b in range(k):
        for c in range(k):
            sum += gcd(a + 1, b + 1, c + 1)


print(sum)

Measured memory_bytes: 69648
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 1e5 + 5 ;
const ll mod = 1e9 + 7 ;
ll qpow(ll a , ll b)
{
   ll ans = 1 ; 
   a %= mod ;
   while(b)
   {
     if(b & 1)  ans = (ans * a) % mod ;
     b >>= 1 , a = (a * a) % mod ;
   }
   return ans % mod ;
}
ll inv(ll x)
{
	return qpow(x , mod - 2) % mod ;
}
ll C(ll n , ll m)
{
	ll ans = 1ll ;
	for(ll i = n ; i >= n - m + 1 ; i --)
	  ans = ans * i % mod ;
	for(ll i = 1 ; i <= m ; i ++)
	  ans = ans * inv(i) % mod ;
	return ans ;
}
int main()
{
	ll n , a , b ;
	scanf("%lld%lld%lld" , &n , &a , &b) ;
	ll ans = qpow(2 , n) ;
	ans = (ans - 1 + mod) % mod ;
	ans = (ans - C(n , a) + mod) % mod ;
	ans = (ans - C(n , b) + mod) % mod ;
	printf("%lld\n" , ans) ;
    return 0 ;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        k: usize,
    }
    let mut ans = 0;
    let mut cnt = 0;
    for i in (1..101).rev() {
        if a % i == 0 && b % i == 0 {
            cnt += 1;
            if cnt == k {
                println!("{}", i);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
N,M,Q = map(int,input().split())
abcd = []
for i in range(Q):
    abcd.append(list(map(int,input().split())))
abcd.sort()

import itertools
A = list(itertools.combinations_with_replacement(range(1,M+1),N))
# print(A)
ans = 0
for item in A:
    tmp = 0
    for req in abcd:
        if item[req[1]-1] - item[req[0]-1] == req[2]:
            tmp+= req[3]
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 21524
import sys
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

N = int(read())
print(main(N))


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

const i64 INF = inf<i64>;
signed main() {
  const i64 M = 998244353;
  i64 N;
  cin >> N;
  vector<i64> D(N);
  cin >> D;
  vector<i64> E(N, 0);
  REP(i, N) {
    if ((i == 0) != (D[i] == 0)) {
      cout << 0 << endl;
      return 0;
    }
    E[D[i]] += 1;
  }
  i64 ans = 1;
  i64 m = *max_element(ALL(D));
  for (i64 i = 1; i <= m; i++) {
    ans = (ans * pow(E[i - 1], E[i], M)) % M;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int n;

int dfs(vector<vi>& g, int x, int p) {
	int res = 0;
	for (auto w : g[x])
	{
		if (w != p) res ^= dfs(g, w, x) + 1;
	}
	return res;
}

int main() 
{
	cin >> n;
	vector<vi> g(n);
	REP(i, n - 1)
	{
		int a, b;
		cin >> a >> b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	if (dfs(g, 0, -1) != 0) cout << "Alice" << endl;
	else cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 11904
def gcd(a,b):
    while True:
        if a<b:
            a,b=b,a
        amari=a%b
        if amari==0:
            break
        else:
            a,b=b,amari
    return(b)

n=int(input())
c=list(map(int,input().split()))
for i in range(n-1,0,-1):
    c[i-1]=int(c[i]*c[i-1]/gcd(c[i],c[i-1]))
print(c[0])


Measured memory_bytes: 5600
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
}

void solve() {
	string s;
	cin >> s;
	int a = 0;
	cin >> a;
	int ans = 0;
	{
		int now = s[0] - '0';
		for (int i = 1; i < s.length();i += 2) {
			if (s[i] == '+') {
				now += s[i + 1] - '0';
			}
			else {
				now *= s[i + 1] - '0';
			}
		}
		if (now == a) {
			ans |= 2;
		}
	}
	{
		stack<int> geko;
		int now = s[0] - '0';
		for (int q = 1; q < s.length(); q += 2) {
			if (s[q] == '+') {
				geko.push(now);
				now = s[q + 1] - '0';
			}
			else {
				now *= s[q + 1] - '0';
			}
		}
		while (geko.empty() == false) {
			now += geko.top();
			geko.pop();
		}
		if (now == a) {
			ans |= 1;
		}
	}
	string answer = "IMLU";
	cout << answer[ans] << endl;
}
int main() {
	init();
	solve();
}


Measured memory_bytes: 3216
k,a,b=map(int,input().split())
if b-a<=2:
    print(1+k)
else:
    ans=1
    cnt=k
    if 1+cnt<=a:
        print(ans+cnt)
    else:
        ans=a
        cnt=cnt-(a-1)
        ans+=(b-a)*(cnt//2)
        cnt-=(cnt//2)*2
        ans+=cnt
        print(ans)


Measured memory_bytes: 3060
nums = []
while True:
    in_line = raw_input().split()
    h = int(in_line[0])
    w = int(in_line[1])
    if h == 0 and w == 0:
        break
    else:
        nums.append([h,w])
for num in nums:
    for i in range(0,num[0]):
        print "#"*num[1]
    print ""

Measured memory_bytes: 6372
from copy import deepcopy
def solve(list):
    lis = []
    for x in list:
        n = x[-1]
        for i in range(n, M+1):
            a = deepcopy(x)
            a.append(i)
            lis.append(a)
    return lis


N, M, Q = map(int, input().split())
li  = []
q = []
for i in range(Q):
    q.append(list(map(int, input().split())))
for i in range(M):
    li.append([i+1])
for i in range(N-1):
    li = solve(li)
m = 0
for x in li:
    cnt = 0
    for y in q:
        [a,b,c,d] = y
        if x[b-1] - x[a-1] == c:
            cnt += d
    m = max(m, cnt)
print(m)

Measured memory_bytes: 117748
from collections import defaultdict
n=int(input())
dic=defaultdict(int)
for x in range(1,100,1):
    for y in range(1,100,1):
        for z in range(1,100,1):
            temp=x**2+y**2+z**2+x*y+y*z+z*x
            dic[temp]+=1
for i in range(n):  print(dic[i+1])

Measured memory_bytes: 11836
#include<iostream>
#include<vector>
#define N 100
#define M 1000
#define INF 1000000000
using namespace std;
int adj[N+1][N+1];
struct edge
{
	int u, v, w;
	edge(int u, int v, int w):u(u),v(v),w(w){}
};
vector<edge> edges;
int n, m;
bool valid(edge e)
{
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(adj[i][e.u]+e.w+adj[e.v][j]==adj[i][j])
				return 0;
	return 1;
}
int main()
{
	cin >> n >> m;
	for(int u = 1; u <= n; u++)
		for(int v = 1; v <= n; v++)
			adj[u][v] = u==v ? 0 : INF;

	while(m--)
	{
		int u, v, w; cin >> u >> v >> w;
		adj[u][v] = adj[v][u] = w;
		edges.push_back(edge(u,v,w));
	}

	for(int k = 1; k <= n; k++)
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);

	int total = 0;
	for(const edge& e : edges)
		total += valid(e);
	cout<<total<<endl;

	return 0;
}

Measured memory_bytes: 256
N, C = list(map(int, input().split()))
d = []
for i in range(C):
    d.append(list(map(int, input().split())))

c = []
for i in range(N):
    c.append(list(map(int, input().split())))

e = [[0] * (C + 1) for _ in range(3)]

for i in range(N): 
    for j in range(N):
        temp = (i + j) % 3
        e[temp][c[i][j]] += 1

minCount = 500 * 500 * 10000

for i in range(1, C + 1):
    cost1 = 0
    for h in range(1, C + 1):
        cost1 += d[h - 1][i - 1] * e[0][h]

    for j in range(1, C + 1):
        if i == j:
            continue
        cost2 = 0
        for h in range(1, C + 1):
            cost2 += d[h - 1][j - 1] * e[1][h]

        for k in range(1, C + 1):

            if j == k or k == i:
                continue
            cost3 = 0
            for h in range(1, C + 1):
                cost3 += d[h - 1][k - 1] * e[2][h]

            minCount = min(minCount, cost1 + cost2 + cost3)

print(minCount)


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define fast ios_base::sync_with_stdio(false)
#define cintie cin.tie(NULL)
int main()
{
	ll n,m,k1,k2;
	cin>>n>>m;
	k1=0;
	k2=(n+m)/2;
	if(abs(n)==abs(m))
	{
		cout<<0<<endl;
	}
	else if(abs(n-k2)==abs(m-k2))
	{
		cout<<k2<<endl;
	}
	else
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)


int main(){
    int X,Y,Z;
    cin >>X >> Y >> Z;
    cout <<Z << " " << X <<" " << Y <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cstring>

using namespace std;

int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}


int n;
vector<int> a(n);

int dp1[100000], dp2[100000];

int l(int now){
    if(now == 0){
        return 0;
    }
    if(~dp1[now]) return dp1[now];
    return dp1[now] = gcd(l(now - 1), a[now - 1]);
}

int r(int now){
    if(now == n){
        return 0;
    }
    if(~dp2[now]) return dp2[now];
    return dp2[now] = gcd(r(now + 1), a[now]);
}

int main(){
    cin >> n;
    a.resize(n);
    for(auto&& i : a){
        cin >> i;
    }
    int ans = 0;
    memset(dp1, -1, sizeof dp1);
    memset(dp2, -1, sizeof dp2);
    for(int i = 0; i < n; i++){
        ans = max(ans, gcd(l(i), r(i + 1)));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    string n;
    cin >> n;
    int count=0;
    for(int i=0;i<3;i++){
        if(n[i]=='1') count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
uintmax_t combination(unsigned int n, unsigned int r){    //組み合わせ
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int main()
{
    int n;
    cin >> n;
    int b[n-1];
    int MP = 0;
    rep(i, n-1)
    {
        cin >> b[i];
    }
    MP += b[0];
    rep2(i,1,n-1){
        MP += min(b[i-1], b[i]);
    }
    MP += b[n-2];
    cout << MP << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L = INT()

print((L/3)**3)


Measured memory_bytes: 5192
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n,t;
	cin >> n >> t;
	vector<int> arr;
	for(int i = 0; i < n; i++) {
		int c,_t;
		cin >> c >> _t;
		if(_t>t) continue;
		arr.push_back(c);
	}
	if(arr.size()<=0) {
		cout << "TLE" << endl;
		return 0;
	}
	sort(arr.begin(),arr.end());
	cout << arr[0] << endl;
	return 0;
}


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

main() {
    int N,M; cin >> N >> M;
    ll dp[N+1]={0}; map<int, bool> m;
    bool can=true;
    rep(i,M){int a; cin >> a; m[a]=true;}
    dp[0]=1;
    for(int i=1; i<=N; i++){
        if(m[i]&&m[i+1]){can=false; cout << 0 << endl; break;}
        if(m[i]) continue;
        else if(i==1){dp[1]=1; continue;} 
        dp[i]=(dp[i-1]%1000000007+dp[i-2]%1000000007)%1000000007;
    }
    if(can)cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 7296
/**
*    author:  souzai32
*    created: 14.08.2020 17:46:20
**/

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
typedef long long ll;
using namespace std;

int main() {

    int n;
    cin >> n;
    vector<vector<int>> f(n,vector<int>(10));
    rep(i,n){
        rep(j,10) cin >> f.at(i).at(j);
    }
    vector<vector<int>> p(n,vector<int>(11));
    rep(i,n){
        rep(j,11) cin >> p.at(i).at(j);
    }

    ll benefit,ans=ll(-1e9),count;
    vector<int> open(10,0);

    for(int i=1; i<1024; i++){
        open.at(0)++;
        for(int j=0; j<9; j++){
            if(open.at(j)==2){
                open.at(j)=0;
                open.at(j+1)++;
            }
        }
        benefit=0;
        for(int j=0; j<n; j++){
            count=0;
            for(int k=0; k<10; k++){
                if(f.at(j).at(k) && open.at(k)) count++;
            }
            benefit+=p.at(j).at(count);
        }
        ans=max(ans,benefit);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

constexpr lli MOD = 1e9+7;
constexpr lli LIMIT = 1000000000000000000 * 5;
constexpr int tenfive = 100000;


int main() {
	string s;
	map<char,int> bpos;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		//first
		if (bpos.count(s[i]) == 0) {
			bpos[s[i]] = i;
		}
		//other
		else {
			int dist = i - bpos[s[i]] + 1;
			if (dist <= 3) {
				cout << bpos[s[i]] +1<< " " << i+1<< endl;
				return 0;
			}
			bpos[s[i]] = i;
		}

	}

	cout << -1 << " " << -1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
using namespace std;

int n;
vector<int> G[101];
int ans=0;
int mn[101];
bool vis[101];
bool nuse[101];
int INF=10000;
vector<int> group;

int dfs(int v){
	vis[v]=true;
	int res=0;
	for(int i=0;i<G[v].size();i++){
		if(vis[G[v][i]])continue;
		vis[G[v][i]]=true;
		res=max(res,dfs(G[v][i]));
		vis[G[v][i]]=false;
	}
	return res+1;
}

int searchmin(int v){
	int res=G[v].size();
	vis[v]=true;
	group.push_back(v);
	for(int i=0;i<G[v].size();i++){
		if(!vis[G[v][i]])res=min(res,searchmin(G[v][i]));
	}
	return res;
}

int main(void){
	while(1){
		for(int i=0;i<101;i++)G[i].clear(),mn[i]=INF;
		memset(nuse,false,sizeof(nuse));
		ans=0;
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			int a,b;
			cin >> a >> b;
			G[a-1].push_back(b-1);
			G[b-1].push_back(a-1);
		}
		for(int i=0;i<101;i++){
			if(mn[i]!=INF)continue;
			group.clear();
			memset(vis,false,sizeof(vis));
			int mini=searchmin(i);
			for(int j=0;j<group.size();j++)mn[group[j]]=mini;
		}
		for(int i=0;i<101;i++){
			if(G[i].size()==mn[i]){
				memset(vis,false,sizeof(vis));
				ans=max(ans,dfs(i));
			}
		}
		cout << ans << endl;
	}
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

template <class T>
T fast_pow(T n, int exp) {
  T ret = 1, mul = n;
  while (exp > 0) {
    if (exp & 1) ret *= mul;
    mul *= mul;
    exp /= 2;
  }
  return ret;
}

// MODINT
class modint {
 public:
  ll n;
  int mod = MOD;

  modint(const ll x = 0) noexcept : n(x) {}
  modint& operator+=(const modint a) {
    n += a.n;
    n %= mod;
    return *this;
  }
  modint operator+(const modint a) { return modint(*this) += a; }
  modint& operator-=(const modint a) {
    n += (mod - a.n);
    n %= mod;
    return *this;
  }
  modint operator-(const modint a) { return modint(*this) -= a; }
  modint& operator*=(const modint a) {
    n *= a.n;
    n %= mod;
    return *this;
  }
  modint operator*(const modint a) { return modint(*this) *= a; }
  modint pow(ll exp) {
    if (exp == 0) return 1;
    modint a = pow(exp >> 1);
    a *= a;
    if (exp & 1) a *= *this;
    return a;
  }
  modint inverse() { return pow(mod - 2); }
  modint operator/(const modint a) { return modint(*this) /= a; }
  modint& operator/=(modint a) { return (*this) *= a.inverse(); }
};
ostream& operator<<(ostream& o, const modint& m) {
  o << m.n;
  return o;
}

modint fact(int n) {
  static vector<modint> f = {1, 1};
  while (n >= (int)f.size()) f.push_back(f[f.size() - 1] * modint(f.size()));
  return f[n];
}

modint f(int r, int c) { return fact(r + c) / fact(r) / fact(c); }

modint sumF(int r, int c) {
  if (r < 0 || c < 0) return 0;
  return f(r + 1, c + 1) - f(r, 0);
}

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

  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  cout << sumF(r2, c2) - sumF(r2, c1 - 1) - sumF(r1 - 1, c2) + sumF(r1 - 1, c1 - 1) << endl;

  return 0;
}


Measured memory_bytes: 35172
def solve():
    N = int(input())
    A = []
    for i in range(N):
        a = int(input())
        A.append(a)
    
    A_sorted = sorted(A, reverse=True)

    ans = []
    for a in A:
        if a == A_sorted[0]:
            ans.append(A_sorted[1])
        else:
            ans.append(A_sorted[0])
    
    print(*ans, sep='\n')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 80728
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 5e3 + 5, mx = 3234566667;
const int inf = 1e18;
const int mod = 1e9 + 7;


set<int> all;

bool check(int n){
	std::vector<int> digs;
	while(n) digs.push_back(n%10), n/=10;
	bool y = true;
	for(int i = 1; i < sz(digs); i++)
		y &= abs(digs[i] - digs[i-1]) <= 1;
	return y;
}

void go(int num){
	if(num > mx)
		return;

	if(all.count(num))
		return;
	all.insert(num);

	int last = num % 10;
	if(last == 0){
		go(num*10);
		go(num*10+1);
	}else{
		go(num*10 + last);
		if(last != 9)
			go(num*10 + last + 1);
		go(num*10 + last - 1);
	}
}


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

  	for(int i = 1; i <= 10; i++)
  		if(check(i))
  			go(i);

  	std::vector<int> ans;
  	for(int i : all)
  		ans.push_back(i);
  	int k;
  	cin >> k;
  	cout << ans[k-1] << '\n';

}



Measured memory_bytes: 6140
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
			}

			w = v;

			str02.append("#");
			while (w - 2 > 0) {
				str02.append(".");
				w--;
			}
			str02.append("#");

			System.out.println(str01);
			while (h - 2 > 0) {
				System.out.println(str02);
				h--;
			}
			System.out.println(str01);
			System.out.println("");
		}
	}
}

Measured memory_bytes: 27100
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

int main() {
    string s;
    int ans = 0;
    cin >> s;
    for(int i=0; i<s.size()/2; i++){
        if(s[i]!=s[s.size()-1-i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
main(){
  int a[11][11],n,i,j,ans=0,tate[101]={0},yoko[101]={0},subete=0;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	scanf("%d",&a[i][j]);
      }
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	ans=a[i][j]+ans;
      }
      yoko[i]=ans;
      ans=0;
    }
    ans=0;
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	ans=a[j][i]+ans;
      }
      tate[i]=ans;
      ans=0;
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	printf("%5d",a[i][j]);
      }
      printf("%5d\n",yoko[i]);
    }
    for(i=0;i<n;i++){
      printf("%5d",tate[i]);
    }
    for(i=0;i<n;i++){
      subete=tate[i]+subete;
    }
    printf("%5d\n",subete);
    subete=0;
  }
  return 0;
}

Measured memory_bytes: 612
S = list(input())
odd, even = [], []
for i, v in enumerate(S):
    if i % 2 == 0:
        if v == "R" or v == "U" or v == "D":
            continue
        else:
            odd.append(v)
            break

    else:
        if v == "L" or v == "U" or v == "D":
            continue
        else:
            even.append(v)
            break

print("No") if odd or even else print("Yes")


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* Strongly Connected Component */

/*
  1. dfsをして、戻るときに1から順に番号を付ける
  2. 数値が大きいノードから逆辺を使ってdfsをする。
  すでに訪れているノードには行かない。
  たどり着けるノードが同じ連結成分に属する。
*/

struct SCC{
  int n;
  vector<vector<int> > G, rG;
  vector<int> vs, cmp;
  vector<bool> used;

  SCC(int n):n(n), G(n), rG(n), cmp(n){}

  void add_edge(int from, int to){
    G[from].push_back(to);
    rG[to].push_back(from);
  }

  void dfs(int v){
    used[v] = true;
    for(int to : G[v])
      if(!used[to]) dfs(to);
    vs.push_back(v);
  }

  void rdfs(int v, int k){
    used[v] = true;
    cmp[v] = k;
    for(int to : rG[v])
      if(!used[to]) rdfs(to, k);
  }

  int solve(){
    used.assign(n, false);
    vs.clear();
    for(int i=0; i<n; i++)
      if(!used[i]) dfs(i);
    used.assign(n, false);
    int k = 0;
    for(int i=(int)vs.size()-1; i>=0; i--)
      if(!used[vs[i]]) rdfs(vs[i], k++);
    return k; //強連結成分数
  }

  //属する強連結成分番号(トポロジカル順)
  int operator[](int k) const {
    return cmp[k];
  }
};

int main(){
  int N, M;

  cin >> N >> M;

  vector<int> ans;
  SCC scc(N);

  for(int i=0; i<M; i++) {
    int a, b;
    cin >> a >> b;
    scc.add_edge(a-1, b-1);
  }

  scc.solve();

  for(int i=0; i<N; i++) {
    bool first = true;

    for(int j=0; j<N; j++) {
      if (scc[i] == scc[j]) {
        if (!first) printf(" ");
        printf("%d", j+1);
        first = false;
      }
    }

    puts("");
  }


  return 0;
}



Measured memory_bytes: 4384
l=input()
n=len(l)
mod=1000000007
dp=[0]*n
dp[0]=2
ans=[0]*n
ans[0]=1
for i in range(1,n):
  if l[i]=='0':
    dp[i]=(dp[i-1])%mod
    ans[i]=(ans[i-1]*3)%mod
  else:
    dp[i]=(dp[i-1]*2)%mod
    ans[i]=(ans[i-1]*3+dp[i-1])%mod
print((ans[n-1]+dp[n-1])%mod)


Measured memory_bytes: 11032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 200000;

int N;
int A, B;

vector<pair<int, int>> T[MAX_N];

ll modpow(ll, ll, ll);
ll modinv(ll, ll);
int dfs(int, int);
ll calc_z();

int main() {
    // input
    cin >> N;
    REP(i, N-1) {
        cin >> A >> B; A--; B--;
        T[A].PB(MP(B, -1));
        T[B].PB(MP(A, -1));
    }

    dfs(0, -1);
    // REP(i, N) {
    //     printf("%d:", i);
    //     REP(j, T[i].size()) printf(" (%d, %d)", T[i][j].first, T[i][j].second);
    //     printf("\n");
    // }
    ll z = calc_z();
    PRINT(z);
    return 0;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

int dfs(int v, int pv) {
    int num_chi = 1; // 自分自身も含む
    REP(i, T[v].size()) {
        int nv = T[v][i].first;
        if (nv == pv) continue;
        T[v][i].second = dfs(nv, v);
        num_chi += T[v][i].second;
    }
    REP(i, T[v].size()) {
        if (T[v][i].first == pv) T[v][i].second = N - num_chi;
    } 
    return num_chi;
}

ll calc_z() {
    ll x = modpow(2, N, MOD);
    ll x_inv = modinv(x, MOD);
    ll y = 0;

    REP(i, N) {
        y = (y + modpow(2, N-1, MOD)) % MOD;
        y = (y-1) % MOD;
        REP(j, T[i].size()) {
            y = (y - modpow(2, T[i][j].second, MOD) + 1) % MOD;
        }
    }

    ll z = (x_inv * y) % MOD;
    if (z < 0) z += MOD;
    return z;
}

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


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

    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3=x2-(y2-y1);
    int y3=y2+(x2-x1);
    int x4=x3-(y3-y2);
    int y4=y3+(x3-x2);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

}


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

string S;
int K;
vector<string> vs;

int main(void) {
	cin >> S >> K;

	int sz = S.size();
	for (int i = 0; i < sz; ++i) {
		for (int j = 1; j <= K; ++j) {
			if (i + j > sz)
				break;
			string sub = S.substr(i, j);
			vs.push_back(sub);
		}
	}

	sort(vs.begin(), vs.end());
	vs.erase(unique(vs.begin(), vs.end()), vs.end());

	cout << vs[K - 1] << '\n';
	return 0;
}


Measured memory_bytes: 1660