akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
#define ll long long
using namespace std;
int n,q;
vector<int>a[200005];
int cnt[200005],ans[200005];
void dfs(int p,int fa,int add)
{
	add+=cnt[p];
	ans[p]=add;
	for (int i=0;i<a[p].size();i++)
	{
		int v=a[p][i];
		if (v!=fa)
			dfs(v,p,add);
	}
}
int main()
{
	fast;
	cin>>n>>q;
	for (int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	for (int i=1;i<=q;i++)
	{
		int x,c;
		cin>>x>>c;
		cnt[x]+=c;
	}

	dfs(1,0,0);
	for (int i=1;i<=n;i++)
		cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 21632
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}

	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int n,a,b,p,p2;
			int index,result;
			String s,s2;
			n = sc.nextInt();
			Map <String,Integer> mapName = new TreeMap<String,Integer> ();
			Map <Integer,Integer> mapScore = new TreeMap<Integer,Integer> ();

			for(index=0;index<n;index++) {
				s = sc.next();
				p = sc.nextInt();
				s2="";
				p2=100-p;
				if(p2==0) s2="0000";
				else if(p2<10) s2="000"+p2;
				else if(p2<100) s2="00"+p2;
				else if(p2<1000) s2="0"+p2;
				mapName.put(s+s2,index);
				mapScore.put(index,p);
				}
			sc.close();


			for(String key:mapName.keySet()) {
				index=mapName.get(key);
				System.out.println(index+1);
				}

			

			// 出力

	}
}

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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

ll n;

ll f(ll k) {
    if(k == 1) return 0;
    ll N = n;
    while(N%k == 0) {
        N /= k;
    }
    if(N == 1) {
        return 1;
    }
    ll rem = N%k;
    if(rem == 1) return 1;
    else return 0;
}

void solve() {
    cin >> n;
    ll ans = 0;
    map<ll, ll> mp;
    for(ll i = 1; i*i <= n; i++) {
        if((n-1)%i == 0) {
            ans += 2;
            mp[(n-1)] = 1;
            mp[(n-1)/i] = 1;
            if(i * i == n-1) {
                ans --;
            }
        }
    }
    ans --;
//    debug1(ans)
    for(ll i = 1; i*i <=n; i++) {
        if(n%i == 0) {
            if(mp[i] == 0)
                ans += f(i);
            if(i * i != n) {
                if(mp[n/i] == 0)
                    ans += f(n/i);
            }
        }
    }
    cout << ans ;
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 640
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;



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

    struct Point {
        int64_t x;
        int64_t y;
        bool operator<(const Point& d) const {
            return x == d.x ? y < d.y : x < d.x;
        }
    };

    std::map<Point, size_t> C;

    // 枠は [1, H-2]まで
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t ay, bx;
        std::cin >> ay >> bx;

        for (int64_t xx = std::max<int64_t>(1, bx-2); xx <= std::min<int64_t>(bx, W-2); ++xx) {
            for (int64_t yy = std::max<int64_t>(1, ay-2); yy <= std::min<int64_t>(ay, H-2); ++yy) {
                ++ C[{xx, yy}];
            }
        }
    }

    std::vector<int64_t> ans(10);

    ans[0] = (H-2) * (W-2);

    for (auto c: C) {
        ans[c.second]++;
        ans[0]--;
    }

    for (auto a: ans) {
        std::cout << a << std::endl;
    }

    return 0;
}


Measured memory_bytes: 56448
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int MAX = 100005;
const int N = 100005;
LL fact[MAX], invfact[MAX], inv[MAX];
LL cumsum[N];

// テーブルを作る前処理
void init() {
	fact[0] = fact[1] = 1;
	invfact[0] = invfact[1] = 1;
	inv[0] = inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fact[i] = fact[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		invfact[i] = invfact[i - 1] * inv[i] % MOD;
	}
	for (int i = 0; i < MAX - 1; i++) {
		cumsum[i + 1] = (cumsum[i] + inv[i + 1]) % MOD;
	}
}

int main() {
	init();
	int n;
	scanf("%d", &n);
	LL ret = 0;
	REP(i, n) {
		LL a;
		scanf("%lld", &a);
		ret =  (ret + (a * ((cumsum[i + 1] + cumsum[n - i] - 1 + MOD) % MOD))%MOD)%MOD;
	}
	cout << (fact[n] * ret) % MOD << endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll x;
  cin >> x;
  ll n = 100;
  ll count = 0;
  while (n < x) {
    count++;
    n += n / 100;
  }
  cout << count << endl;
}


