akhauriyash/Code-Regression huggingface dataset:
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn

object Main extends App {

  final val nil = -1
  
  case class Node(var parent: Int = -1,var left: Int = -1, var right: Int = -1){
    
    def typeInfo: String = if(parent == -1) {
      "root"
    } else if(left == nil ) {
      "leaf"
    } else {
      "internal node"
    }
    
    def nodeLiteral(depth: Int, childs: Array[Int]): String = {
      s"parent = $parent, depth = $depth, $typeInfo, [${childs.mkString(", ")}]"
    }
    override def toString: String = s"parent = $parent, depth = X, $typeInfo, [child]"
    
  }
  
  def setDepth(index: Int, cnt: Int): Unit = {
    //println("setDepth:" + index)
    depth(index) = cnt
    if(input(index).right != nil){ // brother
      setDepth(input(index).right, cnt)
    }
    if(input(index).left != nil){ // child
      setDepth(input(index).left, cnt + 1)
    }
  }
  
  def getChild(index: Int): Array[Int] = {
    if(input(index).left == nil){
      Array.empty[Int]
    } else {
      var node = input(input(index).left)
      var ret = ArrayBuffer(input(index).left)
      while(node.right != nil){
        ret += node.right
        node = input(node.right)
      }
      ret.toArray
    }
  }
  
  val n = StdIn.readLine().trim.toInt
  val input = Array.fill[Node](n)(null)
  val depth = Array.fill[Int](n)(0)

  (0 until n).foreach{ _ =>
    val a = StdIn.readLine().trim.split(" ").map(_.toInt)
    val i = a(0)
    val c = a.drop(2)
    var before: Int = -1
    input(i) = if(input(i) == null) Node(nil, nil, nil) else input(i)
    c.zipWithIndex.foreach{ ci =>
      input(ci._1) = if(input(ci._1) == null) Node(i, nil, nil) else input(ci._1)
      
      if(ci._2 == 0) {
        input(i).left =  ci._1
      }
      
      if(before != nil){
        input(before).right = ci._1
      }
      before = ci._1
      input(ci._1).parent = i
    }
    
    
  }

  var root = nil
  (0 until n).foreach{ i =>
    //println(s"$i:" + input(i))
    if(input(i).parent == nil) root = i
  }
  
  setDepth(root, 0)
  
  (0 until n).foreach{ i =>
    val ch = getChild(i)
    println(s"node $i: " + input(i).nodeLiteral(depth(i), ch))
  }

}


Measured memory_bytes: 331152
#include "bits/stdc++.h"
using namespace std;

int n, k;

int main(){
	cin >> n >> k;
	int mdc;
	int maior = 0;
	for(int i = 1; i <= n; ++i){
		int a;
		cin >> a;
		maior = max(maior,a);
		if(i == 1) mdc = a;
		else mdc = __gcd(mdc,a);
	}
	if(k > maior) cout << "IMPOSSIBLE\n";
	else if(k % mdc != 0) cout << "IMPOSSIBLE\n";
	else cout << "POSSIBLE" << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	while(1){
		int n, i, j;
		int a[4], b[4];
		long c[4];
		
		scanf(" %d", &n);
		if(n==0) break;

		for(i=0; i<n; i++){
			for(j=0; j<4; j++)
				scanf(" %d", &a[j]);
			for(j=0; j<4; j++)
				scanf(" %d", &b[j]);
			
			c[0] = a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3];
			c[1] = a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2];
			c[2] = a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1];
			c[3] = a[0]*b[3] + a[1]*b[2] - a[2]*b[1] +a[3]*b[0];
				
			for(j=0; j<4; j++) {
				printf("%ld", c[j]);
				if(j<3) printf(" ");	
			}
			printf("\n");
		
		}

	}

	return 0;
}

