akhauriyash/Code-Regression huggingface dataset:
N,Q = (int(i) for i in input().split())  
S = input()
AC_count = [0] * N
for i in range(1,N):
    AC_count[i] = AC_count[i - 1]
    if S[i - 1] + S[i] == 'AC':
        AC_count[i] += 1

for _ in range(Q):
    l,r = (int(i) for i in input().split())
    ans = AC_count[r-1] - AC_count[l-1] 
    print(ans)

Measured memory_bytes: 53080
using System;
class iclass
{
    public static void Main()
    {
        int S = Int32.Parse(Console.ReadLine());
        int s = S % 60;
        int m = ((S - s) % 3600) / 60;
            
        int h = (S - s - m) / 3600;
        Console.WriteLine(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 15964
a, b, c, d = [int(i) for i in input().split()]

def gcd(x, y):
	if x % y == 0:
		return y
	return gcd(y, x % y)
	
def num(x, c, d):
	return x - x // c - x // d + x // (c * d // gcd(c, d))

undera = num(a - 1, c, d)
underb = num(b, c, d)
print(underb - undera)

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

ll gcd(ll a, ll b)
{
    if(a == 0) return b;
    else if(b == 0) return a;
    else if(a > b) return gcd(a % b, b);
    else return gcd(a, b % a);
}

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

ll count(ll n, ll p)
{
    return n - n / p;
}

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll G = lcm(C, D);
    ll ans = count(B, C) + count(B, D) - count(B, G) - count(A-1, C) - count(A-1, D) + count(A-1, G);
    _PR(ans);

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string s, t;
  cin >> s >> t;

  vector<string> ans;

  for (int i = 0; i < s.size() - (t.size() - 1); i++) {
    string temp = s;
    int count = 0;
    bool flag = true;

    for (int j = 0; j < t.size(); j++) {
      if (i + count < s.size()) {
        if (s[i + count] == t[j] || s[i + count] == '?') {
          temp[i + count] = t[j];
          count++;
        } else {
          flag = false;
          break;
        }
      }
    }

    if (flag) {
      for (int k = 0; k < temp.size(); k++) {
        if (temp[k] == '?') temp[k] = 'a';
      }
      // cout << temp << endl;

      ans.push_back(temp);
    }
  }

  if (ans.empty()) {
    cout << "UNRESTORABLE" << endl;
  } else {
    cout << ans[ans.size() - 1] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,k;
	cin >> n >> k;
	int x[n];
	REP(i,n) cin >> x[i];
	int ans=0;
	REP(i,n){
		ans+=min(x[i],k-x[i]);
	}
	cout << ans*2 << endl;
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,A[100010],B[100010],C[100010],D[100010],i,j;
long long E[100010],sum=0;
int main(){
    cin>>n;
    for(i=1;i<=n;i++) cin>>A[i];
    for(i=1;i<=n;i++) cin>>B[i];
    for(i=1;i<=n;i++) cin>>C[i];
    sort(A+1,A+1+n);
    sort(B+1,B+1+n);
    sort(C+1,C+1+n);
    for(i=1;i<=n;i++){
        D[i]=C+1+n-upper_bound(C+1,C+1+n,B[i]);
        E[i]=E[i-1]+D[i];
    }
    for(i=1;i<=n;i++){
        if(B+1+n-upper_bound(B+1,B+1+n,A[i])>0){
            sum+=E[n]-E[upper_bound(B+1,B+1+n,A[i])-B-1];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2560
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    macro_rules! get { () => (stdin.next().unwrap().parse().unwrap()) }
    
    let n: i32 = get!();
    let a: i32 = get!();
    let b: i32 = get!();
    let ans = std::cmp::min(a * n, b);
    println!("{}", ans);
}

Measured memory_bytes: 4352
#!/usr/bin/python
# -*- coding=utf8 -*-

"""
 a, b, c, N は 1 &#8804; a, b, c &#8804; 100, 1 &#8804; N &#8804; 1000 を満たす. 
"""

def readints(line):
    return map(int, line.split())

def solve(constraint, a, b, c):
    status = [2 for i in range(a+b+c+1)]
    for x, y, z, ok in constraint:
        if ok:
            status[x] = 1
            status[y] = 1
            status[z] = 1

    for x, y, z, ok in constraint:
        if not ok:
            if status[x] == 1 and status[y] == 1:
                status[z] = 0
            if status[y] == 1 and status[z] == 1:
                status[x] = 0
            if status[z] == 1 and status[x] == 1:
                status[y] = 0

    return status

def bar(f):
    a, b, c = readints(f.readline())
    while a and b and c:
        N, = readints(f.readline())
        constraint =  [readints(f.readline()) for i in range(N)]
        for r in solve(constraint, a, b, c)[1:]:
            print r
        a, b, c = readints(f.readline())

if True:
    import sys
    bar(sys.stdin)
else:
    sample_in = """2 2 2
4
2 4 5 0
2 3 6 0
1 4 5 0
2 3 5 1
0 0 0
"""
    # expected output
    """
2
1
1
0
1
0
"""
    from StringIO import StringIO
    foo = StringIO(sample_in)
    bar(foo)

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    int min,cnt=0;
    for(int i=0;i<n;++i){
        cin >> a[i];
        if(a[i]<0){
            a[i]*=-1;
            ++cnt;
        }
        if(i==0) min=a[i];
        if(min>a[i]) min=a[i];
    }
    long int sum=0;
    for(int i=0;i<n;++i) sum += a[i];
    if(cnt%2==1) sum -= min*2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split(" ");
        int height = Integer.parseInt(str[0]);
        int width = Integer.parseInt(str[1]);

        String[][] square = new String[height+2][width+2];

        for(int i = 0 ; i < height+2;i++){
            for(int j = 0;j < width+2;j++){
                square[i][j] = "";
            }
        }


        for(int i = 1 ; i <= height;i++){
            String line = sc.nextLine();
            for(int j = 1;j <= width;j++){
                square[i][j] = String.valueOf(line.charAt(j-1));
            }
        }

        for(int i = 1 ; i <= height;i++){
            for(int j = 1;j <= width;j++){

                if(square[i][j].equals("#")){
                    continue;
                }


                int bombCount = 0;

                if(square[i-1][j-1].equals("#")){
                    bombCount++;
                }

                if(square[i-1][j].equals("#")){
                    bombCount++;
                }

                if(square[i-1][j+1].equals("#")){
                    bombCount++;
                }

                if(square[i][j-1].equals("#")){
                    bombCount++;
                }

                if(square[i][j+1].equals("#")){
                    bombCount++;
                }
                
                if(square[i+1][j-1].equals("#")){
                    bombCount++;
                }

                if(square[i+1][j].equals("#")){
                    bombCount++;
                }

                if(square[i+1][j+1].equals("#")){
                    bombCount++;
                }                
                square[i][j] = Integer.toString(bombCount);
            }
        }

        for(int i = 1 ; i <= height;i++){
            for(int j = 1;j <= width;j++){
                System.out.print(square[i][j]);
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,t;
    cin>>n>>t;
    vector<ll> a(n),b(n);
    for(ll i=0;i<n;i++)
        cin>>a[i]>>b[i];

    ll dp[t][2];
    for(ll i=0;i<t;i++)dp[i][1]=dp[i][0]=0;

    for(ll i=0;i<n;i++){
        for(ll j=t-1;j>=0;j--){
            if( j + a[i] < t){
                dp[j + a[i]][0] = max( dp[j + a[i]][0], dp[j][0] + b[i]);
                dp[j + a[i]][1]= max( dp[j + a[i]][1], dp[j][1] + b[i]);
            }
            dp[j][1] = max( dp[j][1] , dp[j][0] + b[i]);
        }
    }
    cout<<dp[t-1][1]<<"\n";


    return 0;  
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
using namespace std;
const long long MOD = 1000000007;

long long power(long long m, long long n){
    long long res = 1;
    while(n > 0){
        if(n & 1) {
            res = (res * m) % MOD;
        }
        m = (m * m) % MOD;
        n >>= 1;
    }
    return res;
}

long long inverse(long long a){
    return power(a, MOD - 2);
}
int main(void){
    long long n;
    long long a;
    long long b;
    cin >> n >> a >> b;

    long long total = (power(2, n) - 1 + MOD) % MOD;
    long long tmp = 1;
    for(int i = 0; i < a; i++){
        tmp = (tmp * (n - i)) % MOD;
        tmp = (tmp * inverse(i + 1)) % MOD;
    }
    total = (total - tmp + MOD) % MOD;
    tmp = 1;
    for(int i = 0; i < b; i++){
        tmp = (tmp * (n - i)) % MOD;
        tmp = (tmp * inverse(i + 1)) % MOD;
    }
    total = (total - tmp + MOD) % MOD;
    cout << total << endl;
    return 0;
}


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

using namespace std;

int a[200001];

int main()
{
    int n , k;
    cin >> n >> k;
    double mx = 0 , sum = 0;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
        sum += a[i];
        if(i > k) {
            sum -= a[i-k];
        }
        mx = max(sum , mx);
    }
    cout<<fixed << setprecision(8) << (mx + (double)k) / 2;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm> // next_permutation
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate
//#include <unordered_map> //???????????\??¢??°
#include <fstream> //ifstream, ofstream


using namespace std;

//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
#define TEST //*******************************************************************************************************************************************
//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
//??????????????????????????????????????????????????????????§?CPU???????£??????????????????§???TLE?????????????????????????????????????????§????????¨???
#ifdef TEST
#define dout cout
#else
stringstream dummy; //???????????°??????dout?????????????????????????????????
#define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????
//???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1
#endif

//?¨??????????????????????????????????????????????????????´??????OUTPUT2TEXTFILE????????????????????¬???????????????????????????????????¢????????????
//#define OUTPUT2TEXTFILE //*******************************************************************************************************************************************
#ifdef OUTPUT2TEXTFILE
#define dout outputfile //??¨????????????TLE????????§?????????dout?????¨??¨??????????????¢????????????????????????????????????????????§????¨????????????´??????????????£??????????????????????¨?????????????????????????????????????????????§?????????????????????
//TEST??????????????????????????¨???outputfile??????????????????????????????
#define OUTPUTFILENAME "output.txt"
ofstream outputfile(OUTPUTFILENAME);
#define OutputFilePath "/Users/Nag/Documents/Prgm/Test/DerivedData/Test/Build/Products/Debug/output.txt"
#endif



#define disp(A) dout << #A << " = " << (A) << endl
#define disP(A) dout << (A) << " "
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)

#define dispAll(A,n) dout << #A << " = "; rep(j, 0, (n)) {disP(A[j]);} dout << endl


const int INF = 2e9-1;



int main(){
    string s;
    cin >> s;
    
    int ans = 0;
    char currentPosition = 'A';
    
    rep(i,0,s.size()) {

        ans += (s[i] - currentPosition <= 0 ? s[i] - currentPosition + 26 : s[i] - currentPosition);
        
        currentPosition = s[i];
    }
    
    
    cout << ans/26 << endl;
    
    
#ifdef OUTPUT2TEXTFILE
    outputfile.close();
    cout << "\"" << OutputFilePath << "\"" << endl;
#endif
    
    return 0;
}

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

typedef long long int ll;

int main(){
 int N;
 cin >> N;
 bool frag = 0;
 for(int i = 1;i < 10;i++){
     for(int j = 1;j < 10;j++){
         if(N == i * j){
             frag = 1;
         }
     }
 }
 if(frag){
     cout << "Yes" << endl;
 }else{
     cout << "No" << endl;
 }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n;
  vector<intll> v(n);
  
  rep(i,n)
    cin >> v.at(i);
  
  sort(all(v));
  reverse(all(v));
  
  stack<intll> data ;
  int count = 0;
  intll ans = 1 ;
  data.push(0);
  rep(i,n){
    if(v.at(i) == data.top()){
       ans *= data.top();
       data.pop();
       count ++ ;
       v.at(i) = 0;
    }
    if(count ==2)
      break;
    data.push(v.at(i));
  }
  
  
  if(count <2)
    cout << 0;
  else 
    cout << ans ;
    
 
  
  
 


}


Measured memory_bytes: 1664
#include <cmath>
#include <cstdint>
#include <iostream>

using namespace std;

bool is_prime(uint32_t n) {
  for (uint32_t i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

uint32_t above_prime(uint32_t n) {
  for (uint32_t i = n;; i++) {
    if (is_prime(i)) {
      return i;
    }
  }
}

uint32_t below_prime(uint32_t n) {
  for (uint32_t i = n;; i--) {
    if (is_prime(i) || i == 1) {
      return i;
    }
  }
}

int32_t main() {
  while (true) {
    uint32_t n;
    cin >> n;
    if (n == 0) break;

    uint32_t above = above_prime(n);
    uint32_t below = below_prime(n);

    cout << above - below << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
deque <int> dq[100];
char s[200010], s1[200010][11], s2[200010][11];
int n, q;
bool chck1(int x){
    if(x==0)
        return 1;
    x=n-x;
    for(int i=0; i<q; ++i){
        if(s2[i][0]=='R'){
            if(s1[i][0]==s[x]){
                ++x;
            }
        }
        else{
            if(x>0)
            if(s1[i][0]==s[x]){
                --x;
            }
        }
        if(x==n)
            return 1;
    }
    return 0;
}
bool chck2(int x){
    if(x==0)
        return 1;
    --x;
    for(int i=0; i<q; ++i){
        if(s2[i][0]=='L'){
            if(s1[i][0]==s[x]){
                --x;
            }
        }
        else{
            if(x<n-1)
            if(s1[i][0]==s[x]){
                ++x;
            }
        }
        if(x==-1)
            return 1;
    }
    return 0;
}
int main()
{
    while(cin>>n>>q){
        scanf("%s",s);
        int ans=n;
        for(int i=0; i<q; ++i){
            scanf("%s%s",s1[i],s2[i]);
        }
        int st=0, nd=n, md;
        while(st<nd){
            md=(st+nd+1)/2;
            if(chck1(md)){
                st=md;
            }
            else{
                nd=md-1;
            }
        }
        ans-=st;
        st=0, nd=n;
        while(st<nd){
            md=(st+nd+1)/2;
            if(chck2(md)){
                st=md;
            }
            else{
                nd=md-1;
            }
        }
        ans-=st;
        ans=max(0, ans);
        cout<<ans<<endl;
    }
    return 0;
}




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

const int MAX_W = 1000+1;
const int MAX_N = 10000+1;

int dp[MAX_N][MAX_W]; // dp[i][j]: 重さj以下でi~n-1の宝を使った時の最大の価値
int weight[MAX_N];
int value[MAX_N];
int n, w;
int ans_v, ans_w; // 答え

void solve() {
  ans_v = ans_w = -1;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= w; j++)
      dp[i][j] = -1;
  
  for (int j = 0; j <= w; j++)
    dp[n][j] = 0;

  for (int i = n-1; i >= 0; i--) {
    for (int j = 0; j <= w; j++) {
      if (j >= weight[i])
        dp[i][j] = max(
            dp[i+1][j],
            dp[i+1][j-weight[i]] + value[i]);
      else
          dp[i][j] = dp[i+1][j];

      if (ans_v < dp[i][j] || ans_v <= dp[i][j] && j < ans_w) {
        // 最小の重さを記録しておく
        ans_v = dp[i][j];
        ans_w = j;
      }
    }
  }
}

int main() {
  int case_num = 0;

  while(cin >> w, w != 0) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      char c; // カンマは読み捨てる
      cin >> value[i] >> c >> weight[i];
    }
    solve();
    case_num++;
    cout << "Case " << case_num << ":" << endl;
    cout << ans_v << endl << ans_w << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan =new Scanner(System.in);
		double a;
		double b;
		double  d;
		double  r;
		double  f;
		
		a=scan.nextInt();
		b=scan.nextInt();
		d=a/b;
		r=a%b;
		f=a/b;
		System.out.printf("%d %d %f \n", (int)d,(int)r,f);
		//System.out.println((int)d+" "+(r+" "+f);
		scan.close();
	}
}


Measured memory_bytes: 26344
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>

#define SIZE 100002
typedef long long ll;
 
using namespace std;
 

 int main(){
     ll X;
     cin >> X;
     ll n = 100;
     int t=0;
     while(n < X){
         n *= 1.01;
         t++;
     }
    cout << t;
     return 0;
 }

Measured memory_bytes: 3636
N,M=map(int,input().split())
AC=[0] * (N + 1)
WA=[0] * (N + 1)
cnt_AC=0
cnt_WA=0

for _ in range(M):
  i,s=input().split()
  i=int(i)
  if AC[i]==0:
    if s=='WA':
      WA[i]+=1
    if s=='AC':
      AC[i]=1
      cnt_WA+=WA[i]
cnt_AC=sum(AC)
print(cnt_AC,cnt_WA)

Measured memory_bytes: 4596
#include <algorithm>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <stack>
#include <string>
#include <vector>
#include <queue>

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

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

VI ans = {0, 1, 2, 3, 4, 5, 6, 7};

map<VI, int> m;

void solve(){
  queue<pair<VI,int>> q;
  q.push({ans, 0});
  m.insert({ans, 0});

  while(true){
    if(q.size() == 0){
      break;
    }
    pair<VI,int> tmp = q.front();

    q.pop();

    if((*m.begin()).first != tmp.first){
      if(m.find(tmp.first) != m.end()){
        continue;
      }
    }
    m.insert(tmp);

    int p;
    REP(i, 0, 8){
      if(tmp.first[i] == 0){
        p = i;
      }
    }
    if(p > 0 && p != 4){
      VI v = tmp.first;
      int j = p - 1;
      int res = v[p];
      v[p] = v[j];
      v[j] = res;
      q.push({v, tmp.second + 1});
    }
    if(p < 4){
      VI v = tmp.first;
      int j = p + 4;
      int res = v[p];
      v[p] = v[j];
      v[j] = res;
      q.push({v, tmp.second + 1});
    }
    if(p < 7 && p != 3){
      VI v = tmp.first;
      int j = p + 1;
      int res = v[p];
      v[p] = v[j];
      v[j] = res;
      q.push({v, tmp.second + 1});
    }
    if(p >= 4){
      VI v = tmp.first;
      int j = p - 4;
      int res = v[p];
      v[p] = v[j];
      v[j] = res;
      q.push({v, tmp.second + 1});
    }
  }
  return;
}

int main(){
  VI in(8);

  solve();

  while(true){
    bool f = false;
    REP(i, 0, 8){
      cin >> in[i];
      if(cin.eof()){
        f = true;
        break;
      }
    }
    if(f == true){
      break;
    }
    int tmp = m[in];
    cout << tmp << endl;
  }
  return 0;
}

Measured memory_bytes: 5744
A, B, C, X, Y = map(int, input().split())

if 2 * C >= A + B:
    ans = A * X + B * Y
elif X > Y:
    ans = 2 * C * Y + min(A, 2 * C) * (X - Y)
else:
    ans = 2 * C * X + min(B, 2 * C) * (Y - X)

print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = map(int,readline().rstrip().split())
        tes[i][x-1] = y #ここまでが入力

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1 #全状態2**N通りを作っておく
    flag = True
    for j in range(N):
        if hon[j]:      #hon=1ならtesとの整合性を比較
            for k in range(N):
                if tes[j][k] == -1:
                    continue    #証言されていない部分は飛ばす
                if tes[j][k] != hon[k]:
                    flag = False
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

class DisjointSet {
public:
  vint v;
  DisjointSet(int n) : v(n, -1) {}

  int root(int n) { return v[n] < 0 ? n : (v[n] = root(v[n])); }
  bool unite(int a, int b) {
    int ra = root(a), rb = root(b);
    if (ra == rb) return false;
    if (-ra > -rb) swap(ra, rb);
    v[rb] += v[ra];
    v[ra] = rb;
    return true;
  }
  int size() { return count_if(ALL(v), [](int x){ return x < 0; }); }
  int sizeOf(int n) { return -v[root(n)]; } 
};

int main() {
  int li, lj;
  while (cin >> li >> lj) {
    vstring v(li);
    REP(i,li) cin >> v[i];

    vector<vint> vert(li, vint(lj));
    vector<vint> hori(li, vint(lj));

    REP(i,li) {
      DisjointSet ds(lj);
      REP(j,lj-1) if (v[i][j] == '.' && v[i][j+1] == '.') ds.unite(j, j + 1);
      REP(j,lj) hori[i][j] = ds.sizeOf(j);
    }
    
    REP(j,lj) {
      DisjointSet ds(li);
      REP(i,li-1) if (v[i][j] == '.' && v[i+1][j] == '.') ds.unite(i, i + 1);
      REP(i,li) vert[i][j] = ds.sizeOf(i);
    }

    int result = 0;
    REP(i,li) REP(j,lj) gs(result, vert[i][j] + hori[i][j] - 1);
    cout << result << endl;
  }
}


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

void solve()
{
    string s;
    cin >> s;
    if (s[s.length() - 1] == 's')
    {
        s += "es";
    }
    else
    {
        s += "s";
    }
    cout << s << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    auto t1 = high_resolution_clock::now();
    ll test = 1;
    // cin >> test;
    for (ll i = 0; i < test; i++)
    {
        // cout << "Case #" << (i + 1) << ": ";
        solve();
    }
    auto t2 = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(t2 - t1).count();
    // cout << duration << endl;
    return 0;
}

Measured memory_bytes: 3624
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
l = gets.chomp.split.map(&:to_i)
l.sort!

ans = 0
(n-2).times do |i|
  (i+1).upto(n-2) do |j|
    (j+1).upto(n-1) do |k|
      if l[i] + l[j] > l[k] && l[i] != l[j] && l[i] != l[k] && l[k] != l[j]
        ans += 1
      end
    end
  end
end

puts ans

Measured memory_bytes: 14712
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("\\s+|,");
        int w = sc.nextInt();
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        java.util.stream.IntStream.range(1,w+1).forEach(item->list.add(item));
        for(int i=0;i<n;i++)
        {
            SwapAt(list,sc.nextInt(),sc.nextInt());
        }
        for(int item:list)System.out.println(item);
	}

	static void SwapAt(List<Integer> list,int a,int b)
    {
        a--;b--;
        int c =  list.get(a);
        list.set(a,list.get(b));
        list.set(b,c);
    }
}

Measured memory_bytes: 32044
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int a, b, h;
    scan(a);
    scan(b);
    scan(h);
    writeln((a + b) * h / 2);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 305;

int p[MAX][MAX];
int dead[MAX], cnt[MAX];

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);

  REP(i, n) REP(j, m) {
    scanf("%d", &p[i][j]);
    p[i][j]--;
  }

  int rje = n;
  REP(br, m) {
    memset(cnt, 0, sizeof cnt);

    REP(i, n) {
      REP(j, m) {
	if (!dead[p[i][j]]) {
	  cnt[p[i][j]]++;
	  break;
	}
      }
    }

    int mx = 0;
    REP(j, m)
      mx = max(mx, cnt[j]);

    rje = min(rje, mx);
    REP(j, m) {
      if (cnt[j] == mx && !dead[j]) {
	dead[j] = 1;
	break;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> p(N, 0),s(N, 0);
  int st = 0;
  for(int i = 0; i < N; i++) cin >> p[i];  
  for(int i = 0; i < N; i++){
    cin >> s[i];
    st += s[i];
  }
  int candy = 0;
  int pt = 0;
  for(int i = 0; i < N; i++){
    pt += p[i];
    if(i != 0) st -= s[i-1];
    if(pt + st > candy) candy = pt + st;
  }
  cout << candy;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// 人数
        int d = sc.nextInt();// 合宿日数
        int x = sc.nextInt();// 残りのチョコ

        int[] arr = new int[n];

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

        int count = 0;// もともとあったチョコの数
        for (int i = 0; i < n; i++) {
            int day = 1;
            while (day <= d) {
                count++;
                day += arr[i];
            }
        }

        System.out.println(count+x);
    }
}


Measured memory_bytes: 21844
from collections import defaultdict
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

from math import log2

x,y = readInts()
ans = 0

i = 1
while 1:
	if x*2**(i-1)<=y:
		ans+=1
		i+=1
	else:
		print(ans)
		break

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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < n - 1; ++i) {
    cnt += s[i] == s[i + 1];
  }
  cout << min(cnt + 2 * k, n - 1) << endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  string s, t; cin >> s >> t;
  auto isSame = [](const string& s, const string& t, int offset){
    for (int i = 0; i < (int)t.size(); ++i) {
      if (i + offset >= (int)s.size()) {
        return false;
      }
      if (s[i+offset] != '?' && t[i] != s[i+offset]) {
        return false;
      }
    }
    return true;
  };
  int offset = -1;
  for (int i = s.size()-1; i >= 0; --i) {
    if (isSame(s, t, i)) {
      offset = i;
      break;
    }
  }
  if (offset == -1) {
    cout << "UNRESTORABLE" << CRLF;
    return;
  }
  for (int i = 0; i < (int)t.size(); ++i) {
    s[i+offset] = t[i];
  }
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] == '?') {
      s[i] = 'a';
    }
  }
  cout << s << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
def f(a, b):
    ret = 0
    for i in range(len(a)):
        ret += a[i]*b[i]
    return ret
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
print(len(list(filter(lambda x : f(x, b)+c>0, [list(map(int, input().split())) for i in range(n)]))))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>#define PB push_back
#define FOR(n)   for(int i = 0; i < n; ++i)
#define COUT(n)   cout << n << " " << flush
#define ALL(obj)  obj.begin(), obj.end()
using namespace std;

int p(int n) {
	int a = 1;
	FOR(n)
		a *= 10;
	return a;
}

int main() {
	int n, dig = 0, res = 0, pn;
	int d[7] = {0, 9, 0, 999 - 99, 0, 99999 - 9999, 0 };
	cin >> n;
	pn = n;
	while (n) {
		dig++;
		n /= 10;
	}

	for (int i = 1; i < dig; i += 2)
		res += d[i];

	if (dig % 2 == 1)
		for (int i = p(dig - 1); i <= pn; ++i) 
			res++;
		
	cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    int i,flag1=0,flag2=0;
    char s[12];
    scanf("%s",s);
    for(i=0;i<strlen(s);i++)
    {
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')
        {
            flag1++;
            if(flag1>flag2)
                flag2=flag1;
        }
        else
            flag1=0;
    }
    printf("%d",flag2);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


char str[10000];
int len, cnt1, cnt2;

int main(void) {
  while(1) {
    cin >> str;
    len = strlen(str);
    if(cin.eof()) break;

    cnt1 = cnt2 = 0;
    REP(i, 0, len - 2) {
      if(strncmp(str + i, "JOI", 3) == 0) cnt1++;
      if(strncmp(str + i, "IOI", 3) == 0) cnt2++;
    }

    cout << cnt1 << endl;
    cout << cnt2 << endl;
  }

  return 0;
}

Measured memory_bytes: 1148
s = input()
t = input()

def create_alphabet_array(s):
  alphabets = []
  list = [-1] * len(s)
  for i, item in enumerate(s):
    if not item in alphabets:
      alphabets.append(item)
    list[i] = alphabets.index(item)
  return list
  
slist = create_alphabet_array(s)
tlist = create_alphabet_array(t)

if slist == tlist:
  print("Yes")
else:
  print("No")
  

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n,1);
    vector<bool> b(n,false);
    b[0]=true;
    for(int i = 0; i < m; i++) {
        int x,y;
        cin >> x >> y;
        a[x-1]--;
        a[y-1]++;
        if(b[x-1]==true) b[y-1]=true;
        if(a[x-1]==0) b[x-1]=false;
    }

    int ans=0;
    for(int i = 0; i < n; i++) {
        if(b[i]==true) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
const ll INF = 1e10;
const ld eps = 1e-9, pi = acos(-1.0);
typedef pair<ll, ll> P;

int main(){
  ll N, Y;
  cin >> N >> Y;
  for(int i=0;i<=N;i++)
    for(int j=0;i+j<=N;j++){
      int k = N-i-j;
      if(i * 10000 + j * 5000 + k * 1000 == Y){
	cout << i << " " << j << " " << k << endl;
	return 0;
      }
    }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

int main()
{
    string s,t;
    cin >> s >> t;
    int sn = s.size(), tn = t.size();
    vector<char> sc(sn),tc(tn);

    rep(i,sn){
        sc[i] = s[i];
    }
    rep(i,tn){
        tc[i] = t[i];
    }

    sort(sc.begin(),sc.end());
    sort(tc.begin(),tc.end());
    reverse(tc.begin(),tc.end());

    rep(i,sn){
        s[i] = sc[i];
    }
    rep(i,tn){
        t[i] = tc[i];
    }

    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0; 
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    int H, W, N;
    cin >> H >> W;
    cin >> N;
    int a[N];
    REP(i, N)
    {
        cin >> a[i];
    }

    int c[H][W];
    int h = 0, w = 0;
    REP(i, N)
    {
        REP(j, a[i])
        {
            c[h][w] = i + 1;
            if (h % 2 == 0)
            {
                w++;
                if (w == W)
                {
                    h++;
                    w = W - 1;
                }
            }
            else
            {
                w--;
                if (w == -1)
                {
                    h++;
                    w = 0;
                }
            }
        }
    }

    REP(i, H)
    {
        REP(j, W)
        {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}


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

int main() {
    double x1, x2, y1, y2, ans = 0;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    ans = sqrt(pow((x1 - x2), 2.0) + pow((y1 - y2), 2.0));
    printf("%f\n", ans);
    return 0;
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);

    if (a == 1 and b == 2)
        print(3);
    else if (a == 2 and b == 3)
        print(1);
    else
        print(2);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstring>
using namespace std;
int main(int argc, char *argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	int sum=0;
	while(sum<=10000){
		if(a%2==1||b%2==1||c%2==1)break;
		int a1,b1,c1;
		a1=a/2;
		b1=b/2;
		c1=c/2;
		a=b1+c1;
		b=a1+c1;
		c=b1+a1;
		sum++;
	}
	if(sum>10000)sum=-1;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1010;
int numa[maxn];
int numb[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m,x,y;
    while(~scanf("%d%d%d%d",&n,&m,&x,&y))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&numa[i]);
        }
        for(int i=1;i<=m;i++)
        {
            scanf("%d",&numb[i]);
        }
        int tag=-1;
        for(int i=x+1;i<=y;i++)
        {
            bool flag=false;
            for(int j=1;j<=n;j++)
            {
                if(numa[j]>=i)
                {
                    flag=true;
                    break;
                }
            }
            for(int j=1;j<=m;j++)
            {
                if(numb[j]<i)
                {
                    flag=true;
                    break;
                }
            }
            if(!flag) tag=i;
        }
        if(tag!=-1) cout<<"No War"<<endl;
        else cout<<"War"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long long a, b;
    int k;
    cin >> a >> b >> k;
    if (b - a + 1 >= 2 * k) {
        for (int i = 0; i < k; i++) {
            cout << a++ << endl;
        }
        b = b - k + 1;
        for (int i = 0; i < k; i++) {
            cout << b++ << endl;
        }
    }
    else {
        while (a <= b) {
            cout << a++ << endl;
        }
    }
}


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

int n,g[505][505];
int col[505];
void go(int len,int z){
	int st=1;
	while(1){
		for(int i=st;i<st+len*2;i++){
			if(i<st+len)col[i]=1;
			else col[i]=0;
			if(i>n)break;
		}
		st+=len*2;if(st>n)break;
	}
//	cerr<<z<<endl;
//	for(int i=1;i<=n;i++)cerr<<col[i]<<" ";cerr<<endl;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(col[i]!=col[j]&&g[i][j]==-1){
				g[i][j]=z;
			}
		}
	}
}

int main(){
	memset(g,-1,sizeof g);
	cin>>n;
	int Maxlvl=0;
	while((1<<Maxlvl)<n)Maxlvl++;
	cerr<<Maxlvl<<endl;
	for(int i=1;i<=Maxlvl;i++){
		go(1<<i-1,i);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			cout<<g[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int MAXN = 1e05 + 10;
const int MAXM = 1e05 + 10;

struct LinkedForwardStar {
    int to;

    int next;
} ;

LinkedForwardStar Link[MAXM];
int Head[MAXN]= {0};
int size = 0;

void Insert (int u, int v) {
    Link[++ size].to = v;
    Link[size].next = Head[u];

    Head[u] = size;
}

int N, K;
int add = 1;

// 注意，由下往上必比由上往下合并更优
int cnt = 0;
int DFS (int root, int father, int deep) {
	int maxv = deep;
	for (int i = Head[root]; i; i = Link[i].next) {
		int v = Link[i].to;
		maxv = max (maxv, DFS (v, root, deep + 1));
	}
	if (father!= 1 && maxv - deep == K - 1) {
		cnt ++;
		return 0;
	}
	return maxv;
}

int getnum () {
    int num = 0;
    char ch = getchar ();

    while (! isdigit (ch))
        ch = getchar ();
    while (isdigit (ch))
        num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();

    return num;
}

int main () {
    N = getnum (), K = getnum ();
    for (int i = 1; i <= N; i ++) {
        int v = getnum ();
        if (i == 1 && v == 1) add = 0;
        if (i > 1) Insert (v, i);
    }
    DFS (1, 1, 0);
    int ans = cnt + add;
    printf ("%d\n", ans);

    return 0;
}

/*
3 1
2 3 1
*/

/*
4 2
1 1 2 2
*/

/*
8 2
4 1 2 3 1 2 3 4
*/

Measured memory_bytes: 7680
#include <stdio.h>

int selectionSort(int A[],int n){
  int i,j;
  int tmp,count=0;
  for(i=0;i<n;i++){
    int minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]) minj=j;
    }
    if(i!=minj){
      tmp=A[i];
      A[i]=A[minj];
      A[minj]=tmp;
      count++;
    }
  }
  return count;
}

int main(void){
  int i,n;
  scanf("%d",&n);
  int A[n],count;
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  count=selectionSort(A,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2044