Measured memory_bytes: 3568
program sample
  implicit none
  integer :: n,i,j,num100,num10,num1,p1,p2,p3,ans
  character(:),allocatable :: s
  character(1) :: ch(0:9)

  read(*,*) n
  allocate(character(n) :: s)
  read(*,*) s
  ch=['0','1','2','3','4','5','6','7','8','9']
  p1=0
  p2=0
  p3=0
  ans=0
  
  do i=0,999
     num100=i/100
     num10=(i-num100*100)/10
     num1=i-num100*100-num10*10
        p1=index(s(1:n),ch(num100))
        if(p1==0.or.p1==n)then
           cycle
        else
           p2=index(s(p1+1:n),ch(num10))
           if(p2==0)then
              cycle
           else
              p2=p2+p1
              if(p2==n)then
                 cycle
              endif
              p3=index(s(p2+1:n),ch(num1))
              if(p3==0)then
                 cycle
              else
                 ans=ans+1
              endif
           endif
        endif
     enddo     

  write(*,*) ans
           
  stop
end program sample


Measured memory_bytes: 3000
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define ABSS(a, b) (a > b ? a - b : b - a)

typedef struct {
	uint32_t a;
	uint32_t b;
	uint32_t nextIdx;
	uint32_t prevIdx;
} L_t;

static uint32_t beginIdx;

static L_t L[100000];
static uint32_t endCount[100000];

static void removeElement(const size_t idx) {
	if (L[idx].nextIdx != UINT32_MAX) {
		if (L[idx].prevIdx != UINT32_MAX) {
			L[L[idx].prevIdx].nextIdx = L[idx].nextIdx;
			L[L[idx].nextIdx].prevIdx = L[idx].prevIdx;
		}
		else {
			L[L[idx].nextIdx].prevIdx = UINT32_MAX;
			beginIdx = L[idx].nextIdx;
		}
	}
	else {
		if (L[idx].prevIdx != UINT32_MAX) {
			L[L[idx].prevIdx].nextIdx = UINT32_MAX;
		}
		else {
			beginIdx = UINT32_MAX;
		}
	}

	endCount[L[idx].b]--;
}

static void disconnectIsland(const uint32_t endPos) {
	uint32_t i = beginIdx;
	while (i != UINT32_MAX) {\
		if (L[i].a < endPos && L[i].b >= endPos) {
			removeElement(i);
		}
		i = L[i].nextIdx;
	}
}

int main(void) {
	uint32_t N, M;

	scanf("%"PRIu32" %"PRIu32"\n", &N, &M);
	for (uint32_t i = 0; i < N; i++) {
		endCount[i] = 0;
	}
	for (uint32_t idx = 0; idx < M; idx++) {
		scanf(idx != M - 1 ? "%"PRIu32" %"PRIu32"\n" : "%"PRIu32" %"PRIu32, &(L[idx].a), &(L[idx].b));
		L[idx].a--;
		L[idx].b--;
		L[idx].nextIdx = (idx != M - 1 ? idx + 1 : UINT32_MAX);
		L[idx].prevIdx = (idx != 0 ? idx - 1 : UINT32_MAX);
		endCount[L[idx].b]++;
	}
	beginIdx = 0;

	uint32_t removedBridgeCount = 0;
	for (uint32_t i = 0; i < N && beginIdx != UINT32_MAX; i++) {
		if (endCount[i] > 0) {
			disconnectIsland(i);
			removedBridgeCount++;
		}
	}

	printf("%"PRIu32, removedBridgeCount);

	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
    std::string s;
    s.reserve(100001);
    int q;

    std::cin >> s;
    std::cin >> q;
    bool isAlign = true;
    std::string front, back;
    front.reserve(200001);
    back.reserve(200001);
    for (int i = 0; i < q; ++i)
    {
        int t;
        std::cin >> t;
        if (t == 1)
        {
            isAlign = !isAlign;
        }
        else
        {
            int f;
            char c;
            std::cin >> f;
            std::cin >> c;
            if (f == 1)
            {
                if (isAlign)
                {
                    front.push_back(c);
                }
                else
                {
                    back.push_back(c);
                }
            }
            else
            {
                if (isAlign)
                {
                    back.push_back(c);
                }
                else
                {
                    front.push_back(c);
                }
            }
        }
    }
    std::string ans;
    ans.reserve(300001);
    std::reverse(front.begin(), front.end());
    ans = front + s + back;
    if (!isAlign)
    {
        std::reverse(ans.begin(), ans.end());
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1216
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  int a = 0;
  repi(i, 105, N + 1){
    if(i % 2 == 1){
      int c = 0;
      repi(j, 1, N + 1){
        if(i % j == 0){
          c++;
        }
      }
      if(c == 8){
        a++;
      }
    }
  }
  co(a);
}

Measured memory_bytes: 256
//A - Calc
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int T;
	cin >> T;
	int sum = T + T*T + T*T*T;
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3648
using System.IO;
using System.Linq;
using static System.Console;

namespace ConsoleApp1
{
    public class Program
    {
        static void Main()
        {
            var s1 = ReadLine().Split(' ');

            var n = short.Parse(s1[0]);
            var m = short.Parse(s1[1]);

            var s2 = new string[n];

            for (int i = 0; i < n; i++)
            {
                s2[i] = ReadLine();
            }

            var cakes = s2.Select(x => new Cake(x));

            var p = new long[8];

            p[0] = cakes.Select(x => x.X + x.Y + x.Z).OrderByDescending(x => x).Take(m).Sum();
            p[1] = cakes.Select(x => x.X + x.Y - x.Z).OrderByDescending(x => x).Take(m).Sum();
            p[2] = cakes.Select(x => x.X - x.Y + x.Z).OrderByDescending(x => x).Take(m).Sum();
            p[3] = cakes.Select(x => x.X - x.Y - x.Z).OrderByDescending(x => x).Take(m).Sum();
            p[4] = cakes.Select(x => -x.X + x.Y + x.Z).OrderByDescending(x => x).Take(m).Sum();
            p[5] = cakes.Select(x => -x.X + x.Y - x.Z).OrderByDescending(x => x).Take(m).Sum();
            p[6] = cakes.Select(x => -x.X - x.Y + x.Z).OrderByDescending(x => x).Take(m).Sum();
            p[7] = cakes.Select(x => -x.X - x.Y - x.Z).OrderByDescending(x => x).Take(m).Sum();


            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);
            WriteLine(p.Max());
            Out.Flush();
        }

        public class Cake
        {
            public long X { get; }
            public long Y { get; }
            public long Z { get; }

            public Cake(string s)
            {
                var xyz = s.Split(' ');
                this.X = long.Parse(xyz[0]);
                this.Y = long.Parse(xyz[1]);
                this.Z = long.Parse(xyz[2]);
            }

        }


    }
}