Measured memory_bytes: 604
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, A: int, x: "List[int]"):
    dp = [[0] * (A * N + 1) for _ in range(N + 1)]
    dp[0][0] = 1
    for xi in x:
        for k in reversed(range(1, N + 1)):
            for j in range(xi, A * N + 1):
                if j >= xi:
                    dp[k][j] += dp[k - 1][j - xi]
    print(sum(dp[i][A * i] for i in range(1, N + 1)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    bool snuke[n]={false};
    int d,cnt;
    for(int i=0;i<k;i++)
    {
        cin>>d;
        for(int j=0;j<d;j++)
            {cin>>cnt;
              snuke[cnt-1]=true;  
            }
    }
    int s=0;
    for(int k=0;k<n;k++)
    {
        if(!snuke[k])
            s++;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3548
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
 
using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  3e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;
 
ll test = 1, n , ans[N], p2[N];
string x;
 
void calc(ll f, ll mod){
	p2[0] = 1;
	for(int i = 1; i <= n; i++) p2[i] = (2*p2[i-1])%mod;
	ll res = 0;
	for(int i = 0; i < n; i++){
		if(x[i] == '1') res = (res+p2[i])%mod;
	}
	for(int i = 0; i < n; i++){
		if(x[i] == f+'0'){
			ll res1, ct = 1;
			if(f == 0) res1 = (res+p2[i])%mod;
			else res1 = (res-p2[i]+mod)%mod;
			while(res1){
				res1 = res1%(__builtin_popcount(res1));
				ct++;
			}
			ans[i] = ct;
		}
	}
}
 
void solve(){
	cin>>n>>x;
	reverse(x.begin(), x.end());
	ll ct = 0;
	for(int i = 0; i < n; i++) ct += x[i]-'0';
	if(ct+1) calc(0,ct+1);
	if(ct-1) calc(1,ct-1);
	for(int i = n-1; i >= 0; i--) deb1(ans[i])
}
 
int main(){
	fastio;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
}

Measured memory_bytes: 6876
r,D,x = map(int,input().split())
X = [0,0,0,0,0,0,0,0,0,0,0]
X[0] = r*x - D
for i in range(10):
    X[i+1] = r*X[i] - D
for j in range(10):
    print(X[j])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
typedef long long ll;
#define PI 3.14159265359
using namespace std;

bool newcoun[100001];
bool counter[100001];
bool firused[100001];
bool secused[100001];
int councoun[100001];

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}


int main(){
	ll n, k, maximum = 0;
	cin >> n >> k;
	vector<pair<ll, ll> > vec(n);
	for (int i = 0; i < n; i++){
		cin >> vec[i].second >> vec[i].first;
		newcoun[vec[i].second] = true;
	} 
	for (int i = 0; i <= n; i++){
		if (newcoun[i]){
			maximum++;
		}
	}
	sort(vec.begin(), vec.end(), greater<pair<int, int> >());

	ll sumoisi = 0;
	for (int i = 0; i < k; i++){
		sumoisi += vec[i].first;
		counter[vec[i].second] = true;
		councoun[vec[i].second]++;
		if (firused[vec[i].second]){
			secused[vec[i].second] = true;
		}else{
			firused[vec[i].second] = true;
		}
	}
	ll coun = 0;

	for (int i = 1; i <= n; i++){
		if (counter[i]){
			coun++;
		}
	}

	sumoisi += coun*coun;
	ll ans = sumoisi;

	priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > pq;
	priority_queue<pair<ll, ll> > pq2; 
 
	for (int i = k-1; i >= 0; i--){
		if (secused[vec[i].second] && councoun[vec[i].second] > 1){
			pq.push(make_pair(vec[i].first, vec[i].second));
			councoun[vec[i].second]--;
		}
	}

	for (int i = k; i < n; i++){
		if (!firused[vec[i].second]){
			pq2.push(make_pair(vec[i].first, vec[i].second));
		}
	}
	for (int i = coun; i < maximum; i++){
		if (pq.empty()){
			cout << ans << endl;
			return 0;
		}
		pair<ll, ll> p = pq.top();
		pq.pop();
		sumoisi -= p.first;
		if (pq2.empty()){
			cout << ans << endl;
			return 0;
		}
		pair<ll, ll> p2 = pq2.top();
		while(firused[p2.second]){
			if (pq2.empty()){
				cout << ans << endl;
				return 0;
			}
			pq2.pop();
			p2 = pq2.top();
		}
		pq2.pop();
		firused[p2.second] = true;
		sumoisi += p2.first;
		sumoisi += (i+1)*(i+1);
		sumoisi -= i*i;
		ans = max(ans, sumoisi);
	}

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

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

int main() {
  int n,x,y;
  cin>>n>>x>>y;
  if(n>x+y)
    cout<<min(x,y)<<' '<<0<<endl;
  else
    cout<<min(x,y)<<' '<<x+y-n<<endl;
}

Measured memory_bytes: 256
from enum import Enum
import sys
import math

#0:中央,1:南,2:東,3:西,4:北,5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])

    def get_Top(self):
        return self.number[0]

dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0],table[1],table[2],table[3],table[4],table[5])

loc_array=str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d"%(dice.get_Top()))



Measured memory_bytes: 6388
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[11],t[12];
    int i=0,j=0;
    scanf("%s%s",s,t);
    while(s[i]!='\0'){
        if(s[i]==t[i])
            j++;
        i++;
    }
    if((j==i)&&(strlen(s)+1==strlen(t)))
        printf("Yes\n");
    else 
        printf("No\n");
    return 0;
}

