akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<iostream>
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;

int main(void)
{
    IOS
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    a--;b--;c--;d--;
    string s;
    cin >> s;

    int st = 0;
    int dt = 0;
    int dtmp = 0;
    int e = max(c,d);
    FOR(i,a,e) {
        if (((i > a) || (i+1 < c)) && ((i > b) || (i+1 < d))) {
            if ((s[i] == '#')  && (s[i+1] == '#')){
                cout << "No" << endl;
                return 0;
            }
        }
        if ((i >= b) && (i <= d)) {
            if ((s[i-1] == '.') && (s[i] == '.') && (s[i+1] == '.')) {
                dt =1;
            }
        }
    }

    if ((c < d) || (dt > 0)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a[] = sc.next().split("");
		String b[] = sc.next().split("");
		
		int cnt = 0;
		for (int i = 0 ; i < a.length ; i++) {
			if(a[i].equals(b[i])) {
				cnt++;
			}
		}
		
		System.out.println(cnt);

	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<s.size();i++)
	{ 
		s[i]= s[i]+n;
		{if(s[i]>90)
			s[i]=s[i]-26;
		}
	}
	for(int i=0;i<s.size();i++)
		cout<<s[i];
	return 0;
}


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

ans = [sum(A)//2 - sum([A[i] for i in range(1,N,2)])]

for i in range(N-1):
    ans.append(A[i] - ans[-1])

for x in ans:
    print(2*x, end=" ")
print("")

Measured memory_bytes: 20616
object Main {
  def main(args: Array[String]): Unit = {
    def toYen(inputs: String): Double = {
      val Seq(x, u) = inputs.split(" ").toSeq

      if (u == "JPY") x.toDouble
      else x.toDouble * 380000.0
    }

    val n = io.StdIn.readInt()

    val total = Iterator.continually(io.StdIn.readLine())
      .take(n)
      .map(inputs => toYen(inputs))
      .sum

    println(total)
  }
}


Measured memory_bytes: 25416
#include<iostream>
#include<cstdio>
#include<cmath>
#include<bitset>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> list;

int main(){
  int n;
  while(cin>>n,n!=0){
    list.clear();
    for(int i=0;i<n;i++){
      int tmp;
      cin>>tmp;
      list.push_back(tmp);
    }
    sort(list.begin(),list.end());
    long long ans=0;
    long long pre=0;
    for(int i=0;i<n;i++){
      ans+=pre;
      pre=pre+list[i];
    }
    cout<<ans<<endl;
  }
}

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

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  const int p=1000;
  sx+=p; sy+=p; tx+=p; ty+=p;
  char U='U',D='D',L='L',R='R';
  string s1="",s2="",s3="L",s4="R",ans="";
  for(int i=0;i<ty-sy;++i){
    s1+=U; s2+=D; s3+=U; s4+=D;
  }
  s3+=U; s4+=D;
  for(int i=0;i<tx-sx;++i){
    s1+=R; s2+=L; s3+=R; s4+=L;
  }
  s3+=R; s3+=D; s4+=L; s4+=U; 
  ans+=s1+s2+s3+s4;
  cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        
        // 1.値を次のルールで集合に追加する。
        // rule: 自分より小さい値がいれば、自分に最も近い値を自分に書き換える。
        //       いない場合は、誰も書き換えず自分を追加する。
        // 2.「1」を計n回繰り返す。
        // 3.集合のサイズを出力する。
        // ex. {2, 1, 4, 5, 3} =>
        // {2} -> {1,2} -> {1,4} -> {1,5} -> {3,5} ans = 2;
        
        while (n-- > 0) {
            int num = sc.nextInt();
            
            if (map.lowerKey(num) == null) {
                int val = map.getOrDefault(num, 0);
                map.put(num, ++val);
            } else {
                int key = map.lowerKey(num);
                int val = map.get(key);
                if (val == 1) {
                    map.remove(key);
                } else {
                    map.put(key, --val);
                }
                val = map.getOrDefault(num, 0);
                map.put(num, ++val);
            }
        }
        
        int ans = 0;
        for (Integer key : map.keySet()) {
            int val = map.get(key);
            ans += val;
        }
        System.out.println(ans);
    }
}

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

#define N 100005
#define lgN 18
#define LL long long int
const int MOD = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	if (k <= (n + 1)/2) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll Abs(ll x,ll y){
    if(x>=y)return x-y;
    else return y-x;
}

int main(void){
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b)cout<<0<<endl;
    else{
        if(a==b)cout<<1<<endl;
        else{
            if(n==1)cout<<0<<endl;
            else{
                cout<<(n-2)*(b-a)+1<<endl;
            }
        }
    }
    return 0;
}



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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")