Measured memory_bytes: 15712
L, R = map(int, raw_input().split())

"""
R ????????1??????
y 0001????0??????
     ^d   ^rd
x 0001???????1??
             ^ld
L ???????????0???
"""

ans = 0

for d in range(70):
  if d<len(bin(L))-3:
    LD = []
  elif d==len(bin(L))-3:
    LD = [i for i in range(-1,d) if i==-1 or (L>>i&1)==0]
  else:
    LD = [d]
  if d<len(bin(R))-3:
    RD = [d]
  elif d==len(bin(R))-3:
    RD = [i for i in range(-1,d) if i==-1 or (R>>i&1)==1]
  else:
    RD = []
  for ld in LD:
    for rd in RD:
      a = 1
      for i in range(d):
        if i<ld:
          xc = [0, 1]
        elif i==ld:
          xc = [1]
        else:
          xc = [L>>i&1]
        if i<rd:
          yc = [0, 1]
        elif i==rd:
          yc = [0]
        else:
          yc = [R>>i&1]
        c = 0
        for x in xc:
          for y in yc:
            if y>=x:
              c += 1
        a *= c
      ans += a
print ans%(10**9+7)


Measured memory_bytes: 2696
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	deque<int>b;
	int flag = true;
	rep(i, n) {
		int a;
		cin >> a;
		if (flag) {
			b.push_back(a);
			flag = false;
		}
		else {
			b.push_front(a);
			flag = true;
		}
	}
	if (n % 2 == 0) {
		rep(i, b.size()) {
			cout << b[i] ;
			if (i != b.size() - 1) {
				cout << " ";
			}
			else {
				cout << endl;
			}
		}
	}
	else {
		rep(i, b.size()) {
			cout << b[b.size()-1-i];
			if (i != b.size() - 1) {
				cout << " ";
			}
			else {
				cout << endl;
			}
		}
	}
}

Measured memory_bytes: 2944
#include <iostream>
#define rep(i,n) for (int i = 0;i < (n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int N,Y;
  cin >> N >> Y;
  int a=-1,b=-1,c=-1;
  bool ok = false;
  for(int i=0;i<=N;i++){ //一万円札の枚数i
    
    for(int j = 0;i+j<=N;j++){ //五千円札の枚数j
      if(Y == i*10000+j*5000+(N-i-j)*1000){
        a = i; b = j; c = N - i - j;
        ok = true;
        break;
      }
    }
    if(ok) break;
  }
  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
//Template.cpp
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
  cin >> s >> t;
  int len = s.length();
 // unordered_map<char, int>m;
 /* for(int i = 0; i < len; i++){
  m[s[i]]++;
  }*/
  int c = 0;
