akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		string[] first = Console.ReadLine().Split();

		int n = int.Parse(first[0]);
		int m = int.Parse(first[1]);

		int[] cs = Console.ReadLine().Split().Select(str => int.Parse(str)).ToArray();

		int[] minCounts = new int[50001];

		for (int i = 1; i <= n; i++)
		{
			// コイン持っているかどうか
			for (int ci = 0; ci < m; ci++)
			{
				if (cs[ci] == i)
				{
					minCounts[i] = 1;
					break;
				}
			}

			if (minCounts[i] > 0)
			{
				continue;
			}

			int min = n;
			for (int j = 1; j < i; j++)
			{
				int current = minCounts[i - j] + minCounts[j];
				if (current < min)
				{
					min = current;
				}
				if (i - j < j)
				{
					break;
				}
			}
			minCounts[i] = min;
		}

		System.Console.WriteLine(minCounts[n]);
	}
}



Measured memory_bytes: 9776
import java.util.Scanner;

public class Main {

    static long dp[][][];
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] n = sc.next().toCharArray();
        int K = sc.nextInt();

        System.out.println(digitDP(n, K));
    }

    static long digitDP(char[] s, int K) {

        final int L = s.length;
        dp = new long[103][2][K + 1];
        dp[0][0][0] = 1;
        for (int i = 0 ; i < L ; i++) {
            final int D = s[i] - '0';
            for (int j = 0 ; j < 2 ; j++) {
                for (int k = 0 ; k <= K ; k++) {
                    for (int d = 0 ; d <= (j != 0 ? 9 : D) ; d++) {
                        if (d == 0) {
                            dp[i + 1][(j == 1 || (d < D)) ? 1 : 0][k] += dp[i][j][k];
                        } else {
                            if (k < K) {
                                dp[i + 1][(j == 1 || (d < D)) ? 1 : 0][k + 1] += dp[i][j][k];
                            }
                        }

                    }
                }
            }
        }

        return dp[L][0][K] + dp[L][1][K];
    }

}

