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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int x,n;
    cin >> x >> n;
    int ans=101,ansd=101;
    vector<int> ng(102);
    REP(i,n){
        int p;
        cin >> p;
        ng[p] = 1;
    }
    REP(i,102){
        if(ng[i]==1){
            continue;
        }
        int d = abs(i - x);
        if(d<ansd){
            ansd = d;
            ans = i;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int main(){
    fcin;
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<int> red, blue;
    for(int i = 0; i < a; i++){
        int x;  cin >> x;
        red.pb(x);
    }
    for(int i = 0; i < b; i++){
        int x;  cin >> x;
        blue.pb(x);
    }
    sort(red.rbegin(), red.rend());
    sort(blue.rbegin(), blue.rend());
    
    int t = max(0, a - x);
    while(t--) red.pop_back();

    t = max(0, b - y);
    while(t--) blue.pop_back();

    t = x + y;
    ll ans = 0;
    
    priority_queue<int> pq;
    a = red.size();
    b = blue.size();
    for(int i = 0; i < a; i++) pq.push(red[i]);
    for(int i = 0; i < b; i++) pq.push(blue[i]);
    for(int i = 0; i < c; i++){
        int x;  cin >> x;
        pq.push(x);
    }

    while(t--){
        ans += pq.top();
        pq.pop();
    }
    
    cout << ans << endl;
    return 0;
}




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

int main(){
  ld w,h,x,y; cin >> w >> h >> x >> y;
  ld area = (w * h) / 2;

  cout << std::fixed << std::setprecision(6) << area << ' ';

  if(w / 2 == x && h / 2 == y) {
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
  
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main()
{int N;cin >> N;
 vector<int> H(N,0); vector<int> J(N-1,0);
 if(N == 1){cout << 1 << endl;}
 else{
   for(int i = 0; i < N; i++){
   cin >> H[i];}
 
 int max_height = 0;
 
 for(int i = 0; i < N; i++)
 {max_height = max(H[i],max_height);
  J[i] = max_height;}
   
  int cnt = 1;
   
   for(int j = 1 ; j < N; j++)
   {if(J[j-1] <= H[j]){cnt++;}}
   
   cout << cnt << endl;}
 
   return 0;}


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

int main()
{
    vector<int> v;
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = 1; i <= __gcd(a, b); ++i)
    {
        if (a % i == 0 && b % i == 0)
            v.push_back(i);
    }
    nth_element(v.begin(), v.begin() + v.size() - k, v.end());
    cout << v[v.size() - k] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = Integer.parseInt(in.next());
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(in.next());
                sum += arr[i];
            }

            int g = Math.round((float) sum / n);
            int result = 0;
            for (int i : arr) {
                result += Math.pow(g - i, 2);
            }
            out.append(String.valueOf(result));
        }

    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    while(t--)
    {
        int n,m,i,x,y,z;
        cin>>n;
        int arr[n+1];
        map<int,int> mp;
        int sum=0;
        for(i=0;i<n;i++) {
            cin>>arr[i];
            mp[arr[i]]++;
            sum+=arr[i];
        }
        cin>>m;
        for(i=0;i<m;i++) {
            cin>>x>>y;
            sum+=(mp[x]*(y-x));
            cout<<sum<<endl;
            mp[y]+=mp[x];
            mp[x]=0;
        }
    }
    return 0;
}

Measured memory_bytes: 10364
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        pn(nl()*nl());
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj =true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 33056
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    S = list(input()[:-1])

    cnt = 1
    for i in range(N-1):
        if S[i]!=S[i+1]:
            cnt += 1
    
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4084
/* ITP1_10_A:Distance */
/* 20181125 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

int main(void) {
	double x1, y1, x2, y2;
	double distance;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

	printf("%f\n", distance);

	return 0;
}


Measured memory_bytes: 2112
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	static final int SIEVE = 10000000;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BitSet prime = new BitSet(SIEVE);
		prime.flip(2, SIEVE);
		for (int i = 2;i < SIEVE;++ i) if (prime.get(i)) for (int j = 2;i * j < SIEVE;++ j) prime.set(i * j, false);
		int like[] = new int[100002];
		like[0] = 0;
		for (int i = 1;i <= 100000;++ i) like[i + 1] = like[i] + (prime.get(i) & prime.get(i + 1 >> 1) ? 1 : 0);
		int Q = sc.nextInt();
		while((Q--) != 0) {
			int l = sc.nextInt(), r = sc.nextInt()+1;
			System.out.println(like[r] - like[l]);
		}
		sc.close();
	}
}


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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
bool comp(pair<int,int>p1,pair<int,int>p2)
{
    return p1.second<p2.second;
}
ll gcd (ll a,ll b)
{
    if(a==0)
        return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b)
{
    return a/gcd(a, b) * b;
}
ll n,q,k;
vector<pair<ll,ll> > v[MAXN];
map<ll,ll> m;
bool vis[MAXN];
void dfs(ll a,ll sum)
{
    vis[a]=1;
    for(int i=0;i<v[a].size();i++)
    {

        if(!vis[v[a][i].first])
        {
            m[v[a][i].first]=sum+v[a][i].second;
            dfs(v[a][i].first,sum+v[a][i].second);
        }

    }
}
int main()
{
    FAST
cin>>n;
for(int i=0;i<n-1;i++)
{
    ll a,b,c;
    cin>>a>>b>>c;
    v[a].push_back(make_pair(b,c));
    v[b].push_back(make_pair(a,c));
}

cin>>q>>k;
dfs(k,0);
while(q--)
{
    ll a,b;
cin>>a>>b;
cout<<m[a]+m[b]<<endl;
}
    return 0;

}


Measured memory_bytes: 23040
#include<iostream>

using namespace std;

int main(){
  int w,h;
  cin >> h >> w;
  char picture[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> picture[i][j];

    }
  }

  for(int i=0;i<h;i++){
    for(int k=0;k<2;k++){
      for(int j=0;j<w;j++){
        cout << picture[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

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

int gcd(int a, int b)
{
    if ( a % b == 0)
        return b;

    return gcd( b, a % b );
}

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

    long long ans = 0;
    N++;
    for (int i = 1; i < N; i++) {
        for(int j = 1; j < N; j++) {
            for(int k = 1; k < N;k++) {
                int a = gcd(max(i,j), min(i,j));
                ans += gcd(max(a,k), min(a,k));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *next,*prev;
};

Node *nil;

Node* ListSearch(int key){
  Node *cur=nil->next;
  while(cur  != nil && cur ->key != key){
    cur=cur->next;
  }
  return cur;
}

void Init(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}

void printlist(){
  Node *cur=nil->next;
  int isf=0;
  while(1){
    if(cur==nil)break;
    if(isf++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}

void DeleteNode(Node *t){
  if(t==nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void DeleteFirst(){
  DeleteNode(nil->next);
}

void DeleteLast(){
  DeleteNode(nil->prev);
}
void DeleteKey(int key){
  DeleteNode(ListSearch(key));
}
void insert(int key){
  Node *x=(Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
int main(){
  int key,n,i,size=0;
  char com[20];
  int np=0,nd=0;

  scanf("%d",&n);
  Init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
        if(com[6]=='F')DeleteFirst();
        else if(com[6]=='L')DeleteLast();
      }
      else{
        DeleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printlist();
  return 0;
}






Measured memory_bytes: 33796
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int maxn=1e5+10;
vector<int>v;
int a[maxn],n,ans; 
int cnt[maxn];
set<int>s;
inline int getid(int x){return lower_bound(v.begin(),v.end(),x)-v.begin()+1;}
main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),v.push_back(a[i]);
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=1;i<=n;i++)
	{
		set<int>::iterator it=s.upper_bound(-getid(a[i]));
		if(it!=s.end())
		{
			if(++cnt[getid(a[i])]==1)
			{
//				printf("!%d\n",a[i]);
				s.insert(-getid(a[i]));
			}
			if(--cnt[-*it]==0)
			{
//				printf("@%d\n",-*it);
				s.erase(it);
			}
		}
		else
		{
//				printf("#%d\n",a[i]);
			++cnt[getid(a[i])];
			s.insert(-getid(a[i]));
			ans++;
		}
	}
	printf("%lld\n",ans);
}
/*
6 
3 2 1 3 1 1
*/

Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  int A[N];

  int th_ex = 1;
  int even_cnt = 0;
  for(int i=0; i<N; i++) {
    int tmp;
    cin >> tmp;
    if(tmp%2 == 0) even_cnt++;
    th_ex *= 3;
  }
  int tw_ex = pow(2, even_cnt);

  cout << th_ex - tw_ex << endl;
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  set<int> D;
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    D.insert(d);
  }
  
  for (int i = N; i <= 10 * N; i++) {
    bool B = true;
    int X = i;
    while (X > 0) {
      if (D.count(X % 10)) {
        B = false;
        break;
      }
      X /= 10;
    }
    if (B) {
      cout << i << endl;
      break;
    }
  }
}

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

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

