akhauriyash/Code-Regression huggingface dataset:
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef unsigned long long/*-----------*/ulli;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define lb/*---------------------------*/lower_bound
#define ub/*---------------------------*/upper_bound
#define pb/*---------------------------*/push_back
#define popb/*-------------------------*/pop_back

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sz/*---------------------------*/size()

#define MP/*---------------------------*/make_pair
#define bs/*---------------------------*/binary_search
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()

#define ff/*---------------------------*/first
#define ss/*---------------------------*/second

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
    string s,t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s < t)
        cout << "Yes";
    else
        cout << "No";
	return 0;
}










Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static long mod_inv(long a, long m){
		return (a == 1 ? 1 : (1 - m*mod_inv(m%a, a)) / a + m);
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final char[] chs = sc.next().toCharArray();
			
			int[] mods = new int[chs.length + 1];
			for(int i = chs.length - 1, keta = 1; i >= 0; i--, keta = (keta * 10) % 2019) {
				mods[i] = ((chs[i] - '0') * keta + mods[i + 1]) % 2019; 
			}
			
			HashMap<Integer, Long> counts = new HashMap<Integer, Long>();
			for(final int mod : mods) {
				if(!counts.containsKey(mod)) {
					counts.put(mod, 0l);
				}
				counts.put(mod, counts.get(mod) + 1);
			}
			
			long answer = 0;
			for(final long value : counts.values()) {
				answer += value * (value - 1) / 2;
			}
			
			System.out.println(answer);
			
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 49816
import java.util.Arrays;
import java.util.Scanner;

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

	long MODULO = 1_000_000_000 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] t = new int[n];
		int[] p = new int[n];
		int[] x = new int[s];
		for (int i = 0; i < s; ++i) {
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < n; ++i) {
			t[i] = sc.nextInt();
			p[i] = sc.nextInt();
			--p[i];
		}
		int[] w = new int[n];
		for (int i = 0; i < n; ++i) {
			w[i] = t[i] - x[p[i]];
		}
		Arrays.sort(w);
		long ans = 0;
		for (long v : w) {
			ans -= v;
		}
		long[][] f = new long[n + 1][m + 1];
		for (int i = 0; i < f.length; ++i) {
			for (int j = 0; j < f[i].length; ++j) {
				f[i][j] = Integer.MAX_VALUE / 16;
			}
		}
		for (int i = 1; i < f.length; ++i) {
			f[i][1] = w[i - 1] * i;
		}

		for (int j = 2; j <= m; ++j) {
			// j is fixed???
			// Attention: h[i][k]:=f[k][j-1]+w[i-1]*(i-k) is of Monge.
			// min(h[i][]) can be enumerated in O(n*log(n))
			// f[i][j]=min(h[i][])
			long[] v = calc(f, w, j);
			for (int i = 1; i <= n; ++i) {
				// for (int k = 1; k <= i - 1; ++k) {
				// f[i][j] = Math.min(f[i][j], h(f, w, i, j, k));
				// }
				f[i][j] = v[i];
			}
		}

		long min = Integer.MAX_VALUE / 16;
		for (int j = 1; j <= m; ++j) {
			min = Math.min(min, f[n][j]);
		}
		ans += min;
		System.out.println(ans);
	}

	long[] calc(long[][] f, int[] w, int j) {
		int n = f.length - 1;
		int m = f[0].length - 1;
		long[] ret = new long[n + 1];
		Arrays.fill(ret, Integer.MAX_VALUE / 16);
		rec(ret, 1, n, 2, n + 1, f, w, j);
		return ret;
	}

	// [low,high)
	// [left,right)
	long rec(long[] ret, int low, int high, int left, int right, long[][] f, int[] w, int j) {
		int mid = (left + right) / 2;// the value of the variable i
		long v = Long.MAX_VALUE / 16;
		int arg = -1;
		for (int k = Math.max(0, low); k <= Math.min(mid - 1, high); ++k) {
			v = Math.min(v, h(f, w, mid, j, k));
			if (v == h(f, w, mid, j, k))
				arg = k;
		}
		if (right - left > 1) {
			rec(ret, low, arg, left, mid, f, w, j);
			rec(ret, arg, high, mid, right, f, w, j);
		}
		ret[mid] = v;
		return v;
	}

	long h(long[][] f, int[] w, int i, int j, int k) {
		return f[k][j - 1] + w[i - 1] * (i - k);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 78640
N=int(input())
h=list(map(int,input().split()))
idou=[]
i=0
cnt=0
if N==1:
    print(0)
elif N==2:
    if h[1]-h[0]<=0:
        print(1)
    else:
        print(0)
else:
    while i<=N-2:
        if h[i]>=h[i+1]:
            cnt+=1
            if i==N-2:
                idou.append(cnt)
        else:
            idou.append(cnt)
            cnt=0
        i+=1

    print(max(idou))        


Measured memory_bytes: 14228
s = list(input())
flagA = False
flagZ = False

if s[0] == 'A':
    a = 0
    flagA = True

# 文字列の両端から探索していきAのうち最左端にあるものZのうち最右端にあるものの要素数を記録　O(N/2)
i = 1
while not (flagA == True and flagZ == True):

    if s[i] == 'A' and flagA == False:
        a = i 
        flagA = True 
    if s[-i] == 'Z' and flagZ == False:
        z = len(s) - i
        flagZ = True
    
    i += 1
print(z-a+1)

Measured memory_bytes: 4840
// Sasageyo! Sasageyo! Shinzou wo Sasageyo !
// https://goo.gl/IwJzbx

#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

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

#define endl '\n'
const int N = 2000000;
int x[N];
int main()
{
	fast_io;
  int n;
  cin >> n;
  VI a(n);
  for(int i=0;i<n;i++)
    cin >> a[i];
  int s, e, dir;
  s = 0, e = 0, dir = 1;
  x[0] = a[0];
  for(int i=1;i<n;i++) {
    e = (e + dir + N)%N;
    x[e] = a[i];
    swap(s, e);
    dir *= -1;
    trace(s, e, dir);
  }
  for(int i=s;i!=e;i=(i+dir+N)%N) {
    cout << x[i] << " ";
  }
  cout << x[e] << endl;
	return 0;
}

Measured memory_bytes: 3712
N = int(input())
T = list(map(int, input().split()))
M = int(input())
drinks = [ map(int, input().split()) for _ in range(M) ]

for P, X in drinks:
  result = 0
  for i in range(N):
    if i == (P-1):
      result += X
    else:
      result += T[i]
  print(result)

Measured memory_bytes: 38512
#include <stdio.h>

int main(void)
{
	int i, s, sum = 0;
	
	for (i = 0; i < 4; i++){
		scanf("%d", &s);
		sum += s;
	}
	
	printf("%d\n%d\n", sum / 60, sum % 60);
	
	return (0);
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
long long a[100],n;
int main()
{
  cin>>n;
  a[0]=2,a[1]=1;
  for(int i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
  cout<<a[n]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> soinsu(101);
    auto soinsubunkai = [&](int n) {
        int tmp = n;
        for (int i = 2; i <= n; i++)
        {
            if (tmp%i)
                continue;
            while(tmp%i==0 && tmp >= 1){
                soinsu[i]++;
                tmp /= i;
            }
        }
    };
    rep1(i, n + 1) soinsubunkai(i);
    auto f = [&](int len) {
        return count_if(soinsu.begin(), soinsu.end(), [&](int x) -> bool { return x >= len; });
    };
    int ans = f(74) + f(24) * (f(2) - 1) + f(14) * (f(4) - 1) + f(4) * (f(4) - 1) * (f(2) - 2) / 2;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,ans=-1,m;
    scanf("%d%d",&n,&x);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&m);
        int p=abs(x-m);
        if(ans<0)
        {
            ans=p;
            continue;
        }
        ans=__gcd(ans,p);
    }
    printf("%d\n",ans);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,k,n,m,c,t;
    string s;
    cin>>n>>s;c=1;
    for(i=1;i<n;i++){
        if(s[i]!=s[i-1]) c++;
    }
    cout<<c;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

	ll n,k;
	cin >> n >> k;

	ll a[n];
	rep(i,n) cin >> a[i];

	ll mx = -1;
	rep(i,n) mx = max(mx,a[i]);

	if(k > mx){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	} 

	ll g = a[0];
	rep(i,n-1) g = gcd(g,a[i+1]);

	cout << (k % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;	
}

Measured memory_bytes: 1024
S = input()
T = input()

# 始点を決める
ans = 10**10
for i in range(len(S)-len(T)+1):
    # SからTの長さだけ文字引き抜く
    tmp = 0
    for j in range(i, i+len(T)):
        # print(S[j], T[j-i])
        if S[j] == T[j-i]:
            continue
        else:
            tmp += 1
    ans = min(tmp, ans)
    # print()
print(ans)


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A+B+C == 17 && abs(A-B)<3 && abs(B-C)<3){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

int main(){
  int h,w;
  cin >> h >> w;

  for(int i=0;i<h;i++){
    string g;
    cin >> g;

    int cur = -1;
    for(int j=0;j<w;j++){
      if(g[j] == 'c'){
	cur = 0;
      }else if(cur>=0){
	cur++;
      }
      cout << cur << " \n"[j+1==w];
    }
  }
}

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

int main() {
  int N;
  cin >> N;
  std::vector<int> h;
  h.reserve(N);
  copy_n(istream_iterator<int>(cin), N, back_inserter(h));
  std::vector<int> D(N);
  D[0] = 0;
  D[1] = abs(h[0] - h[1]);
  for (int i = 2; i < N; ++i) {
    D[i] =
        min(D[i - 1] + abs(h[i] - h[i - 1]), D[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << D[N - 1] << endl;
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/agc027/tasks/agc027_a
"use strict";
function Main(input) {
  input = input.trim().split("\n");
  let [N, X] = input[0].trim().split(" ").map(Number);
  const a = input[1]
    .trim()
    .split(" ")
    .map(Number)
    .sort((a, b) => a - b);

  let count = 0;
  for (let i = 0; i < N; i++) {
    if (i === N - 1) {
      if (a[i] === X) {
        count++;
      }
    } else if (X >= a[i]) {
      X -= a[i];
      count++;
    } else {
      break;
    }
  }

  console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29440
#include <iostream> 
#include <fstream> 
#include <cmath> 
#include <cstdlib> 
#include <algorithm> 
#include <vector> 
#include <string> 
#include <cstdio> 
#include <stack> 

using namespace std; 
int a; 
int b; 
int c; 

int main(void) { 	
    cin >> a; 	
    cin >> b; 	
    cin >> c; 	
    
    vector<int> t; 	
    t.push_back(a); 	
    t.push_back(b); 	
    t.push_back(c); 	
    sort(t.begin(), t.end()); 	
    
    if(t.at(0) == t.at(1)){
        cout << t.at(2) << endl;
    } 	
    else{
        cout << t.at(0) << endl;
    } 	
    
    return 0; 
    
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();		
		int ans = Integer.MIN_VALUE;
		
		int min = Integer.MAX_VALUE;
		for(int i=1; i<=n; i++){
			int R = sc.nextInt();
			
			if(R - min > ans){
				ans = R - min;
			}
			
			if(R < min){
				min = R;
			}
		}
		
		System.out.println(ans);
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 53840
use std::io;

fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split(' ').flat_map(str::parse).collect()
}

fn main() {
    let l1 = read::<i32>();

    let w_ = l1[0];
    let h_ = l1[1];
    let x = l1[2];
    let y = l1[3];
    let r = l1[4];

    let ans = if x >= r && y >= r && x <= w_ - r && y <= h_ - r {
        "Yes"
    } else {
        "No"
    };

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



Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;
#define INF 1000000000000
#define NOD 1000000007
#define PI 3.141592653589793238462643

int main() {
    int s, w;
    cin >> s >> w;
    if(s > w) cout << "safe" << endl;
    else cout << "unsafe" << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <sstream>
using namespace std;

#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C 9/++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()
 
//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(2e4+20)

#define fori(i,n) for(int i=0; i<n; i++)
#define forl(i,n) for(ll i=0; i<n; i++)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
const  llu int_max = pow(2,32) - 1 ;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.ff < j.ff;
}

int main(int argc, char const *argv[])
{
	int n,cnt=0;
	cin>>n;
	int p[n];
	
	for (int i = 0; i < n; ++i)
	{
		cin>>p[i];
		if(p[i] != i+1)
			cnt++;
	}
	if(cnt==2 || cnt==0 )
		cout<<"YES";
	else
		cout<<"NO";


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int dp[3010][3010];
int main(){
    string s,t;int n,m;
    cin>>s>>t;n=s.length();m=t.length();
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            dp[i][j]=max(dp[i][j],dp[i][j-1]);
            if(s[i-1]==t[j-1])dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
        }
    }
    int a=n,b=m;
    string res="";
    while(a>0&&b>0){
        if(dp[a-1][b-1]+1==dp[a][b]&&s[a-1]==t[b-1]){
            res+=s[a-1];
            a--;b--;
        }else if(dp[a-1][b]==dp[a][b]){
            a--;
        }else if(dp[a][b-1]==dp[a][b]){
            b--;
        }
    }
    reverse(all(res));
    cout<<res<<endl;
}   


Measured memory_bytes: 35584
package main

import (
  "fmt"
)

func main() {
  var A, B, C, X, ans int
  fmt.Scan(&A, &B, &C, &X)
  for i := 0; i <= A; i++ {
    for j := 0; j <= B; j++ {
      for k := 0; k <= C; k++ {
        if i * 500 + j * 100 + k * 50 == X {
          ans++
        }
      }
    }
  }
  fmt.Println(ans)
}

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

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var R = read[0];
            var G = read[1];
            var B = read[2];
            var N = read[3];

            var ret = 0;
            var r = 0;
            while (r * R <= N)
            {
                var g = 0;
                while (r * R + g * G <= N)
                {
                    if ((N - r * R - g * G) % B == 0)
                        ret++;
                    g++;
                }
                r++;
            }

            Console.WriteLine(ret);
        }
    }
}


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

namespace AOJ
{
    public class ITP1_2_B{
        public static void Main(){
            IList<int> abc = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToList();
            int a = abc[0];
            int b = abc[1];
            int c = abc[2];

            if(a < b && b < c){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 18340
# coding: utf-8
S = input()
ans = [1] * len(S)
tmp = []
lr = []
l, r = 0, 0
tmp_l = 0
cnt = 0
for i in range(len(S)-1):
    if S[i:i+2] == "RL":
        r, l = i, i+1
    if S[i] == "L" and S[i+1] == "R":
        if cnt != 0:
            tmp_l += 1
        for j in range(tmp_l, i+1):
            if j == r or j == l:
                continue
            if (j - r) % 2 == 0:
                ans[r] += 1
                ans[j] = 0
            else:
                ans[l] += 1
                ans[j] = 0
        cnt += 1
        tmp_l = i
        # print("cnt =", cnt)
        # print("ans", *ans)
    if i == len(S)-2:
        # print("here")
        if cnt != 0:
            tmp_l += 1
        for j in range(tmp_l, i+2):
            if j == r or j == l:
                continue
            if (j - r - 1) % 2 == 0:
                ans[l] += 1
                ans[j] = 0
            else:
                ans[r] += 1
                ans[j] = 0
print(*ans)


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   int n,i,j;
   cin>>n;
   
   
   string str,str1,str2;
   cin>>str;
   
   if(n%2!=0)
   cout<<"No"<<endl;
   else
   {  
        int j=n/2 , flag=0;
   	   for(int i=0;i<n/2;i++)
   	   {
   	   	  if(str[j]!=str[i])
   	   	  {
   	   	  	flag=1;
   	   	  	break;
		  }
		  j++;   	   	
	   }
	   
	   if(flag==0)
	   cout<<"Yes"<<endl;
	   else
	   cout<<"No"<<endl;
   }


   return 0;
}


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

char str[102];
int n, ans;
stack<int> st1, st2;
int main(){
	scanf("%d%s", &n, str);
	for(int i = 0;i < n;i++){
		if(str[i] == '(')st1.push(1);
		else{
			if(st1.empty())st2.push(1);
			else st1.pop();
		}
	}
	for(int i = 0;i < st2.size();i++)printf("(");
	printf("%s", str);
	for(int i = 0;i < st1.size();i++)printf(")");
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

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

const int U=80*159+1;
bool dp[81][81][U];
int A[81][81];
int B[81][81];
int main() {
	int H,W;
	cin >> H >> W;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> A[i][j];
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> B[i][j];
		}
	}
	dp[0][1][0]=true;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			int v=abs(A[i][j]-B[i][j]);
			for(int k=0;k<U;k++){
				if(dp[i-1][j][k]||dp[i][j-1][k]){
					dp[i][j][k+v]=dp[i][j][abs(k-v)]=true;
				}
			}
		}
	}
	for(int k=0;k<U;k++){
		if(dp[H][W][k]){
			cout << k << endl;
			return 0;
		}
	}
 
	return 0;
}


Measured memory_bytes: 80384
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    vector<ll> sum(n+1);
    rep(i,n) sum[i+1] = a[i]+sum[i];

    typedef pair<ll, ll> P;
    auto func = [&](int b) -> P {
        ll cnt = 0, s = 0;
        rep(i,n) {
            // a[j]+a[i] >= b
            int j = lower_bound(a.begin(), a.end(), b-a[i]) - a.begin();
            cnt += n-j;
            s += a[i]*(n-j);
            s += sum[n] - sum[j];
        }
        return P(cnt, s);
    };

    int left = 0, right = 200010;
    while (left+1<right) {
        int mid = (left+right)/2;
        if (func(mid).first >= m) left = mid;
        else right = mid;
    }
    P p = func(left);
    ll ans = p.second - (p.first-m)*left;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1536
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        var k = int.Parse(Console.ReadLine());
        Console.WriteLine(Regex.Replace(s, $"[^{s[k - 1]}]", "*"));
    }
}


Measured memory_bytes: 16580
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int sum = 0;
		int tmp = n;

		while (tmp != 0) {
			sum += tmp % 10;
			tmp /= 10;
		}

		System.out.println(n % sum == 0 ? "Yes" : "No");

		sc.close();
	}
}


