akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

sa=list(ss())
sb=list(ss())
sc=list(ss())
cnta,cntb,cntc=-1,-1,-1
lensa=len(sa)
lensb=len(sb)
lensc=len(sc)
temp="a"

while lensa!=-1 and lensb!=-1 and lensc!=-1:
    if temp=="a":
        cnta+=1
        lensa-=1
    elif temp=="b":
        cntb+=1
        lensb-=1
    else:
        cntc+=1
        lensc-=1

    if lensa==-1:
        print("A")
        exit()
    elif lensb==-1:
        print("B")
        exit()
    elif lensc==-1:
        print("C")
        exit()
    #print(lensa,lensb,lensc)
    if temp=="a":
        temp=sa[cnta]
    elif temp=="b":
        temp=sb[cntb]
    else:
        temp=sc[cntc]
    

        



Measured memory_bytes: 63852
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)




int main(){ FastIO;

int i,j=0,k=0,n;string s;
cin>>s; n=s.length();
for(i=0;i<n;i++)
{
	if(s[i]=='1') j++;
	else k++;
}
cout<<2*min(j,k);
return 0;
}


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

int main(){
	int A,B;
	cin >> A >> B ;
	if(A == B){
		cout << A*2 << endl;
	}
	else if(A> B){
		cout << (2*A-1)<<endl;
	}

    else{
    	cout << (2*B-1) << endl;

}
}

Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll len(ll a,ll b){
  if(a>b)return len(b,a);
  else{
    if(b%a==0)return (2*(b/a)-1)*a;
    else return 2*a*(b/a)+len(a,b%a);
  }
}

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


  ll n,x;
  std::cin>>n>>x;

  std::cout<<n+len(n-x,x)<<"\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


  