for(int i = 0;i < len;i++){
    if(s[i] != t[i]){
        c++;
    }
}
cout<<c<<'\n';
return 0;
  
}

Measured memory_bytes: 3808
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))

    MAX = max(A) + 1
    flg = [0] * MAX
    tmp = set()
    for a in A:
        if a in tmp:
            flg[a] = 1
        tmp.add(a)

    res = 0
    for a in A:
        if not flg[a]:
            res += 1
        for i in range(a, MAX, a):
            flg[i] = 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 40172
import sys
sys.setrecursionlimit(10**6)
#(a*x)をmで割った余りが1になるようなxを求める
#aで割ったときの余りはa^(-1)をかけた余りと同じ
#逆元a^(-1)を求める
#aとmが互いに素であることが条件

def gyakugen( a, m ):
  b = m
  x, y = 1, 0
  while b>0:
    q = a // b
    a, b = b, a-q*b
    x, y = y, x-q*y
  return x if x>0 else x+m


#(a/b)をmで割った余りを求める
#b^(-1)にaを掛けたものをmで割ればよい

def div_remainder(a,b,m):
    b_inv=gyakugen(b,m)
    a%=m
    return (a*b_inv)%m


#(a*b)をmで割った余りを求める

def multi_remainder(a,b,m):
    a%=m
    b%=m
    return (a*b)%m



#nPrをmで割った余りを求める(ただしn<m、mは素数)

def perm_remainder(n,r,m):
    if r>1:
      return (perm_remainder(n-1,r-1,m)*n)%m
    elif r==1:
      return n
    else:
      return 1

#nCrをmで割った余りを求める(ただしn<m,mは素数)

def comb_remainder(n,r,m):
    r=min(r,n-r)
    return (perm_remainder(n,r,m)*gyakugen(perm_remainder(r,r,m),m))%m


x,y=map(int,input().split())
m=10**9+7
if (2*x-y)%3!=0 or (-x+2*y)%3!=0 or 2*x-y<0 or -x+2*y<0:
  ans=0
else:
  nx=(2*x-y)//3
  n=(x+y)//3
  ans=comb_remainder(n,nx,m)
print(ans)

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

using namespace std;

int N, a[109], need[109];
long long mini, currSum;

void back (int pos)
{
    if (pos > N / 3)
    {
        //cases ++;
        long long aux = currSum;
        for (int i=N / 2 + 1; i<=N; i++)
            if (need[i])
                aux += a[i];
            else
                aux += (a[i] <= 0 ? a[i] : 0);
        for (int i=N / 3 + 1; i<=N / 2; i++)
        {
            int j = 2 * i;
            if (need[i]) aux += a[i];
            else
            if (need[j] || a[j] <= 0) aux += (a[i] <= 0 ? a[i] : 0);
            else aux += (a[i] + a[j] <= 0 ? a[i] + a[j] : 0);
        }
        if (aux < mini)
            mini = aux;
        return ;
    }
    if (need[pos] > 0) currSum += a[pos], back (pos + 1), currSum -= a[pos];
    else
    {
        back (pos + 1);
        currSum += a[pos];
        for (int i=pos * 2; i<=N; i+=pos)
            need[i] ++;
        back (pos + 1);
        currSum -= a[pos];
        for (int i=pos * 2; i<=N; i+=pos)
            need[i] --;
    }
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
back (1);
//printf ("%d\n", cases);
long long ans = -mini;
for (int i=1; i<=N; i++)
    ans += a[i];
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        String s;
        int m, h;
        Scanner sc = new Scanner(System.in);
        while(true){
            s = sc.next();
            if(s.equals("-")) break;
            m = sc.nextInt();
            for(int i = 0; i < m; i ++){
                h = sc.nextInt();
                s = s.substring(h) + s.substring(0, h);
            }
            System.out.println(s);
        }

    }
}

Measured memory_bytes: 26340
#include <stdio.h>