Measured memory_bytes: 22612
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> X(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> X[i];
  }
  if (0 <= X[0]) {
    cout << X[K - 1] << endl;
    return 0;
  }
  if (X[N - 1] <= 0) {
    cout << abs(X[N - K]) << endl;
    return 0;
  }

  int64_t right = static_cast<int64_t>(lower_bound(X.begin(), X.end(), 0) - X.begin());
  int64_t left = (X[right] == 0) ? right : right - 1;
  int64_t result = INT64_MAX;
  if (left >= 0 && left < N) {
    for (int64_t i = left; left - i + 1 <= K && i >= 0; --i) {
      const int64_t remaining = K - (left - i + 1);
      const int64_t temp_1 = abs(X[i]);
      const int64_t right_end = right + remaining - 1;
      if (right_end >= 0 && right_end < N) {
        const int64_t temp_2 = abs(X[i]) + X[right_end];
        result = min(result, temp_1 + temp_2);
      }
    }
  }
  if (right >= 0 && right < N) {
    for (int64_t i = right; i - right + 1 <= K && i < N; ++i) {
      const int64_t remaining = K - (i - right + 1);
      const int64_t temp_1 = X[i];
      const int64_t left_end = left - (remaining - 1);
      if (left_end >= 0 && left_end < N) {
        const int64_t temp_2 = X[i] + abs(X[left_end]);
        result = min(result, temp_1 + temp_2);
      }
    }
  }

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