Measured memory_bytes: 1632
x1,y1,x2,y2 = map(int,input().split())
mvx=x2 - x1 # x移動量計算
mvy=y2 - y1 # y移動量計算
# 右上から左上の点求める
y3 = y2 + mvx # y2 から xの移動量足す
x3 = x2 - mvy # x2 から yの移動量減らす
y4 = y1 + mvx # y1 から xの移動量足す
x4 = x1 - mvy # x1 から y の移動量減らす
print(x3,y3,x4,y4)


Measured memory_bytes: 3064
import math
def eratos(n):
    isprime = [True for i in range(n+1)]
    isprime[0] = False
    isprime[1] = False
    for i in range(2, int(math.sqrt(n))+1):
        if isprime[i]:
            j = i + i
        while j <= n:
            isprime[j] = False
            j = j + i
    return isprime        

if __name__ == "__main__":
    maxn = 10**5+13
    x = int(input())
    ans = 0
    isprime = eratos(maxn)
    for i in range(x, maxn):
        if isprime[i]:
            ans = i
            break
    print(ans)

Measured memory_bytes: 44784
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC110(void);
void ABC111(void);
void ABC112(void);
void ABC113(void);
void ABC114(void);
void ABC115(void);
void ABC116(void);
void ABC117(void);
void ABC118(void);
void ABC119(void);

int main(void){
    ABC110();
}

void ABC110(){
    int n,m,x,y,a,i;
    cin>>n>>m>>x>>y;
    vector<int> vecx,vecy;
    vecx.push_back(x);
    vecy.push_back(y);
    for(i=0;i<n;i++){
        cin>>a;
        vecx.push_back(a);
    }
    for(i=0;i<m;i++){
        cin>>a;
        vecy.push_back(a);
    }
    sort(vecx.begin(),vecx.end());
    sort(vecy.begin(),vecy.end());
    if(vecx[vecx.size()-1]<vecy[0])cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int sy, sx;
    cin >> sy >> sx;
    string s, t;
    cin >> s >> t;
    int l = 1, r = w, u = 1, d = h;
    for (int i = n - 1; i >= 0; --i) {
        if (t[i] == 'L')
            r = min(w, r + 1);
        else if (t[i] == 'R')
            l = max(1, l - 1);
        else if (t[i] == 'U')
            d = min(h, d + 1);
        else
            u = max(1, u - 1);

        if (s[i] == 'L')
            ++l;
        else if (s[i] == 'R')
            --r;
        else if (s[i] == 'U')
            ++u;
        else
            --d;

        if (l > r || u > d) {
            cout << "NO" << endl;
            return 0;
        }
    }
    if (l <= sx && sx <= r && u <= sy && sy <= d)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

int main(){
  int N=0,M=0;
  ll K;
  cin >> N >> M >> K;
  vector<ll> A(N+1,0);
  vector<ll> B(M+1,0);

  REP1(i,N){
    cin >> A.at(i);
    A.at(i)+=A.at(i-1);
  }
  REP1(i,M){
    cin >> B.at(i);
    B.at(i)+=B.at(i-1);
  }

  ll imax=0;
  int i=0,ans=0;
  
  REP(count,N+1){
    if(A.at(count)>K){
      i=count-1;
      break;
    }
    i=count;
  }
  imax=A.at(i);

  int j=0;
  for(i;i!=-1;i--){
    imax=A.at(i);
    FOR(count,j,M+1){
      if(imax+B.at(count)>K){
	j=count-1;
	break;
      }
      j=count;
      ans=max(ans,i+j);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6348
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[3010][3010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,S;
    cin >> N >> S;
    ll A[3010];
    rep(i,0,N) cin >> A[i];
    // dp[0][0] = 1;
    ll ans = 0;
    rep(i,0,N){
        rep(j,0,S+1){
            (dp[i+1][j] += dp[i][j]) %= MOD;
        }
        if(S - A[i] >= 0) ans += dp[i+1][S - A[i]] * (N-i);
        ans %= MOD;
        (dp[i+1][A[i]] += i+1) %= MOD;
        rep(j,1,S+1){
            if(j - A[i] >= 0) (dp[i+1][j] += dp[i][j - A[i]]) %= MOD;
        }
        if(A[i] == S){
            ans += (i+1) * (N-i);
            ans %= MOD;
        }
    }

    print(ans);
    

}

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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i <= int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

const int mod = 1000000007;

inline int add(int a, int b);
inline int sub(int a, int b);

int dp[3005][3005];

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    string s;
    int n;
    cin >> n >> s;

    dp[1][1] = 1;

    forlr(i, 1, n - 1) {
        vector<int> sufadd(n + 2, 0);
        vector<int> prefadd(n + 2, 0);
        forlr(j, 1, i)
            if (dp[i][j] > 0) {
                if (s[i - 1] == '>')
                    prefadd[j] = add(prefadd[j], dp[i][j]);
                else
                    sufadd[j + 1] = add(sufadd[j + 1], dp[i][j]);
            }

        int sum = 0;
        for (int j = 1; j <= i + 1; j++) {
            sum = add(sum, sufadd[j]);
            dp[i + 1][j] = add(dp[i + 1][j], sum);
        }

        sum = 0;
        for (int j = i + 1; j >= 1; j--) {
            sum = add(sum, prefadd[j]);
            dp[i + 1][j] = add(dp[i + 1][j], sum);
        }
    }

    int ans = 0;
    forlr(i, 1, n) {
        ans = add(ans, dp[n][i]);
    }
    cout << ans;
    return 0;
}

int add(int a, int b) {
    int result = a + b;
    if (result >= mod)
        result -= mod;
    return result;
}

int sub(int a, int b) {
    int result = a - b;
    if (result < 0)
        result += mod;
    return result;
}

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

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

  vector<int> A(4);
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "AC") A.at(0)++;
    if (S == "WA") A.at(1)++;
    if (S == "TLE") A.at(2)++;
    if (S == "RE") A.at(3)++;
  }

  cout << "AC x " << A.at(0) << endl;
  cout << "WA x " << A.at(1) << endl;
  cout << "TLE x " << A.at(2) << endl;
  cout << "RE x " << A.at(3) << endl;
}

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

