akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto abk = readln.split.to!(int[]);
    auto A = abk[0];
    auto B = abk[1];
    auto K = abk[2];

    foreach_reverse (k; 1..101) {
        if (A % k == 0 && B % k == 0 && --K == 0) {
            writeln(k);
            return;
        }
    }
}

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

int main() {
	//0000
	/*
	int i, j;

	for (i = 1; i < 10; i++) {
		for (j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	*/

	int i;
	const size_t MNum = 10;
	int MHeight[MNum];
	int MH1 = 0, MH2 = 0, MH3 = 0;
	for (i = 0; i < 10; i++) {
		cin >> MHeight[i];
		if (MHeight[i] > MH1) {
			MH3 = MH2;
			MH2 = MH1;
			MH1 = MHeight[i];
		}
		else if (MHeight[i] > MH2) {
			MH3 = MH2;
			MH2 = MHeight[i];
		}
		else if (MHeight[i] > MH3) {
			MH3 = MHeight[i];
		}
	}
	cout << MH1 << endl << MH2 << endl << MH3 << endl;
	

	return 0;
}

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

#define int long long
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)

int N, K;
int L[11], R[11];
int dp[200010];
int mod = 998244353;

signed main()
{
    cin >> N >> K;
    rep(i, K)cin >> L[i] >> R[i];

    dp[1] = 1;
    for(int i = 2; i <= N; i++)
    {
        int diff = 0;
        rep(j, K)
        {
            diff = (diff + dp[max(0LL, i - L[j])] - dp[max(0LL, i - R[j] - 1)]  + mod) % mod;
        }
        dp[i] = (dp[i - 1] + diff) % mod;
    }

    cout << (dp[N] - dp[N - 1] + mod) % mod << endl;

    return 0;
}


Measured memory_bytes: 5156
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int A, B;
    cin >> A >> B;

    if (A % 2 == 0 || B % 2 == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
q = [int(x) for x in input()]

if sum(q) == 7:
	print("{}+{}+{}+{}=7".format(q[0], q[1], q[2], q[3]))
else:
	if q[0]-q[1]+q[2]+q[3] == 7:
		print("{}-{}+{}+{}=7".format(q[0], q[1], q[2], q[3]))
	elif q[0]+q[1]-q[2]+q[3] == 7:
		print("{}+{}-{}+{}=7".format(q[0], q[1], q[2], q[3]))
	elif q[0]+q[1]+q[2]-q[3] == 7:
		print("{}+{}+{}-{}=7".format(q[0], q[1], q[2], q[3]))	
	elif q[0]-q[1]-q[2]+q[3] == 7:
		print("{}-{}-{}+{}=7".format(q[0], q[1], q[2], q[3]))
	elif q[0]-q[1]+q[2]-q[3] == 7:
		print("{}-{}+{}-{}=7".format(q[0], q[1], q[2], q[3]))
	elif q[0]+q[1]-q[2]-q[3] == 7:
		print("{}+{}-{}-{}=7".format(q[0], q[1], q[2], q[3]))
	elif q[0]-q[1]-q[2]-q[3] == 7:
		print("{}-{}-{}-{}=7".format(q[0], q[1], q[2], q[3]))
	


Measured memory_bytes: 3064
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]

from decimal import Decimal

# エントリーポイント
def main():
    N = input(int)
    TA = input([int, int, N])

    a, b = 1, 1
    for x, y in TA:
        n = max(ceil(Decimal(a) / Decimal(x)), ceil(Decimal(b) / Decimal(y)))
        a, b = n * x, n * y
    print(a + b)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 5600
#include<stdio.h>