int x[N], y[N];
int h, w, q, l, r, d, z;
int v[N];

int main () {
    scanf("%d%d%d", &h, &w, &d);
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++) {
            scanf("%d", &z);
            x[z] = i;
            y[z] = j;
        }
    for (int i = 1; i+d < N; i++) {
        v[i+d] = v[i] + abs(x[i]-x[i+d]) + abs(y[i]-y[i+d]);
    }
    scanf("%d", &q);
    while (q--) {
        scanf("%d%d", &l, &r);
        ll ans = v[r] - v[l];
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2176
S = input()
s_2 = [int(x) for x in S.split()]

if (s_2[1] - s_2[0]+1) <= s_2[2]*2:
    for x in range(s_2[1] - s_2[0] + 1):
        print(s_2[0] + x)

else:    

    # upper
    for x in range(s_2[2]):
        ans = s_2[0] + x
        print(ans)

    #lower
    for x in range(s_2[2]):
        ans = s_2[1] - s_2[2] + x +1
        print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
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; }

#include <iomanip>
int main() {
    int N; cin >> N;
    vector<double> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];

    vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        }
    }
    double res = 0.0;
    for (int j = (N + 1) / 2; j <= N; j++) res += dp[N][j];
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 70784
n,m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i).sort
a.map!{|x| x/=2}

