akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct UnionFind {
  vector<ll> par, siz;

  UnionFind(ll n):par(n),siz(n,1) {
    for (ll i = 0; i < n; ++i) par[i] = i; //すべて根として初期化
  }

  ll root(ll x) {
    if (par[x] == x) return x;
    else return par[x] = root(par[x]);
  }

  void merge(ll x, ll y) {
    ll rx = root(x);
    ll ry = root(y);
    if (rx == ry) return;
    if (siz[rx] < siz[y]) swap(rx, ry);
    par[rx] = ry;
    siz[ry] += siz[rx];
  }

  bool same(ll x, ll y) {
    return root(x) == root(y);
  }

  ll size(ll x) {
    return siz[root(x)];
  }
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n, m;
  cin >> n >> m;
  vector<P> v(m);
  rep(i,m) {
    cin >> v[i].first >> v[i].second;
    v[i].first--; v[i].second--;
  }
  reverse(all(v));
  UnionFind tree(n);
  vector<ll> ans(m+1);
  ans[0] = n*(n-1)/2;
  for (int i = 0; i < m; ++i) {
    if (tree.same(v[i].first, v[i].second)) ans[i+1] = ans[i]; //既に連結
    else ans[i+1] = ans[i] - tree.size(v[i].first) * tree.size(v[i].second);
    debug(v[i].first, v[i].second, ans[i+1]);
    tree.merge(v[i].first, v[i].second);
  }
  for (int i = m-1; i >= 0; --i) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 5248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var arr = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var max = arr.Max();
            var min = arr.Min();

            Console.WriteLine((max - min).ToString());
        }
    }
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define Rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rep(i, n) Rep(i, 0, n)
#define vi vector<int>
#define vvi vector<vi>

typedef long long ll;