int main( void ) 
{
	char s[101],p[101];
	int i,j,k,end;
		
	scanf( "%s", s );
	scanf( "%s", p );
	

	i=end=0;
	while( 1 ) {
		if( p[0] == s[i++] ) {
			j=1;
			k=i;
			if( '\0' == s[k] ) {
				k=0;
			}				
			while( p[j] == s[k] ) {
				j++;
				k++;
			 	if( '\0' == s[k] ) {
					k=0;
				}				
			 }
		 	if( '\0' == p[j] ) {
				printf( "Yes\n" );
				break;
			}			 
		} else {
			if( end ) { 
				printf( "No\n" );	
				break;
			}

			if( '\0' == s[i] ) {
				i=0;	
				end=1;
			} else {		
				j=0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n;
    long long k ; 
    cin>>n >>k;
    vector <int> a(n);
    for(int i =0; i < n; i++){
        cin>>a[i];
    }
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
 
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j <= i + k; j++)
        {
            if (j < n)
            {
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
        }
    }
    cout << dp[n - 1];
}


Measured memory_bytes: 3996
n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

sum = a.reduce(&:+)

divisors = []
(1..(sum**0.5)).each do |i|
  break if i > sum ** 0.5
  if sum % i == 0
    divisors << [i, sum/i]
  end
end

divisors.flatten.sort.reverse_each do |d|
  rem = a.map { |ai| ai%d }.sort
  rem.delete(0)
  n = rem.length
  if n == 0
    puts(d)
    exit
  end
  sum_minus = 0
  sum_plus = d*n - rem.reduce(&:+)
  (n-1).times do |i|
    sum_minus += rem[i]
    sum_plus -= (d - rem[i])
    next if k < [sum_minus, sum_plus].max
    puts(d)
    exit
  end
end

Measured memory_bytes: 3836
#include <iostream>

int main() {
  unsigned long long x;
  std::cin >> x;
  unsigned long long ans = (x / 11) * 2;
  x %= 11;
  if (x > 0) {
    ++ans;
  }
  if (x > 6) {
    ++ans;
  }
  std::cout << ans;
  return 0;
}

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

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

  vector<int> x(N + 1);
  vector<int> y(M + 1);
  x[0] = X;
  y[0] = Y;
  for (int i = 0; i < N; i++) {
    int v;
    cin >> v;
    x[i + 1] = v;
  }
  for (int i = 0; i < M; i++) {
    int v;
    cin >> v;
    y[i + 1] = v;
  }

  // for (int i = 0; i < N + 1; i++) {
  //   cout << x[i] << endl;
  // }

  int max_x = *max_element(x.begin(), x.end());
  int min_y = *min_element(y.begin(), y.end());

  // cout << max_x << endl;
  // cout << min_y << endl;

  if ((min_y - max_x) > 0) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
    #include <string>
#include <map>
    using namespace std;
    int main(){
      int n; cin >> n;
      map<string, int> re;
      while(n--){
        string s; cin >> s;
        ++re[s];
      }
      cout << "AC x " <<re["AC"] << "\n"; 
      cout << "WA x " <<re["WA"] << "\n";
      cout << "TLE x " <<re["TLE"] << "\n";
      cout << "RE x " <<re["RE"] << "\n";
    }

Measured memory_bytes: 3568
/************************************************************
	> File Name: d.cpp
	> Author: TSwiftie
	> Mail: tswiftie@foxmail.com 
	> Created Time: Fri 19 Jun 2020 10:15:34 AM CST
************************************************************/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define int long long
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int INF = 0x3f3f3f3f;
const LL INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int N = 2e5+10;
int a[N],n,ans,t[1000010];
bool ton[1000010];
signed main(void){
	IOS;
	cin >> n;
	for(int i = 1;i <= n;++i)
		cin >> a[i],++t[a[i]];
	sort(a+1,a+1+n);
	for(int i = 1;i <= n;++i){
		if(!ton[a[i]]){
			if(t[a[i]]==1) ++ans;
			for(int j = a[i];j <= 1000010;j+=a[i])
				ton[j] = 1;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 13880
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
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)*}
    };
}
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: usize, Ma: usize, Mb: usize,
        abc: [(usize, usize, usize); N],
    }
    let abrange = 10 * N;
    let mut dp = vec![vec![vec![MOD; abrange+1]; abrange+1]; N+1]; //dp[N][max(a)][max(b)]
    dp[0][0][0] = 0;

    for i in 0..N {
        let a = abc[i].0;
        let b = abc[i].1;
        let c = abc[i].2;
        for j in 0..abrange+1 {
            for k in 0..abrange+1 {
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                if j >= a && k >= b {
                    dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j - a][k - b] + c);
                }
            }
        }
    }
    let mut ans = MOD;

    for j in 0..abrange {
        for k in 0..abrange {
            if (j * Mb != k * Ma) || (j == 0 && k == 0) {
                continue;
            }
            ans = min(ans, dp[N][j][k]);
        }
    }

    println!("{}", if ans != MOD { ans as isize } else { -1 });
}