int main(void) {
	int N;
	scanf("%d",&N);
	int A,B,C,D,X,Y,Z;
	int i,tmp=0;
	A=N/1000;
	B=(N-A*1000)/100;
	C=(N-A*1000-B*100)/10;
	D=(N-A*1000-B*100-C*10);
	for(i=0;i<8;i++){
		if(i==0){
			Z=A+B+C+D;
		}else if(i==1){
			Z=A+B+C-D;
		}else if(i==2){
			Z=A+B-C+D;
		}else if(i==3){
			Z=A+B-C-D;
		}else if(i==4){
			Z=A-B+C+D;
		}else if(i==5){
			Z=A-B+C-D;
		}else if(i==6){
			Z=A-B-C+D;
		}else if(i==7){
			Z=A-B-C-D;
		}
		if(Z==7){
			tmp=i;
			break;
		}
	}
	if(tmp==0){
		printf("%d+%d+%d+%d=%d",A,B,C,D,Z);
	}else if(tmp==1){
		printf("%d+%d+%d-%d=%d",A,B,C,D,Z);
	}else if(tmp==2){
		printf("%d+%d-%d+%d=%d",A,B,C,D,Z);
	}else if(tmp==3){
		printf("%d+%d-%d-%d=%d",A,B,C,D,Z);
	}else if(tmp==4){
		printf("%d-%d+%d+%d=%d",A,B,C,D,Z);
	}else if(tmp==5){
		printf("%d-%d+%d-%d=%d",A,B,C,D,Z);
	}else if(tmp==6){
		printf("%d-%d-%d+%d=%d",A,B,C,D,Z);
	}else if(tmp==7){
		printf("%d-%d-%d-%d=%d",A,B,C,D,Z);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,cnt=0;
	char c;
	cin>>n;
	rep(i,n){
		cin>>c;
		if(c=='R')cnt++;
	}
	Yn(cnt>n-cnt);
}


Measured memory_bytes: 256
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <queue>

using namespace std;

#define ll long long

class Main {
public:
	int doesAliceWins(int a, int b) {
		int aa = a;
		int bb = b;
		if (aa == 1) aa = 14;
		if (bb == 1) bb = 14;
		int ans = (aa > bb) ? 1 : ((aa == bb) ? 0 : -1);
		return ans;
	}
};


int main()
{
	Main m;
	int a, b;

	cin >> a >> b;

	int d = m.doesAliceWins(a, b);
	string text = "";
	if (d == 1) {
		text = "Alice";
	}
	else if (d == 0) {
		text = "Draw";
	}
	else {
		text = "Bob";
	}

	cout << text << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	bool dif=(s[0]!=s.back());
	bool siz=(s.size()%2==0);
	cout<<(dif^siz?"First":"Second")<<endl;
}


Measured memory_bytes: 512
import sys
n=int(input())
currtime=0
currx=0
curry=0
for i in range(n):
  t,x,y=map(int,input().split())
  if abs(y-curry)+abs(x-currx)<=t-currtime and (abs(y-curry)+abs(x-currx))%2==(t-currtime)%2:
    currx=x
    curry=y
    currtime=t
  else:
    print('No')
    sys.exit()
print('Yes')

Measured memory_bytes: 74380
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a[101010];
long long sum[101010],sum1[101010];
int main()
{
	int n,k;
	long long ans=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sum[0]=sum1[0]=0;
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i];
		sum1[i]=sum1[i-1]+max(a[i],0);
	}
	for(int i=k;i<=n;i++)
		ans=max(ans,max(sum[i]-sum[i-k],0ll)+sum1[n]-sum1[i]+sum1[i-k]);
	printf("%lld",ans);
	return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second

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

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

//-----------------------------------------------------------------------------


int s;
int a,b,c,d;
int ls[4];
int sign[4];
bool flg=false;

void dfs(int depth,int sum) {
	//cout<<"depth,sum "<<depth<<' '<<sum<<endl;
	if(depth==4) {
		if(sum==7&&!flg) {
			REP(i,3) cout<<ls[i]<<(sign[i]?'+':'-');
			cout<<ls[3]<<"=7"<<endl;
			flg=true;
		}
		return;
	}
	sign[depth-1]=1;
	dfs(depth+1,sum+ls[depth]);
	sign[depth-1]=0;
	dfs(depth+1,sum-ls[depth]);
	return;
}

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

	cin>>s;
	d=s%10,s/=10; ls[3]=d;
	c=s%10;s/=10;	ls[2]=c;
	b=s%10;s/=10; ls[1]=b;
	a=s;					ls[0]=a;

	dfs(1,a);

	return 0;
}


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

