akhauriyash/Code-Regression huggingface dataset:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
/**
 *
 * @author mba
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String input;
        while((input = bf.readLine()) != null) {
            System.out.println(input.toUpperCase());
        }
    }
    
}

Measured memory_bytes: 16852
def main():
    num = int(input())
    data = list(map(int, input().split()))
    data.sort()

    if data[0] <= 0 and data[num - 1] >= 0:
        now_sei = data[num - 1]
        now_fu = data[0]

        ans = 0
        for i in range(num):
            ans += abs(data[i])
        print(ans)

        for i in range(1, num - 1):
            if data[i] > 0:
                print(now_fu, data[i])
                now_fu -= data[i]
            else:
                print(now_sei, data[i])
                now_sei -= data[i]
        print(now_sei, now_fu)

    elif data[num - 1] < 0:
        ans = data[-1]
        for i in range(num - 1):
            ans += abs(data[i])
        print(ans)

        now_moji = data[-1]
        for i in range(num - 1):
            print(now_moji,  data[i])
            now_moji -= data[i]

    elif data[0] > 0:
        ans = -1 * data[0]
        for i in range(1, num):
            ans += abs(data[i])
        print(ans)

        now_moji = data[0]
        for i in range(1, num - 1):
            print(now_moji,  data[i])
            now_moji -= data[i]
        print(data[num - 1], now_moji)






if __name__ == '__main__':
    main()




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

int main()
{
	int N, A, B, all = 0, b = 0;
	string S;
	cin >> N >> A >> B >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'a') {
			if (all < A + B) {
				all++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (S[i] == 'b') {
			if (all < A + B && b < B) {
				all++;
				b++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
    int u, minv, i;
    int d[MAX], q[MAX], color[MAX];
    
    for ( i = 0; i < n; i++ ) {
        d[i] = INFTY;
        q[i] = -1;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    
    while ( 1 ){
        minv = INFTY;
        u = -1;
        for ( int i = 0; i < n; i ++ ){
            if ( minv > d[i] && color[i] != BLACK ){
                u = i;
                minv =d[i];
            }
        }
        if ( u == -1 ) break;
        color[u] = BLACK;
        for ( int v = 0; v < n; v++ ){
            if ( color[v] != BLACK && M[u][v] != INFTY){
                if ( d[v] > M[u][v] ){
                    d[v] = M[u][v];
                    q[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for ( int i = 0; i < n; i++ ){
        if( q[i] != -1 ) sum += M[i][q[i]];
    }
    
    return sum;
}

int main() {
    cin >> n;
    
    for ( int i = 0; i < n; i++ ){
        for ( int j = 0; j < n; j++ ){
            int e; cin >> e;
            M[i][j] = ( e == -1 ) ? INFTY : e;
        }
    }
    
    cout << prim() << endl;
    
    return 0;
}

Measured memory_bytes: 3104
#include<stdio.h>

int main(){
  	int n,k,sum=0; scanf("%d%d", &n, &k);
	int *arr = (int*)malloc(sizeof(int)*(k+1));
  	for(int i=0;i<k;i++) scanf("%d", &arr[i]), sum += arr[i];
  	if(sum < n) printf("No\n");
    else printf("Yes\n");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int n; cin >> n;
  int res = 0;
  for (int i = 1; i <= n; ++i) res += i * (n - i + 1);
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    res -= u * (n - v + 1);
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int n;cin>>n;
  vector<int> a(n);
  vector<int> sum;
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  int before=a[0];
  int buf=1;
  rep1(i,n-1){
    if(before==a[i])buf++;
    else{
      sum.push_back(buf);
      buf=1;
      before=a[i];
    }
  }
  sum.push_back(buf);
  int len=sum.size();
  rep(i,len){
    //    cout<<sum[i]<<endl;
    sum[i]--;
    //    sum[i]=sum[i]%3;
  }
  int num=0;
  int ans=len;
  rep(i,len)num+=sum[i];
  if(num%2==1)ans--;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string a, b;
    cin >> a >> b;
    if(a.size() != b.size()){
        cout << ((a.size() > b.size()) ? "GREATER" : "LESS") << endl;
    }else{
        if(a == b) cout << "EQUAL" << endl;
        else{
            cout << ((a > b) ? "GREATER" : "LESS") << endl;
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,arr[200001];
int ans=1987654321;

vector <pair<int,int> > before;

bool f(int x)
{
    before.clear();
    if(x==0) return false;
    for(int i=1;i<n;i++)
    {
        if(arr[i-1]<arr[i]) continue;
        while(!before.empty() && before.back().first>=arr[i]) before.pop_back();
        for(int j = arr[i]-1 ; ; j--)
        {
            if(j<0) return false;
            if(before.empty())
            {
                if(x==1) return false;
                before.push_back({j,1});
                break;
            }
            pair <int,int> t = before.back();
            before.pop_back();
            if(t.first == j)
            {
                if(t.second+1>=x) continue;
                t.second++;
                before.push_back(t);
            }
            else
            {
                before.push_back(t);
                if(x==1) return false;
                before.push_back({j,1});
            }
            break;
        }
    }
    return true;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&arr[i]);
    int s=1,e=n;
    for(s=1,e=n;s<=e;)
    {
        int m=(s+e)/2;
        if(f(m)) ans=m,e=m-1;
        else s=m+1;
    }
    if(f(ans-1)) printf("%d",ans-1);
    else if(f(ans)) printf("%d",ans);
    else if(f(ans+1)) printf("%d",ans+1);
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
//const ll mod = 998244353;//1000 * 1000 * 1000 + 7;


void solve() {
    ll n, mod;
    cin >> n >> mod;
    vector<vector<ll> > d(3 * n + 1, vector<ll>(n + 1, 0));
    d[0][0] = 1;
    for (ll len = 0; len < d.size(); ++len) {
        for (int sg = 0; sg <= n; ++sg) {
            d[len][sg] %= mod;
            if (len + 1 < d.size())
                d[len + 1][sg] += d[len][sg];
            if ((len + 2 < d.size()) && (sg + 1 < n + 1)) {
                d[len + 2][sg + 1] += d[len][sg] * (len + 1);
            }
            if ((len + 3 < d.size()) && (sg + 1 < n + 1)) {
                d[len + 3][sg + 1] += d[len][sg] * (len + 1) * (len + 2);
            }
            //cout << d[len][sg] << " ";
        }
        //cout << endl;
    }
    ll res = 0;
    for (int i = 0; i <= n; ++i) {
        res += d[3 * n][i];
        res %= mod;
    }
    cout << res << endl;

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 94336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n, k; cin >> n >> k;
    VI h(n); cin >> h;
    int ans = 0;
    FOR(i, 0, n)if (h[i] >= k)ans++;
    cout << ans << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// dp[V][i] = represents the minimum weight subset of the subarray
// arr[i...N-1] required to get a value of at least V

// dp[V][i] = min(dp[V][i], w[i] + dp[V-val[i]][i+1]);

const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int SUMN = 1e5 + 2;
const int N = 1e2 + 2;

int n, w;
ll dp[N][SUMN];
int weight[N], value[N];

ll solve(int i, int sum) {
	if (sum == 0) 
		return 0;
	if (i == n + 1) 
		return INFLL;

	if (dp[i][sum] != -1)
		return dp[i][sum];

	ll ans = solve(i + 1, sum);
	if (value[i] <= sum)
		ans = min(ans, solve(i + 1, sum - value[i]) + weight[i]);

	return dp[i][sum] = ans;
}

int main() {
	cin >> n >> w;
	for (int i = 1; i <= n; ++i) 
		cin >> weight[i] >> value[i];
	
	memset(dp, -1, sizeof(dp));

	ll ans = 0;
	ll sum = accumulate(value+1, value+1+n, 0);
	for (ll i = sum; i >= 0; --i) {
		if (solve(1, i) <= w) {
			ans = i;
			break;
		}
	}

	cout << ans << "\n";
	
	return 0;
}


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

const int MOD =1000000007;
//

signed main() {
 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++)cin>>a[i];
 int t=0;
 for(int i=0;i<n;i++){
     if(a[i]==t+1)t++;
 }
 if(t==0)cout<<-1;
 else cout<<n-t;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
int main()
{
	long long N,cnt=0;
	cin>>N;
	string S[200000];
	static map<string,long long> m;
	rep(i,N){
		cin>>S[i];
		sort(S[i].begin(),S[i].end());
      m[S[i]]++;
	  cnt+=m[S[i]]-1;
      
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N>>M;
  vector<int>A(N),B(N);
  
  vector<pair<long int, long int>> a(N);
 
  for (int i=0;i<N;i++){
    cin >> A.at(i)>>B.at(i);
  }
  for (int i=0;i<N;i++){
    a.at(i)={A.at(i),B.at(i)};
  }
  
  
  sort (a.begin(),a.end());
    
  long int c=0;
  
  for (int i=0;i<N;i++){
    if (M>=a.at(i).second){
      M-=a.at(i).second;
      c+=a.at(i).first*a.at(i).second;
    
    }
    else {
      c+=M*a.at(i).first;
      break;
    }
  }
  cout << c <<endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<set>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<stdlib.h>
#include<stdio.h>
#include<queue>
#include<stack>
#include<string.h>
#include<limits.h>
using namespace std;
typedef long long ull;

int main(){
    int t=0;
    for(int i=0;i<100000000;i++){
        t++;
    }
    int a[3];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    if(a[0]+a[1]==a[2]){
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private static bool Solve(int N, int[] D, int M, int[] T)
        {
            var dic1 = new Dictionary<int, int>();
            foreach (int d in D)
            {
                if (!dic1.ContainsKey(d)) { dic1[d] = 0; }
                ++dic1[d];
            }
            var dic2 = new Dictionary<int, int>();
            foreach (int t in T)
            {
                if (!dic2.ContainsKey(t)) { dic2[t] = 0; }
                ++dic2[t];
            }
            foreach (var pair in dic2)
            {
                int d = pair.Key;
                if (!dic1.ContainsKey(d) || dic1[d] < dic2[d]) { return false; }
            }
            return true;
        }
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] D = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int M = int.Parse(Console.ReadLine());
            int[] T = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine(Solve(N, D, M, T) ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 56648
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<int> ans(N);
    for(int i = 0; i < 2; i++){
        int cnt = 0;
        for(int j = 0; j < N; j++){
            if(S[j] == 'R') cnt++;
            else{
                ans[j] += cnt / 2;
                ans[j - 1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }
        reverse(all(ans));
        reverse(all(S));
        for(int j = 0; j < N; j++){
            if(S[j] == 'L') S[j] = 'R';
            else S[j] = 'L';
        }
    }
    for(int i = 0; i < N; i++){
        cout << ans[i] << ' ';
    }

}

Measured memory_bytes: 1104
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    if (s[0] != s[1] || s[1] != s[2]) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}

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

int main() {
  int M, D;
  cin >> M >> D;
  int sum = 0;
  
  for (int m = 1; m < M+1; m++){
    for (int d = 1; d < D+1; d++){
      if (d/10 >= 2 && d%10 >= 2 && (d/10)*(d%10) == m) sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
const LL MOD=1000000007;
LL dp[101][10];
LL fb[10+5]={1,1,1,1,1,1,2,3,5,8,13,21,34,55,89};
int main(){
  LL H,W,K;
  cin>>H>>W>>K;
  dp[0][1]=1;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      dp[i][j]=(dp[i-1][j-1]*(fb[j-3+5]*fb[W-j-1+5])+dp[i-1][j]*(fb[j-2+5]*fb[W-j-1+5])+dp[i-1][j+1]*(fb[j-2+5]*fb[W-j-2+5]))%MOD;
    }
  }
  cout<<dp[H][K]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lb(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define sortv(vec) sort(vec.begin(),vec.end())
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;
v<ll> fact;
//factorial
void factorial(ll n)
{
    fact[0] = 1;
    for (ll i = 1; i <=n; i++)
    {
        fact[i] = i * fact[i - 1];
        fact[i] %= M;
    }
}
// modular exponentiation 
ll binpow(ll val, ll deg)
{
    if (!deg)
        return 1 % M;
    if (deg & 1)
        return binpow(val, deg - 1) * val % M;
    ll res = binpow(val, deg >> 1);
    return (res * res) % M;
}
//combination
ll C(ll n, ll i)
{
    if(n<i) return 0;      
    ll res = fact[n]; 
    ll div = fact[n - i] * fact[i];
    div %= M;
    // using fermat little theorum
    div = binpow(div, M - 2); // modular inverse  
    return (res * div) % M; 
}

int main() {
	//your code goes here
	IOS;
	ll n,m;       
	ll j,y,z,t,x,i,q;      
	cin>>n;
	x=n/1000;
	if(x*1000!=n)
	x++;
	cout<<x*1000-n;
	
	
	
	return 0;
}

Measured memory_bytes: 3644
def rec(s_status, cp, con, p, N, M):
    if cp == N:
        for i in range(M):
            sum_s = 0
            for s in con[i]:
                sum_s += int(s_status[s - 1])
            if sum_s % 2 != p[i]:
                return 0
        else:
            return 1
    else:
        res = 0
        res += rec(s_status, cp + 1, con, p, N, M)
        s_status[cp] = True
        res += rec(s_status, cp + 1, con, p, N, M)
        s_status[cp] = False
        return res


def main():
    N, M = map(int, input().split())
    s_status = [False] * N

    con = [[] for _ in range(M)]
    for i in range(M):
        data = list(map(int, input().split()))
        con[i] = data[1:]

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

    print(rec(s_status, 0, con, p, N, M))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [a,b] <- map read . words <$> getLine
  print $ numOfPlndrm a b

numOfPlndrm
  :: Int -> Int -> Int
numOfPlndrm a b = length $ filter isP [a .. b]

isP 
  :: Int -> Bool
isP n = c == C.reverse c
  where
    c = C.pack $ show n

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  ll ans1=n-1;
  ll ans2=0;
  rep(i,n-1){
    if(s[i]==s[i+1]) ans2++;
  }
  ans2+=2*k;
  ll fans=min(ans1,ans2);
  cout << fans << endl;
}

Measured memory_bytes: 3684
# -*- coding: utf-8 -*-
s = list(str(input()))

ans = 0
a = len(s)
if a % 2 == 0:
    for i in range(int(a/2)):
        if s[i] != s[a - 1 - i]:
            ans += 1
else:
    for i in range(a//2):
        if s[i] != s[a - 1 - i]:
            ans += 1
print(ans)


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int N, A, B;

signed main() {
	cin >> N >> A >> B;
	int x = N / (A + B);
	int y = N % (A + B);
	cout << A * x + min(A, y) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

const ll M = 1000000007;

ll kaiM(ll x){
  ll ans = 1;
  if(x == 0) return 1l; 
  for (ll i = 1; i <= x; i++){
    ans *= i;
    ans %= M;
  }
  return ans;
}

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

int main(){
  int X, Y;
  cin >> X >> Y;
  int a, b;

  ll ans, p, q;
  a = ((2 * Y) / 3) - (X / 3);
  b = ((2 * X) / 3) - (Y / 3);

  if((X + Y)%3 == 0 && a >= 0 && b >= 0){
    p = kaiM(a);
    q = kaiM(b);
    ans = kaiM(a + b);
    ans = ans * mpow(p, M-2) % M;
    ans = ans * mpow(q, M-2) % M;
    printf("%lld\n", ans);
  }else{
    printf("0\n");
  }
}


Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int hatv[200001];

int main() {
	IO;
	hatv[0]=1;
	for(int i=1;i<=200000;++i) {
		hatv[i]=hatv[i-1]*10%2019;
	}
	
	string s;
	cin>>s;
	int akt=0;
	vector<int> cnt(2019);
	ll ans=0;
	cnt[0]++;
	for(int i=sz(s)-1;i>=0;i--) {
		akt+=hatv[sz(s)-1-i]*(s[i]-'0');
		akt%=2019;
		ans+=cnt[akt];
		cnt[akt]++;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 4564
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arrX = new int[n];
		int[] arrY = new int[n];
		int[] arrH = new int[n];
		int idx = 0;
		for (int i = 0; i < n; i++) {
		    arrX[i] = sc.nextInt();
		    arrY[i] = sc.nextInt();
		    arrH[i] = sc.nextInt();
		    if (arrH[i] != 0) {
		        idx = i;
		    }
		}
		for (int x = 0; x <= 100; x++) {
		    for (int y = 0; y <= 100; y++) {
		        int h = Math.abs(x - arrX[idx]) + Math.abs(y - arrY[idx]) + arrH[idx];
		        if (h < 1) { 
		            continue;
		        }
		        boolean flag = true;
		        for (int i = 0; i < n; i++) {
		            if (Math.max(h - Math.abs(x - arrX[i]) - Math.abs(y - arrY[i]), 0) != arrH[i]) {
		                flag = false;
		                break;
		            } 
		        }
		        if (flag) {
		            System.out.println(x + " " + y + " " + h);
		            return;
		        }
		    }
		}
	}
}


Measured memory_bytes: 25044
#include <stdio.h>
int main(void){
    // Your code here!
    int N, max = 0,sum = 0;
    int p[10];
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d\n",&p[i]);
        sum += p[i];
        if(max < p[i]) max = p[i];
    }
    printf("%d\n",sum-max/2);
    
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 300;

int N, ans = 0;
vector<string> board;
vector<string> A, B;

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    string tmp; cin >> tmp;
    board.pb(tmp);
  }
  for (int i = 0; i < N; i++) {
    string a = "", b = "";
    for (int j = 0; j < N; j++) {
      a.pb(board[i][j]);
      b.pb(board[j][i]);
    }
    A.pb(a+a);
    B.pb(b+b);
  }
  for (int i = 0; i < N; i++) {
    A.pb(A[i]);
    B.pb(B[i]);
  }

  for (int i = 0; i < N; i++) {
    bool flag = true;
    for (int k = 0; k < N; k++) {
      string tmp_A = A[i+k].substr(k+1, N-k-1);
      string tmp_B = B[k].substr(i+k+1, N-k-1);
      if (tmp_A != tmp_B) {
        flag = false;
      }
    }
    if (flag) {
      ans += N;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }


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

int dp[100][100];
char mp[100][100];
void solve() {
	int h, w; cin >> h >> w;
	rep(i, h)rep(j, w)cin >> mp[i][j];
	rep(i, h)rep(j, w)dp[i][j] = mod;
	dp[0][0] = 0; if (mp[0][0] == '#')dp[0][0] = 1;
	rep(i, h)rep(j, w) {
		if (i + 1 < h) {
			int ad = (mp[i][j] =='.'&& mp[i + 1][j]=='#');
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + ad);
		}
		if (j + 1 < w) {
			int ad = (mp[i][j] == '.'&&mp[i][j+1]=='#');
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + ad);
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    Vi tg(3);
    cin >> n >> tg[0] >> tg[1] >> tg[2];

    Vi v(n);
    REP(i, n) cin >> v[i];

    int mini = 1e9;
    int bitSize = n*2;
    REP(bit, 1 << bitSize) {
        Vi cnt(4, 0);
        Vi sum(4, 0);
        REP(i, n) {
            REP(j, 4) {
                if ((bit >> ((n-i-1)*2)) % 4 == j) {
                    cnt[j]++;
                    sum[j] += v[i];
                    break;
                }
            }
        }
        if (min({cnt[0], cnt[1], cnt[2]}) == 0) continue;
        int res = 10 * (accumulate(cnt.begin(), cnt.begin()+3, 0) - 3);
        REP(i, 3) {
            res += abs(sum[i] - tg[i]);
        }
        mini = min(mini, res);
    }

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

    return 0;
}


Measured memory_bytes: 256
//Heaplax
#include<bits/stdc++.h>
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
    while(ch=getchar(),ch<33);
    if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
    while(ch=getchar(),ch>33)x=x*10+ch-48;
    if(fs)x=-x;
}
using namespace std;
int n,x;
int ans[200005];
bool use[200005];
int main()
{
	re(n),re(x);
	if(x==1 || x==2*n-1)
	{
		puts("No");
		return 0;
	}
	if(x!=2)
		ans[n]=x,ans[n+1]=x+1,ans[n+2]=x-2,ans[n-1]=x-1;
	else 
		ans[n]=x,ans[n+1]=x-1,ans[n+2]=x+2,ans[n-1]=x+1;
	for(int i=1;i<=2*n-1;++i)
		use[ans[i]]=1;
	puts("Yes");
	for(int i=1,j=1;i<=2*n-1;++i)
	{
		while(use[j])++j;
		if(ans[i])printf("%d\n",ans[i]);
		else printf("%d\n",j),use[j]=1;
	}	
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int a = 0, b = 0, c = 0;

    scanf("%d %d %d", &a, &b, &c);

    if ((b/a) >= c) {
        printf("%d\n", c);
    } else {
        printf("%d\n", b/a);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	int n;
	int m=250000;
	bool flag[300000];
	memset(flag, 1, sizeof(flag));
	flag[0]=0, flag[1]=0;
	for(int i=2; i*i<=m; i++){
		if(flag[i]){
			for(int j=2; i*j<=m; j++){
				flag[i*j]=0;
			}
		}
	}
	while(cin >> n && n){
		int ans=0;
		for(int i=n+1; i<=2*n; i++){
			if(flag[i]){
				ans++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}



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

int main(){

  int N;
  cin>>N;
  
  int k=N%10;
  
  if(k==3){cout<<"bon"<<endl;return 0;}
  if(k==0 || k==1 || k==6 || k==8){cout<<"pon"<<endl; return 0;}
  else cout<<"hon"<<endl;

}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int main(){
    string s;
    cin>>s;
    int n;
    cin>>n;
    int ans = 0;
    rep(i,n){
        string t;
        cin>>t;
        t+=t;
        if(t.find(s)!=string::npos)ans++;
    }
    cout<<ans<<endl;
}

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

int cmp(int a, int b){
  return a > b;
}

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  //cout << s << endl;
  sort(t.begin(), t.end(), cmp);
  //cout << t << endl;
  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
a = LI()

# a_i = a_(i+3) に注目

if N % 3 != 0:
    for i in range(N):
        if a[i] != 0:
            print('No')
            break
    else:
        print('Yes')
    exit()

B = list(set(a))
b = len(B)
n = N//3
if b > 3:
    print('No')
elif b == 1:
    for i in range(N):
        if a[i] != 0:
            print('No')
            break
    else:
        print('Yes')
elif b == 2:
    x,y = B
    c = a.count(x)
    if x != 0 and y != 0:
        print('No')
    elif x == 0:
        if c == n:
            print('Yes')
        else:
            print('No')
    else:
        if c == 2*n:
            print('Yes')
        else:
            print('No')
else:
    x,y,z = B
    c = a.count(x)
    d = a.count(y)
    if not (c == d == n):
        print('No')
    else:
        if x ^ y == z:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 93952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  int ans = 0;
  ans += (s[0] == '1');
  ans += (s[1] == '1');
  ans += (s[2] == '1');
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 

//power of 2 ...n&(n-1)==0

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	 //ll testcase;
	 //cin>>testcase;
	 //for(ll t=0;t<testcase;t++)
	{
		// use long long
		//donot memeset other than 0 or 1 or -1
		//segmentation fault-> check for uninitialized global variable or out of bounds
		//always check for bottle neck (whether original constraints can be reduced by introducing some condition)
		//dont rush to writing code think through the logic	
		//implement dijkstra again ---it is bfs because we vis all the points connected to the current point first
		//from every not visited cell we will update the distances of cell which can be visited
		ll a;double b;
		cin>>a>>b;
		int d=(int)round(b*100);
		ll ans=(ll)(a*d);
		cout<<(ll)ans/100<<'\n';
	}
	return 0;
}





























































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

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

  int cnt=0;
  for(int i=0; i<n; i++){
    int h;
    cin >> h;
    if(h>=k) cnt++;
  }

  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = intArray[0];
            int M = intArray[1];
            int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int sum = A.Sum();
            if(N < sum)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(N - sum);
            }
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 29368
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b<c){
        cout<<"NA"<<endl;
    }else if(a>=c){
        cout<<"0"<<endl;
    }else{
        cout<<c-a<<endl;
    }
    
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
set<int> g[112345];
bool cut[112345];

int main() {
	cin >> N;
	REP(i, N - 1) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		g[a].insert(b);
		g[b].insert(a);
	}
	
	queue<int> que;
	REP(i, N) if (g[i].size() == 1) que.push(i);
	
	bool ans = false;
	
	while (!que.empty()) {
		int u = que.front(); que.pop();
		if (cut[u]) continue;
		u = *g[u].begin(); // 葉の親
		if (cut[u]) continue;
		
		int cnt = 0;
		for (set<int>::iterator to = g[u].begin(); to != g[u].end(); ++to) {
			if (cut[*to]) continue;
			
			if (g[*to].size() == 1) {
				cnt++;
				cut[*to] = true;
			}
			else if (g[*to].size() == 2) que.push(*to);
		}
		
		for (set<int>::iterator to = g[u].begin(); to != g[u].end(); ++to) g[*to].erase(u);
		g[u].clear();
		cut[u] = true;
		
		if (cnt >= 2) ans = true;
	}
	
	puts(ans ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 15232
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count=0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        count+=1
print(count)


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

int main()
{
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (u == s)
    cout << a - 1 << ' ' << b << endl;
  else
    cout << a << ' ' << b - 1 << endl;
}

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

int main(void){
    int n,Alice = 0,Bob = 0,a[100];
    cin >> n;
    for(int i = 0;i < n;i++)cin >> a[i];
    sort(a,a+n,greater<int>());
    for(int i = 0;i < n;i++){
        if(i % 2 ==0)Alice += a[i];
        else Bob += a[i];
    }
    cout << Alice - Bob << endl;
    
}

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

int main() {
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i, n-1) cin >> b[i];
    int ans = 0;
    rep(i, n) {
        if (i == 0) ans += b[i];
        else if (i == n-1) ans += b[i-1];
        else ans += min(b[i-1], b[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio
  string s;
  cin >> s;
  if(s[0] == s[1] or s[1] == s[2] or s[2] == s[3])cout << "Bad\n";
  else cout << "Good\n";
  ktj();
}


Measured memory_bytes: 256
n,m = [int(ch) for ch in input().split()]
heights = [int(ch) for ch in input().split()]
graphs = []
for i in range(n):
    graphs.append([])
for i in range(m):
    roadInfo = [int(ch) for ch in input().split()]
    start = roadInfo[0]-1
    end = roadInfo[1]-1
    graphs[start].append(end)
    graphs[end].append(start)
res = []
for i in range(len(graphs)):
    isGood = True
    for v in graphs[i]:
        if heights[i] <= heights[v]:
            isGood = False
            break
    if isGood:
        res.append(i+1)
print(len(res))


Measured memory_bytes: 96868
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N;cin >> N;
    bool ok = false;
    for(LL h = 1;h <= 3500;h++){
        for(LL n = 1;n <= 3500;n++){
            LL si = N*h*n;
            LL bo = 4*h*n-N*(h+n);
            if(bo <= 0)continue;
            if(si % bo == 0){
                cout << h  << " " << n << " " << si/bo << endl;
                ok = true;
                break;
            }
        }
        if(ok)break;
    }
}

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

int main()
{
	int i, n, count=0;
  	string a, b;
  	cin >> a >> b;
  	n=a.length();
  
  	for(i=0; i<n; i+=1)
		if(a[i]!=b[i])
          	count+=1;
  
  	cout << count << endl;
}

Measured memory_bytes: 3900
#include <iostream>
#include <algorithm>
#define rep(i,o,u) for(int i = o;i <= u; i++)
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[200005];
	rep(i,1,n){
		cin >> a[i];
	}
	int mn = a[1],mx = -2000000000;
	rep(i,2,n){
		mx = max(mx,a[i]-mn);
		mn = min(mn,a[i]);
	}
	cout << mx << endl;	
	return 0;
}

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

int main(){
	int a, b, c;
	int i;
	int count = 0;
	cin >> a >> b >> c;

	for(i = a; i <= b; i++){
		if(c % i == 0){
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a := scanFloat64()
	b := scanFloat64()
	h := scanFloat64()
	m := scanFloat64()

	mm := m + h*60

	aa := mm / 12 / 60 * math.Pi*2
	bb := m / 60 * math.Pi*2

	cc := math.Abs(aa - bb)
	// debug(cc)
	fmt.Fprintln(wr, math.Sqrt(a*a+b*b-2*a*b*math.Cos(cc)))

}


Measured memory_bytes: 1760
from bisect import bisect_left,bisect_right
n=int(input())
A=sorted(list(map(int,input().split())))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())))

ans=0
for b in B:
    index_a=bisect_left(A,b)
    index_c=bisect_right(C,b)
    ans +=index_a*(n-index_c)

print(ans)

Measured memory_bytes: 23744