int main() {
  int N;
  cin >> N;
  vi D(N, 0), cnt(N, 0);
  rep(i, N) {
    cin >> D[i];
    if (i == 0) {
      if (D[i] != 0) {
        cout << 0 << endl;
        return 0;
      }
    } else {
      if (D[i] == 0) {
        cout << 0 << endl;
        return 0;
      }
    }
    cnt[D[i]] += 1;
  }
  ll ans = 1;
  if (D[0] != 0) {
    ans = 0;
  } else {
    Rep(i, 1, N) {
      rep(j, cnt[i]) {
        ans *= cnt[i - 1];
        ans %= 998244353;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, m;
    cin >> n >> m;
    int ans = (n-1)*(m-1);
    
    cout << ans << endl;
    return 0;
}


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



int main(){
    long double A, B, C, D; cin >> A >> B >> C >> D;
    long double d1 = 30*C + D / 60 * 30;
    long double d2 = D / 60 * 360;
    long double d = abs(d1-d2);
    d = min(d, 360-d);
    long double rad = 2*(d/360)*M_PI;
    long double temp = (double)pow(A, 2) + (double)pow(B, 2) - 2*A*B* (double)cos(rad);
    cout << setprecision(20) <<  sqrt(temp) << endl;
}


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

int main() {
  int n;
  string s,t;
  string ans = "";
  cin >> n >> s >> t;

  for (int i = 0; i < n; i++) {
    ans += s[i];
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    for(int i=1;i<S.size();i++){
        if(S.at(i-1)==S.at(i)){
            cout<<"no"<<endl;
            return 0;
        }
        }
        cout <<"yes"<<endl;
    
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long num1, num2, dividend, divisor, surplus;
		
		while(scan.hasNext()) {
			num1 = scan.nextLong();
			num2 = scan.nextLong();
			
			if(num1 < num2) {
				dividend = num2;
				divisor = num1;
			} else {
				dividend = num1;
				divisor = num2;
			}
			
			surplus = dividend % divisor;
			while(surplus != 0) {
				dividend = divisor;
				divisor = surplus;
				surplus = dividend % divisor;
			}
			long gcd = divisor;
			long lcm = num1 * num2 / divisor;
			
			System.out.printf("%d %d\n", gcd, lcm);
			
		}
	}
}

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

const int N=100100,mod=998244353;
typedef long long ll;
int ksm(ll a,int b,int c=1){
	for(;b;b/=2,a=a*a%mod)
		if(b&1)c=c*a%mod;
	return c;
}
char S[N],T[N];
int n,f[N],jc[N],jc2[N],ans;

void init(){
	jc[0]=1;
	for(int i=1;i<N;++i)jc[i]=(ll)jc[i-1]*i%mod;
	jc2[N-1]=ksm(jc[N-1],mod-2);
	for(int i=N-1;i;--i)jc2[i-1]=(ll)jc2[i]*i%mod;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>S>>T;n=strlen(S);init();
	int p=0,q=0;
	for(int i=0;i<n;++i)
		if(S[i]=='1'){if(T[i]=='0')++p;else ++q;}
	f[0]=1;
	for(int i=1;i<=p;++i)
		for(int j=1;j<=q;++j)
			f[j]=(f[j]+(ll)i*f[j-1])%mod;
	for(int i=0;i<=q;++i)ans=(ans+(ll)f[i]*jc2[p+i])%mod;
	ans=(ll)ans*jc[p]%mod*jc[p]%mod*jc[q]%mod*jc[p+q]%mod;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		boolean exist = false;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			
			if (d1 == d2) cnt++;
			else cnt = 0;
			
			if (cnt >= 3) {
				exist = true;
				break;
			}
		}
		
		System.out.println(exist ? "Yes" : "No");
		
		sc.close();
	}
}



Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define vi vector<ll>
#define all(_x) _x.begin(), _x.end()
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define lb(_x, _a) (lower_bound(all(_x), _a) - _x.begin())
#define ub(_x, _a) (upper_bound(all(_x), _a) - _x.begin())

int main()
{
  	// ll is int now
    ll x; cin>>x;
    if(x<=4)
    {
        cout<<0<<endl;
        return 0;
    }
    ll a = x/500;
    x = x - a*500;
    a = 1000*a;

    ll b = x/5;
    a += 5*b;

    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    string s = to_string(n);
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == '7')
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

Measured memory_bytes: 3720
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,a[100005],f[100005];
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	f[n]=0;
	f[n-1]=abs(a[n-1]-a[n]);
	for(int i=n-2;i>=1;i--)
	{
		f[i]=min(abs(a[i]-a[i+1])+f[i+1],abs(a[i]-a[i+2])+f[i+2]);
	}
	printf("%lld",f[1]);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'

using namespace std;
typedef pair<int, int> P;
typedef long long LL;

static const int INF = INT_MAX;

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

    int n;
    cin >> n;
    int data;
    deque< int >dq;

    for(int i = 0; i < n; ++i) {
        cin >> data;
        if( i % 2 ) dq.push_front( data );
        else dq.push_back( data );
    }

    if( !( n % 2 ) ) {
        cout << dq.front();
        dq.pop_front();

        while( !dq.empty() ) {
            cout  << " " << dq.front();
            dq.pop_front();
        }

    } else {
        cout << dq.back();
        dq.pop_back();

        while( !dq.empty() ) {
            cout << " " << dq.back();
            dq.pop_back();
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3072
# include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+500;
int main ()
{
	int s[maxn];
	int f[maxn];
	int n;
	int k;
	cin>>n>>k;
	memset (f,0,sizeof(f));
	memset (s,0,sizeof(s));
	for (int i=1;i<=n;++i)
	    cin>>s[i];
	sort(s+1,s+n+1);
	int p=0;
    for (int i=1;i<=n-k+1;++i)
         {
         	f[p]=s[i+k-1]-s[i];
         	p++;
		 }
	sort (f,f+p);
	printf ("%d\n",f[0]);
	return 0;
}

Measured memory_bytes: 1024
import collections
n, m = map(int, input().split())
visited = [False]*n
ships = [set() for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    ships[a-1].add(b-1)
    ships[b-1].add(a-1)

for i in range(1,n-1):
    if 0 in ships[i] and n-1 in ships[i]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Measured memory_bytes: 75604
import java.util.*;

public class Main {
	static public void main(String args[]){
		Scanner sc=new Scanner(System.in);
		 
		 String str=sc.next();
		 String str2=sc.next();
		 
		 char ch=str2.charAt(str2.length()-1);
		 str+=ch;
		 if(str.equals(str2))System.out.print("Yes");
		 else System.out.print("No");
	}
}

Measured memory_bytes: 39364
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))


n_list = list(range(1, n+1))
n_perm = list(itertools.permutations(n_list))

print(abs(n_perm.index(p) - n_perm.index(q)))

Measured memory_bytes: 8052
import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni();
        long[] a = new long[n];
        for(int i = 0; i< n; i++)a[i] = nl();
        long sum = 0;
        for(int i = 0; i< n; i++)sum += a[i]*(i%2==0?1:-1);
        long[] ans = new long[n];
        ans[0] = sum/2;
        for(int i = 1; i< n; i++)ans[i] = a[i-1]-ans[i-1];
        for(long l:ans)p(l*2+" ");
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long IINF = (long)1e18, mod = (long)998244353;
    final int INF = (int)1e9, MX = (int)2e5+5;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-6;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}

Measured memory_bytes: 45760
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod1 1000000007
#define ff first
#define ss second
#define INF INT_MAX
#define INFLL LLONG_MAX
typedef long long int ll;
// #define intLL unsigned long long int//used when x<2^64-1 && x>0
#define int long long//used when x<2^63-1
map<int, int> mp;
const int N=2019;
int32_t main()
{

    IOS;
    string s;
    cin>>s;
    int n=(int)s.size();
    int cur=0, val=1;
    mp[0]=1;
    for(int i=n-1;i>=0;i--)
    {
        cur+=val*(s[i]-'0');
        cur%=N;
        val=val*10;
        val%=N;
        // cout<<cur<<"\n";
        mp[cur]++;
    }
    int ans=0;
    for(auto it: mp)
    {
        // cout<<it.ff<<" "<<it.ss<<"\n";
        int x=it.ss;
        if(x>0)
        x=(x*(x-1))/2;
        ans+=x;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max(a * c, a * d);
    ans = max(b * c, ans);
    ans = max(b * d, ans);
    cout << ans << endl;
}


Measured memory_bytes: 3632
nm = input().split()
n = int(nm[0])
m = int(nm[1])

h = input().split()
h = [int(x) for x in h]


ls = []
for i in range(len(h)):
    tmp = [h[i],[]]
    ls.append(tmp)

for i in range(m):
    ab = input().split()
    a = int(ab[0])
    b = int(ab[1])

    ls[a-1][1].append(b-1)
    ls[b-1][1].append(a-1)
    # print(ls)
    
result  = 0
for i in range(n):
    flag = 0
    for j in range(len(ls[i][1])):
        # print(ls[i][0])
        if ls[ls[i][1][j]][0]  < ls[i][0]:
            # print('i=',i,'相手',ls[ls[i][1][j]][0], '   自分',ls [i][0])
            flag = 0
        else:
            # print('flag',flag )  
            flag = 1  
            break

    if flag == 0:   
        # print(i)
        result +=1
    # print('i=',i,'result=',result)
print(result)

Measured memory_bytes: 37404
import java.util.*
import java.math.*

fun main(args: Array<String>) {
//    var (r, d, x) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val S = readLine()!!.toInt()
//    val D = readLine()!!.split(" ").map { it.toLong() }
//    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    val array = IntArray(26)
    for (c in readLine()!!) {
        array[c-'a']++
    }
    println(if (array.all { it%2 == 0 }) "Yes" else "No")
}


Measured memory_bytes: 33688
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)1000000000000000
#define eps 1e-14
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, s, t) for(int i = (int)(s); i < (int)(t); i++)
#define rrep(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using pii = pair<int, int>;
template<typename T> using mpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vec = vector<T>;
using str = string;
void io_init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int int_in() {
  int w;
  cin >> w;
  return w;
}
void int_out(int w) {
  cout << w << "\n";
}
str str_in() {
  str s;
  cin >> s;
  return s;
}
void str_out(str s) {
  cout << s << "\n";
}
double double_in() {
  double w;
  cin >> w;
  return w;
}
void double_out(double d) {
  cout << fixed << setprecision(10) << d << "\n";
}
template<typename T> vec<T> vec_in(int n) {
  vec<T> v(n);
  rep(i, n) {
    cin >> v[i];
  }
  return v;
}
template<typename T> void vec_out(const vec<T>& v) {
  rep(i, v.size()) {
    if(i != v.size() - 1) {
      cout << v[i] << " ";
    }
    else {
      cout << v[i] << "\n";
    }
  }
}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,-1,0,1};
class unionfind {
public:
  vec<int> d, c;
  unionfind(int n = 0) : d(n), c(n) {
    rep(i, n) {
      d[i] = -1;
      c[i] = 0;
    }
  }
  int find(int b) {
    if(d[b] < 0) {
      return b;
    }
    return find(d[b]);
  }
  int unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a == b) {
      return a;
    }
    if(c[a] > c[b]) {
      d[b] = a;
      return a;
    }
    else if(c[a] == c[b]) {
      d[b] = a;
      c[a]++;
      return a;
    }
    else {
      d[a] = b;
      return b;
    }
  }
};
class bit {
public:
  vec<int> d;
  bit(int n) : d(n) {
    rep(i, n) {
      d[i] = 0;
    }
  }
  void add(int b, int x) {
    for(int i = b + 1; i <= (int)d.size(); i += i & -i) {
      d[i - 1] += x;
    }
  }
  int sum(int l) {
    int r = 0;
    for(int i = l + 1; i > 0; i -= i & -i) {
      r += d[i - 1];
    }
    return r;
  }
  int sum(int b, int e) {
    return sum(e - 1) - sum(b - 1);
  }
};
int bit_mask(int l) {
  return ((int)1 << l) - 1;
}
int bit_get(int a, int b, int l, int m = 1) {
  return (a >> (b * m)) & bit_mask(l * m);
}
void bit_out(int a, int l) {
  rep(i, l) {
    cout << bit_get(a, i, 1);
  }
  cout << "\n";
}