Measured memory_bytes: 63740
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N =3e5+6;
void solve(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll k;
	cin>>k;
	ll val=0;
	val+=( min( k,a));
	k-=min( k,a);
	k-=min( k,b);
	val-=min( k,c);
	cout<<val<<'\n';

}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
//	#ifndef ONLINE_JUDGE
//		cin.tie(NULL);
//		freopen ("INPUT.txt" , "r" , stdin);
//		freopen ("OUTPUT.txt", "w" , stdout);
//	#endif	
    ll t=1;
   // cin>>t;
    for (ll i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "Input2";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("35");
            WillReturn.Add("1");
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        Func<int, int> DeriveCombiCntFunc = (pSum) =>
        {
            int WillReturn = 0;
            for (int A = 0; A <= 9; A++) {
                for (int B = 0; B <= 9; B++) {
                    for (int C = 0; C <= 9; C++) {
                        for (int D = 0; D <= 9; D++) {
                            if (A + B + C + D == pSum)
                                WillReturn++;
                        }
                    }
                }
            }
            return WillReturn;
        };

        InputList.ForEach(X => Console.WriteLine(DeriveCombiCntFunc(int.Parse(X))));
    }
}

Measured memory_bytes: 5772
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 + 7;
int n, k;
vector<int> g[112345];
bool vis[112345];