int main()
{
	int n;
	int cnt = 0;
	stack<int> car;
	vector<int> out;

	while (cin >> n){
		if (n == 0){
			out.push_back(cnt);
			out[cnt] = car.top(); // top pop
			car.pop();
			cnt++;
		}
		else {
			car.push(n);
		}
	}

	for (int i = 0; i < cnt; i++){
		cout << out[i] << endl;
	}

	return (0);
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    int Q;
    cin >> Q;
    rep(q, Q) {
        string S, T;
        cin >> S >> T;
        int s = S.size(), t = T.size();
        VV<int> dp(s + 1, V<int>(t + 1, 0));
        dp[0][0] = 0;
        rep(i, s) dp[i][0] = 0;
        rep(i, t) dp[0][i] = 0;

        rep2(i, 1, s + 1) rep2(j, 1, t + 1) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (S[i - 1] == T[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
        }
        cout << dp[s][t] << endl;
    }

    return 0;
}



Measured memory_bytes: 6928
n = int(input())
a = map(int, input().split())
num4 = 0
num1 = 0
for i in a:
    if i % 4 == 0:
        num4 += 1
        continue
    if i % 2 == 1:
        num1 += 1
if num4 >= num1 or num4 + 1 == num1 and (num4 + num1) % 2 == 1 and n - (num4 + num1) == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 11100
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	bool flag = false;
	for (int i = s.size() - 1; i >= 0; --i) {
		if (s[i] == t[t.size() - 1] || s[i] == '?') {
			if (i + 1 < t.size()) {
				continue;
			}
			flag = true;
			for (int j = t.size() - 1; j >= 0; --j) {
				if (s[i + j - t.size() + 1] != '?' && s[i + j - t.size() + 1] != t[j]) {
					flag = false;
					break;
				}
			}
			if (flag)for (int j = t.size() - 1; j >= 0; --j) {
				s[i + j - t.size() + 1] = t[j];
			}
			if (flag)break;
		}
	}
	if (flag) {
		for (int i = 0; i < s.size(); ++i) {
			if (s[i] == '?')s[i] = 'a';
		}
	}
	if (flag)cout << s << endl;
	else cout << "UNRESTORABLE" << endl;
	return 0;
}



Measured memory_bytes: 256
#あなたはプログラミングコンテストを開催するため問題を N 問作成しました。
#このうち i 問目をコンテストに出題する場合、配点は Pi 点となります。

#これらの問題を使って、以下の条件を満たすコンテストをできるだけ多く開催したいと思います。
#異なるコンテストの間で問題の重複があってはいけません。 最大で何回のコンテストを開催できますか。

#問題が 3 問出題され、1 問目の配点は A 点以下、2 問目の配点は A+1 点以上 B 点以下、3 問目の配点は B+1 点以上である。

N = int(input())

a = input().rstrip().split(" ")
A = int(a[0])
B = int(a[1])
#点数
P = input().rstrip().split(" ")

f = []
for i in range(len(P)):
    if int(P[i]) <= A:
        f.append(int(P[i]))
#print(f)
s = []
for i in range(len(P)):
    if int(P[i]) > A and int(P[i]) <= B:
        s.append(int(P[i]))
#print(s)
t = []
for i in range(len(P)):
    if int(P[i]) > B:
        t.append(int(P[i]))
#print(t)
sum = 0
if len(f) > len(s):
    if len(s) > len(t):
        sum = len(t)
    else:
        sum = len(s)
elif len(f) > len(t):
    sum = len(t)
else:
    sum = len(f)

print(sum)


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll d(ll a,ll b,bool dir,const vector<ll>& X,ll L){
  if(a==b)return 0;
  if(dir)swap(a,b);
  if(a<b) return X[b]-X[a];
  else return (L-X[a])+X[b];
}

ll med(ll a){
  if(a%2==1) return a/2;
  else return (a/2)-1;
}

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

  ll L,N;
  cin>>L>>N;

  vector<ll> X(N);
  rep(i,N)cin>>X[i];

  ll res=-1;
  rep(_,2){
    ll crt=X[0];
    ll p=0,l=1,r=N-1;
    repl(i,1,N){
      if(i%2==1){
        crt+=d(p,r,true,X,L); p=r; r--;
      }else{
        crt+=d(p,l,false,X,L); p=l; l++;
      }
    }
    ll prej=med(N);
    maxch(res,crt);
    repl(i,1,N){
      ll j=med(N-i)+i;
      if(prej==j) crt-=d(j+1,i-1,false,X,L);
      else crt-=d(j,i-1,false,X,L);
      crt+=d(i-1,j,false,X,L);
      maxch(res,crt);
      prej=j;
    }
    reverse(all(X));
    rep(i,N)X[i]=L-X[i];
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1920
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll i,j,n,m,a,b;
	cin>>n>>m>>a>>b;
	if(2*b>n||2*a>m){
		cout<<"-1";return 0;
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(i<b){
				if(j<a)cout<<"0";
				else cout<<"1";
			}else{
				if(j<a)cout<<"1";
				else cout<<"0";
			}
		}
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1280
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function hacking(s) {
    var ret="";
    for (var i=0; i < s.length; i++){
        if (s[i] == '0'){
            ret += '0';
        } else if (s[i] == '1'){
            ret += '1';
        } else if (s[i] == 'B' && ret.length > 0){
            ret = ret.substr(0, ret.length-1);
        }
    }
    return ret;
}

function main() {
    //var l = parseInt(readLine());
    var s = readLine();
    var result = hacking(s);
    process.stdout.write("" + result + "\n");
}


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


//0028
int main(){
	int x,max_freq=0;
	int digit[101]={0};
	

	while(cin >> x ){
		
		max_freq = max(max_freq, ++digit[x]);
		
	}
		for(int i=0; i<101; ++i){
			if(digit[i]==max_freq){
				cout << i << endl;
			}
		}


}

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

int n;
int A[500004];

int Merge(int lft, int mid, int rit){
  int res = 0;
  int n1 = mid - lft;
  int n2 = rit - mid;
  int L[n1 + 1], R[n2 + 1];

  for(int i = 0; i <= n1 - 1; i++){
    L[i] = A[lft + i];
  }
  for(int i = 0; i <= n2 - 1; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;

  int i = 0;
  int j = 0;
  for(int k = lft; k <= rit - 1; k++){
    res++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
    }
  }

  return res;
}

int MergeSort(int lft, int rit){
  int res = 0;

  if(lft + 1 < rit){
    int mid = (lft + rit) / 2;
    res += MergeSort(lft, mid);
    res += MergeSort(mid, rit);
    res += Merge(lft, mid, rit);
  }

  return res;
}

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

    int ans = MergeSort(0, n);

    for(int i = 0; i < n; i++){
      if(i != 0) cout << " ";
      cout << A[i];
    }
    cout << endl;
    cout << ans << endl;
  }
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
using namespace std;
int n ,suma;