#define mod

int dd[111111];

signed main() {
  io_init();
  int nn = int_in();
  rep(ii, nn) {
    dd[ii] = 0;
  }
  rep(ii, nn) {
    dd[int_in()]++;
  }
  bool ff = true;
  if(nn % 2 == 0) {
    rep(ii, nn / 2) {
      if(dd[ii * 2 + 1] != 2) {
        ff = false;
      }
    }
  }
  else {
    if(dd[0] != 1) {
      ff = false;
    }
    rep(ii, nn / 2) {
      if(dd[ii * 2 + 2] != 2) {
        ff = false;
      }
    }
  }
  if(ff) {
    int now = 1;
    rep(ii, nn / 2) {
      now = (now * 2) % 1000000007;
    }
    int_out(now);
  }
  else {
    int_out(0);
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int n;
	cin >> n;
	int p[n];
	rep(i,0,n) cin >> p[i];
	int cnt=0;
	rep(i,1,n-1){
		if((p[i-1]<p[i]&&p[i]<p[i+1]) || (p[i-1]>p[i]&&p[i]>p[i+1])) cnt++;
	}
	cout << cnt << endl;
}

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

int main() {
    int n, p;
    cin >> n >> p;
    vector<int> cnt(2, 0);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cnt[a % 2]++;
    }
    if (cnt[1] == 0 && p == 1) {
        cout << 0 << endl;
    } else if (cnt[1] == 0 && p == 0) {
        cout << (1LL << n) << endl;
    } else {
        cout << (1LL << (n - 1)) << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
ll a[e5];
ll dp[e5];
ll pd[e5];
ll ans;

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

int main(){
  cin >> n;
  for(ll i = 0;i < n;i++) cin >> a[i];
  dp[0] = a[0];
  for(ll i = 1;i < n;i++){
    dp[i] = gcd(dp[i-1], a[i]);
  }
  pd[n-1] = a[n-1];
  for(ll i = n-2;i >= 0;i--){
    pd[i] = gcd(pd[i+1], a[i]);
  }
  ans = max(dp[n-2], pd[1]);
  for(ll i = 1;i < n-1;i++){
    ans = max(ans, gcd(dp[i-1],pd[i+1]));
  }

  cout << ans << endl;

}


Measured memory_bytes: 5120
#include<stdio.h>
int main(void)
{
	int n,x[1000],i,j,w,max,min,cnt;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	min=10000;
	max=0;
	cnt=0;
	for(i=0;i<n;i++){
		if(min>x[i]){
			min=x[i];
		}
		if(max<x[i]){
			max=x[i];
		}
	}
	for(j=min;j<=max;j++){
		cnt++;
	}
	printf("%d\n",cnt/2);
	return 0;
}
			


Measured memory_bytes: 2100
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int n;cin>>n;
    cout<<n/3;
}



Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>

using namespace std;

int main(void) {
	int a, b, c;

	cin >> a >> b >> c;

	if (a<=c && c<=b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()
 
#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)
 
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

const int MAX_N = 205;
const int D = 64;
ll basis[D];
ll arr[MAX_N];
 
int main() { FAST
    int t; cin >> t;
    while(t--) {
        int n; cin >> n;
        M00(i, n) cin >> arr[i];
        string s; cin >> s;
        M00(i, D) basis[i] = 0;
        bool good = 1;
        M00d(i, n) {
            if(!good) break;
            if(s[i] == '0') {
                ll val = arr[i];
                while(val != 0) {
                    int idx = __builtin_clzll(val);
                    if(basis[idx] == 0) {
                        basis[idx] = val;
                        break;
                    }
                    val ^= basis[idx];
                }
            } else {
                ll val = arr[i];
                while(val != 0) {
                    int idx = __builtin_clzll(val);
                    if(basis[idx] == 0) {
                        good = 0;
                        break;
                    }
                    val ^= basis[idx];
                }
            }
        }
        cout << (good ? "0" : "1") << "\n";
    }
}



Measured memory_bytes: 3560
import java.io.BufferedReader;
        import java.io.InputStreamReader;
        import java.util.Scanner;

public class Main {
    public static void main(String []args)
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println((a*b)/2);


    }
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void){

    int N;
    int a = 0, b = 0;
    scanf("%d", &N);
    int A[N];

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

    for(int i = 0; i < N - 1; i++){
        for(int j = N - 1; j > i; j--){

            if(A[j] > A[j - 1]){
            int tmp;
            tmp = A[j];    //sort.
            A[j] = A[j - 1];
            A[j - 1] = tmp;
         }

       }
    }

    for(int k = 1; k < N + 1; k++){
        if(k % 2 == 1){
            a +=  A[k - 1]; //奇数のときはAlice
        }
        if(k % 2 == 0){
            b += A[k - 1];
        }
    }

    printf("%d", a - b);


    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(2*a>b||4*a<b)
    {
        cout<<"No"<<endl;
    }
    else if(b%2==1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;

const int N = 3e5 + 5;



signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++)
        if (i % d == 0)
            ans++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long

signed main() {
        int N;
        cin >> N;
        vector<int> A(N+1), B(N+1);
        for(int i = 1; i <= N; ++i) {
                cin >> A[i];
                A[i] += A[i-1];
        }
        for(int i = 1; i <= N; ++i) {
                cin >> B[i];
                B[i] += B[i-1];
        }
        int res = 0;
        for(int i = 1; i <= N; ++i) {
                res = max(res, A[i] - A[0] + B[N] - B[i-1]);
        }
        cout << res << endl;
        return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	answers := 0
	for i := 1; i <= n; i += 2 {
		cnt := 2 // 1 and self
		for d := 2; d <= i/2; d++ {
			if i%d == 0 {
				cnt += 1
			}
		}
		if cnt == 8 {
			answers += 1
		}
	}

	fmt.Println(answers)
}


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

void stlip(vector<int> &v, string &s) {
  for (auto i = s.rbegin(), e = s.rend(); i != e; i++) {
    v.push_back(*i - 48);
  }
}

void print(vector<int> &v) {
  int n;
  string s;
  for (auto i = v.rbegin(), e = v.rend(); i != e; i++) {
    s += to_string(*i);
  }
  if (s.size() > 80)
    cout << "overflow" << endl;
  else
    cout << s << endl;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    vector<int> v1, v2, ret;
    string a, b;
    bool flag = true;
    cin >> a >> b;
    if (a.size() > 80 || b.size() > 80) {
      cout << "overflow" << endl;
      continue;
    }
    if (a.size() < b.size())
      swap(a, b);
    stlip(v1, a);
    stlip(v2, b);
    v2.resize(v1.size());
    for (int i = 0; i < v1.size(); i++) {
      int tmp;
      tmp = v1[i] + v2[i];
      if (tmp > 9) {
        if (i == v1.size() - 1) {
          v1.resize(v1.size() + 1);
          v2.resize(v1.size() + 1);
        }
        v2[i + 1] += 1;
        tmp -= 10;
      }
      ret.push_back(tmp);
    }
    if (flag)
      print(ret);
  }

  return 0;
}



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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; ++i) cin >> a[i];

    ll mn = LLONG_MAX;
    for (int q=0; q<2; ++q) {
        ll sum = 0, cost = 0;
        for (int i=0; i<n; ++i) {
            if (i % 2 == q) {
                if (sum + a[i] > 0) {
                    sum += a[i];
                } else {
                    cost += -(sum + a[i]) + 1;
                    sum = 1;
                }
            } else {
                if (sum + a[i] < 0) {
                    sum += a[i];
                } else {
                    cost += sum + a[i] + 1;
                    sum = -1;
                }
            }
        }
        mn = min(mn, cost);
    }
    cout << mn << endl;
    return 0;
}

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