l = a[0]
for i in 1..n-1
    if l<m
        g = l.gcd(a[i])
        pa = a[i]/g
        pl = l/g
        if pa.even? || pl.even?
            puts 0
            exit
        else
            l =  g*pa*pl
        end
    else
        puts 0
        exit
    end
end

puts (m-l)/(l*2)+1

Measured memory_bytes: 11488
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::marker::*;
use proconio::*;
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        k: usize,
    }
    // annotate for rust-analyzer
    let k: usize = k;

    let mut q = VecDeque::new();
    for i in 1..=9 {
        q.push_back(i);
    }
    let mut ans = 0u64;
    let mut cnt = 0usize;
    while cnt < k {
        let cur = q.pop_front().unwrap();
        let tail = cur % 10;
        let base = cur * 10;
        if tail == 0 {
            q.push_back(base + tail);
            q.push_back(base + tail + 1);
        } else if tail == 9 {
            q.push_back(base + tail - 1);
            q.push_back(base + tail);
        } else {
            q.push_back(base + tail - 1);
            q.push_back(base + tail);
            q.push_back(base + tail + 1);
        }
        ans = cur;
        cnt += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    while(true){
        int W, D;
        cin >> W >> D;
        if(W == 0) break;

        map<int, int> w_count, d_count;
        for(int i=0;i<W;i++){
            int w;
            cin >> w;
            w_count[w]++;
        }
        for(int i=0;i<D;i++){
            int d;
            cin >> d;
            d_count[d]++;
        }

        int ans = 0;
        for(auto p : w_count){
            d_count[p.first] = max(d_count[p.first], p.second);
        }
        for(auto p : d_count){
            ans += p.first * p.second;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3084
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	ll D, N;
	cin >> D >> N;
	ll n = (ll)pow(100LL, D);
	ll ans = n * N;
	if (N == 100)
		ans += n;
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N,X,ans;
ans=0;
  X=0;
  cin >>N;
  for(int i=1;i<N+1;i++){
for(int j=1;j<i+1;j++){
if(i%j==0){
X++;
}
}
    if(X==8&&i%2==1){
ans++;
    }
    X=0;
}
  cout <<ans<< endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main
{
 
  public static void main(String[] args)
  {
    try{
    	// ??\???????????????
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      // ????????°???????????????
      //int n = Integer.parseInt(br.readLine());
      String[] str = br.readLine().split(" ");
      int[] array = new int[2];
 
      for(int i = 0; i < 2; i++){
        array[i] = Integer.parseInt(str[i]);
      }
      System.out.println(String.valueOf(getGraterValue(array[0],array[1])));
 
    }catch(Exception e){
      System.out.println(e);
    }
  }
 
  public static int getGraterValue(int a,int b){
	  
	  int greaterValue = a > b ? a : b;
	  if(a % greaterValue == 0 && b % greaterValue == 0)
	  {
		  return greaterValue;
	  }
	  else if(greaterValue < 2){
		  return 1;
	  }
	  else{
		  if(greaterValue == a){
			  // x > y
			  //gcd(x, y) = gcd(y, x%y)
			  return getGraterValue(b,a % b);
		  }
		  return getGraterValue(a,b % a);
	  }
  }
}

Measured memory_bytes: 24432
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n, vector<int>(n, inf));
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        g[a][b] = c; g[b][a] = c;
    }
    rep(i, n) g[i][i] = 0;
    
    vector<vector<int>> dist = g;
    rep(k, n) rep(i, n) rep(j, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);
    
    int ans = m;
    rep(i, n) rep(j, i + 1, n) {
        if (g[i][j] == inf) continue;
        rep(x, n) rep(y, n) {
            if (dist[x][i] + g[i][j] + dist[j][y] == dist[x][y]) {
                --ans;
                goto ioi;
            }
        }
    ioi:;
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A*B>C*D){
    cout<<A*B<<endl;
  }
  else{
    cout<<C*D<<endl;
  }
  return 0;
}


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