int dfs(int x, int banned) {
  vis[x] = true;
  if (banned >= k) {
    puts("0");
    exit(0);
  }
  int64_t ans = k - banned;
  int nb = 1 + (banned > 0);
  for (int y : g[x]) if (!vis[y]) {
    ans = ans * dfs(y, nb++) % mod;
  }
  return ans;
}

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0, u, v; i < n - 1; ++i) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  printf("%d\n", dfs(1, 0));
  return 0;
}



Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int main(){
	
	int n, m;
	
	while(true){
		
		cin >> n >> m;
		
		if(n == 0 && m == 0){
			break;
		}
		
		int p[200000];
		
		long long int sum = 0;
		
		for(int i = 0; i < n; i++){
			cin >> p[i];
			sum += p[i];
		}
		
		sort(p, p + n);
		
		for(int i = n - m; i >= 0; i -= m){
			sum -= p[i];
		}
		
		cout << sum << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  bool flag=true;
  int n;
  cin>>n;
  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin>>tmp;
    if(tmp%2!=0) continue;
    if(tmp%3!=0&&tmp%5!=0)
    {
      flag=false;
      break;
    }
  }
  if(flag) cout<<"APPROVED";
  else cout<<"DENIED";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[55][55][2555];
int n,arr[1009];
int A;
long long bt(int id,int sum,int num){
    if(id == n){
        if((double)sum/num==A)return 1;
        else return 0;
    }
    if(dp[id][num][sum] != -1)return dp[id][num][sum];
    long long ret = bt(id+1,sum+arr[id],num+1) + bt(id+1,sum,num);
    dp[id][num][sum] = ret;
    return ret;
}
int main(){
    memset(dp,-1,sizeof(dp));
    cin>>n>>A;
    for(int i=0;i<n;i++)cin>>arr[i];
    cout<<bt(0,0,0)<<endl;
}




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


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


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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    vector<int> p2(n);
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }
    p2 = p;
    sort(p.begin(), p.end());
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i] != p2[i]) cnt++;
    }
    
    if (cnt == 2 || cnt == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    string s;
    cin >> s;
    int n = s.length();
    string r = "";
    for(int i = n-1;i>=0;i--)r+=s[i];
    if(s == r){
        string f = "";
        for(int i = (n-1)/2-1;i>=0;i--)f+=s[i];
        if(f == s.substr(0,(n-1)/2)){
            string b = "";
            for(int i = n-1;i>=(n+3)/2-1;i--)b+=s[i];
            string c =  s.substr((n+3)/2-1);
            if(b == c){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

using namespace std;

using ll = long long;

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

    int n, x; cin >> n >> x;
    vector<int> l(n); for (int& y : l) cin >> y;
    vector<int> d(n + 1);
    d[0] = 0;
    for (int i = 0; i < n; i++) {
        d[i + 1] = d[i] + l[i];
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) if (d[i] <= x) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#include <algorithm>
using namespace std;
int main()
{
	ll N,i,D,a,b,c=0;
	cin>>N>>D;
	for(i=1;i<=N;i++)
	{
		cin>>a>>b;
		if(a*a+b*b<=D*D)
		c++;
	}
	cout<<c;
	return 0;
}

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

int main(){
    
        
        string st1,order,st2;
        cin>>st1;
        
        int m,a,b;
        cin>>m;
        rep(i,m){
            
            cin>>order;
            if(order=="print"){
            
                cin>>a>>b;
                st2=st1.substr(a, b-a+1);
                cout<<st2<<endl;
            }else if(order=="replace"){
            
                cin>>a>>b;
                string word;
                cin>>word;
                st1=st1.replace(a, b-a+1,word );
                
                
            }else{
                cin>>a>>b;
                st2=st1.substr(a, b-a+1);
                reverse(st2.begin(), st2.end());
                st1=st1.replace(a, b-a+1, st2);
            }
        
        
    
        
    }
      
}


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

using P = pair<int64_t,int64_t>;
int main(void) {
    int64_t N,M;
    int64_t money = 0;
    cin >> N >> M;
    vector<P> ab(N);
    for(int i=0;i<N;i++) {
        cin >> ab[i].first >> ab[i].second;
    }

    sort(ab.begin(), ab.end());
    for(int i=0;M;i++) {
        if(ab[i].second <= M) {
            //全部買う
            money += (ab[i].first * ab[i].second);
            M -= ab[i].second;
        } else {
            //残りだけ買う
            money += (ab[i].first * M);
            M =0;
        }        
    }

    cout  << money << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

map<int, int> retMap(int n){
  map<int, int> mp;

  for(int i = 2; i <= n; i++){
    int x = i;
    for(int j = 2; x != 1; j++){
      int cnt = 0;
      while(x % j == 0){
        x /= j;
        cnt++;
      }
      if(cnt > 0) mp[j] += cnt;
    }
  }

  return mp;
}

int calc(const map<int, int>& mp, const vector<int>& v) {
  if((int)v.size() == 0) return 1;

  int ret = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(itr->second >= v[0]){
      map<int, int> nmp(next(itr), mp.end());
      vector<int> nv(next(v.begin()), v.end());
      ret += calc(nmp, nv);
    }
  }

  return ret;
}

int rotateCalc(const map<int, int>& mp, vector<int>& v){
  sort(v.begin(), v.end());

  int ret = 0;
  do{
    ret += calc(mp, v);
  }while(next_permutation(v.begin(), v.end()));

  return ret;
}

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

  map<int, int> mp = retMap(n);

  int ans = 0;
  vector<vector<int>> v {{2, 4, 4}, {2, 24}, {4, 14}, {74}};
  for(auto& x: v) {
    ans += rotateCalc(mp, x);
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    vector<ll> N(4);
    for (ll i = 0; i < 4; i++) {
        cin >> N[i];
    }
    sort(N.begin(), N.end());
    bool ans = true;
    ll d[4] = { 1, 4, 7, 9};
    for (ll i = 0; i < 4; i++) {
        if (N[i] != d[i]) {
            ans = false;
            break;
        }
    }

    cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n,m,d;
	cin>>n>>m>>d;
	double ans = (n-d);
	if(d) ans *= 2;
	ans *= (m-1);
	ans /= n;
	ans /= n;
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n, i, fa = 1, fb = 0, f = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    f =  fa + fb;
    fb = fa;
    fa = f;
  }

  printf("%d\n", f);

  return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = 0;
    for(int i = 1; i <= n; i++) {
      if((sc.nextInt()) != i) t++;
    }
    String ans = "NO";
    if((t == 0) || (t == 2)) ans = "YES";
    System.out.println(ans);
  }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
const int N=50;
int main()
{
    int n,m,c,a[N][N],b[N];
    scanf("%d%d%d",&n,&m,&c);
    for(int i=1;i<=m;i++){
        scanf("%d",&b[i]);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        int tmp=0;
        for(int j=1;j<=m;j++){
            scanf("%d",&a[i][j]);
            tmp=tmp+a[i][j]*b[j];
        }
        if(tmp+c>0){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{
 
    public static void main(String[] args) throws IOException {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        do {
            // input
            char[] firstInput = br.readLine().toCharArray(); // ex : 123
            int[] num = new int[firstInput.length];// base
            char seconInput = 0;
            for (int i = 0; i < firstInput.length; i++) {
                seconInput = firstInput[i];// split
                num[i] = Character.getNumericValue(seconInput);// input info
            }
            // constraints
            if (num[0] == 0 && seconInput == '0' )break;
 
            // plus works & output
            int sum = 0;
            for (int i = 0; i < num.length; i++) {
 
                sum += num[i];
            }
            System.out.println(sum);
        } while (true);
    }
}

Measured memory_bytes: 24516
#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using namespace atcoder;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
  
    int T; cin >> T;
    ll n,m,a,b;
    rep(i,T) {
        cin >> n >> m >> a >> b;
        cout << floor_sum(n,m,a,b) << '\n';
    }
    return 0;
}

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


using namespace  std;
const int maxn = 3007;

int dp[maxn];
int ddp[maxn];

const double eps = 1e-8;
int main()
{
    int A,B,C,D,E,F;
    while(cin>>A>>B>>C>>D>>E>>F){
        A*=100;
        B*=100;
        memset(dp , 0 , sizeof(dp));
        memset(ddp , 0 , sizeof(ddp));
        dp[0]=ddp[0]=1;
        for(int i = 1 ; i < maxn ; i++){
            if(i - A >=0){
                dp[i]+=dp[i-A];
            }
            if(i - B >=0){
                dp[i]+=dp[i-B];
            }
        }
        for(int i = 1 ; i < maxn ; i++){
            if(i - C >= 0){
                ddp[i] += ddp[i-C];
            }
            if(i - D >= 0){
                ddp[i] += ddp[i-D];
            }
        }
        double ans = 0;
        int p= A , pp = 0;

        for(int i = 1 ; i <=F;i++){
            if(dp[i] != 0){
                int test = i /100;
                test *=  E;
                int flag = 1;
                for(int j = 1 ; j <= F && flag ; j++){
//                    cout<<test<<"  dfdsfds "<<j<<endl;
                    if(i+j >F ||  test < j ) {
//                        cout<<"fdfdsa"<<endl;
                        flag = 0;break;
                    }
                    if(ddp[j] != 0){
                        double t = (double)j /((double)i + (double)j);
                        if(t > ans ){
                            ans = t;
                            p = i;
                            pp = j;
                        }
                    }
                }
            }
        }
        cout<<p+pp<<" "<<pp<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        trip [] arr = new trip[n];

        for (int i = 0; i < n; i++) {
            arr [i] = new trip(sc.nextInt(),sc.nextInt(),sc.nextInt());
        }

        int [][] dp = new int [n][3];

        dp[0][0] = arr[0].a;
        dp[0][1] = arr[0].b;
        dp[0][2] = arr[0].c;

        for (int i = 1; i < n; i++) {
            dp[i][0] = Math.max(dp[i-1][1],dp[i-1][2]) + arr[i].a;
            dp[i][1] = Math.max(dp[i-1][0],dp[i-1][2]) + arr[i].b;
            dp[i][2] = Math.max(dp[i-1][0],dp[i-1][1]) + arr[i].c;
        }
        System.out.print(Math.max(Math.max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
    }
}

class trip {

    int a;
    int b;
    int c;

    public trip(int a, int b, int c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }
}


Measured memory_bytes: 99100
#include<iostream>
using namespace std;
int main(void)
{
	int i,a[3],max,min;
	cin>>a[0];
	max=a[0];
	min=a[0];
	for(i=1;i<3;i++){
		cin>>a[i];
		if(max<=a[i]) max=a[i];
		if(min>=a[i]) min=a[i];
	}
	cout<<min<<" "<<max<<endl;
	return 0;
}


Measured memory_bytes: 3120
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n;
		int trib[] =new int[30];
		trib[0]=1;
		trib[1]=2;
		trib[2]=4;
		for(int i=3;i<30;i++){
			trib[i]= trib[i-1] +trib[i-2]+trib[i-3];
		}
		for(;;){
			n=sc.nextInt();
			if(n==0){
				System.exit(0);
			}
			if((trib[n-1]/10)%365==0){
				if(trib[n-1]/10==0){
				System.out.println(1);
				}else{
					System.out.println(((trib[n-1]/10)/365));
				}
				
			}else{
				if(trib[n-1]/10==0){
				System.out.println(1);
				}else{
					System.out.println(((trib[n-1]/10)/365)+1);
				}
			}
			
		
		}
	}
}

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

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

    vector<double> ar(n);
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];//0th index hai
    }
    vector<vector<long double>>dp(n+2,vector<long double>(n+2,0.0));;
    dp[0][0]=1;dp[0][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1-ar[i-1]);//
            }
            else
            {
                dp[i][j]=dp[i-1][j-1]*ar[i-1];
                if(i!=j)
                dp[i][j]+=dp[i-1][j]*(1-ar[i-1]);
            }
         //   cout<<dp[i][j]<<" ";
        }
      //  cout<<endl;
    }
    long double ans=0;
    for(int i=(n/2+1);i<=n;i++)
    {
        ans+=dp[n][i];
    }
    
    cout << fixed << setprecision(10) <<ans; 





}