using namespace std;

int n,k;
int a[200010];
map<int,int> m;
vector<int> v;
long long ans;

bool cmp(int x,int y){
	return m[x]<m[y];
}

int main()
{
	cin>>n>>k;
	int i,j;
	for (i=1;i<=n;i++){
		cin>>a[i];
		if (m[a[i]]==0)v.push_back(a[i]);
		m[a[i]]++;
	}
	if (v.size()<=k){
		cout<<0<<endl;
		return 0;
	}
	sort(v.begin(),v.end(),cmp);
	for (i=0;i<v.size()-k;i++){
		ans+=m[v[i]];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  int rup;
  int mean;
  
  cin >> a;
  cin >> b;
  
  mean = (a + b)/2;
  rup = a + b - 2 * mean;
  
  cout << mean + rup << endl;
}

Measured memory_bytes: 256
N = int(input())
IN = list(map(int,input().split()))
print(*IN)
for i in range(1,N):
    v = IN[i]
    j = i - 1
    while j >= 0 and IN[j] > v:
        IN[j+1] = IN[j]
        j -= 1
    IN[j+1] = v
    print(*IN)


Measured memory_bytes: 5984
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
	int r;
	cin >> r;
	cout << r * r;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b,m;
vector<int>v[501];
bool used[501];
void dfs(int x){
  used[x]=1;
  for(int i=0;i<v[x].size();i++)
    if(!used[v[x][i]])dfs(v[x][i]);
}
main(){
  cin>>n>>m;
  for(int i=0;i<m;i++)
    cin>>a>>b,
    v[a].push_back(b);
 
  int sum=0,aa=0;

  for(int i=1;i<=n;i++)
    if(!used[i])dfs(i),aa++;
  
  for(int i=1;i<=n;i++)
    sum+=v[i].size()-1;

  cout<<sum+aa<<endl;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  VI B(N-1);
  REP(i, N-1) cin >> B.at(i);
  int ans = B.at(0);
  REP(i, N-2)
  {
    ans += min(B.at(i), B.at(i+1));
  }
  ans += B.at(B.size()-1);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def XOR(n):
    if n % 4 == 1:
        return 1
    elif n % 4 == 2:
        return n + 1
    elif n % 4 == 3 or n == 0:
        return 0
    else:
        return n

A, B = map(int, input().split())
print(XOR(B) ^ XOR(A - 1))

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        int count = 0;
        for (int i = 0; i < N; i++) {
            if (h[i] >= K) {
                count++;
            }
        }

        System.out.println(count);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 49524
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

 
//FUNCTION
 
//SOLVE
void solve(void)
{
  int N;
  cin>>N;
  map<char,int> mp;
  for (int i = 0; i < N; i++)
  {
    string str;
    cin>>str;
    if(str[0] =='M' ||str[0] =='A'||str[0] =='R'||str[0] =='C'||str[0] =='H')
    {
      mp[str[0]]++;
      
    }
  }

  if(mp.size() < 3)
  {
    cout<<0<<endl;
    return;
  }

  vector<int> vec(5,0);
  for (auto i : mp)
  {
    static int index = 0;
    vec[index] = i.second;
    index++;
  }
  
  // DEBUG(vec);
  int ANS = 0;
  for (int i = 0; i < 5; i++)
  {
    for (int j = i+1; j < 5; j++)
    {
      for (int k = j+1; k < 5; k++)
      {
        ANS += vec[i]*vec[j]*vec[k];
      }
    }
  }
  cout<<ANS<<endl;
  
    
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<double> dp(n+1,0);
    dp[0]=1;
    for(int i=0;i<n;i++)
    {
        double p;
        cin >> p;
        for(int j=n;j>0;j--) dp[j]=(dp[j-1]*p+dp[j]*(1-p));
        dp[0]*=(1-p);
    }
    double res=0;
    for(int i=(n+1)/2;i<=n;i++) res+=dp[i];
    cout << fixed << setprecision(10) << res << "\n";
    return 0;
}


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

int main() {

  int input1,input2;
  char c;

  int ang = 0;
  double x,y;
  x = y = 0.00;

  while(true) {

    cin >> input1 >> c >> input2;
    if ( input1 == 0 && input2 == 0 ) break;

    x += sin( M_PI * ang / 180 ) * input1;
    y += cos( M_PI * ang / 180 ) * input1;

    ang += input2;

  }

  int x_i = x;
  int y_i = y;

  cout << x_i << endl << y_i << endl;
  return 0;

}

Measured memory_bytes: 1164
from collections import deque

N = int(input())
A_list = sorted([int(input()) for _ in range(N)])

if N == 2:
    print(abs(A_list[0] - A_list[1]))
    exit()

if N == 3:
    a0,a1,a2 = A_list
    print(max(abs(a0-a1) + abs(a1-a2),abs(a1-a2) + abs(a2-a0) ,abs(a0-a2) + abs(a0-a1)))
    exit()
    
q = deque(A_list)
res_q = deque([q.popleft(), q.pop()])
l = res_q[0]
r = res_q[-1]

v1 = v2 =0

v1 = q.popleft()
v2 = q.pop()
res = abs(l-r)
for _ in range(2,N-2):
    diff_l1 = abs(l-v1)
    diff_l2 = abs(l-v2)
    diff_r1 = abs(r-v1)
    diff_r2 = abs(r-v2)
    max_diff = max(diff_l1,diff_l2, diff_r1, diff_r2)
    
    res += max_diff
    if diff_l1 == max_diff:
        l = v1
        v1 = q.popleft()
    elif diff_l2 == max_diff:
        l = v2
        v2 = q.pop()
    elif diff_r1 == max_diff:
        r = v1
        v1 = q.popleft()
    else:
        r = v2
        v2 = q.pop()

# あまった2つの処理
diff_list = [abs(l-v1) + abs(v1-v2),
            abs(l-v1) + abs(r-v2),
            abs(l-v2) + abs(v1-v2),
            abs(l-v2) + abs(r-v1),
            abs(r-v1) + abs(l-v2),
            abs(r-v1) + abs(v1-v2),
            abs(r-v2) + abs(l-v1),
            abs(r-v2) + abs(v1-v2)]
res += max(diff_list)

print(res)

Measured memory_bytes: 8580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] list = sc.next().toCharArray();
		for(int i = 0; i < 3; i++) {
			if(list[i] == '1')System.out.print(9);
			else System.out.print(1);
		}
	}
}