int main()
{
    int m1, d1, m2, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if (m1 == m2)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <set>
#include <unordered_map>
#include <cmath>
#include <memory>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <map>
#include <complex>
#include <iomanip>

int main()
{
    double m = (2.0 * M_PI) / 60.0;
    double h = (2.0 * M_PI) / (60.0 * 12.0);

    int A, B, H, M;
    std::cin >> A >> B >> H >> M;

    auto a = std::polar((double)A, (H * 60 + M) * h);
    auto b = std::polar((double)B, (M * m));

    std::cout << std::fixed << std::setprecision(9)  << std::abs(b - a) << std::endl;

    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int a,b;
    cin >>a >> b;
    cout << a * b << endl;


    return 0;
}

Measured memory_bytes: 3636
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;
/*string shuffle(string a, int b) {
	string c;
	for (int i = 0; i < a.size(); i++) {
		if (i < b) {
			c[a.size() - b + i] = a[i];
		}
		else {
			c[i-b] = a[i];
		}
	}
	for (int i = 0; i < a.size(); i++) {
		a[i] = c[i];
	}
	return a;
}
int main(){
	string str;
	int m, a[100];
	while (cin >> str && str != "-") {
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> a[i];
			str = shuffle(str, a[i]);
		}
		cout << str << endl;
	}
}

*/

struct dice {
	int s[6];
	void roll(char c) {
		int b;
		if (c == 'E') {
			b = s[0];
			s[0] = s[3];
			s[3] = s[5];
			s[5] = s[2];
			s[2] = b;
		}
		if (c == 'N') {
			b = s[0];
			s[0] = s[1];
			s[1] = s[5];
			s[5] = s[4];
			s[4] = b;
		}
		if (c == 'S') {
			b = s[0];
			s[0] = s[4];
			s[4] = s[5];
			s[5] = s[1];
			s[1] = b;
		}
		if (c == 'W') {
			b = s[0];
			s[0] = s[2];
			s[2] = s[5];
			s[5] = s[3];
			s[3] = b;
		}
		if (c == 'R') {
			b = s[1];
			s[1] = s[3];
			s[3] = s[4];
			s[4] = s[2];
			s[2] = b;
		}
	}
	int top() {
		return s[0];
	}
	int right() {
		return s[2];
	}
	int left() {
		return s[3];
	}
	int front() {
		return s[1];
	}

};

int main() {
	dice d;
	for (int i = 0; i < 6; i++) {
		cin >> d.s[i];
	}
	int order;
	cin >> order;
	while(order--) {
		int top, front;
		cin >> top >> front;
		if (d.left() == top) {
			d.roll('E');
		}
		if (d.right() == top) {
			d.roll('W');
		}
		while (d.top() != top) {
			d.roll('N');
		}
		while (d.front() != front) {
			d.roll('R');
		}
		cout << d.right() << endl;
	}
}


Measured memory_bytes: 3088
N=int(input())
X=list(map(int,input().split()))
M=int(input())
A=list(map(int,input().split()))

for a in A:
    i=a-1
    mem=X[i]+1
    if mem in X or mem==2020:
        continue
    else:
        X[i]=mem
for x in X:
    print(x)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0; i<x; i++)
#define repn(i,x) for(int i=1; i<=x; i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())