ll gcd(ll a, ll b) {
	if (a < b) gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}


signed main() {

	int N;
	cin >> N;
	vector<P> AB(N);
	rep(i, N) cin >> AB[i].first >> AB[i].second;
	sort(AB.begin(), AB.end(), [](P & a, P & b) {return a.second < b.second; });

	int remain = 0;
	rep(i, N) {
		if (i == 0) remain = AB[i].second;
		else
			remain += AB[i].second - AB[i - 1].second;
		remain -= AB[i].first;
		if (remain < 0) {
			No;
			return 0;
		}
	}
	Yes;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
 

 
int main() {
    ll n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    ll ans=0;
    bool a[n];//true win
    rep(i,n){
        if(i>=k){
            if(t[i]=='r'){
                if(t[i-k]=='r' && a[i-k]==true){
                    a[i]=false;
                }
                else{
                    ans+=p;
                    a[i]=true;
                }
                
            }
            else if(t[i]=='s'){
                if(t[i-k]=='s' && a[i-k]==true){
                    a[i]=false;
                }
                else{
                    ans+=r;
                    a[i]=true;
                }
            }
            else{
                if(t[i-k]=='p' && a[i-k]==true){
                    a[i]=false;
                }
                else{
                    ans+=s;
                    a[i]=true;
                }
                
            }
        }
        else{
            if(t[i]=='r'){
                ans+=p;
                a[i]=true;
            }
            else if(t[i]=='s'){
                ans+=r;
                a[i]=true;
            }
            else{
                ans+=s;
                a[i]=true;
            }
        }
    }
    cout << ans << endl;
}



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

int N, A;

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

int main() {
	cin >> N >> A;
	int ans = A;

	for (int i = 1; i < N; i++) {
		cin >> A;
		ans = gcd(ans, A);
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

ll f(ll n) {
    ll ans = 0;
    rep(i, 40) {
        ll cnt = (n + 1) / (1LL << (i + 1)) * (1LL << i);
        cnt += max(0LL, (n + 1) % (1LL << (i + 1)) - (1LL << i));
        if (cnt % 2 == 1) ans += (1LL << i);
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    cout << (f(b) ^ f(a - 1)) << endl;
    return 0;
}


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

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

  rep(i, max(a, b)){
    cout << min(a,b);
  }

  cout <<  endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    System.out.println((b-a)==(c-b) ? "YES" : "NO");
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <queue>
#include <map>
#include <deque>
#include <algorithm>
#include <set>
#include <string>
#include <math.h>
#include <stdio.h>
#include<iomanip>



#define ll long long
using namespace std;


ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;

    return n * factorial(n - 1);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, w;
    cin >> n >> w;
    ll sz = 0;
    ll arr[n][2];

    for (ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < 2; j++)
        {
            cin >> arr[i][j];

        }
        sz += arr[i][1];
    }
    ll dp[2][sz + 1];
    for (ll i = 0; i <= sz; i++)
        dp[0][i] = 1e10;

    dp[0][0] = 0;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 0; j <= sz; j++)
            dp[i%2][j] = 1e10;

        for (ll j = 0; j <= sz; j++)
        {
            dp[i%2][j] = min(dp[(i - 1)%2][j], dp[i%2][j]);
            if (j - arr[i - 1][1] >= 0)
                dp[i%2][j] = min(dp[(i - 1)%2][j - arr[i - 1][1]] + arr[i - 1][0], dp[i%2][j]);
        }
    }
    ll ans = 0;
    ll larg = 0;
    for (int i = 0; i <= sz; i++)
    {
        if (dp[n%2][i] <= w){
            ans = i;
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 1792
a = gets.chomp
n = gets.to_i
isReverse = false
l = ""
r = ""

n.times do |i|
    arr = gets.chomp.split(" ")
    if arr[0]=="1" 
        isReverse = !isReverse
        next
    else
        if (arr[1]=="1" && !isReverse)||(arr[1]=="2" && isReverse)
            l.concat(arr[2])
            next
        else
            r.concat(arr[2])
            next
        end
    end
end

ans = l.reverse + a + r

ans.reverse! if isReverse

puts ans

Measured memory_bytes: 3196
(defun attack (a b c d &optional (turn 'takahashi))
  (cond ((<= a 0)
         "No")
        ((<= c 0)
         "Yes")
        ((eq turn 'takahashi)
         (attack a b (- c b) d 'aoki))
        ((eq turn 'aoki)
         (attack (- a d) b c d 'takahashi))))

(princ (attack (read) (read) (read) (read)))

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int main(){
    int x, ans = 0;
    scanf("%d", &x);
    for(ans=1;;ans++){
        x -= ans;
        if(x <= 0) break;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    s = input().rstrip('\n')
    t = input().rstrip('\n')
    import fractions
    lcm = n * m // fractions.gcd(n, m)
    for i in range(0, n * m, lcm):
        if s[i // m] != t[i // n]:
            print(-1)
            exit()
    print(lcm)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64492
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int,int> PII;
#define fi first
#define se second
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout << a * b << endl;
    return 0;
}



Measured memory_bytes: 3196
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[map(int,input().split()) for _ in range(n)]
ans=0
for x in a:
  ans+=(1 if sum(map(lambda y,z:y*z,x,b))>-c else 0)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

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

	vector<vector<LL>> v(N, vector<LL>(N));
	vector<vector<bool>> b(N, vector<bool>(N, false));

	LL sum = 0;

	REP(i, N) {
		REP(j, N) {
			cin >> v[i][j];
			if (i > j) { sum += v[i][j]; }
		}
	}

	bool flag = false;

	REP(i, N) {
		REP(j, N) {
			REP(k, N) {
				if (v[j][k] > v[j][i] + v[i][k]) {
					flag = true;
				}
			}
		}
	}

	if (flag) {
		cout << -1 << endl;
	}
	else {
		REP(j, N) {
			REP(k, N) {
				REP(i, N) {
					if (i != j&&j != k&&k != i) {
						if (v[j][k] == v[j][i] + v[i][k]) {
							if (!b[j][k] && !b[k][j]) {
								b[j][k] = true;
								b[k][j] = true;
								sum -= v[j][k];
								break;
							}
						}
					}
				}
			}
		}
		cout << sum << endl;
	}

}

Measured memory_bytes: 1024
n = int(input())
dictionary = {}

for _ in range(n):
    s = input()
    if s in dictionary.keys():
        dictionary[s] = dictionary[s] + 1
    else:
        dictionary[s] = 1


lst = []

for e in dictionary.items():
    lst.append(list(e))

lst.sort(key=lambda x: (-x[1],x[0]))

memo = lst[0][1]
for key,value in lst:
    if value == memo:
        print(key)
    else:
        break

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

typedef long long ll;

typedef pair<ll, int> p;

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

    int H, W;
    cin >> H >> W;

    vector<string> a(H);

    for(int i = 0; i < H; i++) cin >> a[i];

    for(int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    cout << endl;

    for(int i = 0; i < H; i++) {
        cout << "#";
        cout << a[i];
        cout << "#" << endl;
    }

    for(int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    cout << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

a_set=set()

for index in range(m):
    a_set.add(int(input()))

ans_list = []

ans_list = [0] * (n + 1)

for index in range(n + 1):
    if index == 0:
        ans_list[index] += 1
        continue
    if index == 1 and (index not in a_set):
        ans_list[index] += ans_list[index - 1]
        continue
    
    if index not in a_set:
        if (index - 1) not in a_set:
            ans_list[index] += ans_list[index - 1]
            ans_list[index] %= 1000000007
        if (index - 2) not in a_set:
            ans_list[index] += ans_list[index - 2]
            ans_list[index] %= 1000000007

print(ans_list[n])


Measured memory_bytes: 11884
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
T = 1000000000

for i in range(n):
    if T >= abs((t - H[i] * 0.006) - a):
        T = abs((t - H[i] * 0.006) - a)
        ans = i + 1

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){

int i;
long k,a,b;
long ans=1;

scanf("%ld %ld %ld",&k,&a,&b);

if(b<a+3) ans += k;

else{
ans += a-1;
ans += (b-a)*((k-a+1)/2);

if((k-a)%2==0) ans++;

}


printf("%ld\n",ans);



  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(void){
  
  int a,b,i,A=0,B=0;
  scanf("%d %d",&a,&b);
  if(a>b) {
  for(i=a;i>0;i--){
    B+=b*pow(10,i-1);
  }
    printf("%d",B);
  }
  else if(a<b){
  for(i=b;i>0;i--){
    A+=a*pow(10,i-1);
  }
    printf("%d",A);
  }
  
  else{ for(i=b;i>0;i--){
    A+=a*pow(10,i-1);
  }
    printf("%d",A);
      }
    
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int A;
  	int B;
  	int C;
  	int D;
  	int Sum1; /* 1つ目の長方形の面積 */
  	int Sum2; /* 2つ目の長方形の面積*/
  
  	cin >> A >> B >> C >> D;
  	Sum1 = A * B;
  	Sum2 = C * D;
  	
  	cout << max(Sum1,Sum2) << endl;
  }

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

using namespace std;

typedef long long ll;

#define mod 1000000007
#define siz 100001

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n;
	cin >> n;
	
	vector<ll> v(n);
	
	ll yen = 1000;
	
	for(ll i = 0; i < n; i++) cin >> v[i];
	v.push_back(0);
	
	vector<ll> p;
	
	for(int i = 0; i < n; i++){
	    p.push_back(v[i]);
	
	    if(v[i] <= v[i+1]){
	      
	    }else {
	    	ll b = yen/p.front();
		    yen -= b*p.front();
		    yen += b*p.back();
		    p.clear();
		}
	}

  	cout<< yen <<"\n";
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n;
	cin >> n;
	vi c(n), v(n);
	rep(i, n) cin >> c[i];
	rep(i, n) cin >> v[i];

	int ans = 0;
	rep(i, n)
	{
		if(c[i] > v[i])
			ans += (c[i] - v[i]);
	}

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

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

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

    vector<long long> v(N);
    map<long long,long long> mp;

    for(auto& x:v){
        cin>>x;
    }

    mp[0]++;
    mp[v[0]]++;
    for(long i=1;i<N;++i){
        v[i]+=v[i-1];
        mp[v[i]]++;
    }
    long long ans=0;

    for(auto itr : mp){
        ans += itr.second * (itr.second - 1) / 2;
    }

    cout<<ans<<endl;

}




Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;

class Graph {
    int n;
    vector<vector<pair<int, double>>> adj;
    vector<double> d;
    vector<double> de;
    bool negLoop = false;

public:
    Graph(int n) {
        this->n = n;
        adj = vector<vector<pair<int, double>>>(n, vector<pair<int, double>>());
    }
    void addArc(int a, int b, double w) {
        adj[a].push_back(make_pair(b, w));
    }

    void addEdge(int a, int b, double w) {
        adj[a].push_back(make_pair(b, w));
        adj[b].push_back(make_pair(a, w));
    }

    void bf(int a) {
        d = vector<double>(n, INF);
        de = vector<double>(n);
        d[a] = 0;
        vector<pair<P, double>> edges;
        REP(i,n) {
            for (auto j: adj[i]) {
                edges.push_back(make_pair(P(i,j.first), j.second));
            }
        }
        int loopcnt = 0;
        while (1) {
            loopcnt++;
            bool update = false;
            for (auto e: edges) {
                if (d[e.first.first] != INF && d[e.first.second] > d[e.first.first] + e.second) {
                    if (loopcnt < n) de[e.first.second] = d[e.first.first] + e.second;
                    d[e.first.second] = d[e.first.first] + e.second;
                    update = true;
                }
            }
            if (!update) break;
            if (loopcnt == 2 * n) {
                negLoop = true;
                break;
            }
        }
    }

    bool hasNegLoop() {
        return negLoop;
    }

    bool hasNegLoop(int a) {
        return d[a] != de[a];
    }

    void dijkstra(int a) {
        d = vector<double>(n, INF);
        d[a] = 0;
        priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> q;
        q.push(make_pair(0, a));

        while (!q.empty()) {
            int u = q.top().second;
            q.pop();

            for (auto i: adj[u]) {
                if (d[i.first] > d[u] + i.second) {
                    d[i.first] = d[u] + i.second;
                    q.push(make_pair(d[i.first], i.first));
                }
            }
        }
    }

    double dist(int a) {
        return d[a];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    Graph g(n);
    int a, b, c;
    REP(i,m) {
        cin >> a >> b >> c;
        a--;
        b--;
        g.addArc(a, b, -c);
    }
    g.bf(0);
    if (g.hasNegLoop(n-1)) {
        cout << "inf" << endl;
        return 0;
    }
    cout << -long(g.dist(n-1)) << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 100

void swapper(int *m, int *n) {

    int buf = 0;

    buf = *m;
    *m = *n;
    *n = buf;

}

int main(void) {

    int i, n;
    int a[N];

    for (i = 0; i < N; i++) {
        a[i] = 0;
    }

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    if (n % 2 == 1) {
        for (i = 0; i < (n - 1)/2; i++) {
            swapper(&a[i], &a[n - 1 - i]);
        }
    } else {
        for (i = 0; i < n/2; i++) {
            swapper(&a[i], &a[n - 1 - i]);
        }
    }

    for (i = 0; i < n; i++) {
        if (i == 0) {
            printf("%d", a[i]);
        } else {
            printf(" %d", a[i]);
        }
    }
    printf("\n");

    return 0;

}

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

int main() {
	int n, m, x, stage[100], Ai, asc = 0, desc = 0;
	cin >> n >> m >> x;

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

	for (int i = 1; i <= m; i++) {
		cin >> Ai;
		stage[Ai]++;
	}
	
	for (int i = x; i > 0; i--) {
		asc += stage[i];
	}

	for (int i = x; i < n; i++) {
		desc += stage[i];
	}
	
	if (asc < desc) {
		cout << asc;
	}
	else {
		cout << desc;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
char s[MAXN];
int boom[MAXN];
int from[MAXN];
int dp[MAXN];

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    scanf("%s", s);
    for (int i = 0; i <= N; i++) {
        if (s[i] == '1') boom[i] = 1;
    }
    deque<int> dq;
    dp[N] = 0;
    dq.push_front(N);
    for (int i = N - 1; i >= 0; i--) {
        while (!dq.empty() && dq.front() - i > M) dq.pop_front();
        if (boom[i]) {
           dp[i] = MAXN;
           continue;
        }
        if (!dq.empty()) {
           int cur = dp[dq.front()] + 1;
           from[i] = dq.front();
           dp[i] = cur;
           while (!dq.empty() && dp[dq.back()] == cur) dq.pop_back();
           dq.push_back(i);
        } else dp[i] = MAXN;
    }
    if (dp[0] == MAXN) return !printf("-1\n");
    int cur = 0;
    while (cur != N) {
          int to = from[cur];
          printf("%d ", to - cur);
          cur = to;
    }
    puts("");

    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());
const int N = 666666;
int n,ans[N];Vi e[N],a[2],b[3];
void dfs(int u, int fa, int d)
{
	a[d].pb(u);
	for(int v:e[u])if(v!=fa)
		dfs(v,u,d^1);
}
void put(Vi &a, Vi b){
	for(int x:b)ans[a.back()]=x,a.pop_back();
}
void solve(Vi a){
	rep(i,1,n)if(!ans[i])ans[i]=a.back(),a.pop_back();
}
void print(){
	rep(i,1,n)printf("%d ",ans[i]);exit(0);
}
int main() {
	read(n);rep(i,1,n-1){
		int u,v;read(u);read(v);e[u].pb(v);e[v].pb(u);
	}
	rep(i,1,n)b[i%3].pb(i);
	dfs(1,0,0);
	if(SZ(a[1])>SZ(a[0]))swap(a[0],a[1]);
	if(SZ(a[0])>=SZ(b[1])+SZ(b[2])){
		put(a[0],b[1]);put(a[0],b[2]);
		solve(b[0]);print();
		return 0;
	}
	put(a[0],b[1]);put(a[1],b[2]);
	solve(b[0]);print();
	return 0;
}


Measured memory_bytes: 33304
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <set>
#include <map>
#include <utility>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> A(N), B(N), C(N-1);
  for (auto& ai: A) scanf("%d", &ai), --ai;
  for (auto& bi: B) scanf("%d", &bi);
  for (auto& ci: C) scanf("%d", &ci);

  int res = 0;
  for (size_t i = 0; i < N; ++i) {
    res += B[i];
    if (i > 0) {
      if (A[i-1]+1 == A[i]) {
        res += C[A[i-1]];
      }
    }
  }
  printf("%d\n", res);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
	int a,b;
	char s[15]={};
	bool flag=1;
	cin>>a>>b;
	getchar();
	for(int i=1;i<=a+b+1;i++){
		s[i]=getchar();
	}
	for(int i=1;i<=a+b+1;i++){
		if(i==a+1){
			if(s[i]!='-'){
				flag=0;
			}
		}else{
			if(s[i]<'0'||s[i]>'9'){
				flag=0;
			}
		}
	}
	if(flag==1){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}


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

def bubbleSort(A, N):
    cnt = 0
    flag = 1
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
                flag = 1
                cnt += 1
    return(A, cnt)

out_A, cnt_sort = bubbleSort(A,N)

out_A_str = list(map(str, out_A))
print(" ".join(out_A_str))
print(str(cnt_sort))



Measured memory_bytes: 5600
#pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma") 
 
#include<bits/stdc++.h>
 
#define CFOR(i, str) for(int i = 0; (str)[i]!='\0'; (i)++)
#define FOR(i, s, r) for(int i = (s); i < (r); i++)
#define INF 1e9
#define NINF -1e9
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.rbegin(), v.rend())
#define vmax(v) *max_element(v.begin(), v.end())
#define vmin(v) *min_element(v.begin(), v.end())
#define cnt(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); //+ve = right, -ve = left
#define lld long long int
#define ulld unsigned long long int
typedef long long ll;
using namespace std;
 
ll binpow(ll a, ll b) { 
ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res;
}
 
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
 
bool isPrime(ll n) { 
    if (n <= 1) return false; 
    if (n <= 3) return true; 
    if (n % 2 == 0 || n % 3 == 0) return false; 
    for (ll i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; 
    return true; 
}
void solve(){
      char n,m;
	  cin>>n>>m;
	  if(n>m)
	  {
		  char temp=n;
		  n=m;
		  m=temp;
	  }
	  for(int i=0;i<m-'0';i++)
	  {
		  cout<<n;
	  }
}
int main(){
   ios::sync_with_stdio(0);
   cin.tie(0);
   ll t;
   t=1;
   while(t--)
   { 
   solve();
   }
   return 0;
}

Measured memory_bytes: 3524
package main

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

func main(){
  var sc = bufio.NewScanner(os.Stdin)
  sc.Scan()
  num_str := sc.Text()
  numstr := strings.Split(num_str, " ")
  A, _ := strconv.Atoi(numstr[0])
  B, _ := strconv.Atoi(numstr[1])
  num_plus := A + B
  num_sub := A - B
  num_nul := A * B
  
  num_maxs := []int{num_plus,num_sub,num_nul}
  sort.Ints(num_maxs)
  fmt.Println(num_maxs[2])
}

Measured memory_bytes: 640
S=input()
T=input()
S=list(S)
T=list(T)
flag=0
k=0
p=100
for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j]!=T[j] and S[i+j]!='?':
            k=1
    if k==0:
        flag=1
        p=i
    k=0
if flag==0:
    print('UNRESTORABLE')
else:
    for i in range(len(S)):
        if i==p:
            for j in range(len(T)):
                S[i+j]=T[j]
            i+=len(T)
        else:
            if S[i]=='?':
                S[i]='a'
    S="".join(S)
    print(S)





Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int main(){
  double d, t, x, y, n;
  x = y  = 0;
  n = 90;
  while(scanf("%lf,%lf", &d, &t) && (d || t)){
    y += d * sin(n * M_PI / 180);
    x += d * cos(n * M_PI / 180);
    n -= t;

  }
  printf("%d\n%d\n", (int)x, (int)y);
  return 0;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while (cin >> n){
		int c = 0;
		for (int i=0;i<=9;i++){
			for (int j=0;j<=9;j++){
				for (int k=0;k<=9;k++){
					for (int l=0;l<=9;l++){
						if (i+j+k+l == n){
							c++;
						}
					}
				}
			}
		}
		cout << c << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
import scala.io.StdIn
import java.io.{BufferedReader,InputStreamReader}

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val Array(n, t) = in.readLine.split(" ").map(_.toInt)
  val a = in.readLine.split(" ").map(_.toInt)

  val ans = a./:(t.toLong,0)((acc,ti) => {
    val dur = ti - acc._2
    if(dur < t) (acc._1 + dur, ti)
    else (acc._1 + t, ti)
  })._1

  println(ans)
}

Measured memory_bytes: 52776
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 110000
int N, Q;
string S;
int l[Max];
int r[Max];
int sum[Max];

int main(int argc, const char * argv[]) {
    cin >> N >> Q >> S;
    rep(i, Q) {
        l[i] = inputValue();
        r[i] = inputValue();
    }

    sum[0] = 0;
    repd(i, 1, N) {
        sum[i] = sum[i-1] + ((S[i] == 'C' && S[i-1] == 'A') ? 1 : 0);
    }

    rep(i, Q) {
        output(sum[r[i] - 1] - sum[l[i] - 1]);
    }

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long lll;
lll cel(lll a,lll b)
{
    return a/b+(bool)(a%b);
}
lll gcd(lll a,lll b)
{
    return b?gcd(b,a%b):a;
}
int main()
{
    lll t,a,b,c,d;
    for(scanf("%lld",&t); t--;)
    {
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d),a-=b;
        if(a<0||d<b) printf("No\n");
        else if(b<=c) printf("Yes\n");
        else if(!(d%=b)) printf(c<a%b?"No\n":"Yes\n");
        else if((a-=b*cel(max(0LL,a-c),b))<0) printf("No\n");
        else d=gcd(d,b),a+=d*cel(c+1-a,d),printf(a<b?"No\n":"Yes\n");
    }
    exit(0);
}

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

#define ll long long
using namespace std;

const int N = 105, K = 1e5 + 5;
int n, k, a[N], dp[K];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 1; i <= k; i++) {
        for(int j = 0; j < n; j++) {
            if(i - a[j] >= 0 && dp[i - a[j]] == 0) {
                dp[i] = 1;
            }
        }
    }
    cout << (dp[k] ? "First" : "Second") << endl;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
vector<vector<int>> conset;
int N,M,Q;

void dfs(int n, vector<int> v){
    if (n == N) {
        //DB(n);
        conset.push_back(v);
        return;
    }

    int last = 1;
    if (n >= 1){
        last = v[n-1];
    }

    for (size_t k = last; k <= M; k++) {
        vector<int> newv;
        newv = v;
        newv.push_back(k);
        dfs(n+1,newv);    
    }

    return;
}

int main() {
    cin >> N >> M >> Q;
    vector<int> v;
    dfs(0,v);

    int D = conset.size();
    int ans = 0;

    vector<int> a(Q),b(Q),c(Q),d(Q);
    REP(i,Q){
        int x1,x2,x3,x4;
        cin >> x1 >> x2 >> x3 >> x4;
        x1--; x2--;
        a[i] = x1;
        b[i] = x2;
        c[i] = x3;
        d[i] = x4;
    }

    REP(j,D){
        int nans = 0;
        REP(i,Q){
            if (conset[j][b[i]] - conset[j][a[i]] == c[i]) nans += d[i];
        }
        chmax(ans,nans);
    }


    cout << ans << endl;
}

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

const int mod = int(1E9+7);

int main(){
    int N;
    cin >> N;
    long int a=1;
    for (int i=1; i<N+1; i++){
        a = (a*i)%mod;
    }
    a = a%mod;
    cout << a << endl;
}

Measured memory_bytes: 256
def pff(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1: pf[m] = 1
    return pf
def examB():
    X = I()
    ans = 0
    for i in range(X,0,-1):
        cur = pff(i)
        flag = True
        now = 0
        for j in cur.values():
            if j==1:
                flag = False
            if now==0:
                now = j
            else:
                if now%j!=0 and j%now!=0:
                    flag = False
        if flag:
            ans = i
            break
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3444
/*只要保证这个颜色开始的第一个填在第一个空位上
之后的都随便填即可
所以方案数就是C(空格位置-1,数量-1),组合意义就是开始的第一个颜色只有一个位置能填*/
#include<bits/stdc++.h>
#define Mod 1000000007
#define N 2005
#define M N*N
using namespace std;
int n,K,dp[N][N],fac[M],inv[M];
inline int ksm(int x,int y){
	int ans1=1;while (y){
		if (y&1) ans1=1ll*ans1*x%Mod;
		y>>=1;x=1ll*x*x%Mod;
	}return ans1;
}
inline int C(int n,int m){return 1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod;}
int main(){
	scanf("%d%d",&n,&K);
	if (K==1) return puts("1"),0;dp[0][0]=1;
	fac[0]=1;for (int i=1;i<M;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	inv[M-1]=ksm(fac[M-1],Mod-2);
	for (int i=M-2;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
	for (int i=1;i<=n;i++){
		for (int j=0;j<=i;j++){
			if (i) dp[i][j]=1ll*(dp[i][j]+dp[i-1][j])%Mod;
			if (j) dp[i][j]=1ll*(1ll*dp[i][j-1]*C(n*K-i-(j-1)*(K-1)-1,K-2)%Mod+dp[i][j])%Mod;
		}
	}
	printf("%lld\n",1ll*dp[n][n]*fac[n]%Mod);
	return 0;
}

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

using namespace std;

int A, B;

int main () {

    cin >> A >> B;

    int product;
    if (A >= 1 && A <= 9 && B >= 1 && B <= 9){
        product = A * B;
        cout << product << "\n";
    } else {
        cout << -1 << "\n";
    }
    
    return 0;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val l = mutableListOf<Int>()
    var m = n
    var cur = 2L
    while (cur * cur <= n) {
        var cnt = 0
        while (m % cur == 0L) {
            m /= cur; cnt += 1
        }
        if (cnt > 0) l.add(cnt)
        cur += 1
    }
    if (m != 1L) l.add(1)
    println(l.map { calc(it) }.sum())
}

fun calc(n: Int): Int {
    var ans = 0
    while (((ans+1) * (ans + 2)) / 2 <= n) {
        ans += 1
    }
    return ans
}


Measured memory_bytes: 35528
#include <cstdio>
#include <iostream>
#include <bitset>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
 
using namespace std;
typedef long long ll;
 
#define ALL(obj) (obj).begin(), (obj).end() 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a), greater<int>());
    int i=0;
    while((i+1<n) && ( i < a[i+1] && a[i] > i+1) && a[i+1] != i+1){
        i++;
    }
    int u=0,r=0;
    while(((i+r+1) < n) &&  i < a[i+r+1] ){
        r++;
    }
    while(i+u+1 < a[i]){
        u++;
    }
 //cout << "i : " << i << " a[i+r+1] : " << a[i+r+1] << endl;
  // cout << "r%2 : " << r%2 << endl;
  //cout << "u%2 : " << u%2 << endl;
    if(r%2==1 && u%2==1) cout << "First" << endl;
    else if(r%2==1 && u%2==0) cout << "First" << endl;
    else if(r%2==0 && u%2==1) cout << "First" << endl;
    else if(r%2==0 && u%2==0) cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define INF 2e9

int d[310];
int idx[310];
int c(const void*p,const void*q){
	if(d[*(int*)p]<d[*(int*)q])return -1;
	return 1;
}
int ask(int v,int u){
	printf("? %d %d\n",v,u);
	fflush(0);
	int t;
	scanf("%d",&t);
	return t;
}
int main(){
	int n,s,g;
	scanf("%d%d%d",&n,&s,&g);
	for(int i=1;i<=n;i++){
		d[i]=INF;
		idx[i]=i;
	}
	int dist=ask(s,g);
	for(int i=1;i<=n;i++)if(i!=s&&i!=g){
		int temp1=ask(s,i);
		int temp2=ask(i,g);
		if(temp1+temp2==dist)d[i]=temp1;
	}
	qsort(idx+1,n,sizeof(int),c);
	
	int ans[310]={};
	int cnt=0;
	ans[cnt++]=s;
	for(int i=1;d[idx[i]]!=INF;i++){
		int temp1=ask(s,ans[cnt-1]);
		int temp2=ask(ans[cnt-1],idx[i]);
		if(temp1+temp2==d[idx[i]])ans[cnt++]=idx[i];
	}
	ans[cnt++]=g;
	printf("! ");
	for(int i=0;i<cnt;i++)printf("%d%c",ans[i],i==cnt-1?10:32);
	fflush(0);
}


Measured memory_bytes: 4684
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
void solve()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cout<<"ACL";
	cout<<endl;
}
signed main()
{
	int t=1; 
	while(t--)
		solve();
	return 0;
}



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

int main(void){
int m, n, x, y;

cin >> m >> n >> x >> y;

int xs[100],ys[100];

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

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

int maxx =-101;
int miny = 101;

for (int i =0;i< m ;i++){
if(maxx < xs[i]){
maxx = xs[i];
}
}

for (int i =0;i< n ;i++){
if(miny > ys[i]){
miny = ys[i];
}
}

string result = "War";

if(maxx < miny && maxx < y && miny > x){
result = "No War";
}

cout << result  << endl;
return 0;
}


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

string S;
int A[100005];

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

    int N, K;
    cin >> N >> K >> S;

    int curr = 0, M = 0;
    char prev = 'x';

    for(auto s : S)
    {
        if(s == prev)
            curr++;
        else
        {
            if(curr)
                A[++M] = curr;
            
            curr = 1, prev = s;
        }
    }

    A[++M] = curr;
    int ans = 0;

    for(int i=1; i<=M; i++)
        ans += A[i] - 1;

    K = min(K, M / 2);

    ans += K * 2;
    ans = min(ans, N - 1);

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);
int ctoi(const char);
int digit_sum(int);

// const
const int INF = 10000000;

/*MEMO
辞書順
abc < abcd, atcoder < atlas
*/

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

    int summation = 0;
    REPN(i, N) {
        int d_sum = digit_sum(i);
        if ((A <= d_sum) && (d_sum <= B)) {
            summation += i;
        }
    }
    cout << summation << endl;
    return 0;
}


// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    if (ch == '+') {
        REP(i, vec.size()) {
            vec.at(i) += num;
        }
    } else if (ch == '-') {
        REP(i, vec.size()) {
            vec.at(i) -= num;
        }
    } else if (ch == '*') {
        REP(i, vec.size()) {
            vec.at(i) *= num;
        }
    } else if (ch == '/'){
        REP(i, vec.size()) {
            vec.at(i) /= num;
        }
    } else if (ch == '%') {
        REP(i, vec.size()) {
            vec.at(i) %= num;
        }
    }
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、全てnumの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}

int ctoi(const char c) {
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

int digit_sum(int num) {
    string str = to_string(num);

    int sum = 0;
    REP(i, str.size()) {
        sum += ctoi(str.at(i));
    }
    return sum;
}


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

int main(){

  int N;
  cin >> N;
  vector<int> H(N);

  //旅館の数を入力
  for (int i =0; i < N; i++){
    cin >> H.at(i);
  }

  //海が見える旅館を数える
  int ans = 0;
  for(int i = 0; i < N; i++){
    bool hhh = true;
    for(int j = 0; j < i; j++){
      if(H.at(i) < H.at(j)){
        hhh = false;
        break;
      }
    }
    if(hhh){
      ++ans;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 201001;
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int x;
    cin >> x;
    int ans = (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans;
}


Measured memory_bytes: 256