Measured memory_bytes: 141184
# 配るDP
N = int(input())

INF = 10 ** 5 + 1

dp = [INF for _ in range(N + 1)]
dp[0] = 0

for n in range(N):
    power = 1
    while n + power <= N:
        dp[n + power] = min(dp[n + power], dp[n] + 1)
        power *= 6

    power = 1
    while n + power <= N:
        dp[n + power] = min(dp[n + power], dp[n] + 1)
        power *= 9

print(dp[N])


Measured memory_bytes: 3864
#include <iostream>
using namespace std;
int main(void){
    
    int X;
    cin >> X;
    int dp[100000] = {};
    
    dp[0] = 1;
    dp[100] = 1;
    dp[101] = 1;
    dp[102] = 1;
    dp[103] = 1;
    dp[104] = 1;
    dp[105] = 1;
    
    for(int i = 200; i <= 100000; i++){
        if(dp[i - 100] or dp[i - 101] or dp[i - 102] or dp[i - 103] or dp[i - 104] or dp[i - 105]){
            dp[i] = 1;
        }
    }
    
    cout << dp[X];
   
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

// 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 
// 14 15 15 15 16 16 16 17 17 17

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) scanf("%lld", &a[i]);

    map<ll, ll> fd;
    ll ans = 1;
    
    rep(i, n) {
        ll t = a[i];
        
        if (t == 0) {
            ans *= 3 - fd[0];
            ans %= MOD;
            fd[0] += 1;
        } else {
            ans *= fd[t - 1] - fd[t] % MOD;
            /*
            if (fd[t-1] - fd[t] <= 0) {
                cout << 0 << endl;
                return 0;
            }*/
            // cout << ans << " " << fd[t-1] << endl;
            ans %= MOD;
            fd[t] += 1;
        }
    }

    cout << ans % MOD << endl;
}

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