int main(){
  int c,temp=0;
  int N;
  cin >>N;
  
  vector<int> h(N);
  
  for(int i=0;i<N;i++){
    cin >>h.at(i);
  
  }

  int i=0;
  while(i<N){

    c=0;
    for(int j=i;j<N-1;j++){
    if(h.at(j)<h.at(j+1)){
    break;}
    else{c++;}
  
  }
if(temp<c){temp=c;}    
i+=1+c;
  }
    
  cout <<temp<<endl;
  

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout<<endl;
#define P pair<int, int>
#define prique priority_queue<P, vector<P>, greater<P>>
struct edge { int to, cost; };
using namespace std;
template<typename T> void unsort(vector<T>& vec) {
	sort(all(vec), greater<T>());
	return;
}
int n;
int a[114514];
int cnt1 = 0, cnt2 = 0;
int sum1 = 0, sum2 = 0;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (i % 2 == 0) {
			if (0 < sum1 + a[i]) {
				sum1 += a[i];
				continue;
			}
			cnt1 += 1 - (sum1 + a[i]);
			sum1 = 1;
		}
		else {
			if (sum1 + a[i] < 0) {
				sum1 += a[i];
				continue;
			}
			cnt1 += sum1 + a[i] + 1;
			sum1 = -1;
		}
	}
	rep(i, n) {
		if (i % 2 == 0) {
			if (sum2 + a[i] < 0) {
				sum2 += a[i];
				continue;
			}
			cnt2 += sum2 + a[i] + 1;
			sum2 = -1;
		}
		else {
			if (0 < sum2 + a[i]) {
				sum2 += a[i];
				continue;
			}
			cnt2 += 1 - (sum2 + a[i]);
			sum2 = 1;
		}
	}
	cout << min(cnt1, cnt2) << endl;
}

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

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

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


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();

		List<Integer> list = new ArrayList<>();
		List<Integer> subList = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			list.add(scan.nextInt());
			subList.add(list.get(i));
		}

		Collections.sort(subList);

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

			// A1がAmaxと等しい
			if(subList.get(N -1) == list.get(i)) {
				// 2番目に大きい値
				System.out.println(subList.get(N -2));
			}else {
				System.out.println(subList.get(N - 1));
			}

		}
	}
}