int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string stage;
    cin >> stage;
    a--;
    b--;
    c--;
    d--;
    stage[a] = 'a';
    stage[b] = 'b';
    bool failed = false;
    if (c < d) {
        while ((b < d) && (!failed)) {
            if (stage[b+1] == '.') {
                stage[b] = '.';
                b++;
                stage[b] = 'b';
            }
            else if (stage[b+2] == '.') {
                stage[b] = '.';
                b += 2;
                stage[b] = 'b';
            }
            else
                failed = true;
            if (b > d)
                failed = true;
        }
        while ((a < c) && (!failed)) {
            if (stage[a+1] == '.') {
                stage[a] = '.';
                a++;
                stage[a] = 'a';
            }
            else if (stage[a+2] == '.') {
                stage[a] = '.';
                a += 2;
                stage[a] = 'a';
            }
            else
                failed = true;
            if (a > c)
                failed = true;
        }
    }
    else
    {
        while ((a < c) && (!failed)) {
            if (stage[a+1] == '.') {
                stage[a] = '.';
                a++;
                stage[a] = 'a';
            }
            else if (stage[a+2] == '.') {
                stage[a] = '.';
                a += 2;
                stage[a] = 'a';
            }
            else if (stage[b+1] == '.') {
                stage[b] = '.';
                b++;
                stage[b] = 'b';
            }
            else if (stage[b+2] == '.') {
                stage[b] = '.';
                b += 2;
                stage[b] = 'b';
            }
            else
                failed = true;
            if (a > c || b > d)
                failed = true;
        }
        while ((b < d) && (!failed)) {
            if (stage[b+1] == '.') {
                stage[b] = '.';
                b++;
                stage[b] = 'b';
            }
            else if (stage[b+2] == '.') {
                stage[b] = '.';
                b += 2;
                stage[b] = 'b';
            }
            else
                failed = true;
            if (b > d)
                failed = true;
        }
    }
    if (!failed)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;   
}


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

using namespace std;