int main() {
  int x,y;
  while(true){
    cin >>x>>y;
    if(x==0&&y==0){
      break;}
    if(x>y){
      cout << y << " " << x << endl;}
    if(x<=y){
      cout << x << " " << y << endl;}

}
  
    return 0;
}



Measured memory_bytes: 2968
#include <bits/stdc++.h>
using namespace std;
 
// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
 
const int MOD = 1000000007;
const lint INF = 1LL << 60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define p pair<int, int>
#define plint pair<lint, lint>

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
    vector<int> par;
    UnionFind(int n):par(n){rep(i,n)par[i]=i;}
    int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
    void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
    bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main(void) {
    int x;
    string s;
    
    cin >> x;
    
    int ans = 0;
    ans += x / 500 * 1000;
    x -= x / 500 * 500;
    ans += x / 5 * 5;
    
    cout << ans;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	int start,end;
	scanf("%d %d",&start,&end);

	int N;
	scanf("%d",&N);

	int log_start,log_end;

	for(int loop = 0; loop <N; loop++){

		scanf("%d %d",&log_start,&log_end);
		if(log_end <= start || log_start >= end){
			//Do nothing
		}else{
			printf("1\n");
			return 0;
		}
	}

	printf("0\n");

	return 0;
}

Measured memory_bytes: 3148
public class Main {