Measured memory_bytes: 99316
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
#define int long long
const int inf = 999999999999999999;
typedef long long ll;
typedef long double ld;
signed main() {
	int a, b, c, d, ans;
	cin >> a >> b >> c >> d;
	if (a < c&&b < d)
		ans = b - c;
	if (a <= c&&b >= d)
		ans = d - c;
	if (a > c&&b > d)
		ans = d - a;
	if (a >= c&&b <= d)
		ans = b - a;
	if (ans < 0) ans = 0;
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;



int main(){

	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
 
	int res = A*X + B*Y;
  	for(int i=1; i<= max(X, Y); i++){
    	int ab = i*2;
      	int cand = C*ab + A*max(X-i, 0) +B*max(Y-i, 0);
      	res = min(res, cand);
    }
  
  cout << res << endl;
  return 0;
  
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    int k;
    cin >> k;
    sort(All(a));
    rep(i, k) a[2] *= 2;
    int ans = a[0] + a[1] + a[2];
    c(ans);
    return 0;
}

Measured memory_bytes: 256
#
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    N, X = map(int, input().split())
    L = list(map(int, input().split()))

    ans = 1
    pos = [0] * (N + 1)
    for i in range(N):
        pos[i + 1] = pos[i] + L[i]
        if pos[i + 1] <= X:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

using Graph = vector<vector<int>>;

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }

    void inputGraph(Graph &g,int path_num,bool isdirected){
        for(int i = 0;i < path_num;i++){
            int a,b;
            cin >> a >> b;
            a--;b--;
            if(isdirected){
                g[a].push_back(b);
            }
            else{
                g[a].push_back(b);
                g[b].push_back(a);
            }
        }
    }
}

void calculate(){
    int N,M;
    Input::input(N,M);
    vector<int> H(N);
    Input::inputVec(H);
    Graph city(N);
    Input::inputGraph(city,M,false);
    int res = 0;
    for(int i = 0;i < N;i++){
        bool flag = true;
        for(auto j : city[i]){
            if(H[i] <= H[j]) flag = false;
        }
        if(flag) res++;
    }
    cout << res << '\n';
}

int main(int,char**){
    calculate();    
}




Measured memory_bytes: 8720
#include<iostream>
using namespace std;
#define ll long long int
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll k=(n/(a+b))*a;
  if(n%(a+b)>a){
    k+=a;
  }
  else
    k+=(n%(a+b));
  cout<<k;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
g = [[] for _ in range(n+1)]
for _ in range(n-1):
    a,b,c = map(int,input().split())
    g[a].append((b,c))
    g[b].append((a,c))
q,k  = map(int,input().split())
dis = [float('inf')]*(n+1)
dis[k] = 0
que = deque(g[k])
while que:
    x,y  = que.popleft()
    if dis[x] == float('inf'):
        dis[x] = y
        for x_, y_ in g[x]:
            que.append((x_, dis[x]+y_))
    else:
        dis[x] = min(dis[x], y)

ans = []
for _ in range(q):
    x,y = map(int,input().split())
    ans.append(dis[x] + dis[y])
for a in ans:
    print(a)

Measured memory_bytes: 49684
n,m = map(int,input().split())

a = list(map(int,input().split()))

a1 = sorted(a,reverse = True)
max_a = sum(a)

flag = 0
for i in range(m):
    if a1[i] * 4*m  >= max_a:
        pass
    else:
        flag = 1
if flag == 0:
    print("Yes")
else:
    print("No")

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

int main() {
    int N, X[102];
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
        ans += X[i];
    }
    int x1 = ans / N;
    int x2 = x1 + 1;
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < N; ++i) {
        ans1 += (x1 - X[i]) * (x1 - X[i]);
        ans2 += (x2 - X[i]) * (x2 - X[i]);
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    yahooProcon2019QualB()
}

fun yahooProcon2019QualB() {
    val abList = (1..3).map { readLine()!!.split(' ').map { it.toInt() } }

    val answer = if (abList.flatten().groupBy { it }.map { it.value.size }.sorted() == listOf(1, 1, 2, 2)) {
        "YES"
    } else "NO"

    println(answer)
}