Measured memory_bytes: 21716
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

#define MOD 1000000007



int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	long long a, b;
	cin >> n >> a >> b;
	vector<long long > vec(n);
	for (int i = 0; i < n; i++)
		cin >> vec[i];

	long long left = 0, right = 1e9 + 1;
	while (left < right)
	{
		long long med = (left + right) / 2;

		vector<long long> tmp = vec;
		for (long long& val : tmp)
		{
			val -= med * b;
		}

		long long need_op = 0;
		for (long long& val : tmp)
		{
			if (val <= 0)
				continue;
			need_op += (val + (a - b) - 1) / (a - b);
		}
		if (need_op <= med)
		{
			right = med;
		}
		else
		{
			left = med + 1;
		}
	}

	cout << left;


	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
#include <unordered_map>
#include <cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define INF 0x7f7f7f7f  //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m, n) for (int i = m; i < n; i++)
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
inline int read()
{
    char ch = getchar();
    int x = 0, f = 0;
    while (ch < '0' || ch > '9')
        f |= ch == '-', ch = getchar();
    while (ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    return f ? -x : x;
}

#define int ll
const int N = 2e5 + 10;
int a[N];
bool st[N];
signed main() {
    // STDIN
    int n, k; cin >> n >> k;
    rep(i, 1, n) cin >> a[i];
    int cnt = 0;
    int p = 1;
    while (true)
    {
        st[p] = true;
        cnt++;
        p = a[p];
        if (st[p])break;
        if (cnt == k)
        {
            cout << p << endl;return 0;
        }
    }
    int dk = k-cnt;
    cnt = 0;
    int tp = p;
    while (true)
    {
        cnt++;
        p = a[p];
        if (p == tp)break;
        if (cnt == dk)
        {
            cout << p << endl; return 0;
        }
    }
    int mk = dk%cnt;
    while (mk--)
    {
        p = a[p];
    }
    cout << p << endl;
}


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

int main(){
  
  int N;
  cin >> N;
  
  vector<int> V(N);
  vector<int> C(N);
  
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  
  for(int i=0;i<N;i++){
    cin >> C.at(i);
  }
  
  int sum=0;
  for(int i=0;i<N;i++){
    int mouke = V.at(i) - C.at(i);
    if(mouke>0){
      sum += mouke;
    }
  }
  cout << sum << endl;
}

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

int main(){
string S;
cin>>S;
int len=S.length();
char s[4]={'R','U','D','L'};
int right=0;
for(int i=0;i<len;i++){
    if(S[i]==s[0]||S[i]==s[1]||S[i]==s[2]||S[i]==s[3]){
        if(i%2==0){
            if(S[i]==s[0]||S[i]==s[1]||S[i]==s[2]){
                right++;
            }
            
        }
        else{
            if(S[i]==s[3]||S[i]==s[1]||S[i]==s[2]){
                right++;
            }
        }
    }
}
if(right==len){
    cout<<"Yes";
}
else{
    cout<<"No";
}
   return 0;
   
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
struct pref{
    int num,p,y;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll x;
    cin >> x;

    ll max= -1;
    FOR(i,1,1001){
        FOR(j,2,11){
            if(powl(i,j)<=x && max<powl(i,j)) max= powl(i,j);
        }
    }
    
    cout << max << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
  int count[100];
  int i, j, k, l, soeji = 0;
  int num;

  while(scanf("%d",&num) != EOF){
    count[soeji] = 0;

    for(i=0; i<=9; i++){
      for(j=0; j<=9; j++){
	for(k=0; k<=9; k++){
	  for(l=0; l<=9; l++){
	    if(num == i+j+k+l){
	      count[soeji]++;
	    }
	  }
	}
      }
    }
  soeji++;
  }
  for(i=0; i<soeji; i++){
  printf("%d\n", count[i]);
  }

  return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int c[10][1005];

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = INF_32;
    rep(div, 1 << (h - 1))
    {
        int g = 0;
        vector<int> id(h); // i行目が何グループ目か
        rep(i, h)
        {
            id[i] = g;
            if (div >> i & 1) { // 1をシフトするやつはlong longだと死ぬ
                ++g;
            }
        }
        ++g;
        rep(i, g) rep(j, w) c[i][j] = 0; // iグループ目のj列目の数
        rep(i, h) rep(j, w) c[id[i]][j] += (s[i][j] - '0');

        int num = g - 1;
        vector<int> now(g);
        auto add = [&](int j) {
            rep(i, g) now[i] += c[i][j];
            rep(i, g) if (now[i] > k) return false;
            return true;
        };
        rep(j, w)
        {
            if (!add(j)) {
                num++;
                now = vector<int>(g);
                // 一旦リセットしてからもう一度add(j)
                if (!add(j)) { // 1列を追加するだけでもダメだったら絶対不可能
                    num = INF_32;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }

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

Measured memory_bytes: 256
s=str(input())
aa=int(s[0:2])
bb=int(s[2:])

if bb < 1 or bb > 12:
  if aa < 1 or aa > 12:
    print('NA')
  else:
    print('MMYY')
else:
  if aa < 1 or aa > 12:
    print('YYMM')
  else:
    print('AMBIGUOUS')

Measured memory_bytes: 3060
N = int(input())
L = list(map(int, input().split()))

ans = 0

for i in range(N):
    for j in range(i,N):
        if i==j:
            continue
        else:
            for k in range(j,N):
                if i==k:
                    continue
                elif j==k:
                    continue
                else:
                    temp_max = max(L[i],L[j],L[k])
                    if L[i]+L[j]+L[k] > 2*temp_max:
                        if L[i]==L[j] or L[j]==L[k] or L[k]==L[i]:
                            continue
                        else:
                            ans += 1

print(ans)

Measured memory_bytes: 9216
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll n;
	cin>>n;
	cout<<(180*n-360)<<endl;
	return 0;
}


Measured memory_bytes: 256