Measured memory_bytes: 22100
def main():
    N, X, T = map(int, input().split())
    #A_list = list(map(int, input().split()))

    a = N // X
    b = N % X

    if b != 0 :
        print(T*(a + 1))
    else :
        print(T*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include <numeric>

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(p) cerr<<#p<<'='<<(p.first)<<" "<<p.second<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
const ll MOD = 1e9 + 7;
const int N = 1e3+5;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char button[4]={'L','R','U','D'};

// Ahhiya thi lakhvanu chalu thasse....


signed main() {
    FAST
    int q = 1;
    //cin>>q;
    while (q--) {
        char c;
        cin>>c;
        if(isupper(c)){
            cout<<'A';
        }
        else{
            cout<<'a';
        }
    }
}

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

int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
   
      if(S[K-1] == 'A'){
        S[K-1] = 'a';
      }else if(S[K-1] == 'B'){
        S[K-1] = 'b';
      }else{
        S[K-1] = 'c';
      }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
using namespace std;

int main() {
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int X;
    int sqnum;
    cin >> X;
    if (X == 2) {
        cout << X << endl;
    } else {
        if (X % 2 == 0) X++;
        int flag = 0;
        while(flag == 0) {
            sqnum = (int) sqrt(X);
            int i = 3;
            for (i = 3; i <= sqnum; i+=2) {
                if (X % i == 0) {
                    break;
                } else if (i == sqnum || i == sqnum - 1) {
                    flag = 1;
                }
            } 
            X += 2;
        }
        cout << X - 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int gcd(int a, int b){
	if(a > b) swap(a,b);
	while(b > 0){
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}

void solve(){
	int a, b;
	cin >> a;
	cin >> b;
	cout << gcd(a,b) << endl;

}

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

Measured memory_bytes: 1192
#include <bits/stdc++.h>  
using namespace std; 
int main(){
    char a[100005],b[100005];
    cin>>a;
    int a1=strlen(a),ans=0;
    for(int i=0;i<a1;i++){
        if(a[i]=='b') b[i]='d';
        if(a[i]=='d') b[i]='b';
        if(a[i]=='q') b[i]='p';
        if(a[i]=='p') b[i]='q';
    }
    for(int i=0;i<a1;i++){
        if(a[i]!=b[a1-i-1]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    if(S == "SUN")
        cout << 7;
    else if(S == "MON")
        cout << 6;
    else if(S == "TUE")
        cout << 5;
    else if(S == "WED")
        cout << 4;
    else if(S == "THU")
        cout << 3;
    else if(S == "FRI")
        cout << 2;
    else if(S == "SAT")
        cout << 1;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int b1[3][10],b2[3][10],b3[3][10],b4[3][10];
  int n,b,f,r,v;
  scanf("%d",&n);
  for (int i = 0; i < 3; i++)
  {
    
    for (int j = 0; j < 10; j++)
    {
      b1[i][j] = 0;
      b2[i][j] = 0;
      b3[i][j] = 0;
      b4[i][j] = 0;
    //  printf("%d",b1[i][j]);
    }
  //  printf("\n");
    
  }
  for (int s = 0; s < n; s++)
  {
    scanf("%d %d %d %d",&b,&f,&r,&v);
    if(b == 1)b1[f-1][r-1] += v;
    else if(b == 2)b2[f-1][r-1] += v;
    else if(b == 3)b3[f-1][r-1] += v;
    else if(b == 4)b4[f-1][r-1] += v;
  }
  
    for (int i = 0; i < 3; i++)
  {
    
    for (int j = 0; j < 10; j++)
    {
      printf(" %d",b1[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");
      for (int i = 0; i < 3; i++)
  {
    
    for (int j = 0; j < 10; j++)
    {
      printf(" %d",b2[i][j]);
    }
    printf("\n");
  }
   printf("####################\n");
         for (int i = 0; i < 3; i++)
  {
    
    for (int j = 0; j < 10; j++)
    {
      printf(" %d",b3[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");
           for (int i = 0; i < 3; i++)
  {
    
    for (int j = 0; j < 10; j++)
    {
      printf(" %d",b4[i][j]);
    }
    printf("\n");
  }
   return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    vector<int>v(3);
    for(int i=0;i<3;i++) cin>>v[i];
    sort(all(v));
    cout<<v[0]+v[1]<<endl;
    End;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#define BIG 1000000000
#define BIGNUM 1000000
#define SIZE 1000
using namespace std;

int pop_get(stack<int> &s) {
	int tos = s.top();
	s.pop();
	return tos;
}

int main() {
	char str[10];
	stack<int> s;
	int a, b;
	while (scanf("%s", str)!=EOF) {
		switch (str[0]) {
		case '+':
			b = pop_get(s);
			a = pop_get(s);
			s.push(a + b);
			break;
		case '-':
			b = pop_get(s);
			a = pop_get(s);
			s.push(a - b);
			break;
		case '*':
			b = pop_get(s);
			a = pop_get(s);
			s.push(a * b);
			break;
		default:
			s.push(atoi(str));
		}
	}
	printf("%d\n", s.top());
	return 0;
}

Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#include<cstring> 
using namespace std;
long long a[3010][3010],f[3010][3010][4],ans;
int n,m,k;
int main()
{
    int i,j,t1,t2,t3;
    cin>>n>>m>>k;
    for(i=1;i<=k;i++)
    {
        scanf("%d%d%d",&t1,&t2,&t3);
        a[t1][t2]=t3;
    }
    for(i=1;i<=n;i++)
     for(j=1;j<=m;j++)
     {
          f[i][j][0]=max(f[i][j][0],f[i-1][j][0]);
          f[i][j][0]=max(f[i][j][0],f[i-1][j][1]);
          f[i][j][0]=max(f[i][j][0],f[i-1][j][2]);
          f[i][j][0]=max(f[i][j][0],f[i-1][j][3]);
          f[i][j][0]=max(f[i][j][0],f[i][j-1][0]);
          f[i][j][1]=max(f[i][j][1],f[i][j-1][1]);
          f[i][j][2]=max(f[i][j][2],f[i][j-1][2]);
          f[i][j][3]=max(f[i][j][3],f[i][j-1][3]);
          if(a[i][j]!=0)
          {
              f[i][j][1]=max(f[i][j][1],f[i-1][j][0]+a[i][j]);
              f[i][j][1]=max(f[i][j][1],f[i-1][j][1]+a[i][j]);
              f[i][j][1]=max(f[i][j][1],f[i-1][j][2]+a[i][j]);
              f[i][j][1]=max(f[i][j][1],f[i-1][j][3]+a[i][j]);
              f[i][j][1]=max(f[i][j][1],f[i][j-1][0]+a[i][j]);
              f[i][j][2]=max(f[i][j][2],f[i][j-1][1]+a[i][j]);
              f[i][j][3]=max(f[i][j][3],f[i][j-1][2]+a[i][j]);
          }
     }
    ans=max(ans,f[n][m][0]);
    ans=max(ans,f[n][m][1]);
    ans=max(ans,f[n][m][2]);
    ans=max(ans,f[n][m][3]);
    cout<<ans;
    system("pause");
}
    


Measured memory_bytes: 356424
#include<stdio.h>

int main(){
  int N,i,j,min,temp,swap=0;
  int A[100];

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

  for(i=0;i<N;i++){
    min=i;
    for(j=i+1;j<N;j++){

      if(A[j]<A[min]) {
	min=j;
      }
    }
    if(i!=min){    
    temp=A[i];
    A[i]=A[min];
    A[min]=temp;
    swap++;
    }

  }
    for(i=0;i<N-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d\n%d\n",A[N-1],swap);
  
} 



Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

using ld = long double;
using Point = complex<ld>;
using Set = vector<Point>;
const ld pi = acos(-1);
constexpr ld eps = 1e-9;
constexpr ld inf = 1e12;

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

    int n;
    cin >> n;
    int sz = 1 << n;
    vector<int> a(sz);
    for(int i = 0; i < sz; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    vector<int> s;
    s.push_back(a.back());
    a.back() = -1;
    for(int i = 0; i < n; ++i){
        vector<int> foo = s;
        sort(foo.begin(), foo.end());
        int pos = sz - 1;
        while(foo.size() > 0 && pos >= 0){
            if(a[pos] == -1){
                --pos;
            }
            else{
                if(foo.back() > a[pos]){
                    foo.pop_back();
                    s.push_back(a[pos]);
                    a[pos] = -1;
                }
                --pos;
            }
        }
        if(foo.size() > 0){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> idx;
    rep(i, n) idx[a[i]] = i;
    sort(all(a));
    ll cnt = 0;
    rep(i, n) {
        if (abs(i - idx[a[i]]) % 2 != 0) cnt++;
    }
    cout << (cnt / 2) << endl;
    return 0;
}


Measured memory_bytes: 7296
import sys
from collections import deque
import copy
def main():
    N = input()
    if N[-1] == '3':
        print("bon")
    elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1]== '8':
        print("pon")
    else:
        print("hon")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9540
#include<bits/stdc++.h>
using namespace std;
#define M 100003
int main(){
  int X;cin>>X;
  vector<bool>prime(M+1,true);
  for(int i=2;i<=M;i++){
    if(prime[i]){
      for(int j=2;i*j<=M;j++)prime[i*j]=false;
    }
    if(i>=X && prime[i]){cout<<i;return 0;}
  }
}


Measured memory_bytes: 256
import queue

H, W = map(int,input().split())

#[y][x]
a = [list(input()) for i in range(H)]
mod = 10**9 + 7

#[y][x]
dp = [[1 for _ in range(W)] for _ in range(H)]

#1行目
for i in range(1,W):
    if a[0][i] == "#":
        dp[0][i] = 0
        for j in range(i+1,W):
            dp[0][j] = 0
        break


#1列目
for i in range(1,H):
    if a[i][0] == "#":
        dp[i][0] = 0
        for j in range(i+1,H):
            dp[j][0] = 0
        break

#y
for i in range(1,H):
    #x
    for j in range(1,W):
        if a[i][j] == "#":
            dp[i][j] = 0
        else:
            dp[i][j] = dp[i-1][j] + dp[i][j-1]

print(dp[H-1][W-1] % mod)

Measured memory_bytes: 167132
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";
	ll k;
	cin>>k;
	cin>>s;
	if(SZ(s)<=k) sres=s;
	else {
		sres=s.substr(0,k)+"...";
	}

	cout << sres << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3660
using System;


namespace ConsoleApplication46
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int d = int.Parse(input[3]);
            int e = int.Parse(input[4]);
            int f = int.Parse(input[5]);
            string input2 = Console.ReadLine();
            for (int x = 0; x < input2.Length; x++)
            {
                char[] hougaku = input2.ToCharArray();
                string hougaku2 = hougaku[x].ToString();
                int kari = 0;
                if (hougaku2 == "S")
                {
                     kari = a;
                     a = e;
                     e = f;
                     f = b;
                     b = kari;
                }
                else if(hougaku2 == "E")
                {
                    kari = a;
                    a = d;
                    d = f;
                    f = c;
                    c = kari;
                }
                else if (hougaku2 == "N")
                {
                    kari = a;
                    a = b;
                    b = f;
                    f = e;
                    e = kari;
                }
                else if (hougaku2 == "W")
                {
                    kari = a;
                    a = c;
                    c = f;
                    f = d;
                    d = kari;
                }
            }
            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 9272
#include<stdio.h>

int main(void)
{
  int w=0,h=0,x=0,y=0,r=0;
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

if ((x - r) < 0)
{
printf("No\n");
}

else if ((x+r)>w)
{
printf("No\n");
}
else if ((y-r)<0)
{
printf("No\n");
}
else if ((y+r)>h)
{
printf("No\n");
}
else
{
printf("Yes\n");
}


return 0;
}


Measured memory_bytes: 2108
/** 
 *  Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long double a,b,c;
    cin>>a>>b>>c;
    if((a+b+(2*sqrt(a)*sqrt(b))) < c)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 3e5 + 5;
const ll maxm = 1e3 + 5;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
ll n, m, k, ans;
ll h[maxn], w[maxn];
ll cnth[maxn], cntw[maxn];
vector<int> v[maxn];
struct TreeNode{
    ll l, r, ma;
};
TreeNode t[maxn << 2];
ll lc(ll p){return p << 1;}
ll rc(ll p){return p << 1 | 1;}
void pushup(ll p){
    t[p].ma = max(t[lc(p)].ma, t[rc(p)].ma);
    return ;
}
void build(ll l, ll r, ll p){
    t[p].l = l, t[p].r = r;
    if(l == r){
        t[p].ma = cntw[l];
        return ;
    }
    ll mid = (l + r) >> 1;
    build(l, mid, lc(p));
    build(mid + 1, r, rc(p));
    pushup(p);
    return ;
}
void modify(ll x, ll add, ll p){
    ll l = t[p].l, r = t[p].r;
    if(l == r){
        t[p].ma += add;
        return ;
    }
    ll mid = (l + r) >> 1;
    if(x <= mid){
        modify(x, add, lc(p));
    } else {
        modify(x, add, rc(p));
    }
    pushup(p);
    return ;
}
int main(){
    cin.tie(0);
    cin >> n >> m >> k;
    for(int i = 1;i <= k;i++){
        cin >> h[i] >> w[i];
        v[h[i]].push_back(w[i]);
        cnth[h[i]]++;
        cntw[w[i]]++;
    }
    build(1, m, 1);
    for(int i = 1;i <= n;i++){
        for(auto j : v[i]){
            modify(j, -1, 1);
        }
        // cout << t[1].ma << endl;
        ans = max(ans, t[1].ma + cnth[i]);
        for(auto j : v[i]){
            modify(j, 1, 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 53856
#include <stdio.h>

int linearSearch();

int main(){
  int s,t,i,j,A[10001],B[501],C=0;
  scanf("%d",&s);
  for(i=0; i<s; i++) scanf("%d",&A[i]);
  scanf("%d",&t);
  for(j=0; j<t; j++){
    scanf("%d",&B[j]);
    if(linearSearch(B[j], s, A) != -1) C++;
  }
  printf("%d\n",C);
}

int linearSearch(int key, int n, int A[]){
  int i=0;
  A[n] = key;
  while(A[i] != key) i++;
  if(i!=n) return i;
  else return -1;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    string a,b,c;
    int ia, ib, ic;
    cin >> a >> b >> c;
    ia = 0; ib = 0; ic = 0;
    int na = a.length();
    int nb = b.length();
    int nc = c.length();
    int tmp = 1;
    while(true){
        if(tmp == 1){
            if(ia == na){
                printf("A\n");
                return 0;
            }
            tmp = a[ia] - 'a' + 1;
            ia++;
        }
        else if(tmp == 2){
            if(ib == nb){
                printf("B\n");
                return 0;
            }
            tmp = b[ib] - 'a' + 1;
            ib++;
        }
        else{
            if(ic == nc){
                printf("C\n");
                return 0;
            }
            tmp = c[ic] - 'a' + 1;
            ic++;
        }
    }

}

Measured memory_bytes: 3488
from sys import exit
from random import randrange
MOD = 10**9+7
n, k = map(int, input().split())
b = list(map(int, input().split()))
a = []
if n == k:
	ans = 1
	for x in b:
		ans *= x
		ans %= MOD
	print(ans)
	exit()
for x in b:
	if x != 0:
		a.append(x)
if len(a) < k:
	print(0)
	exit()

a.sort(key=lambda x: -abs(x))
#print(a)
ans = 1
minus = 0
for i in range(k):
	ans *= a[i]
	ans %= MOD
	if a[i] < 0:
		minus += 1

if minus%2 == 0:
	print(ans)
	exit()

if len(a) == k:
	if len(a) < n:
		print(0)
		exit()

for i in range(k, len(a)):
	if a[i] < 0:
		minus += 1

if minus == len(a):
	if len(a) < n:
		print(0)
		exit()
	ans = 1
	for i in range(k):
		ans *= a[-i-1]
		ans %= MOD
	print(ans)
	exit()

flg1 = False
for i in range(k-1, -1, -1):
	if a[i] * a[k] < 0:
		p, q = a[i], a[k]
		flg1 = True
		break

flg2 = False
for i in range(k, len(a)):
	if a[k-1] * a[i] < 0:
		r, s = a[k-1], a[i]
		flg2 = True
		break

if flg1 and flg2:
	if abs(q*r) >= abs(p*s):
		ans *= pow(p, MOD-2, MOD)
		ans *= q
		print(ans%MOD)
	else:
		ans *= pow(r, MOD-2, MOD)
		ans *= s
		print(ans%MOD)

elif flg1:
	ans *= pow(p, MOD-2, MOD)
	ans *= q
	print(ans%MOD)

elif flg2:
	ans *= pow(r, MOD-2, MOD)
	ans *= s
	print(ans%MOD)

else:
	print("コーナーケース多すぎん？")

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

int main() {

	int N, max_a = -100, min_a = 100;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
		max_a = max(max_a, a.at(i));
		min_a = min(min_a, a.at(i));
	}

	int cost_min = pow(200,2)*100;
	for (int i = min_a; i <= max_a; i++) {
		int cost = 0;
		for (int j = 0; j < N; j++) cost += pow(i - a.at(j), 2);
		cost_min = min(cost_min, cost);
	}

	cout << cost_min << endl;

	return 0;
}

Measured memory_bytes: 256
a=[]
for _ in[0]*int(input()):
 X,z=input(),[]
 for y in input():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=[len(z)]
print(*a,sep='\n')


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

int main(){
	string str;
	cin >> str;
	if(str=="Sunny"){
		cout << "Cloudy" << endl;
	}else if(str=="Cloudy"){
		cout << "Rainy" << endl;
	}else{
		cout << "Sunny" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    vector<int> v(N);
    scan(v);

    ll pre = 0;
    REP(i, N) {
        if (i % 2 == 0)
            pre += v[i];
        else
            pre -= v[i];
    }
    vector<int> ans(N);
    ans[0]     = pre;
    ans[N - 1] = 2 * v[N - 1] - pre;
    FOR(i, 1, N - 1) { ans[i] = 2 * v[i - 1] - ans[i - 1]; }
    print(ans);

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<28
#define MAX 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;

int n, a[100005];
int dp[MAX];

int main()
{
    FASTIO
    //double start_time = clock();
    /* #ifndef ONLINE_JUDGE
     freopen("in.txt", "r", stdin);
     freopen("out.txt", "w", stdout);
   #endif*/
    cin>>n;
    for(int i = 1; i <= n; i++)
        cin>>a[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = dp[i-1] + abs (a[i] - a[i-1]);
        if(i > 2){
            dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n]<<endl;

//       double end_time = clock();
//    printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}

Measured memory_bytes: 4428
/**************************************************************
	File name: A.cpp
	Author: huhao
	Email: 826538400@qq.com
	Create time: 2019/8/24 下午8:03:14
**************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
int main()
{
	int m=read(),d=read(),ans=0;
	fr(i,1,d)
	{
		if(i%10>=2&&i/10>=2)
			ans+=((i%10)*(i/10)<=m);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(2147483647)
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

# ループを見つける(5000), 一周のスコアを確認
is_visit = [0 for _ in range(n)]
loop = []

def search(i, j):
    if is_visit[i] == 0:
        is_visit[i] = j
        l.append(i)
        search(p[i]-1, j)
    else:
        pass

loop_id = 1
for i in range(n):
    l = []
    search(i, loop_id)
    if len(l) != 0:
        loop.append(l)
        loop_id += 1
# print(loop)
# print(is_visit)
s_list = [0 for _ in range(len(loop))]
for i in range(len(s_list)):
    l = loop[i]
    s = 0
    for j in range(len(l)):
        s += c[l[j]]
    s_list[i] = s

ans = [0 for _ in range(n)]
for i in range(n):
    # i からはじめて最大スコア
    l = loop[is_visit[i]-1] # 所属するループ
    tmp1 = 0 # ループによるスコア
    tmp_k = k
    s = s_list[is_visit[i]-1]
    if s > 0 and k > len(l):
        # 回るほどお得で一周より回れる
        tmp1 += s*(tmp_k//len(l)-1)
        tmp_k -= (tmp_k//len(l)-1)*len(l)
    elif s <= 0 and k > len(l):
        tmp_k -= (tmp_k//len(l)-1)*len(l)
        if tmp_k == 0:
            tmp_k = len(l)
    pointer = p[i]
    tmp2 = [c[pointer-1] for _ in range(tmp_k)] # 愚直に進んだ点数
    if tmp_k != 0:
        for j in range(1, tmp_k):
            # k回目までの累積和で最大を求める
            pointer = p[pointer-1]
            tmp2[j] = tmp2[j-1] + c[pointer-1]
    # print(i, l, s, tmp_k, tmp1, tmp2)
    if len(tmp2) != 0:
        ans[i] = tmp1 + max(tmp2)
    else:
        ans[i] = tmp1
# print(ans)
print(max(ans))


Measured memory_bytes: 137680
#include<stdio.h>
int main(void){
  int i;
  int q = 0;
  int r = 0;
  int p = 0;
  int a = 0;

  scanf("%d",&i);

  if(i>499) {
    q = i/500 ;
  }
  a = i - 500*q;
  if(a>4){
    r = a/5;
  }
  p = q * 1000 + r * 5;

  printf("%d\n", p);
  return 0;
}


Measured memory_bytes: 128
import sys
from collections import deque
input = sys.stdin.readline

n, q = map(int, input().split())
g = [[] for _ in range(n)]
cnt = [0] * n

for i in range(n - 1):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

for i in range(q):
    p, x = map(int, input().split())
    cnt[p - 1] += x
    
q = deque([0])
flag = [False] * n

while q:
    v = q.pop()
    flag[v] = True
    for e in g[v]:
        if flag[e]:
            continue
        cnt[e] += cnt[v]
        q.append(e)
        
print(*cnt)


Measured memory_bytes: 56084
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc     = new Scanner(System.in);
		Integer nowTem = Integer.valueOf(sc.nextLine());

		if(nowTem >= 30) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35724
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);
	cout << a << " " << b << " " << c << endl;
	return 0;
}


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

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

    while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }

        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int N;
vector<int> h(N);

int cost(int a, int b) {
    return abs(h.at(a) - h.at(b));
}

int main() {
    int K;
    cin >> N >> K;
    h.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> h.at(i);
    }

    vector<int> dp(N, INF);
    dp.at(0) = 0;
    for (int i = 0; i < N; i++) {
        for (int k = 1; k <= K; k++) {
            int keep = dp.at(i);
            if (i - k >= 0) {
                if (dp.at(i - k) + cost(i - k, i) < keep) {
                    keep = dp.at(i - k) + cost(i - k, i);
                }
            }
            dp.at(i) = keep;
        }
    }

    cout << dp.at(N - 1) << endl;
}

Measured memory_bytes: 1024
using System;

public class Hello
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = new int[n];
        var b = new int[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            a[i] = int.Parse(line[0]);
            b[i] = int.Parse(line[1]);
        }
        Array.Reverse(a); Array.Reverse(b);
        Console.WriteLine(getAns(a, b, n));
    }
    public static long getAns(int[] a, int[] b, int n)
    {
        var ret = 0L;
        for (int i = 0; i < n; i++)
        {
            if ((a[i] + ret) % b[i] == 0) continue;
            ret += (b[i] - (a[i] + ret) % b[i]);
        }
        return ret;
    }
}


Measured memory_bytes: 15820
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
    }
}

// 二項係数計算
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;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
	ll n; cin>>n;
	ll k; cin>>k;
	COMinit();
	if(k>=n)k=n-1;
	ll ans=1;
	FOR(i,1,k+1){
		ll tmp=COM(n,i);
		tmp*=COM(n-1,i);
		tmp%=MOD;
		ans+=tmp;
		ans%=MOD;
		//cout<<i<<","<<tmp<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12160
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N, W = [int(item) for item in input().split()]
    item = np.array([[int(item) for item in input().split()] for _ in range(N)])


    dp = np.full(10**5 + 1, W+1)
    dp[0] = 0

    for i in range(N):
        w, v = item[i]
        np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])

    print(np.max(np.where(dp <= W)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 13984
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios::sync_with_stdio(0);  //fast input and output
    cin.tie(0);
    ll n,i,c=0;
   string s;
   cin>>n;
   cin>>s;
   for(i=0;i<n-2;i++)
   {
       if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        c++;
   }
   cout<<c;

    return 0;
   }


Measured memory_bytes: 256
n = int(input())
g = [[] for _ in range(n)]
z = []
for _ in range(n-1):
    a,b = [int(x)-1 for x in input().split()]
    g[a].append(b)
    g[b].append(a)
    if a<b:
        z.append((a,b))
    else:
        z.append((b,a))

from collections import deque

parent = [0]*n
mc = 0
en = dict()

q = deque()
used = [0]*n
q.append(0)
used[0] = 1
while q:
    p = q.popleft()
    color = 0
    for i in g[p]:
        if used[i] != 1:
            color += 1
            used[i] = 1
            if color==parent[p]:
                color += 1
            if p<i:
                en[(p,i)]=color
            else:
                en[(i,p)]=color
            parent[i] = color
            q.append(i)
    mc = max(mc,color)

print(mc)
for i in z:
    print(en[i])

Measured memory_bytes: 92320
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let q: usize = it.next().unwrap().parse().unwrap();
    for _ in 0..q {
        let k: usize = it.next().unwrap().parse().unwrap();
        let mut d = 0;
        let mut m = 0;
        let mut dm = 0;
        let mut dmc = 0u64;
        for i in 0..n {
            if i >= k {
                match s[i - k] {
                    'D' => {
                        dm -= m;
                        d -= 1;
                    },
                    'M' => {
                        m -= 1;
                    },
                    _ => (),
                }
            }
            match s[i] {
                'D' => d += 1,
                'M' => {
                    dm += d;
                    m += 1;
                },
                'C' => {
                    dmc += dm;
                },
                _ => (),
            }
        }
        println!("{}", dmc);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 13560
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
long long power(long long k , long long n , long long m=1e9+7)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
long long fact(long long n , long long m = 1e9+7)
{
    long long a = 1 ;
    if(n==0 || n==1)
    {
        return(1) ;
    }
    while(n>0)
    {
        a = (a%m * n%m)%m ;
        n-- ;
    }
    return(a) ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
  	cin>>a>>b ;
  	if(b%a==0)
  	{
  		cout<<a+b ;
	  }
	 else
	 {
	 	cout<<b-a ;
	  } 
}

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

int main() {
    string c;
    cin >> c;
    if(c == "a" || c == "e" || c == "i" || c == "o" || c == "u"){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

template<class D>
struct Hungarian {
    V<D> le, ri;
    V<int> perm;

    Hungarian(const VV<D> &c) {
        int n = int(c.size()), m = int(c[0].size());
        assert(n <= m);
        le = V<D>(n, D(0)); ri = V<D>(m, D(0));
        perm = V<int>(n);
        V<int> to_r(n, -1), to_l(m, -1);

        for (int s = 0; s < n; s++) {
            V<bool> l_u(n), r_u(m); l_u[s] = true;
            V<int> tr(m, -1), min_l(m, s);
            V<D> min_cost(m);
            for (int j = 0; j < m; j++) min_cost[j] = c[s][j] + le[s] + ri[j];
            while (true) {
                int r = -1;
                D d = numeric_limits<D>::max();
                for (int j = 0; j < m; j++) {
                    if (!r_u[j] && min_cost[j] < d) {
                        r = j;
                        d = min_cost[j];
                    }
                }
                for (int i = 0; i <= s; i++) if (l_u[i]) le[i] -= d;
                for (int j = 0; j < m; j++) {
                    if (r_u[j]) ri[j] += d;
                    else min_cost[j] -= d;
                }
                tr[r] = min_l[r];
                int l = to_l[r];
                if (l == -1) {
                    while (r != -1) {
                        int nl = tr[r], nr = to_r[nl];
                        to_l[r] = nl; to_r[nl] = r;
                        r = nr;
                    }
                    break;
                }
                l_u[l] = r_u[r] = true;
                for (int j = 0; j < m; j++) {
                    D cost = c[l][j] + le[l] + ri[j];
                    if (cost < min_cost[j]) {
                        min_l[j] = l;
                        min_cost[j] = cost;
                    }
                }
            }
        }
        perm = to_r;
    }
};

 
using D = double;
const D PI = acos(D(-1)), EPS = 1e-10;
using P = complex<D>;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
 
    D ans = 0;
 
    int n;
    cin >> n;
    V<P> up(n), dw(n);
    D x, y;
    cin >> x >> y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y; up[i] = P(x, y);
        cin >> x >> y; dw[i] = P(x, y);
        ans += abs(up[i]-dw[i]);
    }
 
    int l = int(up.size()), r = int(dw.size());
    VV<D> cost(l, V<D>(r));
    for (int i = 0; i < l; i++) {
        for (int j = 0; j < r; j++) {
            cost[i][j] = abs(up[i] - dw[j]);
        }
    }
    auto perm = Hungarian<D>(cost).perm;
    for (int i = 0; i < l; i++) {
        ans += cost[i][perm[i]];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3872
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
   cin >> a >> b >> c >> d;
   cout << min(a, b) + min(c, d);
}



Measured memory_bytes: 3632
__MATCH = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6, ]
__INF = float('inf')


def match_matching(N: int, M: int, A: list) -> int:
    # dp で最大桁数を求める
    dp = [-__INF] * (N+1)
    dp[0] = 0
    for i in range(1, N+1):
        dp[i] = max([-__INF] +
                    [dp[i - __MATCH[a]] for a in A if i >= __MATCH[a]]) + 1

    # 各桁の数字を決める
    _A = sorted(A, reverse=True)
    used_matches = 0
    ans = 0
    for n in range(dp[N], 0, -1):
        for a in _A:
            used_matches += __MATCH[a]
            if used_matches <= N and dp[N-used_matches] == n - 1:
                ans = ans * 10 + a
                break
            used_matches -= __MATCH[a]

    return ans


if __name__ == "__main__":
    N, M = [int(s) for s in input().split()]
    A = [int(s) for s in input().split()]

    ans = match_matching(N, M, A)

    print(ans)


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

int main() {

    int a, b;
    cin >> a >> b;

    if(a >= 13){
        cout << b << endl;
    }    
    else if(a <= 5){
        cout << 0 << endl;
    }
    else{
        cout << b / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int solve() {
  int N; cin >> N;
  vector<LL> A(N); cin >> A;
  string S; cin >> S;

  vector<LL> base;
  for (int i = N - 1; i >= 0; --i) {
    LL a = A[i];
    if (S[i] == '0') {
      for (LL b : base) {
        a = min(a, a^b);
      }
      if (a != 0) base.push_back(a);
    } else {
      for (LL b : base) {
        a = min(a, a^b);
      }
      if (a != 0) return 1;
    }
  }
  return 0;
}

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; ++i) {
    cout << solve() << endl;;
  }
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N, K; cin >> N >> K;
  ll ans = K;
  rep(i, N - 1) {
    ans *= K - 1;
  }

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

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


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    map<ll, ll> v2i;
    REP(i, n){
        v2i[a.at(i)] = i;
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    for(ll i = 0; i < a.size(); i += 2){
        ans += (v2i.at(a.at(i)) % 2 != 0);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296