Measured memory_bytes: 36292
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,C,X,Y = map(int, lines.pop(0).split(' '))
    res = 0
    AB = (A + B)/2
    res = min(AB, C) * min(X, Y) * 2

    diff = abs(X - Y)
    if X > Y:
        res += min(A, 2*C) * diff
    else:
        res += min(B, 2*C) * diff

    print(int(res))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3064
s = list(input())
for x in range(len(s)-1, 0, -1):
    if s[x] == "Z":
        hold_z = x+1
        break
for x in range(len(s)):
    if s[x] == "A":
        hold_a = x+1
        break
print(hold_z - hold_a + 1)

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

int main(){
    ll x,y;
    cin>>x>>y;
    ll ans=0;
    vector<ll>v;
    for(ll i=x;i<=y;){
        v.push_back(i);
        if(i*2<=y)i=i*2;
        else break;
    }
    cout<<v.size();
}

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

using namespace std;

const int MOD = 1e9 + 7;
const long long INF = 1e18;
const int MaxN = 3e3 + 33;
const int MaxD = 100;

int dp[MaxN][MaxN];

void up(int & x, int y)
{
    x += y;
    if(x >= MOD)
        x -= MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

    int n;
    string s;
    cin >> n >> s;

    dp[1][1] = 1;

    for(int i = 2; i <= n; ++i)
    {
        vector <int> sum(n + 1);
        for(int j = 1; j <= n; ++j)
            sum[j] = (dp[i - 1][j] + sum[j - 1]) % MOD;


        for(int a = 1; a <= i; ++a)
        {
            if(s[i - 2] == '<')
            {
                dp[i][a] = sum[a - 1];
            }else
            {
                dp[i][a] = sum[n] - sum[a - 1];
                if(dp[i][a] < 0)
                    dp[i][a] += MOD;
            }
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; ++i)
        ans = (ans + dp[n][i]) % MOD;
    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 34560
import sys
#sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  C={'AC':0,'WA':0,'TLE':0,'RE':0}
  for _ in range(n):
    s=input().strip("\n")
    C[s]+=1
  print('AC x '+str(C['AC']))
  print('WA x '+str(C['WA']))
  print('TLE x '+str(C['TLE']))
  print('RE x '+str(C['RE']))


Measured memory_bytes: 67916
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    int N; cin >> N;
    vector<int> A(N+1);
    vector<int> B(N);
    vector<int> C(N);
    int ans=0;
    rep(i,N){
        cin >> A[i];
        A[i]--;
    }
    A[N]=-1;

    rep(i,N){
        cin >> B[i];
        ans+=B[i];
    }

    rep(i,N-1){
        cin >> C[i];
    }

    for(int i=0; i<N; i++){
        if(A[i]+1==A[i+1]){
            ans+=C[A[i]];
        }
    }


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

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n;
  cin >> n;
  vi32 cnt(n);
  vector<pair<int, int>> pa;
  vector<vector<pair<int, int>>> edges(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    cnt[a]++;
    cnt[b]++;
    pa.emplace_back(a, b);
    edges[a].emplace_back(b, i);
    edges[b].emplace_back(a, i);
  }
  int ma = 0;
  rep(i, n) amax(ma, cnt[i]);
  cout << ma << endl;
  vi32 col(n - 1);
  function<void(int, int, int)> dfs = [&](int v, int p, int vv) {
    int c = 1;
    for (auto pa : edges[v]) {
      int u, i;
      tie(u, i) = pa;
      if (u == p) continue;
      if (c == vv) c++;
      col[i] = c;
      dfs(u, v, c);
      c++;
    }
  };
  dfs(0, -1, 0);
  rep(i, n - 1) {
    cout << col[i] << endl;
  }
}


Measured memory_bytes: 9980
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int a[510][510], b[510][510];
int c[100010];
map<int, P> ma, mb;
int ya[510], xa[510], yb[510], xb[510];
int cra, crb, ccra, ccrb;
int counta, countb;

int main(){
    int n, u, v, m;
    cin >> n >> u >> v >> m;
    rep(i, 0, n){
        rep(j, 0, n){
            cin >> a[i][j];
            ma[a[i][j]] = {i, j};
        }
    }
    rep(i, 0, n){
        rep(j, 0, n){
            cin >> b[i][j];
            mb[b[i][j]] = {i, j};
        }
    }
    rep(i, 0, m){
        cin >> c[i];
    }
    if(n == 1){
        rep(i, 0, m){
            if(ma.count(c[i])) counta++;
            if(mb.count(c[i])) countb++;
            if(counta == u && countb < v){
                cout << "USAGI" << endl; return 0;
            }
            if(counta < u && countb == v){
                cout << "NEKO" << endl; return 0;
            }
        }
        cout << "DRAW" << endl;
        return 0;
    }
    rep(i, 0, m){
        if(ma.count(c[i])){
            int y = ma[c[i]].first;
            int x = ma[c[i]].second;
            ya[y]++;
            xa[x]++;
            if(y == x) cra++;
            if(y + x == n - 1) ccra++;
            if(ya[y] == n) counta++;
            if(xa[x] == n) counta++;
            if(y == x && cra == n) counta++;
            if(y + x == n - 1 && ccra == n) counta++;
        }
        if(mb.count(c[i])){
            int y = mb[c[i]].first;
            int x = mb[c[i]].second;
            yb[y]++;
            xb[x]++;
            if(y == x) crb++;
            if(y + x == n - 1) ccrb++;
            if(yb[y] == n) countb++;
            if(xb[x] == n) countb++;
            if(y == x && crb == n) countb++;
            if(y + x == n - 1 && ccrb == n) countb++;
        }
        // cout << counta << ' ' << countb << endl;
        if(counta >= u && countb < v){
            cout << "USAGI" << endl;
            return 0;
        }
        if(counta < u && countb >= v){
            cout << "NEKO" << endl;
            return 0;
        }
    }
    cout << "DRAW" << endl;
}


Measured memory_bytes: 22604
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b<<'\n';
}


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

