akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

import static java.lang.System.*;

// https://atcoder.jp/contests/abc097/tasks/arc097_b
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        int[] p = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            p[i] = sc.nextInt();
        }

        UnionFindTree tree = new UnionFindTree(N + 1);

        for (int i = 0; i < M; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            tree.union(x, y);
        }

        int cnt = 0;
        for (int i = 1; i <= N; i++) {
            if (i == p[i] || tree.same(p[i], i)) {
                cnt++;
            }
        }

        out.println(cnt);
    }
}

// https://gist.github.com/keitin/e5ba4ba4ccd6cd3afb3485c5ea85846c#file-union-find-java
class UnionFindTree {
    int[] parent; //インデックスにとノードを対応させ、そのルートノードのインデックスを格納
    int[] size;   //インデックスとノードを対応させ、そのルートノードと同じグループに属する頂点数を格納
    int[] rank; //parentと同様に、木の高さを格納

    public UnionFindTree(int size) {
        this.parent = new int[size];
        this.size = new int[size];
        this.rank = new int[size];

        for (int i = 0; i < size; i++) {
            makeSet(i);
        }
    }

    public void makeSet(int i) {
        parent[i] = i;
        size[i] = 1;
        rank[i] = 0; //集合の高さ
    }

    public void union(int x, int y) {
        int xRoot = find(x);
        int yRoot = find(y);

        //xが属する木の方が大きい場合
        if (rank[xRoot] > rank[yRoot]) {
            parent[yRoot] = xRoot; //yの親をxに更新
            size[xRoot] = size[xRoot] + size[yRoot];
        } else if (rank[xRoot] < rank[yRoot]) {
            parent[xRoot] = yRoot;
            size[yRoot] = size[xRoot] + size[yRoot];
        } else if (xRoot != yRoot) {
            parent[yRoot] = xRoot;
            rank[xRoot]++; //同じ高さの木がルートの子として着くから大きさ++;
            size[xRoot] = size[xRoot] + size[yRoot];
        }
    }

    //引数の属する木のルートのidを返す
    public int find(int i) {
        if (i != parent[i]) {
            parent[i] = find(parent[i]);
        }
        return parent[i];
    }

    //引数の属する木のサイズを返す
    public int size(int i) {
        if (i != parent[i]) {
            size[i] = size(find(i));
        }
        return size[i];
    }

    //同じ木に属しているか
    public boolean same(int x, int y) {
        return find(x) == find(y);
    }
}