int main() // OKKKKKKKKOOOOOOOOKKKKKKKKOOOOK
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    while (true)
    {
        int cant = 0;
        cin >> n >> suma;
        if (n == 0 && suma == 0) break;
        for (int a = 1 ; a <= n ;a++)
            for (int b = a+1 ; b <= n;b++)
                for (int c = b+1 ; c <= n ;c++)
                    if ((a+b+c) == suma)
                        if (a != b && a != c && b!= c)
                            cant++;
        cout << cant << endl;
    }
    return 0;
}



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

int main(void) {
  ll A, B;
  string S;
  cin >> A >> B >> S;

  bool f = true;
  REP(i, 0, A) f = f && ('0' <= S[i] && S[i] <= '9');
  f = f && S[A] == '-';
  REP(i, 0, B) f = f && ('0' <= S[i + A + 1] && S[i + A + 1] <= '9');

  cout << (f ? "Yes" : "No") << endl;
}


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

int main() {
  int N;
  cin >> N;
  int p = 0, w = 0, g = 0, y = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "P")
      p++;
    if (s == "W")
      w++;
    if (s == "G")
      g++;
    if (s == "Y")
      y++;
  }
  int ans = 0;
  if (p > 0)
    ans++;
  if (w > 0)
    ans++;
  if (g > 0)
    ans++;
  if (y > 0)
    ans++;
  if (ans == 3)
    cout << "Three";
  if (ans == 4)
    cout << "Four";
}

Measured memory_bytes: 3556
import math
N = int(input())
N_kaizyo = math.factorial(N)
sosuu_list = []
count = 1
ans = 1
def check_sosuu(x):
    i = math.floor(math.sqrt(x))
    for j in range(2,i + 1):
        if (x % j == 0):
            return False

    return True

for i in range(2, N + 1):
    if (check_sosuu(i)):
        sosuu_list.append(i)

for sosuu in sosuu_list:
    while N_kaizyo % sosuu == 0:
        N_kaizyo //= sosuu
        count += 1
    ans *= count
    count = 1