int main() {
  int n;
  cin >> n;
  int l[n+1];

  rep (i,n){
    cin >> l[i];
  }
  sort(l,l+n);
  int sum=0;
  rep (i,n-1){
    sum+=l[i];
  }
  if (sum>l[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

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


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  string L;
  cin >> L;
  int N = L.size();
  vector<vector<long long>> dp(N + 1, vector<long long>(2, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++){
    if (L[i] == '0'){
      dp[i + 1][0] = dp[i][0];
      dp[i + 1][1] = dp[i][1] * 3;
    }
    if (L[i] == '1'){
      dp[i + 1][0] = dp[i][0] * 2;
      dp[i + 1][1] = dp[i][0] + dp[i][1] * 3;
    }
    dp[i + 1][0] %= MOD;
    dp[i + 1][1] %= MOD;
  }
  cout << (dp[N][0] + dp[N][1]) % MOD;
}

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

#define mod (long)1000000007

int main() {
	int n;
	long ans = 1;
	cin >> n;

	for (int i = 2; i <= n; i++) {
		ans = (ans * i) % mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	int a[n+1];
	int i;
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	int left = n/2;
	for(i=0;i<left;i++){
		printf("%d ",a[n-i*2]);
	}
	int right = n - left;
	if(n%2==0){
		for(i=0;i<right;i++){
			printf("%d ",a[1+2*i]);
		}
	}else{
		printf("%d ",a[1]);
		for(i=1;i<right;i++){
			printf("%d ",a[i*2]);
		}
	}
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
template<typename T> T GCD(T a, T b)
{if (a % b == 0){return b;} return(GCD(b, a%b));}
template<typename T> T LCM(T a, T b)
{return(a/GCD(a,b)*b);}

int main(){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long ans = (B - A + 1);
    long long AB = LCM(C, D);
    ans -= ((B / C) - ((A - 1) / C));
    ans -= ((B / D) - ((A - 1) / D));
    ans += ((B / AB) - ((A - 1) / AB));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc034/tasks/agc034_a

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        String S = sc.next();
        sc.close();
        boolean pass = true;
        for (int i=A+1;i<C-1;i++){
            String s1 = String.valueOf(S.charAt(i-1));
            String s2 = String.valueOf(S.charAt(i));
            if (s1.equals("#") && s2.equals("#")){
                System.out.println("No");
                return;
            }
        }
        for (int i=B+1;i<D-1;i++){
            String s1 = String.valueOf(S.charAt(i-1));
            String s2 = String.valueOf(S.charAt(i));
            if (s1.equals("#") && s2.equals("#")){
                System.out.println("No");
                return;
            }
        }
        if (C>D){
            for (int i=B-1;i<D;i++){
                String s1 = String.valueOf(S.charAt(i-1));
                String s2 = String.valueOf(S.charAt(i));
                String s3 = String.valueOf(S.charAt(i+1));
                if (s1.equals(".") && s2.equals(".") && s3.equals(".")){
                    pass = true;
                    break;
                } else {
                    pass = false;
                }
            }
        }
        if (pass){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

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

  
  ll ans =10000000000000;



  for( ll i=1;i<=sqrt(n);i++){
    
    if(n%i==0){
      ll x=i;
      ll y=n/i;
      ans = min(ans,x + y -2);
    }
  }

  cout << ans << endl;
}

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

int main(){
    int n, T;
    cin >> n >> T;
    vector<int> c(n), t(n);
    for (int i=0; i<n; i++){
        cin >> c[i] >> t[i];
    }

    int ans = 10000;
    for (int i=0; i<n; i++){
        if(t[i] <= T){
            ans = min(ans, c[i]);
        }
    }

    if(ans > 1000){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,m;
ll fact[N];

int main(){
    read2i(n,m);
    if(abs(n-m) > 1) return cout <<0, 0;

    fact[0] = 1;
    lp(i,1,N) fact[i] = fact[i-1] * i % mod;
    cout <<(n == m ? 2 : 1) * fact[n] % mod * fact[m] % mod;
}

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<string>
#include<queue>
#define MAX 1002
using namespace std;

char xy[MAX][MAX];
int cost[MAX][MAX];
int hp[MAX][MAX];

struct state{
  int x;
  int y;
  int co;
  int hp;
  state(){}
  state(int x,int y,int co,int hp):
    x(x),y(y),co(co),hp(hp){}
};

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

int H,W,N;

int solve(int x,int y){
  int i,j;
  queue<state> q;
  q.push( state(x,y,0,1) );
  cost[x][y]=0;
  hp[x][y]=1;

  while( !(q.empty()) ){

    state p = q.front();
    q.pop();

    x=p.x;
    y=p.y;

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

      if( x+dx[i] < 0 || x+dx[i] >= W || y+dy[i] < 0 || y+dy[i] >= H )
	continue;

      if(xy[y+dy[i]][x+dx[i]]=='X') continue;

      if(xy[y+dy[i]][x+dx[i]]-'0' == p.hp){
	
	if(p.hp >= N){
	  return p.co+1;
	}
	
	while( !(q.empty()) ){
	  q.pop();
	}

	//printf("%d\n",p.hp+1);
	
	q.push( state(x+dx[i],y+dy[i],p.co+1,p.hp+1) );
	
	break;
	
      }


      if(cost[x+dx[i]][y+dy[i]]<=p.co+1){
	if(hp[x+dx[i]][y+dy[i]]>=p.hp){
	  continue;
	}
      }
      
      
      cost[x+dx[i]][y+dy[i]]=p.co;
      hp[x+dx[i]][y+dy[i]]=p.hp;

      q.push( state(x+dx[i],y+dy[i],p.co+1,p.hp) );


    }

  }

  return -1;
}

main(){
  int i,j,sx,sy;

  cin >> H >> W >> N;

  for(i=0;i<H;i++){
    scanf("%s",xy[i]);
    for(j=0;j<W;j++){
      if(xy[i][j]=='S'){
	sx=j;
	sy=i;
      }
    }
  }

  int n=solve(sx,sy);

  cout << n << endl; 
  
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

// パスカルの三角形を使った実装
ll C[55][55]; // C[n][k] -> nCk

void comb_table(int N){
    for(int i=0; i<=N; i++){
        for(int j=0; j<=i; j++){
            if(j==0 || j==i) C[i][j] = 1LL;
            else C[i][j] = (C[i-1][j-1]+C[i-1][j]);
        }
    }
}

int main(){
    int N, A, B; cin >> N >> A >> B;
    vector<ll> v(N);
    for(int i=0; i<N; ++i) cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());

    comb_table(52);

    if(v[0] == v[A-1]){
        
        ll ave = v[0];
        int cnt = 0;
        for(int i=0; i<N; ++i) if(v[i] == v[0]) ++cnt;

        ll ans = 0;
        for(int i=A; i<=min(cnt, B); ++i) ans += C[cnt][i];
        cout << ave << endl;
        cout << ans << endl;

    } else {

        double ave = 0.0;
        for(int i=0; i<A; ++i) ave += v[i];
        ave /= A;

        int cnta = 0, cntb = 0;
        for(int i=0; i<N; ++i){
            if(v[i] == v[A-1]){
                if(i < A) ++cnta;
                ++cntb;
            }
        }
        ll ans = C[cntb][cnta];
        printf("%.8lf\n", ave);
        cout << ans << endl;
    }
}

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

using i64 = int64_t;

int calc_left_to_right(string s){
    int res = s[0] - '0';
    for(int i=1;i<s.size();i+=2){
        if(s[i] == '+'){
            res += s[i+1] - '0';
        }else{
            res *= s[i+1] - '0';
        }
    }
    return res;
}

int calc_mul_first(string s){
    stack<int> stk;
    stk.push(s[0]-'0');
    for(int i=1;i<s.size();i+=2){
        if(s[i] == '+'){
            stk.push(s[i+1]-'0');
        }else{
            int n = stk.top(); stk.pop();
            stk.push((s[i+1]-'0')*n);
        }
    }
    int res = 0;
    while(!stk.empty()){
        res += stk.top();
        stk.pop();
    }
    return res;
}

int main(){
    string expr;
    int ans;
    cin >> expr >> ans;
    int a = calc_left_to_right(expr), b = calc_mul_first(expr);
    char c;
    if(a == ans && b == ans)c = 'U';
    else if(a == ans)c = 'L';
    else if(b == ans)c = 'M';
    else c = 'I';
    cout << c << endl;

    return 0;
}



Measured memory_bytes: 3216
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <cstring>
#include <cassert>

#define rep(i,e) for(int i=0;i<(e);i++)
#define rep1(i,e) for(int i=1;i<=(e);i++)
#define repx(i,x,e) for(int i=(x);i<=(e);i++)
#define pii pair<int,int>
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define mset(var,val) memset(var,val,sizeof(var))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

#ifdef local
    #define dbg(args...) do { cout  << #args << " -> "; err(args); } while (0)
#else
    #define dbg(...)
#endif

void err() {  }
//template<template<typename...> class T, typename t, typename... Args>
//void err(T<t> a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); }
template<typename T, typename... Args>
void err(T a, Args... args) { cout << a << ' '; err(args...); }


typedef long long ll;
template <class T>
void test(T a) {
    cout<<a<<endl;
}
template <class T,class T2>
void test(T a,T2 b) {
    cout<<a<<" "<<b<<endl;
}
template <class T,class T2,class T3>
void test(T a,T2 b,T3 c) {
    cout<<a<<" "<<b<<" "<<c<<endl;
}
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int mod = 998244353;

const int N = 1e3+5;

vector<ll> a;


void work() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n){
        ll x;
        cin >> x;
        ans += x-1;
    }


    cout << ans << endl;
}


int main() {
#ifdef local
    freopen("in.txt","r",stdin);
//        freopen("out1.txt","w",stdout);
#endif // local
    IOS;
//    init();
//    int t;
//    cin >> t;
//    scd(t);
//    for(; t--;)
        work();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
  int n,tmp;
  std::cin >> n;
  std::vector<int> v;
  int ans=0;

  for (size_t i = 0; i < n; i++) {
    std::cin >> tmp;
    v.push_back(tmp);
  }

  for (int i = 1; i < n-1; i++) {
    if(v[i-1]>v[i] && v[i+1]<v[i])ans++;
    else if(v[i-1]<v[i] && v[i+1]>v[i])ans++;
  }

  std::cout << ans << '\n';



  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

bool check(string s)
{
	for (int i = 0, j = s.length() - 1; i < j; ++i, --j)
		if (s[i] != s[j])
			return 0;

	return 1;
}
int32_t main()
{
	c_p_c();

	string s; cin >> s;
	int n = s.length();
	if (check(s) && check(s.substr(0, (n - 1) / 2)) && check(s.substr((n + 1) / 2, n - (n + 1) / 2)))
		cout << "Yes\n";

	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,M;
    cin >>N>>M;
    vector<int>vec(N,0);
    vector<int>vec2(N,0);
    for(int i=0;i<M;i++){
        int x;
        string y;
        cin >>x>>y;
        if(vec.at(x-1)==0){
        if(y=="AC"){
            vec.at(x-1)++;
        }
        if(y=="WA"){
            vec2.at(x-1)++;
        }
      }
    }
    int WAcount=0;
      int ACcount=0;
      for(int i=0;i<N;i++){
          if(vec.at(i)==1){
              ACcount++;
              WAcount+=vec2.at(i);
          }
      }
      cout <<ACcount<<" "<<WAcount<<endl;;
}

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

int n;
long long int dat[300000];

void init(int nn){
	n = 1;
	while(n < nn) n *= 2;
	for(int i = 0;i < n * 2 - 1;i++){
		dat[i] = 0ll;
	}
}

void add(int x,int i){
	x += n - 1;
	dat[x] += i;
	while(x){
		x = (x - 1) / 2;
		dat[x] = dat[x * 2 + 1] + dat[x * 2 + 2];
	}
}

long long int sum(int s,int t,int k,int l,int r){
	if(t <= l || r <= s) return 0;
	if(s <= l && r <= t) return dat[k];
	return sum(s,t,k * 2 + 1,l,(l + r) / 2) + sum(s,t,k * 2 + 2,(l + r) / 2,r);
}

int main(){
	int q;
	cin >> n >> q;
	init(n);
	for(int i = 0;i < q;i++){
		int a,b,c;
		cin >> a >> b >> c;
		if(a == 0){
			add(b - 1,c);
		}else{
			cout << sum(b - 1,c,0,0,n) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5124
inp = input().split()

stack = []
for i in range(len(inp)):
    if inp[i].isdecimal():
        stack.append(inp[i])
    else:
        a = int(stack.pop())
        b = int(stack.pop())
        
        if inp[i] == "+":
            stack.append(b + a)
        elif inp[i] == "-":
            stack.append(b - a)
        elif inp[i] == "*":
            stack.append(b * a)

print(*stack)


Measured memory_bytes: 5600
#include<stdio.h>                                                               
int main()                                                                      
{   int a[100005]={0};                                                          
	int n;                                                                         
	scanf("%d",&n);                                                                
	for(int i=1;i<=n;i++)                                                          
	{                                                                              
		scanf("%d",&a[i]);                                                            
	}                                                                              
	int sum=0;                                                                     
	if(a[1]==1)                                                                    
	{                                                                              
		int t=a[2];                                                                   
		a[2]=a[1];                                                                    
		a[1]=t;                                                                       
		sum=sum+1;                                                                    
	}                                                                              
	for(int i=2;i<n;i++)                                                           
	{                                                                              
		if(a[i]==i)                                                                   
		{                                                                             
			int p=a[i+1];                                                                  
			a[i+1]=a[i];                                                                 
			a[i]=p;                                                                 
			sum++;                                                                       
		}                                                                             
	}                                                                              
	  if(a[n]==n)                                                                  
	 {
 		int n=a[1];
 		a[1]=a[n];
 		a[n]=n;
 		sum++;
 	}                                                                              
	printf("%d\n",sum);                                                            
	                                                                               
}                                                                               
                                                                                
                                                                                
                                                                                

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static String nl = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int cnt = 0;
		StringBuilder sb = new StringBuilder();
		if(n%2==0) {
			//相方（足して2n+1）以外と結べば良い
			for(int i=0;i<n-1;i++) {
				for(int j=i+1;j<n;j++) {
					if(i+j+2==n+1)continue;
					sb.append((i+1) + " " + (j+1) + nl);
					cnt ++;
				}
			}
		}
		else {
			//最大数は全てと結び、それ以外は、足してnになるもの以外と結ぶ
			for(int i=0;i<n-2;i++) {
				for(int j=i+1;j<n-1;j++) {
					if(i+j+2==n)continue;
					sb.append((i+1) + " " + (j+1) + nl);
					cnt ++;
				}
			}
			for(int i=0;i<n-1;i++) {
				sb.append(i+1 + " " + n + nl);
				cnt++;
			}
		}
		System.out.println(cnt);
		System.out.println(sb.toString());
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 x;
  double p;
  cin >> x >> p;
  p /= 100;
  double ans;
  if (x % 2 == 0) {
    ans = x / (2 * p);
  } else {
    ans = 1.0 + (p * (x - 1) + (1.0 - p) * (x + 1)) / (2 * p);
  }
  printf("%.10f\n", ans);
  return 0;
}



Measured memory_bytes: 256
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    boxes = [0] * (N+1)
    ans_boxes = [0]
    [ans_boxes.append(x) for x in list(map(int, input().split()))]

    count = 0
    ans = []

    def judge(n):
        s = 0

        nn = n
        while nn < len(boxes):
            s += boxes[nn]
            nn += n

        if s % 2 == ans_boxes[i]:
            return True
        else:
            return False

    for i in reversed(range(1, len(boxes))):
        if judge(i):
            continue

        else:
            count += 1
            ans.append(i)
            boxes[i] += 1
            if judge(i):
                pass
            else:
                print(-1)
                sys.exit()

    print(count)
    if ans:
        print(*ans, sep=' ')


if __name__ == '__main__':
    main()



Measured memory_bytes: 15376
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
map<P,P> G;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};

set<PP> used;
set<P> checked;
int check(P head){
  P leg = G[head];
  if(used.count(PP(head,leg)))return 1;
  if(used.count(PP(leg,head)))return 0;
  used.insert(PP(head,leg));
  checked.insert(head);
  checked.insert(leg);

  int res = 1;
  for(int i=0;i<4;i++){
    int nx = head.second+dx[i];
    int ny = head.first+dy[i];
    P nhead = P(ny,nx);
    if(nhead == leg || !G.count(nhead))continue;
    res &=check(nhead);
  }

  for(int i=0;i<4;i++){
    int nx = leg.second+dx[i];
    int ny = leg.first+dy[i];
    P nleg = P(ny,nx);
    if(nleg == head || !G.count(nleg))continue;
    res &=check(G[nleg]);
  }
  return res;
}

signed main(){
  int n;
  while(cin>>n,n){
    G.clear();
    for(int i=0;i<n;i++){
      int x,y;
      char dir;
      cin>>x>>y>>dir;
      int a = x + (dir == 'x');
      int b = y + (dir == 'y');
      G[P(y,x)] = P(b,a);
      G[P(b,a)] = P(y,x);
    }

    int ans = 1;
    checked.clear();
    for(PP a:G){
      if(!ans || checked.count(a.first))continue;
      used.clear();
      if(check(a.first)) continue;
      used.clear();
      if(check(a.second))continue;
      ans = 0;
    }
    cout<<(ans? "Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 12764
n=int(input())
A=list(map(int,input().split()))
L=0
R=0
now=A[0]
add=0
flag=0 #越しているなら1
Ans=[]
while R<n-1:
    if flag==0:
        R+=1
        if now+A[R]==now^A[R]:
            now+=A[R]
        else:
            Ans.append([L,R-1])
            flag=1
    else:
        now-=A[L]
        L+=1
        if now+A[R]==now^A[R]:
            now+=A[R]
            flag=0
if flag==0:
    Ans.append([L,R])
else:
    while L<n-1:
        now-=A[L]
        L+=1
        if now+A[R]==now^A[R]:
            Ans.append([L,R])

#print(Ans)
ans=0
for i in range(len(Ans)):
    d=Ans[i][1]-Ans[i][0]+1
    ans+=(d+1)*d//2
    if i!=0:
        d=Ans[i-1][1]-Ans[i][0]+1
        if d>0:
            ans-=(d+1)*d//2
print(ans)

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



int main(){
    double a,b,h,m;
    double pi=3.141592653589793;
    cin >> a >> b >> h >> m;
    cout << fixed << setprecision(15) << sqrt(a*a+b*b-2*a*b*cos((h/12+m/720)*2*pi-(m/60)*2*pi)) << "\n";
    return 0;
}

Measured memory_bytes: 4248
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] s = new String[N];
		int[] t = new int[N];
		for (int i=0;i<N;i++) {
			s[i] = sc.next();
			t[i] = sc.nextInt();
		}
		String X = sc.next();
		int index = -1;
		for (int i=0;i<N;i++) {
			if (X.equals(s[i])) index=i;
		}
		int ans = 0;
		for (int i=index+1;i<N;i++) {
			ans += t[i];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
'use strict'

function main(input){
  const lines = input.split('\n');
  const S = lines[0];
  const T = lines[1];

  let tIndices = [];
  for(let i=0;i<S.length-T.length+1;i++){
    let same_count=0;
    for(let j=0;j<T.length;j++){
      let partS = S.slice(i,i+T.length).split('');
      let partT = T.split('');
      if( partS[j]=='?' || partS[j]==partT[j]){
        same_count++;
      }
    }
    if(same_count==T.length){
      tIndices.push(i);
    }
  }

//  console.log(tIndices);

  if(tIndices.length==0){
    console.log('UNRESTORABLE');
    return;
  }

  let results =[];

  for(let tIndex of tIndices){
    let current = []
    for(let i =0;i<S.length;i++){
      if(i>=tIndex && i < tIndex+T.length){
        current.push(T[i-tIndex]);
      }else{
        if(S[i]=='?'){
          current.push('a');
        }else{
          current.push(S[i]);
        }
      }
    }
    results.push(current.join(''));
  }

  console.log(results.sort()[0]);
}

main( require('fs').readFileSync('/dev/stdin','utf8') )

Measured memory_bytes: 8268
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,b,c;
  b=0;
  c=1000000;
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
      b=0;
    while(a%2==0){
        a /=2;
        b ++;
      }
    if(c>b){
      c=b;
    }
    }
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
 
class UnionFind {
public:
    vl parent;  // 親ノード
    vl Siz;  // 集合の大きさ
    
    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }
 
    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }
 
    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }
 
    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }
        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }
        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }
 
    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
};
 
int main() {
    ll n, q;
    cin >> n >> q;
 
    UnionFind Uni(n);
    rep(i, q) {
        ll t, u, v;
        cin >> t >> u >> v;
        if(t == 0) {
            Uni.unite(u, v);
        }
        else if(t == 1) {
            if(Uni.same(u, v)) {
                out(1);
            }
            else {
                out(0);
            }
        }
    }
    
    re0;
}

Measured memory_bytes: 5972
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
  if(a>b){
    return gcd(b,a);
  }
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  string s;
  cin>>s;
  int N=0;
  int W=0;
  int S=0;
  int E=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='N'){
      N++;
    }
    if(s[i]=='W'){
      W++;
    }
    if(s[i]=='S'){
      S++;
    }
    if(s[i]=='E'){
      E++;
    }

  }
  if(((N>0&&S>0)||(N==0&&S==0))&&((W>0&&E>0)||(W==0&&E==0))){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }


}






Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A[] = new int[N];
		for(int i=0;i<N;i++){
			A[i]=Integer.parseInt(sc.next());
		}
		sc.close();
		
		boolean flag = true;
		int count = 0;
		while(flag){
			flag=false;
			for(int j=N-1;j>0;j--){
				if(A[j]<A[j-1]){
					int temp=A[j];
					A[j]=A[j-1];
					A[j-1]=temp;
					count++;
					flag=true;
				}
			}
		}
		
		for(int i=0;i<N-1;i++){
			System.out.print(A[i]+" ");
		}
		System.out.println(A[N-1]);
		System.out.println(count);
		

	}
	

}