int height(int n) {
  if (n == 1)
    return 1;
  return n + height(n - 1);
}

int main(void) {
  int a, b;
  cin >> a >> b;
  int n = b - a;
  cout << height(n) - b << endl;
}


Measured memory_bytes: 256
def examA():
    X = LI()
    for i in range(len(X)):
        if X[i]==0:
            ans = i+1
    print(ans)
    return

def examB():
    X, Y = LI()
    ans = "No"
    for i in range(X+1):
        if i*2+(X-i)*4==Y:
            ans = "Yes"
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,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()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 77036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s;
  cin>>s;
  vector<int>num(4);
  rep(i,4) num[i]=s[i]-'0';
  for(int tmp=0;tmp<(1<<3);tmp++){
    int sum=num[0];
    string s;
    s=(char)('0'+num[0]);
    bitset<3>t(tmp);
    rep(i,3){
      if(t.test(i)){
        sum+=num[i+1];
        s+='+';
        s+=(char)('0'+num[i+1]);
      }
      else{
        sum-=num[i+1];
        s+='-';
        s+=(char)('0'+num[i+1]);
      }
    }
      if(sum==7){
        s+="=7";
        cout<<s<<endl;
        return 0;
      }
  }
}

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

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

  ll left = 4 * a * b;
  ll num = c - a - b;
  ll right = num * num;

  if (num < 0) {
    cout << "No" << endl;
    return 0;
  }

  if (left < right) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
    long long N;
    cin >> N;
    long long A[N+1];
    long long i;
    for(i=1; i<=N; i++){
        cin >> A[i];
    }
    vector<long long> tei_L[N+1], tei_R[N+1];
    for(i=1; i<=N; i++){
        if(i-A[i]>=1){
            tei_L[i-A[i]].push_back(i);
        }
        if(i+A[i]<=N){
            tei_R[i+A[i]].push_back(i);
        }
    }
    long long counta=0;
    for(i=1; i<=N; i++){
        counta += (long long)(tei_L[i].size()*tei_R[i].size());
    }
    cout << counta << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 22952
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] A = new int[N];
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            if(map.containsKey(A[i]))
                map.put(A[i], map.get(A[i])+1);
            else
                map.put(A[i], 1);
        }
        sc.close();
        
        int ans = map.size();
        int cnt = 0;
        for(Integer key: map.keySet()){
            cnt += map.get(key)-1;
        }

        if(cnt % 2 == 0)
            System.out.println(ans);
        else
            System.out.println(ans-1);
    }
}

Measured memory_bytes: 63400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        String S = scanner.next();
        
        if (S.equals("ARC")) {
            System.out.println("ABC");
        } else {
            System.out.println("ARC");
        }
    }
}


Measured memory_bytes: 35572
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int ans;
string s;

main(){
    cin>>s;
    rep(i,6)if(s[i]=='1')ans++;
    dans;
}



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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    for(int i=0; i<s.size(); i++)
    {
        n -= s[i] == t[i];
    }
    cout << n;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