print(ans%(10 ** 9 + 7))


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[100005], b[100005], c[100005];
ll dp[100005][5];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cin >> b[i];
		cin >> c[i];
	}
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];

	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	int max =-1e5;
	for (int i = 0; i < 3; i++) {
		if (max < dp[n - 1][i]) {
			max = dp[n - 1][i];
		}
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans;
int main(void){
    cin>>n;
    for(ll i=1LL;i*i<n;i++){
        if(n%i==0){
            if(n%(n/i-1)==n/(n/i-1))ans+=n/i-1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

with sys.stdin as f:
    s_input = f.read()

    in_list = s_input.splitlines()
    n = int(in_list[0])
    a = in_list[1].split()
    a = [int(i) for i in a]

    a.sort(reverse=True)

    sc_a = 0
    sc_b = 0
    for alc in a[0::2]:
        sc_a += alc

    for bob in a[1::2]:
        sc_b += bob

    print(sc_a - sc_b)
        
sys.exit(0)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int f1[100005],g1[100005],f2[100005],g2[100005];
int n,a[100005],maxx[25][100005],lg2[100005];
ll ans;
int ask(int l,int r)
{
	if(l>r)return 0;
	int d=lg2[r-l+1];
	return max(maxx[d][l],maxx[d][r-(1<<d)+1]);
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)lg2[i]=lg2[i>>1]+1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		maxx[0][i]=a[i];
	}
	for(int i=1;i<=lg2[n];i++)
	  for(int j=1;j<=n;j++)
	    maxx[i][j]=max(maxx[i-1][j],maxx[i-1][j+(1<<(i-1))]);
	for(int i=1;i<=n;i++)
	{
		f1[i]=i-1;
		while(a[f1[i]]<a[i]&&f1[i])f1[i]=f1[f1[i]];
	}
	for(int i=n;i>=1;i--)
	{
		g1[i]=i+1;
		while(a[g1[i]]<a[i]&&g1[i]<=n)g1[i]=g1[g1[i]];
	}
	for(int i=1;i<=n;i++)
	{
		int l=1,r=f1[i]-1;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(ask(mid,f1[i]-1)>a[i])l=mid+1;
			else r=mid-1;
		}
		f2[i]=r;
		f2[i]=max(f2[i],0);
		l=g1[i]+1,r=n;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(ask(g1[i]+1,mid)>a[i])r=mid-1;
			else l=mid+1;
		}
		g2[i]=l;
		g2[i]=min(g2[i],n+1);
		ans+=1ll*a[i]*(1ll*(i-f1[i])*(g2[i]-g1[i])+1ll*(f1[i]-f2[i])*(g1[i]-i));
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int N, max,
      sum = 1,
      ans = 0,
      ss = 0;
  cin >> N;
  max = N;
  vector<string> s(N);
  vector<int> a(N);
  while (sum >= -1) {
    for (int i = 0; i < max; i++) {
      string str;
      cin >> str;
      int j;
      for (j = 0; j < ss; j++) {
        if (s.at(j) == str) {
          a.at(j) += sum;
          break;
        }
      }
      if (sum == 1) {
        if (j == ss) {
          s.at(j) = str;
          ss++;
          a.at(j)++;
        }
      }
    }
    if (sum == 1) {
      cin >> max;
    }
    sum -= 2;
  }
  for (int i = 0; i < ss; i++) {
    if (ans < a.at(i)) {
      ans = a.at(i);
    }
  }
  cout << ans << endl;
}


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

int main(void){
    int N, M, H[100100] , A ,B;
    int i, j , k[100100]={} ,sum=0 ;
    int Am[100100]={}, Bm[100100]={};

    scanf("%d%d" ,&N ,&M);
    for( i= 1 ; i<=N ; i++){
        scanf("%d" ,&H[i]);
    };

    for( j=1 ; j<=M ; j++){
        scanf("%d%d" ,&A ,&B);
        if(H[A]>=H[B]){
            k[B]=1;
        };
        if(H[B]>=H[A]){
            k[A]=1;
        }
    };

    for(i=1 ;i<=N ; i++){
        if(k[i]){}else{
            sum++;
        };
    };
    printf("%d", sum);

    return 0;
}


Measured memory_bytes: 2520
#include <iostream>

using namespace std;

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

  int a_sum=0;
  for (int i = 0; i < N; ++i)
  {
    int a;
    cin >> a;
    a_sum += a - 1;
  } 

  cout << a_sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string S;

int main() {
  INCANT;
  cin >> S;
  string T = "";
  for (int i=0; i<=S.size()-1; i+=2) T+=S[i];
  cout << T << "\n";
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;



int main() {
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	for (int i = 0; i < 5; ++i) {
		if (a[i] == 0) {
			cout << i+1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3672
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  lli N, K;
  cin >> N >> K;
  N %= K;
  cout << min(N, K - N) << endl;
  return 0;
}


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

typedef long long ll;
ll n, m, v, la, st, cnt, e, w, po, w2, a[100005], s[100005];
int main()
{
	ll i, j;
	cin >> n >> m >> v >> la;
	for (i = 1; i <= n; i++) {
		scanf ("%lld", &a[i]);
	}
	sort(a + 1, a + n + 1);
	st = n - la + 1;
	for (i = st; i >= 1; i--) {
		s[i]= s[i + 1] + a[i];
	}
	for (i = 1; i <= n; i++) {
		if (i >= st) cnt++;
		else {
			e = a[i] + m;
			if (e >= a[st]) {
				w = e * (st - i) - (s[i + 1]);
				po = (la - 1) + i;
				w2 = max(m * (v - po), 0ll);
				if (w >= w2) cnt++;
			}
		}
	}
	cout << cnt << endl;
    return 0;
}


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

int main (){
  ll n; cin >> n;
  for(int i=1;i<10;i++){
      if(n % i == 0 && n/i <10){
           cout << "Yes" << endl;
           return 0;
      }
  }
  cout << "No" << endl;

}

Measured memory_bytes: 256