Measured memory_bytes: 3952
from collections import*
n,k,l=map(int,input().split());d=[-1]*n;t=[-1]*n;M=lambda:map(int,input().split());r=range
def f(l,x):
  if l[x]<0:return x
  else:l[x]=f(l,l[x]);return l[x]
def u(l,x,y):
  if f(l,x)!=f(l,y):l[f(l,y)]=f(l,x)
for _ in r(k):a,b=M();u(d,a-1,b-1)
for _ in r(l):a,b=M();u(t,a-1,b-1)
p=[(f(d,i),f(t,i))for i in r(n)];c=Counter(p);print(*[c[p[i]]for i in r(n)])

Measured memory_bytes: 44388
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
	cin >> n;
	si st;
	for (int i = 0; i < n; i++)
	{
		int x; cin >> x;
		st.insert(x);
	}
	if (sz(st) == n)
		cout << "YES";
	else
		cout << "NO";

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
#define f first
#define s second
typedef pair<int,int> pii;
const int N=1e2+5;
const int K=1e5+5;
const int mod=998244353;
const ll inf=1e18+7;
int a[N],dp[K],n,k;
int main()
{
    scanf("%d%d",&n,&k);
    forn(i,1,n){
        scanf("%d",&a[i]);
    }
    forn(i,1,k){
        int curr=0;
        forn(j,1,n){
            if(i-a[j]>=0){
                curr|=(dp[i-a[j]]^1);
            }
            dp[i]=curr;
        }
        //printf("dp[%d]:%d\n",i,dp[i]);
    }
    if(dp[k]){
        printf("First\n");
    }
    else{
        printf("Second\n");
    }
    return 0;
}