struct sta{
  int id;
  int pos;
  pair<LL,LL> d;
};

int main(){
  int n,t;
  cin >> n >> t;
  map<string,int> mp;
  vector<vector<string>> name(n);
  vector<vector<int>> time(n);
  vector<vector<pair<int,int>>> id(n);
  string a,b;
  cin >> a >> b;
  int k;
  rep(i,n){
    cin >> k;
    name[i]=vector<string>(k);
    id[i]=vector<pair<int,int>>(k);
    time[i]=vector<int>(k-1);
    rep(j,k){
      cin >> name[i][j];
      mp[name[i][j]]=-1;
    }
    rep(j,k-1){
      cin >> time[i][j];
    }
  }
  int sn = 0;
  for(auto &p:mp) p.second=(sn++);
  int from=mp[a], to=mp[b];
  vector<int> count(sn,0);
  rep(i,n){
    rep(j,id[i].size()){
      int x = mp[name[i][j]];
      id[i][j]={x,count[x]};
      count[x]++;
    }
  }
  vector<vector<pair<int,int>>> ro(sn);
  rep(i,sn){
    ro[i]=vector<pair<int,int>>(count[i]);
  }
  rep(i,n){
    rep(j,id[i].size()){
      ro[id[i][j].first][id[i][j].second]={i,j};
    }
  }
  vector<vector<pair<LL,LL>>> dist(sn);
  rep(i,sn){
    dist[i]=vector<pair<LL,LL>>(count[i],{LINF,LINF});
  }
  vector<bool> norikae(sn,false);
  priority_queue<sta,vector<sta>,function<bool(sta,sta)>>
    heap([](const sta &a, const sta &b){return a.d>b.d;});
  rep(i,count[from]) heap.push({from,i,{0,0}});

  pair<LL,LL> ans={LINF,LINF};
  while(!heap.empty()){
    sta now = heap.top();
    heap.pop();
    if(dist[now.id][now.pos].first!=LINF) continue;
    dist[now.id][now.pos]=now.d;
    if(now.id==to) ans=min(ans,now.d);
    if(!norikae[now.id]){
      norikae[now.id]=true;
      rep(i,count[now.id]){
        if(dist[now.id][i].first==LINF)
        heap.push({now.id,i,{now.d.first+t,now.d.second+1}});
      }
    }
    auto p = ro[now.id][now.pos];
    if(p.second>0){
      auto nxp = id[p.first][p.second-1];
      LL ds = time[p.first][p.second-1];
      if(dist[nxp.first][nxp.second].first==LINF)
      heap.push({nxp.first,nxp.second,{now.d.first+ds,now.d.second}});
    }
    if(p.second<id[p.first].size()-1){
      auto nxp = id[p.first][p.second+1];
      LL ds = time[p.first][p.second];
      if(dist[nxp.first][nxp.second].first==LINF)
      heap.push({nxp.first,nxp.second,{now.d.first+ds,now.d.second}});
    }
  }
  if(ans.first==LINF) cout << -1 << endl;
  else cout << ans.first SP ans.second << endl;
  return 0;
}



Measured memory_bytes: 26644
// Aizu Vol-10 1018: Cheating on ICPC
// 2017.8.20 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

int p[102];

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int N;
	int i, s, k;

	while (scanf("%d", &N) == 1) {
		for (i = 0; i < N; i++) scanf("%d", p + i);
		qsort(p, N, sizeof(int), cmp);
		for (s = 0, k = N, i = 0; i < N; i++, k--) s += p[i]*k;
		printf("%d\n", s);
	}
	return 0;
}

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

int main(){
    int N;
    int K;
    int h[100001];
    long long dp[100001];
    cin>>N>>K;
    for(int i=1;i<=N;i++){
        cin>>h[i];
        dp[i]=INFINITY;
    }
    dp[1]=0;
    for(int i=2;i<=N;i++){
        for(int j=1;j<=K;j++){
            if(i-j<1){
                break;
            }
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[N]<<endl;
    return 0;
}

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

int main(){
  int A, B, i, cnt = 0, a, b, c, d;
  cin >> A >> B;

  for ( i = A; i < B + 1; i++)
  {
    a = i / 10000;
    b = i / 1000 % 10;
    c = i / 10 % 10;
    d = i % 10;
    if (a == d && b == c)
    {
      cnt ++;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3588