Measured memory_bytes: 26176
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

ll N, K;
ll a[2000];

int main(void){
	cin >> N >> K;
	for(int i=0;i<N;i++) cin >> a[i];

	ll cnt = 0, cnt2 = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if (a[i] > a[j]){
				cnt2++;
				if (i < j) cnt++;
			}
		}
	}
	ll ans = (cnt % MOD * K % MOD + cnt2 * (K * (K-1) / 2LL % MOD) % MOD) % MOD;
	cout << ans << endl;




	


    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	s := nextString()
	t := nextString()

	ans := func() string {
		for i := 0; i < len(s); i++ {
			if s[i] != t[i] {
				return "No"
			}
		}
		return "Yes"
	}()

	fmt.Println(ans)
}


Measured memory_bytes: 1756
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B = MI()
    print(min(N*A, B))
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
function main(input) {
  var N = input[0]-0;
  var ans = "Yes";
  var map = {};
  var next = "";
  for(var i=1;i<=N;i++){
    var str = input[i];
    if(map[str]){
      ans = "No";
      break;
    }else{
      if(next!=""){
        if(str[0] != next){
          ans = "No";
          break;
        }
      }
      next = str[str.length-1];
      map[str] = true;
    }
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

int main() {
  int k=1;
  while(true){
    int a;
    cin>>a;
    if(a==0) break;
    cout<<"Case "<<k<<": "<<a<<endl;
    k++;
  }
}


Measured memory_bytes: 3072
s = int(input())
mod = 10 ** 9 + 7


def cmb(n, r):
    # Combinationを算出, 5C2 = 10など
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


max_index = s // 3
pat = 0

if max_index == 0:
    pass
else:
    for i in range(max_index):
        pat += cmb((s - (i + 1) * 3) + i, i)
        
ans = pat % mod
print(ans)

Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// combination
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*******************************************************/
int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ll n;
  cin >> n;
  vector<string> s;
  REP(i,n){
      string si;
      cin >> si;
      s.PB(si);
  }
  ll ac = 0;
  ll wa = 0;
  ll tle = 0;
  ll re = 0;
  REP(i, n)
  {
      if(s[i] == "AC"){
          ac += 1;
      } else if (s[i] == "WA"){
          wa += 1;
      } else if (s[i] == "TLE"){
          tle += 1;
      } else if (s[i] == "RE"){
          re += 1;
      }
  }
  cout << "AC x " + to_string(ac) << endl;
  cout << "WA x " + to_string(wa) << endl;
  cout << "TLE x " + to_string(tle) << endl;
  cout << "RE x " + to_string(re) << endl;
}

Measured memory_bytes: 7400
N, M = map(int, input().split())

s = []
for i in range(M):
    s_list = list(map(int, input().split()[1:]))
    s.append(s_list)

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

ans = 0

#print(p)
#print(s)

for i in range(2**N):
    #print("i: {}".format(i))
    
    found = True
    for m in range(M):
        #print("m: {}".format(m))
        # 各スイッチを見てゆく
        count = 0
        for k in range(N):
            #print("k: {}".format(k))
            if k+1 not in s[m]:
                continue

            state = (i >> k) & 1
            #print("state: {}".format(state))
            if state == 1:
                count += 1
                #print("count: {}".format(count))

        if p[m] != (count % 2):
            found = False
            break

    if found:
        ans += 1

print(ans)


Measured memory_bytes: 41200
#include<iostream>
using namespace std;
int main(){
	int n,k,a[105],i,j,count=0,d,c;
	cin>>n>>k;
	for(i=0;i<=n;i++)
	a[i]=0;
	for(i=0;i<k;i++)
	{
		cin>>d;
		for(j=0;j<d;j++)
		{
			cin>>c;
			a[c]=1;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]==0)
		count++;
	}
	cout<<count;
	return 0;
}

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

#define rep(i,n) for(int i=0; i < n; i++)
using namespace std;

int main()
{
    int x, happy = 0;
    cin >> x;

    while (x >= 500) {
        x -=  500;
        happy += 1000;
    }

    while (x >= 5) {
        x -= 5;
        happy += 5;
    }


    cout << happy << endl;
    return 0;
}

Measured memory_bytes: 256