Measured memory_bytes: 640
#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++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  int a;
  if (2 * x == w && 2 * y == h)
    a = 1;
  else
    a = 0;
  printf("%.6lf %d\n", (w * h) / 2, a);
  return 0;
}

Measured memory_bytes: 256
def lp(node,memo,graph):
    if memo[node] != -1:
        return memo[node]
    cand = [0]
    if graph[node]:
        for neighbor in graph[node]:
            cand.append(lp(neighbor,memo,graph))
        maximam = max(cand)+1
    else:
        maximam = 0
    memo[node]=maximam
    return maximam

import sys
sys.setrecursionlimit(10**5)
N,M = map(int, input().split())
graph = {}
for i in range(N+1):
    graph[i] = []
for _ in range(M):
    x,y = map(int,input().split())
    graph[x].append(y)
ans = 0
memo = [-1]*(N+1)
for i in range(1,N+1):
    ans = max(ans, lp(i,memo,graph))
print(ans)

Measured memory_bytes: 145168
N = int(input())
S = input()
min_num = 10**7
west_num = [0]
east_num = [0]
w_max = 0
e_max = 0
for i in range(0, N): #累積和を求める.
    if S[i] == 'W':
        w_max += 1
    else:
        e_max += 1
        
    west_num.append(w_max)
    east_num.append(e_max)