  private static void solve() {
    int n = ni();
    char[] s = ns();

    int ret = 1;
    char d = s[0];
    for (char c : s) {
      if (d != c) {
        d = c;
        ret++;
      }
    }
    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 27220
import bisect
n, k = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]

a = [int(i) for i in range(10) if i not in d]

ans = ""
next_d = 0
for i in range(len(str(n))-1, -1, -1):
    idx = bisect.bisect_left(a, int(str(n)[i])+next_d)
    if idx == len(a):
        next_d = 1
        ans = str(a[0]) + "".join([str(a[0]) for j in range(len(ans))])
    else:
        next_d = 0
        if str(n)[i] == str(a[idx]):
            ans = str(a[idx]) + ans
        else:
            ans = str(a[idx]) + "".join([str(a[0]) for j in range(len(ans))])
if next_d == 1:
    idx = bisect.bisect_left(a, 1)
    if idx == len(a):
        ans = str(a[0]) + "".join([str(a[0]) for j in range(len(ans))])
    else:
        if str(a[idx]) == "1":
            ans = str(a[idx]) + ans
        else:
            ans = str(a[idx]) + "".join([str(a[0]) for j in range(len(ans))])
print(ans)

Measured memory_bytes: 3188
open System

let NM = stdin.ReadLine().Split(' ');
let N = NM.[0] |> int;
let M = NM.[1] |> int;


let data : int [] = Array.zeroCreate M
for i in 0..N-1 do
  let mutable ct = stdin.ReadLine().Split(' ');
  let mutable c = ct.[0] |> int;
  for j in 1..c do
    let mutable m = ct.[j] |> int;
    data.[m-1] <- data.[m-1]+1;

let mutable count = 0;
for i in 0..M-1 do
  if data.[i] = N then
     count <- count+1;

count |> printfn "%d"

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

using namespace std;

int n, a[20200], b[20200];
int p[20200];

int main () {
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> p[i];
		a[i] = i * 20200;
		b[i] = (n - i + 1) * 20200;
	}

	for (int i = 1, cur = 0; i <= n; i ++) {
		int j = p[i];
		if(j > n / 2)
		 	a[j] += cur;
		else
			b[j] += cur;
		++ cur;
	}

	for (int i = 1; i <= n; i ++)
		cout << a[i] << ' ';
	cout << '\n';
	for (int i = 1; i <= n; i ++)
		cout << b[i] << ' ';
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void) {

	int i, j, H, W;

	while (1) {

		scanf("%d %d", &H, &W);
		
		if (H == 0 && W == 0) {
				break;
			}

		for (i = 0; i < H; i++) {

			for (j = 0; j < W; j++) {

				printf("#");

			}

			printf("\n");

		}
printf("\n");
	}

	
	
	return(0);

}


Measured memory_bytes: 2044
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
   //freopen("data.in","r",stdin);
   //freopen("data.out,"w",stdout);
   int n;
   cin>>n;
   char s[2][100];
   cin>>s[0]>>s[1];
   int i;
   ll ans=3;
   int flag;
   if(n>1&&s[0][0]==s[0][1])
   {
   	  ans=6;
   	  i=2;
   	  flag=0;
   }
   else
   {
   	 ans=3;
   	 i=1;
   	 flag=1;
   }
   
   for(int j=i;j<n;j++)
   {
   	  
   	  if(s[0][j]==s[0][j+1])
   	  {
   	  	    if(flag==1)
   	     	ans=(ans*2)%mod;
   	     	else
   	     	ans=(ans*3)%mod;
   	     	
   	     	j++;
   	     	flag=0;
   	     	
	  }
	  else
	  {
	  	    if(flag==1)
	  	    ans=(ans*2)%mod;
	  	    flag=1;
	  	  
	  }
	  
   }

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  char a[n];
  int cntred=0,cntw=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    char ch=a[i];
    if(ch=='R')
      cntred++;
    else
      cntw++;
  }
  if(cntred==0 && cntw>0)
    cout<<0;
  else if(cntw==0 && cntred>0)
    cout<<0;
  else
  {
    int cnt=0;
    for(int i=0;i<cntred;i++)
    {
      if(a[i]=='W')
        cnt++;
    }
    cout<<cnt;
  }
  return 0;
}