Measured memory_bytes: 89572
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vll divisor(ll n) {
    vll ans;
    for (ll i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ans.push_back(i);
            if (i*i != n) ans.push_back(n/i);
        }
    }
    sort(all(ans));
    return ans;
}

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

    auto d = divisor(n);

    ll ans = 0;
    for (ll x : d) {
        ll m = n/x-1;
        if (m == 0) continue;
        if (n/m != n%m) continue;
        ans += m;
    }

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod2=1000000007;
ll mod=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    int p[n];rep(i,0,n)cin>>p[i];
    rep(i,0,n){
        rep(j,0,n){
            swap(p[i],p[j]);
            int c=0;
            rep(k,0,n){
                if(p[k]!=k+1){
                    c=1;
                    break;
                }
            }
            if(c==0){
                cout<<"YES"<<endl;
                return 0;
            }
            swap(p[i],p[j]);
        }
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
a = int(input())
b = [int(i) for i in input().split(" ")]
c = [int(i) for i in input().split(" ")]


def cal(data):
    length = len(data)
    mem = [1] * length
    buf = [1]
    result = 0
    for i in range(1, length):
        buf.append(buf[i-1]*i)
    buf.reverse()
    for i in range(length):
        result += buf[i] * (sum(mem[:data[i]]))
        mem[data[i]-1] = 0
    return result


print(abs(cal(b)-cal(c)))


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

typedef long long ll;

int main()
{
    int n,k,i;
    cin >> n >> k;
    vector<int> p(n);
    for(i = 0;i < n;++i){
        cin >> p.at(i);
    }
    ll sum = 0;
    for(i = 0;i < k;++i){
        sum += p.at(i);
    }
    ll max_s = sum;
    for(i = 0;i < n-k;++i){
        sum -= p.at(i);
        sum += p.at(i + k);
        if(sum > max_s){
            max_s = sum;
        }
    }
    double max_d = (double)max_s;
    max_d = (max_d + k)/2;
    cout << std::setprecision(10) << max_d << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	string s; cin >> s;
	REP(i, s.size() - 1) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;


	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int tmp = 99;
    int tmp2;
    rep(i, 4){
        tmp2 = N%10;
        if(tmp==tmp2){
            printf("Bad\n");
            return 0;
        }
        tmp = tmp2;
        N /=10;
    }
    printf("Good\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N,T;
    cin >> N >> T;
    vector<ll> V(N);
    rep(i,0,N)cin >> V[i];
    ll difmax = 0, mini = V[0];
    int cnt = 0;
    rep(i,1,N){
        mini = min(mini, V[i]);
        if(difmax < V[i] - mini){
            difmax = V[i] - mini;
            cnt = 1;
        }else if(difmax == V[i] - mini){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string a;
  cin >> a;
  ll ans = 0;
  rep(i,a.length()){
    if(a[i]=='+') ans++;
    if(a[i]=='-') ans--;
    
  }
  pri(ans);

  return 0;
}


Measured memory_bytes: 256
int main(){
  int n,d[100],a=0,b=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&d[i]);
    a+=d[i];
  }
  for(int i=0;i<n;i++){
    b+=d[i]*(a-d[i]);
  }
  printf("%d\n",b/2);
  return 0;
}

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);



int main() {
	int N;
	cin >> N;
	string s, t;
	cin >> s >> t;

	string s_tmp = s, t_tmp = t;
	int ans = N;
	for (int i = 0; i < N; ++i) {
		if (s_tmp == t_tmp) {
			break;
		}
		else {
			s_tmp.erase(0, 1);
			t_tmp.erase(t_tmp.size() - 1, 1);
			++ans;
		}
	}

	cout << ans << endl;
}


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

int count_num_digits(long long digit) {
    int num = 0;

    do {
        digit /= 10;
        ++num;
    } while (digit != 0);
    return num;
}

int main() {
    long long N;
    long long a, b;
    int ans;

    cin >> N;

    ans = count_num_digits(N);
    for (a = 1LL; a*a <= N; ++a) {
        if ((N % a) == 0) {
            int num_digits;

            b = N / a;
            num_digits = max(count_num_digits(a), count_num_digits(b));
            ans = min(ans, num_digits);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int n ,l;
    cin >> n >> l;
    vector<string> vec(n);
    for(int i=0;i<n;i++) cin >> vec[i] ;
    sort(vec.begin() ,vec.end());
    for(int i=0;i<n;i++) cout << vec[i];
    cout <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
#include <iterator>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------



int main() {

  string s;
  int k;
  cin >> k >> s;
  int size = s.size();

  if(size<=k) cout << s << endl;
  else {
    string t = s.substr(0,k);
    t += "...";
    cout << t << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
		long a =long.Parse(Console.ReadLine());
		if (IsPrime(a))
		{
			Console.WriteLine(a.ToString().Length);
			return;
		}
		for(long i=(long)Math.Floor(Math.Sqrt(a)); i>0; i--)
		{
			if(a%i==0)
			{
				Console.WriteLine((a/i).ToString().Length);
				return;
			}
		}
    }

	static bool IsPrime(long num)
	{
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.Sqrt(num);
		for (long i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}
}


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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);
const ll MOD=1000000007;

string S; ll dp[100010][13];
int input()
{
    cin>>S;
}

int solve()
{
    int N=S.length();
    for(int i=0;i<13;++i) dp[1][i]=0ll;
    if(S[0]=='?'){
        for(int j=0;j<10;++j){
            dp[1][j]=1ll;
        }
    } else {
        int j=S[0]-'0';
        dp[1][j]=1ll;
    }
    // dp[0][0]=1ll;

    for(int i=0;i<N;++i){
        if(S[i]=='?'){
            for(int j=0;j<13;++j){
                for(int k=0;k<10;++k){
                   dp[i+1][(j*10+k)%13]+=dp[i][j];
                   dp[i+1][(j*10+k)%13]%=MOD;
               }
           }
        } else {
            int k=S[i]-'0';
            for(int j=0;j<13;++j){
                dp[i+1][(j*10+k)%13]+=dp[i][j];
                dp[i+1][(j*10+k)%13]%=MOD;
            }
        }
    }
    cout<<dp[N][5]<<endl;
    // for(int j=0;j<5;++j) {for(int i=0;i<13;++i) cout<<dp[j][i]<<" "; cout<<"\n";}
    // cout<<endl;
}

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

Measured memory_bytes: 10704
#! /usr/bin/env perl
use strict;
use warnings;


sub Check_Prime_number{
    my $number = shift;

    if($number == 2){
        return 1;
    }
    for my $tmp (2..$number-1){
        if($number % $tmp ==0){
            return 0;
        }
    }
    return 1;
}

my $x = <>;
chomp $x;
my $i =0;
my $ans =0;

while(1){
    if(Check_Prime_number($x+$i) == 1){
        $ans=$x+$i;
        last;
    }
    else{
        $i+=1;
    }
}

print("$ans\n");



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int N, M;
int l[100010], r[100010];

int main() {
    cin >> N >> M;
    rep(i, M) cin >> l[i] >> r[i];

    sort(l, l+M);
    sort(r, r+M);
    int ans;
    int l_max = l[M-1], r_min = r[0];
    if (l_max <= r_min) ans = r_min - l_max + 1;
    else ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 1024
from copy import deepcopy
s = input()
t = input()
l_t = len(t)

def check(x, y):
    for i, j in zip(x, y):
        if i == j or i == '?':
            continue
        else:
            return False
    return True


ans = 'z' * (len(s) + 1)
for k in range(len(s) - l_t + 1):
    x = s[k:k+l_t]
    if check(x, t):
        cand = list(deepcopy(s))
        cand[k:k+l_t] = list(t)
        cand = ''.join(cand)
        cand = cand.replace('?', 'a')
        if cand < ans:
            ans = cand

if not ans == 'z' * (len(s) + 1):
    print(ans)
else:
    print('UNRESTORABLE')




Measured memory_bytes: 3444
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

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

    if (a <= x && x <= (a + b)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
using namespace std;
int a[100];
int main()
{
    int n;
    while(cin>>n){
        int i=0;
        while(n){
            a[i]=n%-2;
            if(a[i]==-1){
                n=n/-2+1;
                a[i]=1;
            }else{
                n=n/-2;
            }
            i++;
        }
        if(i==0){
            cout<<0<<endl;
            continue;
        }
        for(int j=i-1;j>=0;j--){
            cout<<a[j];
        }
        cout<<endl;
    }
    return 0;
}


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

int main() 
{
  int n,i;
  cin >> n;
  int flag =0;
  long long sum=0;
  for(i=1;i<=n;i++)
  { 
      if( (i%3)!=0 && (i%5)!= 0)
      {
          sum += i;
      }
  }
  cout << sum;

}



Measured memory_bytes: 3636
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val dList = readIntegerList()
    val dMap = elementCountMap(dList)

    val m = readInteger()
    val tList = readIntegerList()
    val tMap = elementCountMap(tList)

    for (e in tMap) {
        val dCount = dMap.getOrDefault(e.key, 0)
        if (dCount < e.value) {
            out.print("NO")
            return
        }
    }
    out.println("YES")
}

/** O(n) */
fun <T>elementCountMap(list: List<T>): Map<T, Int> {
    val countMap = mutableMapOf<T, Int>()
    for (e in list) {
//        countMap[e] = (countMap[e] ?: 0) + 1
        countMap.merge(e, 1) { oldValue, value -> oldValue + value }
    }
    return countMap
}


fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 93724
void main() {
	("aiueo".canFind(rs) ? "vowel" : "consonant").writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.07.12 23:01:56
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    while (true) {
        int n, w, d;
        cin >> n >> w >> d;
        if (w == 0) break;
        int t = 0;
        set< tuple< int, int, int > > st;
        st.insert(make_tuple(t++, w, d));
        for (int i = 0; i < n; i++) {
            int p,s;
            cin >> p >> s;
            auto a = next(st.begin(), p - 1);
            int _w = get< 1 >(*a);
            int _d = get< 2 >(*a);
            st.erase(a);
            s %= (_w + _d) * 2;
            if (0 < s && s < _w) {
                st.insert(make_tuple(t++, min(s,_w-s), _d));
                st.insert(make_tuple(t++, max(s,_w-s), _d));
            }
            else if (_w < s && s < _w + _d) {
                s -= _w;
                st.insert(make_tuple(t++, _w, min(_d-s,s)));
                st.insert(make_tuple(t++, _w, max(_d-s,s)));
            }
            else if (_w + _d < s && s < _w * 2 + _d) {
                s -= _w + _d;
                st.insert(make_tuple(t++, min(s,_w-s), _d));
                st.insert(make_tuple(t++, max(s,_w-s), _d));
            }
            else if (_w * 2 + _d < s && s < _w * 2 + _d * 2) {
                s -= _w * 2 + _d;
                st.insert(make_tuple(t++, _w, min(_d-s,s)));
                st.insert(make_tuple(t++, _w, max(_d-s,s)));
            }
        }
        vector< int > ans;
        for(auto b : st) {
            ans.push_back(get< 1 >(b) * get< 2 >(b));
        }
        sort(ans.begin(), ans.end());
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i];
            if (i != ans.size() - 1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

using ld = long double;
int n;
ld dp[305][305][305];

ld memo_rec(int One, int Two, int Three){
    if(dp[One][Two][Three] != -1)   return dp[One][Two][Three];
    if(One + Two + Three == 0)  return dp[One][Two][Three] = 0.0;
    
    ld res = 1.0;
    if(One > 0) res += memo_rec(One - 1, Two, Three) * One / n;
    if(Two > 0) res += memo_rec(One + 1, Two - 1, Three) * Two / n;
    if(Three > 0)   res += memo_rec(One, Two + 1, Three - 1) * Three / n;
    res *= (ld)n / (One + Two + Three);

    return dp[One][Two][Three] = res;
}

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

    cin >> n;
    vector<int> cnt(4, 0);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        ++cnt[a];
    }
    
    for(int i = 0; i <= 300; ++i){
        for(int j = 0; j <= 300; ++j){
            for(int k = 0; k <= 300; ++k){
                dp[i][j][k] = -1;
            }
        }
    }

    cout << fixed << setprecision(15);
    cout << memo_rec(cnt[1], cnt[2], cnt[3]) << endl;
}

Measured memory_bytes: 438528
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
    lint A, B, M;
    cin >> A >> B >> M;

    vector<lint> a(A);
    for(auto& elem : a)  cin >> elem;

    vector<lint> b(B);
    for(auto& elem : b)  cin >> elem;

    lint ami = *min_element(a.begin(), a.end());
    lint bmi = *min_element(b.begin(), b.end());

    lint ans = ami + bmi;
    while(M--) {
        lint x, y, c;
        cin >> x >> y >> c;
        x--, y--;

        lint cand = a[x] + b[y] - c;
        ans = min(ans, cand);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
//----------------------Shanu Garg here---------------------
//-------------Search on youtube : Shanu Garg---------------
//-Studying at National Institute of Technology Delhi(NITD)-
//---------------------From Delhi, India--------------------

#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define memset(a,first,last,val) fs(i,first,last,1) a[i]=val
#define nl cout<<"\n";
#define chk(x) cout<<#x<<x<<" ", nl
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vvi vector<vi>
#define pr pair<ll, ll>
#define vii vector<pair<int, int>>
#define vll vector<pr>
#define vl vector<ll>
#define m(a,b) map<a, b>
#define mid(a,b) ((a+b)/2)
#define pb push_back
#define LCM(a,b) ((a*b)/__gcd(x,y))
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;

class triplet{
    public:
    ll f, s, t;};

vl in(ll n){vl v;ll x;
    f(i,n)
    cin>>x, v.pb(x);
    return v;}

vll in_pr(ll n){
    vll ar;
    ll x,y;
    f(i,n)
    {cin>>x>>y;
    ar[i]={x,y};
    }return ar;
}
void out(vl v, char ch='\0'){
    fl(i,v)
    cout<<i<<ch;
}

void solve(){
       ll N,x,sum=0;
       cin>>N;
       vl d;
       f(i, N)
       cin>>x, d.pb(x);

       f(i, N){
           fs(j, i+1, N, 1){
               sum+=(d[i]*d[j]);
           }
       }
       cout<<sum;
}

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




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

int main() {
	// your code goes here
	int n, d;
	int x, y, count {0};
	
	scanf("%d %d", &n, &d);
	while(n--){
	    scanf("%d %d", &x, &y);
	    if(x > d || y > d){
	        continue;
	    }
	    
	    long double dist {0};
	    dist = sqrt((pow(x,2) + pow(y,2)));
	    if(dist <= d){
	        count += 1;
	       // printf("%d %d\n", x,y);
	    }
	}
	printf("%d", count);
	return 0;
}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n + 1), bs(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	for (auto &b : bs)
	{
		cin >> b;
	}

	int64_t ans = 0;
	for (int64_t i = 0; i < n; i++)
	{
		ans += min(bs[i], as[i] + as[i + 1]);
		if (as[i] < bs[i])
		{
			as[i + 1] = max(int64_t(0), as[i + 1] - (bs[i] - as[i]));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python
# coding: utf-8

# In[10]:


N = int(input())
b = list(map(int, input().split()))


# In[11]:


op = []
mylist = [x for x in b]
f = True
while len(mylist)>0:
    for i in reversed(range(len(mylist))):
        if mylist[i] == i+1:
            op.append(mylist.pop(i))
            break
    else:
        f = False
        break
if f:
    ans = list(reversed(op))
    for x in ans:
        print(x)
else:
    print(-1)


# In[ ]:






Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i;
  int N;cin>>N;
  vector<tuple<string,int,int>> rest(N);
  for(i=0;i<N;i++){cin>>get<0>(rest[i])>>get<1>(rest[i]);get<1>(rest[i])*=-1;get<2>(rest[i])=i+1;}
  sort(rest.begin(),rest.end());
  for(i=0;i<N;i++)cout<<get<2>(rest[i])<<endl;
}


Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main extends App {
  Iterator.continually(readInt).takeWhile(_!=0).foreach { n=>
    val total = (1 to 2*n).toList
    val taro = { for(i<-0 until n) yield readInt }.toList.sorted
    val hanako = (total filterNot taro.toSet).sorted
    def play(t:List[Int],h:List[Int],x:Int,turn:Int):(Int,Int) = {
      if(h.length==0 || t.length==0) (h.length,t.length)
      else if(turn%2 == 0) {
        if(t.exists(_ > x)) {
          val y = t.find(_>x).get
          play(t.filter(_!=y),h,y,turn+1)
        } else play(t,h,0,turn+1)
      } else {
        if(h.exists(_ > x)) {
          val y = h.find(_>x).get
          play(t,h.filter(_!=y),y,turn+1)
        } else play(t,h,0,turn+1)
      }
    }
    val (t,h) = play(taro,hanako,0,0)
    println(t)
    println(h)
  }
}

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

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

    vector<int> d(n);
    for (auto i = 0; i < n; i++) cin >> d[i];

    sort(d.begin(), d.end());
    auto del = unique(d.begin(), d.end());
    d.erase(del, d.end());

    cout << d.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<ll>> dp(n,vector<ll>(2));
    dp[0][0] = a[0];
    dp[1][0] = dp[0][0]+a[1];
    dp[1][1] = dp[0][0]-a[0]*2-a[1];
    rep2(i,2,n) {
        dp[i][0] = max(dp[i-1][0],dp[i-1][1])+a[i];
        dp[i][1] = max(dp[i-1][0]-a[i-1]*2,dp[i-1][1]+a[i-1]*2)-a[i];
    }
    cout << max(dp[n-1][0],dp[n-1][1]) << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define INF 1000000000000000000
using namespace std;

int main() {
  int N;
  cin>>N;
  vector<long long> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  long long ans=a.at(0);
  for(int i=1;i<N;i++){
    if(a.at(i)==0){
      ans=0;
      break;
    }
    else if(INF/a[i]<ans){
      ans=-1;
      break;
    }
    else{
      ans=ans*a[i];
    }
  }
  cout<<ans<<endl;
  
}


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

using namespace std;

int main(){
    long N;
    cin>>N;
    vector<int> zyunban(N);
    vector<int> manzokudo(N);
    vector<int> bonus(N-1);

    for (auto &&x : zyunban)
    {
        cin>>x;
    }
    for (auto &&x : manzokudo)
    {
        cin>>x;
    }
    for (auto &&x : bonus)
    {
        cin>>x;
    }
    long ans=0;
    for (int i = 0; i < N; i++)
    {
        if(i==0){
            ans+=manzokudo[zyunban[i]-1];
        }else
        {
            if (zyunban[i-1]+1==zyunban[i])
            {
                ans+=manzokudo[zyunban[i]-1]+bonus[zyunban[i]-2];
            }else
            {
            ans+=manzokudo[zyunban[i]-1];                
            }
            
            
        }
        
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s1=sc.next();
        String s2=sc.next();
        int a=0;
        for(int l=0;l<s1.length();l++){
            char[] c1=s1.toCharArray();
            if(!s1.equals(s2)){
                //System.out.println("A");
                char ch=c1[s1.length()-1];
                for(int i=s1.length()-1;i>0;i--){
                    c1[i]=c1[i-1];
                }
                c1[0]=ch;
                s1=String.valueOf(c1);
            }
            else{
                a=1;
                break;
            }
        }
        if(a==1){
            System.out.println("Yes");
        }    
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 20820
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  ll a,b,c,d;
  
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  while(a>=1&&c>=1){
    c -= b;
    if(c<=0) break;
    a -= d;
  }
  if(a>=1) printf("Yes");
  else printf("No");
  
  return 0;
}



Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<MACROS>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define 	TIEMPO_CORRIDA		cerr << "tiempo: "<<1.0*clock()/CLOCKS_PER_SEC <<" seg.\n";
#define 	FILES				freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define 	FORIT(it,e)			for(it = e.begin() ; it != e.end() ; it++)
#define 	FOR(i,a,b)			for(i = a ; i < b ; i++)
#define 	RFOR(i,a,b)			for(i = a ; i >= b ;i--)
#define 	FORSW(i,a,b,sw)		for(i = a ; i < b && sw ; i++)
#define 	RFORSW(i,a,b,sw)	for(i = a ; i >= b && sw ; i--)
#define 	fast 				ios::sync_with_stdio(false),cin.tie(),cout.tie();
#define 	to_int(x) 			atoi(x.data())
#define 	to_long(x) 			atoll(x.data())
#define 	ALL(x) 				x.begin(),x.end()
#define 	RALL(x) 			x.rbegin(),x.rend()
typedef 	long long 			ll;
typedef 	pair<int,int> 		ii;
typedef 	pair<ll,ll> 		lolo;
const		int 				modN = 1e9+7;
const		double 				PI = 3.1415926535897932384626433832795028841;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

int main(){
	int n;scanf("%d",&n);
	while(n>1000){
		n-=1000;
	}
	n = 1000-n;
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 3756
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

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

void Main()
{
  ll x, n; cin >> x >> n;
  vll p(n); rep(i, n) cin >> p[i];
  ll ans = 0;
  for(ll i = 0;i <= n;i++)
  {
    if(find(all(p), x - i) == p.end()) fin(x - i);
    if(find(all(p), x + i) == p.end()) fin(x + i);
  }
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 3728
n = int(input())

l1 = 2
l2 = 1
l3 = 3

if n >= 2:
    for i in range(n - 1):
        t = l1 + l2
        l1 = l2
        l3 = t
        l2 = l3
    print(l3)
else:
    if n == 1:
        print(l2)
    else:
        print(l1)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,Q;
    cin>>N>>Q;

    while(Q--){
            int a,b;
        cin>>a>>b;
        if(N==1){
            cout<<min(a,b)<<endl;
        }
        else{
            while(a!=b){
                if(a>b)swap(a,b);
                b=(b+N-2)/N;
            }
            cout<<a<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("output.txt","r",stdin)
#define write freopen("input.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;


int main(){

    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++) cin >> arr[i];

    vector<ll> pvv;

    for(int i=1;i<=100;i++){
        ll val = 0;
        for(auto a:arr){
            val += sqr(abs(a-i));
        }
        pvv.push_back(val);
    }

    sort(pvv.begin(),pvv.end());

    cout << pvv[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <string>
#define pii pair<int,int>
#define fi first
#define se second
#define pcc pair<char,char>

using namespace std;

typedef long long ll;

int main(){
        int n, m; cin >> n >> m;
        int e[55][55], d[55];
        memset(e,0,sizeof(e));
        memset(d,0,sizeof(d));
        while(m--){
                int u, v; cin >> u >> v;
                e[u][v] = e[v][u] = 1;
                d[u]++, d[v]++;
        }
        int ok = 1, ans = 0;
        while(ok){
                int ok = 0, u = 0;
                for(int i = 1; i <= n; ++i) if(d[i] == 1) {u = i; d[i]--; break;}
                for(int i = 1; i <= n; ++i){
                        if(e[u][i]){
                                ok = 1;
                                d[i]--;
                                ++ans;
                                e[u][i] = e[i][u] = 0;
                        }
                }
                if(ok == 0) break;
        }
        cout << ans << endl;
        return 0;
}


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

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

  if(a == b){
    cout << "a == b";
  }else if(a < b){
    cout << "a < b";
  }else{
    cout << "a > b";
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 3068
def syukuhakuhi(n, k, x, y):
    sum = 0
    for i in range(n):
        if (i + 1) <= k:
            sum += x
        else:
            sum += y
    return sum


string_list = [input() for i in range(4)]

n = int(string_list[0])
k = int(string_list[1])
x = int(string_list[2])
y = int(string_list[3])

answer = syukuhakuhi(n, k, x, y)
print(answer)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define DEBUG(x) cout << #x << " = " << x << endl
#define pb push_back
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    //freopen("input.txt", "r", stdin);
    ll n, m;
    cin >> n >> m;

    ll x0;
    cin >> x0;
    ll sx = 0;
    for (ll i = 1; i < n; i++)
    {
        ll x1;
        cin >> x1;
        sx += (x1 - x0) * i * (n-i);
        sx %= MOD;
        x0 = x1;
    }

    ll y0;
    cin >> y0;
    ll sy = 0;
    for (ll i = 1; i < m; i++)
    {
        ll y1;
        cin >> y1;
        sy += (y1 - y0) * i * (m-i);
        sy %= MOD;
        y0 = y1;
    }

    cout << (sx * sy) % MOD;

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin>>N;
  long long ans;
  for(long long i=(N+1)/2;i>0;i--){
    if(i*i<=N){
      ans=i*i;
      break;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 5005
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
using namespace std;

int n, sol;

void print(int arr[MAXN][MAXN], int r, int s) {
	 for (int i = 0; i < r; ++i) {
		 for (int j = 0; j < s; j++) {
			 cout << arr[i][j] << " ";
		 }
		 cout << "\n";
	 }
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	int x = 1;
	while (true) {
		if (pow(10, x) > n) break;
		++x;
	}
	--x;
	if (not(x % 2)) sol += (n - pow(10, x) + 1);
	while (x > 0) {
		if (x % 2) {
			sol += (pow(10, x) - pow(10, x - 1));
		}
		x--;
	}	
	cout << sol;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
 
int main()
{
  string s;
  getline(cin,s);
  int len;
  len=s.length();
  if(s[len-1]=='s')
  {
    s=s+"es";
  }
  else
  {
    s.push_back('s');
  }
  cout<<s;
 return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int f(long long a,long long b)
{
    long long c;
    while(b)
    {
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
int main()
{
    long long a,b;
    while(scanf("%lld %lld",&a,&b)!=EOF)
    {
        long long k=f(a,b);
        printf("%lld %lld\n",k,(a/k)*b);
    }
    return 0;
}

Measured memory_bytes: 596
import numpy as np
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]

ans = np.zeros((h, w), dtype=np.int)
cnt = 1
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i][j] = cnt
            cnt += 1

for i in range(h):
    for j in range(w - 1):
        if ans[i][j + 1] == 0:
            ans[i][j + 1] = ans[i][j]
for i in range(h):
    for j in range(w - 1, 0, -1):
        if ans[i][j - 1] == 0:
            ans[i][j - 1] = ans[i][j]
for i in range(w):
    for j in range(h - 1):
        if ans[j + 1][i] == 0:
            ans[j + 1][i] = ans[j][i]
for i in range(w):
    for j in range(h - 1, 0, -1):
        if ans[j - 1][i] == 0:
            ans[j - 1][i] = ans[j][i]

for i in range(h):
    print(' '.join(map(str, ans[i])))


Measured memory_bytes: 27528
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=sum(B)
prev=A[0]
for i in range(1,n):
    if A[i]==prev+1:
        ans+=C[prev-1]
    prev=A[i]
print(ans)

Measured memory_bytes: 38384
import math

a, b, x = map(int, input().split())
l = a * a
h = x / l
if h < b / 2:
    m = h * a
    y = (2 * m) / b
    ans = math.degrees(math.atan(b/y))
    print(ans)
else:
    m = (b - h) * 2
    ans = math.degrees(math.atan(m/a))
    print(ans)

Measured memory_bytes: 3060