for i in range(0, N):
    num = west_num[i] + east_num[-1] - east_num[i+1]
    if num < min_num:
        min_num = num
        
print(min_num)

Measured memory_bytes: 17644
using System;
using System.Linq;

namespace C
{
	internal class Program
	{
		private static int n;
		private static int m;

		private static readonly int div = 1000000007;

		public static void Main(string[] args)
		{
			var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			n = inputs[0];
			m = inputs[1];

			switch (Math.Abs(n - m))
			{
			case 0:
				Console.WriteLine(factorialMod(n) * factorialMod(m) % div * 2 % div);
				break;
			case 1:
				Console.WriteLine(factorialMod(n) * factorialMod(m) % div);
				break;
			default:
				Console.WriteLine(0);
				break;
			}
		}

		private static long factorialMod(int n)
		{
			var result = 1L;
			for (var i = 2; i <= n; i++)
			{
				result *= i;
				result %= div;
			}

			return result;
		}
	}
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        boolean[] isSeated = new boolean[100000];
        
        for(int i = 0; i < N; i++) {
            int l = scan.nextInt();
            int r = scan.nextInt();
            
            for(int j = l-1; j < r; j++) {
                isSeated[j] = true;
            }
        }
        
        int count = 0;
        for(int i = 0; i < 100000; i++) {
            if(isSeated[i]) count++;
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 24288
import math
from itertools import permutations
N = int(input())
TOWNS = [tuple(map(int, input().split())) for _ in range(N)]

cands = [p for p in permutations([i for i in range(0, N)], N)]
s = 0
for cand in cands:
    for i in range(N-1):
        start = TOWNS[cand[i]]
        dist = TOWNS[cand[i+1]]
        s += math.sqrt((start[0] - dist[0])**2 + (start[1] - dist[1])**2)

print(s / math.factorial(N))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

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

    ll i = 1, count = 0;
    while (n > 0) {
        i *= 26;
        n -= i;
        count++;
    }

    n += i - 1;

    vector<int> p(count);
    // ll div = 1;
    // rep(j,count) {
    //     div *= 26;
    // }

    // rep(j,count) {
    //     p[j] = n / div;
    //     div /= 26;
    //     n %= div;
    // }

    rep(j,count) {
        p[j] = n % 26;
        n /= 26;
    }

    rep(i, count) {
        ll ind = count - i - 1;
        char out;
        // if (p[ind] == 0) {out = 'z';}
        // else out = 'a' + p[ind];
        out = 'a' + p[ind];
        cout << out;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
// ITP1_8_A Toggling Cases
import java.io.*;

class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         char[] c = br.readLine().toCharArray();
         for (int i = 0; i < c.length; i++) {
            if (c[i] >= 'A' && c[i] <= 'Z')
               c[i] = Character.toLowerCase(c[i]);
            else if (c[i] >= 'a' && c[i] <= 'z')
               c[i] = Character.toUpperCase(c[i]);
         }

         //System.out.println(String.valueOf(c));
         System.out.println(c);
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
}

Measured memory_bytes: 16864
x = int(input())
if x >= 1800:
  print(1)
elif x >= 1600:
  print(2)
elif x >= 1400:
  print(3)
elif x >= 1200:
  print(4)
elif x >= 1000:
  print(5)
elif x >= 800:
  print(6)
elif x >= 600:
  print(7)
else:
  print(8)


Measured memory_bytes: 9168
### subroutines

def make_area(an, w)
  w[3] = an
  area = [w]

  start = w[0]

  while w[1] != start
    c1 = w[1]
    w1 = w[4]
    links1 = $links[c1]
    nl1 = links1.length

    wi = links1.index(w1)

    w = links1[(wi + nl1 - 1) % nl1]
    w[3] = an
    area << w
  end

  area
end

### main

while true
  $cn, $wn = gets.strip.split(' ').map{|s| s.to_i}
  break if $cn == 0 && $wn == 0

  $clmns = $cn.times.map{gets.strip.split(' ').map{|s| s.to_i}}

  $walls = $cn.times.map{[]}
  $links =  $cn.times.map{[]}

  $wn.times do
    c0, c1 = gets.strip.split(' ').map{|s| s.to_i}
    c0 -= 1
    c1 -= 1

    x0, y0 = $clmns[c0]
    x1, y1 = $clmns[c1]

    w0 = $walls[c0][c1] = [c0, c1, Math.atan2(y1 - y0, x1 - x0), nil]
    w1 = $walls[c1][c0] = [c1, c0, Math.atan2(y0 - y1, x0 - x1), nil]
    w0[4] = w1
    w1[4] = w0

    $links[c0] << w0
    $links[c1] << w1
  end
  #p $walls

  for c in (0...$cn)
    $links[c].sort!{|wa, wb| wa[2] <=> wb[2]}
  end
  #p $links

  an = 0
  $areas = []

  for ci in (0...$cn)
    for wi in $links[ci].each_index
      w = $links[ci][wi]
      if w[3].nil?
        $areas << make_area(an, w)
        an += 1
      end
    end
  end
  #p an
  #$areas.each{|ar| p ar.map{|w| $clmns[w[0]]}}

  cimin = (0...$cn).min{|a, b| $clmns[a] <=> $clmns[b]}
  s_area = $links[cimin].last[3]
  #p cimin
  #p s_area

  dists = an.times.map{an + 1}
  dists[s_area] = 0
  visited = []
  visited[s_area] = 1

  q = [s_area]

  while ! q.empty?
    a0 = q.shift

    for w0 in $areas[a0]
      a1 = w0[4][3]
      if visited[a1].nil?
        visited[a1] = 1
        dists[a1] = dists[a0] + 1
        q << a1
      end
    end
  end

  puts dists.max
end

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int ans;
  string s;
  cin >> s;

  rep(i,4){
    if(s[i]=='+') ans++;
    else ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<string> st;
long long frek[203];
int main()
{
    string a,s;
    long long i,j,z=0;
    cin>>a;
    z=1;
    for(i=0;i<a.length();++i)
    {
        frek[a[i]]++;
        z+=i-frek[a[i]]+1;
    }
    cout<<z<<endl;
}


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

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    IOS
    //io_set();
    ll n;
    cin>>n;
    cout<<(n*(n+1))/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;
	while (b!=0){
		a-=d;
		c-=b;
		if (c<=0){
			cout<<"Yes"<<endl;
			break;
		}
		if (a<=0){
			cout<<"No"<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == b + 1 || b == a + 1||a==b)cout << "Yay!" << endl;
	else cout << ":(" << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = [[0, 0, 0]] + [[int(i) for i in input().split()] for _ in range(N)]
YN = "Yes"
for i in range(N):
    a = (L[i + 1][0] - L[i][0])
    b = (abs(L[i + 1][1] - L[i][1]) + abs(L[i + 1][2] - L[i][2]))
    if b > a:
        YN = "No"
        break
    if a % 2 == 0 and b % 2 != 0:
        YN = "No"
        break
    if a % 2 != 0 and b % 2 == 0:
        YN = "No"
        break
print(YN)

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

int main() {
  char X, Y;
  cin >> X >> Y;

  if(X>Y){
    cout << '>' << endl;
  }
  else if(X<Y){
    cout << '<' << endl;
  }
  else{
    cout << '=' << endl;
  }

return 0;  
}

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

namespace _0075
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> number = new List<string>();
            string d = "";
            string[] t = new string[3];
            double w = 0;
            double h = 0;

            while ((d = Console.ReadLine()) != null)
            {
                t = d.Trim().Split(',');
                w = double.Parse(t[1]);
                h = double.Parse(t[2]);

                if ((Program.BMI(w,h)) >= 25)
                {
                    number.Add(t[0]);
                }
            }
            foreach (string item in number)
            {
                Console.WriteLine(item);
            }
        }
        static double BMI(double w, double h)
        {
            double answer = 0;
            answer = w / Math.Pow(h,2);
            return answer;
        }
    }
}



Measured memory_bytes: 17820
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n= scan.nextInt();
		double v[]=new double[n];
		for(int i=0;i<n;i++) {
			v[i]=scan.nextDouble();
		}
		scan.close();
		Arrays.sort(v);

