akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;


int main(){

   // freopen("input.txt","r",stdin);

    int N;

    int arr[200];

    cin >> N;

    long long int sum = 0;

    for(int i=0; i<N; i++){
        cin >> arr[i];
        sum += arr[i];
    }

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

    for(int i=0; i<nitr; i++){
        cin >> a >> b;

        if(arr[a-1] > b){
        cout << sum - (arr[a-1] - b) << endl;
        }else{
         cout << sum + (b - arr[a-1]) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    int x;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        System.out.println(x*x*x);
        
    }
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

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

    while(t--)
    {
       ll a,b,n;
       cin>>a>>b>>n;
       ll sol;

       if(n>=b-1)
       {
          sol= (a*(b-1))/b - a*((b-1)/b);

       }
       else
       {
          sol= (a*(n))/b - a*((n)/b);

       }

       cout<<sol<<endl;
    }
  return 0;
}



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

int main(){
    int N;
    cin >> N;
    int H[N];
    for(int n=0; n<N; n++){
        cin >> H[n];
    }
    string res = "Yes";
    int D[N-1];
    for(int n=N-1; n>0; n--){
        D[N-n-1] = H[n]-H[n-1];
    }
    for(int n=0; n<N-1; n++){
        if(D[n] <= -2){
            res = "No";
            break;
        }
        if(D[n] == -1 && n != N-2){
            D[n+1] -= 1;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
# C - Average Length

N = int(input())
P = [tuple(map(int, input().split())) for _ in range(N)]

def calcDist(Y):
    dist = 0
    for i in range(1, len(Y)):
        dist += pow(pow(P[Y[i]][0] - P[Y[i-1]][0], 2) + pow(P[Y[i]][1] - P[Y[i-1]][1], 2), 0.5)
    return dist

def dfs(X):
    global ans
    if len(X)==N:
        ans.append(calcDist(X))
        return
    for i in range(N):
        if i not in X:
            X.append(i)
            dfs(X)
            X.pop()

ans = []
X = []
dfs(X)

print(sum(ans)/len(ans))



Measured memory_bytes: 4468
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
ll const MAX = 3e3 + 5;
double p[MAX];
double dp[MAX][MAX] = {};
int main() {
	ll n;
	cout.precision(13);
	cin >> n;
	REP(i, 1, n) {
		cin >> p[i];
	}
	dp[1][0] = 1 - p[1];
	dp[1][1] = p[1];
	REP(i, 2, n) {
		REP(j, 0, i) {
			if (j == 0) {
				dp[i][0] = dp[i - 1][0] * (1 - p[i]);
			}
			else if (j == i) {
				dp[i][i] = dp[i - 1][i - 1] * p[i];
			}
			else {
				dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
			}
		}
	}
	double ans = 0;
	REP(j, n / 2 + 1, n) {
		ans += dp[n][j];
	}
	cout << ans << endl;
}

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

using namespace std;

#define lint long long

int main(){
    int N;
    cin >> N;
    
    vector<int> p(N);
    for(int i = 0; i < N; ++i){
        cin >> p[i];
    }
    
    sort(p.begin(), p.end());
    
    int ans = 0;
    
    for(int i = 0; i < N - 1; ++i){
        ans += p[i];
    }
    ans += p[N - 1] / 2;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long all = a + b;
		long wari = n / all;
		wari = wari * a;
		long amari = n % all;
		long hasuu = a > amari ? amari : a;
		System.out.println(wari + hasuu);

		sc.close();
	}

}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	string s,t;
	cin >> s >> t;
	int a,b;
	cin >> a >> b;
	string u;
	cin >> u;
	cout << (s == u ? a-1 : a) << " " << (s == u ? b : b-1)  << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	if(N == 3 || N == 5 || N == 7){
		cout << "YES" << endl;
    }else{
      cout << " NO" << endl;
    }
  
  
	return 0;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
p = [2]
res = [0] * (pow(10, 5) + 1)
for i in range(3, pow(10, 5), 2):
  f = 0
  for x in p:
    if i % x == 0:
      f = 1
      break
  if f == 0: p.append(i)
ps = set(p)
for i in range(3, len(res) - 1):
  if i % 2 == 0: res[i] = res[i - 1]
  x = (i in ps) and (((i + 1) // 2) in ps)
  res[i] = res[i - 1] + x
#print(res[: 100])
for _ in range(N):
  a, b = map(int, input().split())
  print(res[b] - res[a - 1])

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

int main() {

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

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (w[i] == w[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	for (int i = 0; i < n - 1; i++) {
		if (w[i][w[i].size() - 1] != w[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		
		int max = Math.min(a, b); 
		int min;
		if (a + b <= n) {
			min = 0;
		} else {
			min = a + b - n;
		}
		System.out.println(max + " " + min);
	}

}


Measured memory_bytes: 21328
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int N;
    cin>>N;
    bool b = false;
    REP(i,1,10)
        REP(j,1,10)
            if(i*j==N) b = true;
    
    if(b==true) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int m;
	cin >> m;
	cout << 48 - m << endl;
}

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

int main(){
	std::cout<<std::fixed<<std::setprecision(8);
	double a,b,x,sup,hei,A=0,ans;
	cin >> a;
	cin >> b;
	cin >> x;
	sup = a*a*b - x;
	hei = sup*2/(a*a);
	if(b >= hei){
		ans = atan(hei/a)*180/M_PI;
	}
	else{
		A = x*2/(a*b);
		ans = atan(b/A)*180/M_PI;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			ans+=a[i]*a[j];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	price, _ := strconv.Atoi(s.Text())

	if mod := price % 1000; mod == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1000 - mod)
	}

}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    int a[n];
    f(i, n) cin>>a[i];
    int ans = 1;
    int mn = a[0];
    f(i, n) {
        if(i == 0) continue;
        if(a[i] < mn) ans++;
        mn = min(mn, a[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
 
public class Main{
 
    public static void main(String[] args) throws Exception
    {
        String[] strRing = {"24532453","64136413","56215621","51265126","63146314","54235423"};
        String strT,strS,strB;
        int nE=0,nW=0;
        boolean bInsane=false,bSum=false;
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
        int n = Integer.parseInt(br.readLine() );// input n
        String[] strValue = br.readLine().split(" ");// input Dice value
 
 
        StringBuilder sb = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
 
        for(String strEach : strValue)
        {
            sb.append(strEach);
        }
 
        sb.append(sb);
 
        String strStr = sb.toString();
 
 
        HashMap<String,String> map = new HashMap<String,String>();
 
        for(int i=0; i<6; i++)
        {
            map.put(strValue[i],Integer.toString(i+1) );
        }
 
        for(int i=0; i<n-1; i++)
        {
            String[] str = br.readLine().split(" ");//get 2nd dice
 
    try{
 
            strT = map.get(str[0]);
            strS = map.get(str[1]);
            strB = Integer.toString(7 - Integer.parseInt(strT) );
             
        }catch(NumberFormatException e){
            strB = null;
            strT = null;
            strS = null;
             
        }
 
            String strBST = strB + strS + strT;
 
            for(int j=0; j<6; j++)
            {
                if(-1 < strRing[j].indexOf(strBST) )
                {
                    nE = j;
                    nW = 5-j;
                }
            }
 
            if(strValue[nE].equals(str[2]) && strValue[nW].equals(str[3]) )
            {
                int nB = Integer.parseInt(strB);
                bInsane = strValue[nB-1].equals(str[5]) ? true : false;
 
//              System.out.println(strValue[nB-1].equals(str[5]) ? "Yes" : "No");
            }
            else
            {
                for(String strEach : str)
                {
                    sb2.append(strEach);
                }
 
                if(-1 < strStr.indexOf(sb2.toString() ) ) bInsane = true;
                else bInsane = false;
//              System.out.println("No");
            }
 
            bSum = bSum | bInsane;
 
            if(bSum)
            {
                System.out.println("No");
                System.exit(0);
            }
 
        }
 
        System.out.println("Yes");
 
    }
}

Measured memory_bytes: 24468
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#define SIZE 105

using namespace std;


typedef long long int ll;
typedef pair<int,int> P;
int A[SIZE];
int B[SIZE]; 
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i];
    for(int i=0;i<n;i++)cin>>B[i];
    int ret=0;
    for(int i=0;i<n;i++)
    {
    int sum=0;
    for(int j=0;j<=i;j++)sum+=A[j];
    for(int j=i;j<n;j++)sum+=B[j];
    ret=max(ret,sum);
    }
    cout<<ret;
    system("pause");
    return 0;
}   

Measured memory_bytes: 504
H,W = map(int,input().split())
A = [list(map(int,input().split())) for i in range(H)]
B = []
for h in range(H):
    for w in range(W):
        if A[h][w]%2==1:
            if w+1<W:
                B.append([h+1,w+1,h+1,w+2])
                A[h][w+1]+=1
            elif h+1!=H:
                B.append([h+1,w+1,h+2,w+1])
                A[h+1][w]+=1
print(len(B))
for b in B:
    print(*b)

Measured memory_bytes: 30300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int N, M;

vector<vector<int>> G;


int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> M;

    G.resize(N);

    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;

        G[a].PB(b);
        G[b].PB(a);
    }

    vector<int> mark(N);
    mark[0] = -1;
    vector<int> seen(N);


    queue<int> q;
    q.push(0);

    while (!q.empty()) {
        int t = q.front();
        q.pop();

        for (int v : G[t]) {
            if (!mark[v]) {
                //            cout << v << ' ' << t + 1 << endl;
                mark[v] = t + 1;
                q.push(v);
            }
        }
    }

    cout << "Yes" << endl;

    REP(i, N - 1)
    {
        cout << mark[i] << endl;
    }
}


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

#define int long long
#define EB emplace_back
#define S second
#define F first

using namespace std;

int32_t main()
{

	

	int tt=1;
	// cin>>tt
	 while(tt--)
	 {
	 int n; cin>>n;
	 map<string,int> mp;
	 for (int i = 0; i < n; ++i)
	 	{
	 		string str; cin>>str;
	 		mp[str]++;
	 	}	
	 std::vector<string> v;
	 int mx=0 ;
	 for(auto x : mp) mx=max(mx,x.S);

	 for(auto x : mp) if(x.S==mx) v.EB(x.F);
	 	sort(v.begin(), v.end());
	 for(auto x: v) cout<<x<<endl;


	 	

	 }
	return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



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

    li res = 0;
    repp(a, 1, n + 1) {
        repp(b, 1, n + 1) {
            repp(c, 1, n + 1) {
                res += __gcd(a, __gcd(b, c));
            }
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll M, N;
  cin >> N >> M;
  
  ll x = 2;
  ll y = 1;
  ll NN = M * 2 + 1;
  
  ll rb = NN / 2 + 1, re = NN;
  ll lb = 1, le = NN / 2;
  rep(i, M) {
    if(i % 2 == 0) {
      cout << rb << " " << re << endl;
      rb ++; re --;
    } else {
      cout << lb << " " << le << endl;
      lb ++; le --;
    }
    
  }
}

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 2019;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll L, R;
    cin >> L >> R;

    if(L/2019 == R/2019){
    	ll tmp = (1ll<<60);
    	for(ll i=L;i<=R;i++){
    		for(ll j=L;j<=R;j++){
    			if(i<j){
    				chmin(tmp, (i%mod)*(j%mod)%mod);
    			}
    		}
    	}
    	cout << tmp << endl;
    }else{
    	cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9 + 7

def factorial(n):
    num = 1
    for i in range(1, n+1):
        num = (num * i) % mod
    return num 

# aのb乗をpで割った余を計算する
def calc(a, b, p):
    if b == 0:
        return 1
    if b % 2 == 0:
        d = calc(a, b//2, p)
        return (d**2) % p
    else:
        return (a * calc(a, b-1, p)) % p

for i in range(1, K+1):
    if i > N-K+1 or i-1 > K-1:
        print(0)
    else:
        ans = (factorial(N-K+1)*calc(factorial(i), mod-2, mod)*calc(factorial(N-K+1-i), mod-2, mod)) % mod
        ans = (ans * ((factorial(K-1)*calc(factorial(i-1), mod-2, mod)*calc(factorial(K-i), mod-2, mod)) % mod)) % mod
        print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;

int main(void){
    int n, all_w = 0;
    cin >> n;

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

    vector<int> map(n);
    map[0] = w[0];

    for(int i = 1;i < n;i++){
        map[i] = map[i-1] + w[i];
    }

    int min = abs(map[0] - (all_w - map[0]));
    int tmp;
    for(int i = 1;i < n;i++){
        tmp = abs(map[i] - (all_w - map[i]));
        if(min > tmp)   min = tmp;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt(); //N日

		ArrayList<Long> capital = new ArrayList<>();
		capital.add(1000L);
		capital.add(0L);
		//capital{現金,株}

		Map<Integer, Integer> stockPrice = new HashMap<Integer, Integer>();

		for(int i = 1; i <= N; i++) {
			stockPrice.put(i, sc.nextInt());
		}

		sc.close();

		for(int i = 1; i < N; i++) {
			//さいしゅうびまで
			if(stockPrice.get(i) < stockPrice.get(i+1) & capital.get(1) == 0) {
				//次の日に株価が上がって、かつ株を持ってない場合
				//株は買わないといけない(i日に)

				//株を買う操作
				long stock = capital.get(0) / stockPrice.get(i);
				long money = capital.get(0) % stockPrice.get(i);

				capital.set(0, money);
				capital.set(1, stock);

			}else if(stockPrice.get(i) > stockPrice.get(i+1) & capital.get(1) != 0) {
				//次の日に株価が下がって、かつ株を持ってる
				//株は全部売っていい(i日に)

				//株を売る操作
				long stockSellMoney = capital.get(1) * stockPrice.get(i);
				long money = capital.get(0);

				capital.set(0, money + stockSellMoney);
				capital.set(1, 0L);

			}
			//System.out.println(i + "日目 cash = " + capital.get(0) + " stock = " + capital.get(1));
		}

		//最終日まで上がり続けたときに売らないといけない
		if(capital.get(1) != 0) {
			//株持ってる
			//最終日に現金化
			long stockSellMoney = capital.get(1) * stockPrice.get(N);
			long money = capital.get(0);

			capital.set(0, money + stockSellMoney);
			capital.set(1, 0L);

		}

		//結果発表！！！
		System.out.println(capital.get(0));
	}



}


Measured memory_bytes: 27168
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

const int MOD = 1e9 + 7;
const int SIZE = 1e5 + 10;

int main() {
	int N;
	int a[SIZE];
	int p,i;

	cin >> N;
	for (int i = 1; i <= N; ++i)
		cin >> a[i];

	p = a[1];
	for (i = 1; i <= N; ++i) {
		if (p == 2)
			break;
		p = a[p];
	}
	if (p == 2)
		printf("%d\n", i);
	else
		printf("-1\n");
}

Measured memory_bytes: 640
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 998244353
#define mp make_pair
#define ff first
#define ss second
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%lld",&a)
#define pf printf
#define sz(a) (ll)(a.size())
#define psf push_front
#define ppf pop_front
#define ppb pop_back
#define pb push_back
#define pq priority_queue
#define all(s) s.begin(),s.end()

using namespace std;

vector<int> h(1);
vector<int> val(1,-1);
int x,y;

int dp(int n)
{
    if(val[n-1]==-1)
    {
        if(n==x)
        {
            val[n-1]=0;
            return 0;
        }
        else
        {
            val[n-1]=abs(h[n+1]-h[n])+dp(n+1);
            for(int i=2;i<=y && i+n<=x;i++)
                val[n-1]=min(val[n-1],abs(h[n+i]-h[n])+dp(n+i));
        }
    }
    return val[n-1];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>x>>y;
    h.resize(x+1,0);
    val.resize(x,-1);
    f(i,1,x+1)
        cin>>h[i];
    cout<<dp(1);
}

Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    int n ; cin >> n;
    vector<int> a(10e6,0);
    int max_a = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        int x; cin >> x;
        a[x]++;
        max_a = max(x,max_a);
    }

    int max_sum = 0; 
    for ( int i = 1 ; i < max_a+2 ; i++ ){
        int x = a[i-1] + a[i] + a[i+1];
        max_sum = max(x,max_sum);
    }
    cout << max_sum << endl;
}

Measured memory_bytes: 39296
#include <iostream>

using namespace std;

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

    long long a[100001];
    for (long long i = 0; i < n; i++)
        cin >> a[i];

    long long sum;

    sum = 0;
    long long ret1 = 0;
    for (long long i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0 && sum <= 0) {
            ret1 += abs(sum) + 1;
            sum = 1;
        } else if (i % 2 == 1 && sum >= 0) {
            ret1 += abs(sum) + 1;
            sum = -1;
        }
    }

    sum = 0;
    long long ret2 = 0;
    for (long long i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0 && sum >= 0) {
            ret2 += abs(sum) + 1;
            sum = -1;
        } else if (i % 2 == 1 && sum <= 0) {
            ret2 += abs(sum) + 1;
            sum = 1;
        }
    }

    cout << min(ret1, ret2) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define matr vector<vector<int> > 
 
#define all(x) x.begin(), x.end()
 
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 1e9 + 9, inf = 1e9, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
int n; 

void solve() { 
    cin >> n; 
    cout << (n - 1) * n / 2; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;
  
int main() {
  int N;
  cin >> N;
  vm dp(N+1,0);
  dp[0]=1;
  vm acc(N+2,0);
  rep(i,N+1) {
    acc[i+1]=acc[i]+dp[i];
  }
  mint ans = 0;
  rep(i,N) {
    vm dp2(N+1,0);
    vm acc2(N+2,0);
    srep(j,3,N+1) {
      dp2[j] = acc[j-2];
    }
    dp = dp2;
    rep(j,N+1) {
      acc2[j+1] = acc2[j]+dp[j];
    }
    acc = acc2;
    ans += dp[N];
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void) {
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  puts(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H ? "Yes" : "No");

  return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    ll n = 0, m = 0;
    cin >> n >> m;
    if (m < n*2) {
        cout << m/2 << endl; 
    }
    else {
        cout << n + (m-2*n)/4 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n, k;
    std::cin >> n >> k;

    int32_t result = k;
    for (int i = 0; i < n - 1; ++i)
    {
        result *= k - 1;
    }

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


Measured memory_bytes: 256
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut sum:usize = 0;
    let mut v:usize = 0;
    for i in 0..n-1 {
        let a:usize = read!();
        if v<a {
            sum+=v;
        }
        else {
            sum+=a;
        }
        if i==0 {
            sum+=a;
        }
        if i==n-2 {
            sum+=a;
        }
        v = a;
    }
    println!("{}",sum);
}

Measured memory_bytes: 2120
N = int(input())
money = [input().split() for i in range(N)]

JPY = [int(money[i][0]) for i in range(N) if money[i][1] == 'JPY']
BTC = [float(money[i][0]) * 380000 for i in range(N) if money[i][1] == 'BTC']

print(sum(JPY) + sum(BTC))

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

using namespace std;
typedef long long ll;

ll cubic(ll n) {
    return 1ll * n * n * n;
}

int main() {
    ll n, k;
    cin >> n >> k;
    if (k & 1) {
        ll ans = n / k;
        cout << cubic(ans) << endl;
    } else {
        ll ans1 = n / k;
        k /= 2;
        ll ans2 = n / k;
        ans2 -= ans1;
        cout << cubic(ans1) + cubic(ans2) << endl;
    }
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 256
N = int(input())

a, b, c, d = 0, 0, 0 ,0
for _ in range(N):
  s = input()
  if s == 'AC':
    a += 1
  elif s == 'WA':
    b += 1
  elif s == 'TLE':
    c += 1
  else:
    d += 1
    
print('AC x ' + str(a))
print('WA x ' +str(b))
print('TLE x ' + str(c))
print('RE x ' + str(d))

Measured memory_bytes: 8948
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int S[300010];
int T[300010];
int C[300010];
map<int, int> mp;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int K = (1 << N);
    rep(i, K) cin >> S[i];
    sort(S, S + K);
    int cnt = 1;

    rep(i, K) {
        if (i > 0 && S[i] > S[i - 1]) cnt++;
        T[i] = cnt;
    }
    reverse(T, T + K);
    rep(i, K) C[T[i]]++;
    vector<int> R[20];
    R[0].push_back(T[0]);
    rep(i, N) {
        int D[300010] = {};
        sort(R[i].begin(), R[i].end(), greater<int>());
        rep(j, R[i].size()) {
            R[i + 1].push_back(R[i][j]);
            D[R[i][j]]++;
        }
        int maximam = T[0];
        rep(j, R[i].size()) {
            int less = max(1, R[i][j] - maximam);
            while (D[R[i][j] - less] + 1 > C[R[i][j] - less]) {
                less++;
                maximam = min(maximam, R[i][j] - less);
                if (R[i][j] - less <= 0) {
                    cout << "No" << endl;
                    return 0;
                }
                
            }   
            // cout << maximam << endl;
            D[R[i][j] - less]++;
            if (R[i][j] - less <= 0) {
                cout << "No" << endl;
                return 0;
            }
            R[i + 1].push_back(R[i][j] - less);
        }
        
        //rep(i, N + 1) cout << i << " " << D[i] << endl;
    }
    sort(R[N].begin(), R[N].end(), greater<int>());
    // rep(i, R[N].size()) {
    //     cout << R[N][i] << " ";
    // }
    // cout << endl;
    
    // rep(i, K) cout << T[i] << " ";
    // cout << endl;
    rep(i, R[N].size()) {
        if (R[N][i] < T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 6776
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

const int maxn = 2000;

int dp[maxn + 1][maxn + 1][2];
int min_dp_0[maxn + 1][maxn + 1];
int max_dp_1[maxn + 1][maxn + 1];

int main() {
  int n, start_a, start_b;
  scanf("%d %d %d", &n, &start_a, &start_b);
  vector<int> values(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &values[i]);
  for (int i = n; i >= 0; --i)
    for (int j = n; j >= 0; --j) {
      if (i == n && j == n) continue;
      for (int turn = 0; turn < 2; ++turn) {
        if (i == n || j == n) {
          int last_a = i > 0 ? values[i - 1] : start_a;
          int last_b = j > 0 ? values[j - 1] : start_b;
          dp[i][j][turn] = abs(last_a - last_b);
        } else if (turn == 0) {
          dp[i][j][turn] = max_dp_1[max(i, j) + 1][j];
        } else {
          dp[i][j][turn] = min_dp_0[i][max(i, j) + 1];
        }
      }
      min_dp_0[i][j] = dp[i][j][0];
      if (j + 1 <= n)
        min_dp_0[i][j] = min(min_dp_0[i][j], min_dp_0[i][j + 1]);

      max_dp_1[i][j] = dp[i][j][1];
      if (i + 1 <= n)
        max_dp_1[i][j] = max(max_dp_1[i][j], max_dp_1[i + 1][j]);
    }
  printf("%d\n", dp[0][0][0]);
  return 0;
}


Measured memory_bytes: 62848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define o(s) cout<< s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a,b; cin>>a>>b;
    o((a%2==1&&b%2==1?"Yes":"No"));
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	int n;
	cin>>n;
	string p;
	cin>>p;
	if(n&1){cout<<"No";return 0;}
	for (int i = 0; i < n/2; ++i)
		if(p[i]!=p[i+n/2]){cout<<"No";return 0;}
	cout<<"Yes";
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int N, M;
vector<int> edge[1000];
bool E[1000][1000];
int par[1000];
int nxt[1000];
bool live[1000];
bool saw[1000];
vector<int> loop;

int dfs(int st, int v, int p) {
    saw[v] = true;
    for (int e : edge[v]) {
        if (e == st) {
            par[e] = v;
            return v;
        }
        if (saw[e]) continue;
        par[e] = v;
        int r = dfs(st, e, v);
        if (r != -1) return r;
    }
    return -1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i,M) {
        int A, B; cin >> A >> B;
        A--; B--;
        edge[A].push_back(B);
        E[A][B] = true;
    }
    memset(par, -1, sizeof(par));
    int st = -1;
    rep(i,N) {
        memset(saw, 0, sizeof(saw));
        par[i] = i;
        int tmp = dfs(i, i, i);
        if (tmp != -1) {
            st = tmp;
            break;
        }
    }
    if (st == -1) {
        cout << -1 << endl;
        return 0;
    }
    {
        int pos = st;
        while (true) {
            loop.push_back(pos);
            pos = par[pos];
            if (pos == st) break;
        }
    }
    rep(i,loop.size()) {
        nxt[i] = (i+1)%(int)loop.size();
        live[i] = true;
    }
    reverse(loop.begin(), loop.end());
    rep(i,loop.size()) {
        if (!live[i]) continue;
        rep(_j,(int)loop.size()-1) {
            int j = (i-1-_j+loop.size())%loop.size();
            if (!live[j]) continue;
            if (E[loop[i]][loop[j]]) {
                int now = (i+1)%loop.size();
                while (now != j) {
                    live[now] = false;
                    now = (now+1)%loop.size();
                }
                break;
            }
        }
    }
    int K = 0;
    rep(i,loop.size()) if (live[i]) K++;
    cout << K << endl;
    rep(i,loop.size()) if (live[i]) cout << loop[i]+1 << endl;
}

Measured memory_bytes: 1408
#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 REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    REP(i, N) cin >> A[i];
    REP(i, M) cin >> B[i];

    vector<ll> sumA(N + 1), sumB(M + 1);
    REP(i, N) sumA[i + 1] += sumA[i] + A[i];
    REP(i, M) sumB[i + 1] += sumB[i] + B[i];

    ll ans = 0;

    REP(i, N+1) 
    {
        ll t = K - sumA[i];
        if(t < 0) break;
        int c = upper_bound(all(sumB), t) - sumB.begin() - 1;
        chmax(ans, i + c);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 1e5 + 5;

int n, m;
int p[N];
vector<int> g[N];
vector<bool> vis(N, false);
map<int, int> cnt;	

void dfs(int u);
				
int32_t main() {
	fast_cin();  
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> p[i];
	}
	for (int i = 0, u, v; i < m; ++i) {
		cin >> u >> v;
		g[u].push_back(v), g[v].push_back(u);
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (!vis[i]) {
			cnt.clear();
			dfs(i);
			for (auto it : cnt) {
				ans += (it.second == 2);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

void dfs(int u) {
	vis[u] = true;
	++cnt[u], ++cnt[p[u]];
	for (int v : g[u]) {
		if (!vis[v]) {
			dfs(v);
		}
	}
}

Measured memory_bytes: 17792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			int x = scanner.nextInt(), y = scanner.nextInt();
			System.out.println((n > k) ? k * x + (n - k) * y : n * x);
		}
	}
}


Measured memory_bytes: 35676
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val k = (a + b) / 2
    val dk: Double = (a.toDouble() + b) / 2
    if (k.toDouble() == dk) {
        print(k)
    } else {
        print("IMPOSSIBLE")
    }
}


Measured memory_bytes: 31392
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> >adj;
vector<int>vis;
vector<int>ans;
void dfs(int u)
{
  for(auto x : adj[u])
  {
    if(vis[x])
    {
      ans[x]=min(ans[u]+1,ans[x]);
      return ;
    }
    else
    {
      vis[x]=1;
      ans[x]=ans[u]+1;
    }
    dfs(x);
  }
  return ;
}
int main()
{
  int n,m;
  cin>>n>>m;
  adj.resize(n);
  vis.resize(n);
  ans.resize(n);
  for(int i=0;i<m;i++)
  {
    int e,f;
    cin>>e>>f;
    e--;
    f--;
    adj[e].push_back(f);
    adj[f].push_back(e);
  }
  ans[0]=0;
  dfs(0);
  if(ans[n-1]!=0)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}

Measured memory_bytes: 13552
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X, Y, Z, K = mapint()
As = list(mapint())
Bs = list(mapint())
Cs = list(mapint())
As.sort(reverse=True)
Bs.sort(reverse=True)
Cs.sort(reverse=True)

from heapq import heappop, heappush
Q = []
heappush(Q, (-(As[0]+Bs[0]+Cs[0]), 0, 0, 0))
s = set()
for _ in range(K):
    v, a, b, c = heappop(Q)
    print(-v)
    if a+1<X and not (a+1, b, c) in s:
        s.add((a+1, b, c))
        heappush(Q, (-(As[a+1]+Bs[b]+Cs[c]), a+1, b, c))
    if b+1<Y and not (a, b+1, c) in s:
        s.add((a, b+1, c))
        heappush(Q, (-(As[a]+Bs[b+1]+Cs[c]), a, b+1, c))
    if c+1<Z and not (a, b, c+1) in s:
        s.add((a, b, c+1))
        heappush(Q, (-(As[a]+Bs[b]+Cs[c+1]), a, b, c+1))

Measured memory_bytes: 79352