int main(){
    long long n, m;
    cin >> n >> m;
    vector<pair<long long, long long>>v, v1;
    for(long long i = 0; i < n; ++i){
        long long tmp, tmp1; cin >> tmp >> tmp1;
        v.push_back(make_pair(tmp, tmp1));
    }
    for(long long i = 0; i < m; ++i){
        long long tmp, tmp1; cin >> tmp >> tmp1;
        v1.push_back(make_pair(tmp, tmp1));
    }
    for(long long i = 0; i < n; ++i){
        long long min = INT_MAX, ans;
        for(long long j = 0; j < m; ++j){
            if(abs(v[i].first - v1[j].first) + abs(v[i].second - v1[j].second) < min){
                min  = abs(v[i].first - v1[j].first) + abs(v[i].second - v1[j].second);
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
    return 0;

}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
       Scanner in = new Scanner(System.in);
       int a, b;
       int idx = 0;
       while(true) {
	       a = in.nextInt();
	       b = in.nextInt();
	       if(a == 0 && a == b) return;
	       if(a<b) System.out.printf("%d %d\n", a, b);
	       else System.out.printf("%d %d\n", b, a);
       }
    }
}

Measured memory_bytes: 31744
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>p(n);
	rep(i, n) {
		cin >> p[i];
	}
	int ans = 0;
	rep(i, n - 2) {
		if (p[i + 1] != max(max(p[i], p[i + 1]), p[i + 2]) && p[i + 1] != min(min(p[i], p[i + 1]), p[i + 2])) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//Colorful Hats 2

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int mod=1000000007;
    nvarep(n,a);
    vector<deque<int>>t(3,{-1});
    int ans=1;
    rep(i,0,n){
        int c=0;
        rep(j,0,3)if(t[j].back()+1==a[i])c++;
        ans=(ans*c)%mod;
        rep(j,0,3){
            if(t[j].back()+1==a[i]){
                t[j].pb(a[i]);
                break;
            }
        }
    }
    cout<<ans<<nnn;
    return 0;
}

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

const int maxn = 2e5+10;
typedef long long ll;

int a[maxn];
ll sum[maxn];
map<ll, ll> mp;
int main()
{

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

    for (int i=0;i<n;i++){
        mp[sum[i]]++;
    }

    ll ans = 0;
    map<ll, ll>::iterator it = mp.begin();
    while (it != mp.end()) {
        if (it->second > 1) {
            ans += (it->second) * (it->second-1) / 2;
        }
        if (it->first == 0) ans+=it->second;
        it ++;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int N;
    std::cin >> N;
    
    std::unordered_map<char, uint64_t> m; 
    m['M'] = 0;
    m['A'] = 0;
    m['R'] = 0;
    m['C'] = 0;
    m['H'] = 0;

    std::string S;
    for (int i = 0; i < N; ++i) {
        std::cin >> S;
        const char c = S[0];

        if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') {
            m[c] += 1;
        }
    }

    uint64_t ans = m['M'] * m['A'] * m['R']
                 + m['M'] * m['A'] * m['C']
                 + m['M'] * m['A'] * m['H']
                 + m['M'] * m['R'] * m['C']
                 + m['M'] * m['R'] * m['H']
                 + m['M'] * m['C'] * m['H']
                 + m['A'] * m['R'] * m['C']
                 + m['A'] * m['R'] * m['H']
                 + m['A'] * m['C'] * m['H']
                 + m['R'] * m['C'] * m['H'];

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n, k = inp
t = na(k,0)
(1..n).each do |d|
  t[d%k] += 1
end
ans = t[0]**3
ans += t[k/2]**3 if(k.even?)
p ans

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

typedef long long ll;
typedef unsigned long long ull;

typedef struct Node{
    int key;
    Node *parent;
    Node *lhs, *rhs;
} Node;

typedef struct{
    Node *root;
} BinaryTree;

void init_node(Node *node, int val){
    node->key = val;
    node->parent = nullptr;
    node->lhs = nullptr;
    node->rhs = nullptr;
}

void init_bintree(BinaryTree *T){
    T->root = nullptr;
}

void insert(BinaryTree *T, Node *node){
    Node *parent = nullptr;
    Node *x = T->root;
    while(x != nullptr){
        parent = x;
        if(node->key < x->key) x = x->lhs;
        else x = x->rhs;
    }
    node->parent = parent;
    if(parent == nullptr) T->root = node;
    else if(node->key < parent->key) parent->lhs = node;
    else parent->rhs = node;
}

void print_preorder(Node *n){
    if(n == nullptr) return;
    cout << ' ' << n->key;
    print_preorder(n->lhs);
    print_preorder(n->rhs);
}

void print_inorder(Node *n){
    if(n == nullptr) return;
    print_inorder(n->lhs);
    cout << ' ' << n->key;
    print_inorder(n->rhs);
}

void print(BinaryTree *T){
    print_inorder(T->root);
    cout << endl;
    print_preorder(T->root);
    cout << endl;
}

void find(BinaryTree *T, int val){
    Node *n = T->root;
    while(n != nullptr){
        if(n->key == val){
            cout << "yes" << endl;
            return;
        }
        if(val < n->key) n = n->lhs;
        else n = n->rhs;
    }
    cout << "no" << endl;
    return;
}

BinaryTree T;
Node n[500000];

int main(){
    int idx = 0;
    int m, v;

    init_bintree(&T);
    cin >> m;
    for(int i=0;i<m;i++){
        string comm;
        cin >> comm;
        if(comm=="print") print(&T);
        else if(comm=="insert"){
            cin >> v;
            init_node(n+idx, v);
            insert(&T, n+idx);
            idx++;
        }else if(comm=="find"){
            cin >> v;
            find(&T, v);
        }
    }
    
    
    return 0;
}


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

int main()
{
    char s;
    cin >> s;

    if(s >= 'a' && s <= 'z')
    {
        cout << "a" << endl;
    }
     if(s >= 'A' &&  s <= 'Z')
    {
        cout << "A" << endl;
    }



    return 0;
}



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

const int inf = 1e9;
const ll linf = 1e18;

ll len(int n) { return (1LL << (n + 2)) - 3; }

ll find(int n, ll x)
{
    if (n == 0) return 1;

    const ll mid = (len(n) + 1) / 2;
    if (x == 1) {
        return 0;
    } else if (x < mid) {
        return find(n - 1, x - 1);
    } else if (x == mid) {
        return find(n - 1, x - 1) + 1;
    } else if (x < len(n)) {
        return find(n - 1, len(n-1)) + 1 + find(n - 1, x - mid);
    } else {
        return 2 * find(n - 1, len(n-1)) + 1;
    }
}

int main()
{
    int n; cin >> n;
    ll x; cin >> x;
    cout << find(n, x) << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
c = list(map(int, input().split()))

dp = [float("inf")]*(n+1)
dp[0] = 0
for i in range(m):
    for j in range(c[i], n+1):
        dp[j] = min(dp[j], dp[j-c[i]]+1)
print(dp[n])



Measured memory_bytes: 7524
<?php

list($n, $m) = explode(' ', trim(fgets(STDIN)));
$h_list = explode(' ', trim(fgets(STDIN)));
$answer = $h_list;
for ($i = 1; $i <= $m; ++$i) {
    list($a, $b) = explode(' ', trim(fgets(STDIN)));
    if ($h_list[$a - 1] < $h_list[$b - 1]) {
        unset($answer[$a - 1]);
    } elseif ($h_list[$a - 1] > $h_list[$b - 1]) {
        unset($answer[$b - 1]);
    } else {
        unset($answer[$a - 1]);
        unset($answer[$b - 1]);
    }
}

echo count($answer);


Measured memory_bytes: 27276
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s, t;
    cin >> s;
    cin >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main() {
	int i, a, b, c;
	a = 0;
	b = 0;
	c = 0;
	while (cin >> i) {
		if (a < i) {
			c = b;
			b = a;
			a = i;
		}
		else if (b < i) {
			c = b;
			b = i;
		}
		else if (c < i) {
			c = i;
		}
	}
	cout << a << endl << b << endl << c << endl;
	return 0;
}

Measured memory_bytes: 1160
//B
//Author : Sidiq Tri Pratikto
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
//order_of_key(x) = number of elements stricly smaller than x
//find_by_order(x) = return x-th largest element
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
int frek[101];

int main() {
	int N, K, ans = 0;
	scanf("%d%d", &N, &K);
	for (int i = 0; i < K; i++) {
		int x, y;
		scanf("%d", &x);
		for (int j = 0; j < x; j++) {
			scanf("%d", &y);
			frek[y]++;
		}
	}
	for (int i = 1; i <= N; i++) {
		if (frek[i] == 0) ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3840
#include <stdio.h>
int main(void) {
    int a,b,c,d,e,f,g,h,i,j;
    scanf("%d%d%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
    printf("%d\n",a+b+c+d+e+f+g+h+i+j);
    return 0;
}

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

#define int long long
#define MAX_N (200005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;

class DisjointSet{
public:
    vector<int> rank, p;
    
    DisjointSet() {}
    DisjointSet(int size){
        rank.resize(size, 0);
        p.resize(size, 0);
        for(int i=0; i<size; i++) makeSet(i);
    }
    
    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }
    
    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }
    
    void unite(int x, int y){
        link(findSet(x), findSet(y));
    }
    
    void link(int x, int y){
        if(rank[x] > rank[y]){
            p[y] = x;
        } else {
            p[x] = y;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }
    
    int findSet(int x){
        if(x != p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    DisjointSet ds = DisjointSet(N);


    for(int i=0; i<M; i++){
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--; Y[i]--;
        if(ds.same(X[i],Y[i])) continue;
        ds.unite(X[i],Y[i]);
    }

    set<int> st;
    for(int i=0; i<N; i++){
        st.insert(ds.findSet(i));
    }

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

}

Measured memory_bytes: 8832
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iomanip>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int N;
ll cum_sum[200010];
int ans;
map<ll, int> m;

int main()
{	
	cin >> N;
	rep(i, N) {
		int d; cin >> d;
		cum_sum[i + 1] = cum_sum[i] + d;
		
	}

	for (int i = 0; i <= N; i++) {
		if (!m[cum_sum[i]])m[cum_sum[i]] = i+1;
		else {
			ans = max(ans, i+1 - m[cum_sum[i]]);
			m[cum_sum[i]] = min(m[cum_sum[i]], i+1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17112
import sys
N = int(input())
LU, LD, LR, LL = [], [], [], []
for _ in range(N):
    x, y, d = sys.stdin.readline().split()
    x = int(x)
    y = int(y)
    if d == 'R':
        LR.append((x, y))
    elif d == 'L':
        LL.append((x, y))
    elif d == 'U':
        LU.append((x, y))
    elif d == 'D':
        LD.append((x, y))
if LR:
    lrx, lry = map(list, zip(*LR))
else:
    lrx, lry = [], []
if LL:
    llx, lly = map(list, zip(*LL))
else:
    llx, lly = [], []
if LU:
    lux, luy = map(list, zip(*LU))
else:
    lux, luy = [], []
if LD:
    ldx, ldy = map(list, zip(*LD))
else:
    ldx, ldy = [], []

inf = 100000000000000.0
maxxp = max(lrx + [-inf])
maxxz = max(lux + ldx + [-inf])
maxxm = max(llx + [-inf])
minxp = min(lrx + [inf])
minxz = min(lux + ldx + [inf])
minxm = min(llx + [inf])

maxyp = max(luy + [-inf])
maxyz = max(lly + lry + [-inf])
maxym = max(ldy + [-inf])
minyp = min(luy + [inf])
minyz = min(lly + lry + [inf])
minym = min(ldy + [inf])

def calc(t):
    maxx = max(maxxp + t, maxxz, maxxm - t)
    minx = min(minxp + t, minxz, minxm - t)
    maxy = max(maxyp + t, maxyz, maxym - t)
    miny = min(minyp + t, minyz, minym - t)
    
    return abs(maxx - minx)*abs(maxy - miny)

lo = 0.0
hi = 10000000000.0
for _ in range(1000):
    b1 = (2*lo + hi)/3
    b2 = (lo + 2*hi)/3
    if calc(b1) < calc(b2):
        hi = b2
    else:
        lo = b1
print(calc(lo))


Measured memory_bytes: 67292
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

int main() {
ll N;
  cin>>N;
  map<ll,ll> S;
  ll sum=0;
  for(ll i=0;i<N;i++) {
ll A;
    cin>>A;
    sum+=A;
    S[A]++;
  }
  
  ll Q;
  cin>>Q;
  for(ll i=0;i<Q;i++) {
ll A,B;
    cin>>A>>B;
    sum+=S[A]*(B-A);
    cout<<sum<<endl;
    S[B]+=S[A];
    S.erase(A);
  }
}
  
  
  
  
  
  
  
  
  

Measured memory_bytes: 7472
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		s = s.replace("eraser","Q");
		s = s.replace("erase","Q");
		s = s.replace("dreamer","Q");
		s = s.replace("dream","Q");
		for( int i=0; i<s.length(); i++ ){
			if( s.charAt(i)!='Q' ){
				System.out.println("NO");
				break;
			}
			if( i==s.length()-1 ){
				System.out.println("YES");
			}
		}	
	}
}


Measured memory_bytes: 31700
#include <iostream>
#include <string>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()


int main(){
	string str;
	cin >> str;
	int counter = 0;
	char before = str[0], after;
	REP(i,1,str.size()){
		after = str[i];
		if(after != before) counter++;
		before = after;
	}
	printf("%d\n", counter);

	return 0;
}


Measured memory_bytes: 512
from fractions import gcd
from collections import defaultdict
def getlist():
	return list(map(int, input().split()))

L = [1 for i in range(1000001)]
L[0] = 0
L[1] = 0
plist = []
for i in range(1000001):
	if L[i] == 1:
		plist.append(i)
		c = 2
		while True:
			if i * c <= 1000000:
				L[i * c] = 0
				c += 1
			else:
				break

#処理
A, B = getlist()
G = gcd(A, B)
D = defaultdict(int)
for i in plist:
	while True:
		if G % i == 0:
			D[i] += 1
			G = G // i
		else:
			break
if G != 1:
	D[G] += 1

ans = len(D) + 1
print(ans)

Measured memory_bytes: 16404
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

fn trans(dp: &mut Vec<usize>, k: usize, p: usize) {
    for i in (1..p).rev() {
        dp[i] = ((p - k) * dp[i] + dp[i - 1]) % p;
    }
    dp[0] = (p - k) * dp[0] % p;
}

fn calc(l: usize, r: usize, a: &Vec<usize>, memo: &Vec<usize>, mut ans: &mut Vec<usize>, p: usize) {
    if l + 1 == r {
        if a[l] == 1 {
            for (ans, memo) in ans.iter_mut().zip(memo.iter()) {
                *ans = (*ans + p - *memo) % p;
            }
        }
        return;
    }
    let mut dp = memo.clone();
    let m = (l + r) / 2;
    for i in l..m {
        trans(&mut dp, i, p);
    }
    calc(m, r, &a, &dp, &mut ans, p);
    dp = memo.clone();
    for i in m..r {
        trans(&mut dp, i, p);
    }
    calc(l, m, &a, &dp, &mut ans, p);
}

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        p: usize,
        a: [usize; p],
    }
    let mut dp = vec![0; p];
    let mut ans = vec![0; p];
    dp[0] = 1;
    calc(0, p, &a, &dp, &mut ans, p);
    for i in 0..p {
        if i > 0 {
            write!(out, " ").unwrap();
        }
        write!(out, "{}", ans[i]).unwrap();
    }
    write!(out, "\n").unwrap();
}

fn main() {
    run();
}


Measured memory_bytes: 4476