		double ave=(v[0]+v[1])/2;
		for(int i=1;i<n-1;i++) {
			ave=(ave+v[i+1])/2;
		}
		System.out.println(ave);
	}

}

Measured memory_bytes: 23252
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int t = sc.nextInt();
        int ans = x - t;
        if (x - t < 0) {
            ans = 0;
        }
        System.out.println(ans);
    }
    
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=2e5+10;
vector<set<ll>> G(N);
vec al(N);
ll x,y;
void dfs(ll f) {
  al[f]=1;
  if(f<1e5)x++;
  else y++;
  for(ll t:G[f]) {
    if(!al[t]) dfs(t);
  }
}

int main() {
  ll n;
  cin >> n;
  for(ll i=0;i<n;i++) {
    ll x,y;
    cin >> x >> y;
    x--;y--;
    y+=1e5;
    G[x].insert(y);
    G[y].insert(x);
  }
  ll ans=0;
  for(ll i=0;i<2e5;i++) {
    if(!al[i]&&G[i].size()) {
      x=0,y=0;
      dfs(i);
      ans+=x*y;
    }
  }
  cout << ans-n << endl;
}

Measured memory_bytes: 22528
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
ll rui[100001];
ll d[100000];

int main()
{
	int n;
	ll ans=0;
	cin>>n;
	fill(d,d+100000,0);
	for(int i=0;i<n;i++)
	{
		int c;
		cin>>c;
		c--;
		d[c]++;
	}
	rui[0]=0;
	for(int i=0;i<100001;i++)
		rui[i+1]=rui[i]+d[i];
	for(int i=0;i<100001;i++)
	{
		if(n-rui[i]==rui[i])
			ans++;	
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
//No change above here

const ll maxi = 2 * 1e5 + 5;
ll mod = 5;
double pi = 3.141592653589793238;

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

ll gcd(ll a, ll b)
{
	if (a == 0)
		return b;
	else
		return gcd(b % a, a);
}

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

ll max_subarray(vector<int>& v)
{
	if (v.empty())
		return 0;
	ll glob = v[0], loc = v[0];
	for (int i = 1; i < v.size(); ++i)
	{
		loc = max(v[i] + 0LL, loc + v[i]);
		glob = max(loc, glob);
	}
	return glob;
}

long long num_digits(long long x)
{
	long long ans = 0;
	while (x)
	{
		++ans;
		x /= 10;
	}
	return ans == 0 ? 1 : ans;
}

vector<int> topological_sort(vector<vector<int>>& graph, int n, vector<int>& indegree)
{
	vector<int> ans;
	stack<int> s;
	for (int i = 0; i < n; ++i)
		if (indegree[i] == 0)
			s.push(i);
	while (!s.empty())
	{
		int x = s.top();
		s.pop();
		ans.push_back(x);
		for (auto& adj : graph[x])
			if (--indegree[adj] == 0)
				s.push(adj);
	}
	return ans;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }


//declare needed things here

int main()
{
	IOS;
	ll  n, x, t;
	cin >> n >> x >> t;
	cout << (((n - 1) / x + 1) * t) << endl;
	return 0;
}


Measured memory_bytes: 3636