Measured memory_bytes: 3352
import java.util.Scanner;

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

		Scanner scanner = new Scanner(System.in);

		int height = scanner.nextInt();
		int width = scanner.nextInt();

		// ??¢???
		int area = height * width;

		// ??¨????????????
		int lengthOfAround = (height * 2) + (width * 2);

		System.out.println(area + " " + lengthOfAround);
	}

}

Measured memory_bytes: 17160
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    IN(ll, X);
    vi C(N);
    vvi A(N, vi(M));
    REP(i, N)
    {
        cin >> C[i];
        REP(j, M)
        {
            cin >> A[i][j];
        }
    }
    ll ans = -1;
    REP(p, 1 << N)
    {
        vi y(M);
        ll cost = 0;
        REP(i, N)
        {
            if ((p >> i) & 1)
            {
                cost += C[i];
                REP(j, M)
                {
                    y[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        REP(i, M)
        {
            ok &= y[i] >= X;
        }
        if (ok)
        {
            if (ans == -1)
            {
                ans = cost;
            }
            else
            {
                CH(min, ans, cost);
            }
        }
    }
    OUT(ans);
}


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

int fun(int a){
    int ans=1;
    int n=a;
    rep(i,a){
        ans*=n;
        n--;
    }
    return ans;
}

int main(){
  int n; cin >> n;
  vector<int> so(n);
  rep(i,n) so[i]=i+1;
  int leng=n;
  int pans=1; int qans=1;
  rep(i,n){
      int p; cin >> p;
      rep(j,n){
      if(p==so[j]){
      pans+=((fun(leng-1)*j));
      so[j]=n+1;
      sort(so.begin(),so.end());
      }
      }
      leng--;
  }
  rep(i,n) so[i]=i+1;
  leng=n;
  rep(i,n){
      int q; cin >> q;
      rep(j,n){
      if(q==so[j]){
      qans+=((fun(leng-1)*j));
      so[j]=n+1;
      sort(so.begin(),so.end());
      }
      }
      leng--;
  }
  cout << abs(pans-qans) << endl;
return 0;
}


Measured memory_bytes: 256
total_cards = int(input())
cards_list = list(map(int,input().split()))
alice=0
bob=0
cards_list.sort(reverse=True)
for i in range(len(cards_list)):
    if i%2==0:
        alice +=cards_list[i]
    else:
        bob +=cards_list[i]
ans = alice -bob
print(ans)

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

using namespace std;

int h,w;

int gcd(int x,int y){
    return (y == 0)?x:gcd(y,x%y);
}

void solve(){
    int i,j;
    string str;
    int a,b;
    cin >> h >> w >> a >> b;
    /*todo
    for(int h = 1;h < 100;h++){
        for(int w = 1;w < 100;w++){
            for(int a = 0;a <= w/2;a++){
                for(int b = 0;b <= h/2;b++){
                    cout << h << w << a << b;
                    if(abs(h*a-w*b)%gcd(h-2*b,w-2*a)){
                        cout << "yes" << endl;
                    }
                    else{
                        cout << "no" << endl;
                    }
                }
            }
        }
    }*/
    for(i = 0;i < h;i++){
        for(j = 0;j < w;j++){
            if((i < b && j < a) || (i >= b && j >= a)){
                cout << 1;
            }
            else{
                cout << 0;
            }
        }
        cout << endl;
    }
}

int main(){
    solve();
}


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

int main(){
  unsigned long int x;
  int8_t mod;
  int8_t n;

  cin >> x;

  mod = x%11;
  if(mod!=0){
    if(x%11<=6)n=1;
    else n=2;
  }
    
  cout<< (x/11)*2 + n << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int i=1; i<10; i++){
            if(N%i==0 && N/i<10){
                System.out.println("Yes");
                return;

            }
        }

		System.out.println("No");
	}
}

Measured memory_bytes: 35768
s = gets.strip.chars.reverse.join
strings = %w(dream dreamer erase eraser).map {|str| str.chars.reverse.join}

while true
  can = false
  strings.each do |str|
    if s[0..str.length - 1] == str
      s = s[str.length..-1]
      can = true
    end
  end

  if !can
    puts "NO"
    break
  end

  if s.empty?
    puts "YES"
    break
  end
end


Measured memory_bytes: 10748
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.nextLine();
        int res = 0;
        for (char c : line.toCharArray()) {
            res += c == '+' ? 1 : -1;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 35824