akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする
template<class T> void chmin(T &a, T b){ if(a>b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

/*
 * */
int main() {
    char b;
    cin >> b;

    map<char,char> change;
    change['A'] = 'T';
    change['T'] = 'A';
    change['C'] = 'G';
    change['G'] = 'C';
    
    cout << change[b] << endl;
}

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

int main () {
  int K;
  cin >> K;
  if ( K % 2 == 0 ) cout << ( K / 2 ) * ( K / 2 ) << endl;
  else cout << ( K / 2 + 1 ) * ( K / 2 ) << endl;
}

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

int main(){
    int n; cin >> n;
    int cnt = 1, ans = 0;
    while(cnt <= n){
        if(to_string(cnt).size() % 2 == 1) ans++;
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=100+10;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),sum+=a[i];
    if(sum%n==0)
    {
        int k=sum/n;
        int ans=0;
        for(int i=1;i<=n;i++)
            ans+=(a[i]-k)*(a[i]-k);
        printf("%d\n",ans);
    }
    else
    {
        int k=sum/n;
        int ans=0;
        for(int i=1;i<=n;i++)
            ans+=(a[i]-k)*(a[i]-k);
        int ans1=0;
        k++;
        for(int i=1;i<=n;i++)
            ans1+=(a[i]-k)*(a[i]-k);
        printf("%d\n",min(ans,ans1));
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
#define inf 0x3f3f3f
typedef long long ll;
const int maxn = 15;
char s[maxn];
int main(){
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 760
#include<iostream>
#include<algorithm>
using namespace std;
int num[1005];
int main()
{
	int n,k;
	cin>>n>>k;
	int i,j,a,b;
	for(i=1;i<=k;i++)
	{
		cin>>a;
		for(j=1;j<=a;j++)
		{
			cin>>b;
			num[b]++;
		}
	}
	int sum=0;
	for(i=1;i<=n;i++)
	{
		if(num[i]==0) sum++;
	}
//	cout<<num[1]<<" "<<num[2]<<" "<<num[3]<<endl;
	cout<<sum;
	return 0;
}

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

bool check(long long b, long long n){
    long long ok = 1;
    long long ng = b + 1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if ((2 * mid + n) * (n + 1) / 2 <= b) ok = mid;
        else ng = mid;
    }
    return ((2 * ok + n) * (n + 1) / 2 == b);
}

void solve(long long b, long long n, int &ans){
    long long ok = 1;
    long long ng = b + 1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if ((2 * mid + n) * (n + 1) / 2 <= b) ok = mid;
        else ng = mid;
    }
    ans = ok;
}

int main(){
    long long b;
    while (1){
        cin >> b;
        if (b == 0) break;
        long long start = 1; int ans;
        while ((start + 1) * (start) / 2 <= b) start++;
        for (long long i = start; i > 0; i--){
            if (check(b, i - 1)){
                solve(b, i - 1, ans);
                start = i;
                break;
            }
        }
        cout << ans << " " << start << endl;
    }
}


Measured memory_bytes: 3004
#include<stdio.h>
int main() {
	int S, h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	m = (S-3600*h) / 60;
	s = S-3600*h-60*m;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		int M=in();
		if(!M) break;
		vector<vector<int>> dp(M+1,vector<int>(1001,0));
		dp[0][0]=1;
		for(int i=1;i<=M;i++){
			int v=in(),n=in();
			REP(j,1001){
				dp[i][1000-j] = dp[i-1][1000-j];
				REP(k,n){
					if((1000-j)+(k+1)*v<=1000) dp[i][(1000-j)+(k+1)*v]+=dp[i][1000-j];
				}
			}
		}
		int N=in();
		REP(i,N){
			out(dp[M][in()]);
		}
	}
	
	return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int main() {
	int n;
	int d[100] = {};
	ll s = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
		s += d[i];
	}
	ll a = 0;
	for (int i = 0; i < n; i++)
	{
		a += d[i] * (s - d[i]);
	}
	cout << a/2;
}

Measured memory_bytes: 256
N, T = list(map(int, input().split()))
CT = []
ans = []
for i in range(N):
    CT.append(list(map(int, input().split())))
    if CT[i][1] <= T:
        ans.append(CT[i][0])
else:
    if not ans:
        print("TLE")
    else:
        print(min(ans))


Measured memory_bytes: 3060
n,X = map(int,input().split())
x = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i] = x[i] - X
from fractions import gcd
ans = b[0]
for i in range(1, n):
    ans = gcd(ans, b[i])
print(abs(ans))

Measured memory_bytes: 15020
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
 		
int main() {

string S,T;
vecs(R)
cin>>S>>T;
fx(S.size()){
	if(S.at(x)==T.at(0)||S.at(x)=='?'){
		int i=0;
		while(i<T.size()&&x+i<S.size()&&(S.at(x+i)==T.at(i)||S.at(x+i)=='?')){i++;}
		
		if(i==T.size()){
		string K=S;
		i=0;
		while(i<T.size()){
			K.at(x+i)=T.at(i++);
		}
		fy(K.size()){
			if(K.at(y)=='?'){K.at(y)='a';}
		}
		pb(R,K)
		}
	}
	
}
if(R.size()!=0){
sorts(R)

ce(R.at(0))
}else{
	ce("UNRESTORABLE")
}

}

Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
    tmp = input[0].split(" ");
 
    const n = parseInt(tmp[0]);
 
    if (n < 1001) {
        console.log( '%d', 1000-n);
    } else if (n%1000 == 0){
        console.log( '0' );
    } else {     
        const n3str = n.toString().slice(-3)
        const n3 = parseInt(n3str);
        console.log( '%d', 1000-n3);
    }
 
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  int n;	cin >> n;
  vector<int>	L(n);
  for(int i=0;i<n;i++)	cin >> L[i];
  
  sort(L.begin(),L.end());
  int ans=0;
  for(int a=0;a<n;a++){
    for(int b=a+1;b<n;b++){
      int left=b+1;
      int right=lower_bound(L.begin(),L.end(),L[a]+L[b])-L.begin();
      ans+=right-left;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3568
#include<iostream>
#include<cstring>
using namespace std;
char a[101];
long long int str2;
int main()
{
	cin>>a;
	cin>>str2;
	long long int len = strlen(a);
	int count = 0;
	for(int i =0; i < len; i ++)
	{
			if(a[i]=='1')
				count++; 
			else
			  break;
	}
	if(str2<=count)
		printf("1\n");
	else
		printf("%c\n",a[count]);
		
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;

int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll n,m,ans=0;
	cin>>n>>m;
	while(m--){
		ll t;
		cin>>t;
		ans+=t;
	}
	if(ans>=n)puts("Yes");
	else puts("No");	
	return 0;
}

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

#define ll long long
#define mod 1000000007
ll cnt[30],dp[30][2];
int n;
string str;

ll rec(int p,int f)
{
    if(p==26) return (f==1);
    ll &ret=dp[p][f];
    if(ret!=-1) return ret;
    ret=rec(p+1,f);
    ret%=mod;
    ret+=1LL*cnt[p]*rec(p+1,1);
    ret%=mod;
    return ret;
}

int main()
{
    cin >> n >> str;
    for(int i=0; i<n; i++) cnt[str[i]-'a']++;
    memset(dp,-1,sizeof dp);
    printf("%lld\n",rec(0,0));
}


Measured memory_bytes: 512
fn dfs(v: usize, adjl: &Vec<Vec<usize>>, mut used: HashSet<usize>, res: &mut usize) {
    used.insert(v);
    for &u in &adjl[v] {
        if !used.contains(&u) {
            dfs(u, adjl, used.clone(), res);
        }
    }
    // まだ全部じゃない
    for i in 0..adjl.len() {
        if !used.contains(&i) {
            return;
        }
    }
    *res += 1;
}

fn solve() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut adjl = vec![vec![]; n];
    for _ in 0..m {
        let (a, b): (usize, usize) = (read::<usize>() - 1, read::<usize>() - 1);
        adjl[a].push(b);
        adjl[b].push(a);
    }
    let mut res = 0;
    let used = HashSet::new();
    dfs(0, &adjl, used, &mut res);
    println!("{}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2276
#include <stdio.h>

int main()
{
  int n,k;
  scanf("%d%d",&n,&k);
  int p[n];
  int i;
  i = 0;
  while (i < n)
  {
    scanf("%d",&p[i]);
    i++;
  }
  i = 0;
  int j,t;
  j = 0;
  while (i < n)
  {
    j = 0;
    while (j < n)
    {
      if (p[i] < p[j])
      {
        t = p[i];
        p[i] = p[j];
        p[j] = t;
      }
      j++;
    }
    i++;
  }
  i = 0;
  int sum;
  sum = 0;
  while (i < k)
  {
    //printf("%d",p[i]);
    sum += p[i];
    i++;
  }
  printf("%d",sum);
}

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

int main( )
{
    int n = 0;
    string s; cin >> s;

    for (int i = 0; i < s.size( ); i++)
    {
        if (s[i] == '+')    n++;
        else                n--;
    }

    cout << n << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

template <typename T>
struct fenwick_tree {
    int n, power; // min power s.t. n <= power && power = 2^k;
    vector<T> data;
    fenwick_tree(int n=0) : n(n), data(n+1) {
        power = 1;
        while (power < n) power <<= 1;
    }
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) data[i] += x;
    }
    // [0, i)
    T sum(int i) {
        T res = 0;
        for (; i; i -= i&-i) res += data[i];
        return res;
    }
    // [l, r)
    T sum(int l, int r) { return sum(r) - sum(l);} 
    // min x s.t. v0 + v1 + v2 + ... + vx　>= w
    int lower_bound(T w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int i = power; i; i >>= 1) {
            if (i+x <= n && data[i+x] < w) {
                w -= data[i+x];
                x += i;
            }
        }
        return x;
    }
};

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

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i], a[i]--;

    vector<int> right(n+1, n);
    auto ys = make_vec<int>(n+1, 0);
    rrep(i, n) {
        ys[right[a[i]]].push_back(i);
        right[a[i]] = i;
    }
    
    auto qs = make_vec<pair<int, int>>(n+1, 0);
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        qs[r].emplace_back(l, i);
    }

    fenwick_tree<int> ft(n+1);
    vector<int> ans(q);
    for (int r = n; r >= 0; --r) {
        for (auto [l, id] : qs[r]) ans[id] = ft.sum(l, r+1);
        for (int y : ys[r]) ft.add(y);
    }
    rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 59884
#include<stdio.h>
#include<stdbool.h>

int main(){
 int A,B,C,D;
 bool flg = true;
 
 scanf("%d%d%d%d",&A,&B,&C,&D); 
 
 while(flg == true){
   C = C - B;
   if(C <= 0){
   puts("Yes");
   break;
   }
   
   A = A-D;
   if(A <= 0){
     puts("No");
     break;
   }
 }

 return 0;
  
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
        p[i]--;
    }
    int ans = 0;
    for(int i=0;i<n-1;i++){
        if(p[i] == i){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    if(p[n-1]==n-1){
        swap(p[n-1],p[n-2]);
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include<vector>
#include<algorithm>
#include <set>
#include<cmath>
//#include<dequeue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    char *c;
    c=new char(3);
    scanf("%s",c);
//    printf("%s",c);
    if(c[0]=='S'&&c[1]=='U')printf("7\n");
    if(c[0]=='M')printf("6\n");
    if(c[0]=='T'&&c[1]=='U')printf("5\n");
    if(c[0]=='W')printf("4\n");
    if(c[0]=='T'&&c[1]=='H')printf("3\n");
    if(c[0]=='F')printf("2\n");
    if(c[0]=='S'&&c[1]=='A')printf("1\n");
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    string a;
    a = to_string(N);

    if(a.at(0) == '7' || a.at(1) == '7' || a.at(2) =='7'){
        cout << "Yes" << endl;
    } 
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int D; cin >> D;
    vector<int> c(26+1, 0);
    for(int i = 1; i <= 26; i++) cin >> c[i];
    vector<vector<int>> s(D+1, vector<int>(26+1, 0));
    for(int i = 1; i <= D; i++)for(int j = 1; j <= 26; j++) cin >> s[i][j];
    vector<int> t(D+1, 0);
    for(int i = 1; i <= D; i++) {
        t[i] = rand() % 25 + 1;
        //cout << t[i] << endl;
    }
    ll ans = 0;
    int mx = 0;
    int id = 0;
    for(int _ = 0; _ <= 100000; _++){
        vector<int> last(26+1, 0);
        auto f = [&](int d){
            int res = 0;
            for(int i = 1; i <= 26; i++){
                res += c[i] * (d - last[i]);
                //if(mx < c[i] * (d - last[i])) id = i;
            }
            return res;
        };
        vector<int> old = t;
        t[rand() % (D-1) + 1] = rand() % 25 + 1;
        ll tmp = 0;
        for(int day = 1; day <= D; day++){
            //mx = 0;
            //t[day] = id;
            int con = t[day];
            tmp += s[day][con];
            last[con] = day;
            tmp -= f(day); 
        }
        if(ans > tmp) {
            t = old;
            continue;
        }
        ans = max(ans, tmp);
    }
    for(int i = 1; i <= D; i++) cout << t[i] << endl;
}

Measured memory_bytes: 3692
<?php
fscanf(STDIN, "%d ", $k);
fscanf(STDIN, "%d %d", $a ,$b);

$flg = false;
for($i= $a; $i <= $b ;$i++){
    if($i % $k == 0){
        echo 'OK';
        $flg = true;
        break;
    }
}

if(!$flg){
    echo 'NG';
}

?>

Measured memory_bytes: 16188
n = int(input())
a = list(map(int, input().split()))
b = []

if n % 2 == 0:
    for i in range(n - 1, 0, -2):
        b.append(a[i])
    for i in range(0, n, 2):
        b.append(a[i])
else:
    for i in range(n - 1, -1, -2):
        b.append(a[i])
    for i in range(1, n, 2):
        b.append(a[i])

for i in range(len(b)):
    print(b[i], end=" ")


Measured memory_bytes: 26180
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val b = (0 until n - 1).map { sc.next().toInt() }
    println(problem140c(n, b))
}

fun problem140c(n: Int, b: List<Int>): Long {
    val dp = (0 until n).map { 0L }.toMutableList()
    dp[0] = b[0].toLong()
    for (i in 1 until n) {
        if (i >= n - 1) {
            dp[i] += b[i - 1].toLong()
        } else {
            dp[i] = Math.min(b[i], b[i - 1]).toLong()
        }
    }
    return dp.sum()
}

Measured memory_bytes: 31520
//import java.util.Scanner;
//
//public class Main {
//	public static void main(String[] args) {
//
//		Scanner sc = new Scanner(System.in);
//
//		String s = sc.next();
//
//		System.out.println(s.equals("Sunny") ? "Cloudy" : s.equals("Cloudy") ? "Rainy" : "Sunny");
//
//	}
//}

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		boolean flg = false;

		for (int i = 0; i < s.length(); i = i + 2) {
			if (!(s.charAt(i) == 'R' || s.charAt(i) == 'U' || s.charAt(i) == 'D')) {
				flg = true;
				break;
			}
		}

		for (int i = 1; i < s.length(); i = i + 2) {
			if (!(s.charAt(i) == 'L' || s.charAt(i) == 'U' || s.charAt(i) == 'D')) {
				flg = true;
				break;
			}
		}

		if (flg) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}
}

Measured memory_bytes: 23508
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)] 
a=e[0][0]
b=e[0][1]
for i in range(n-1):
  k=[-(-a//(e[i+1][0])),-(-b//(e[i+1][1]))]
  a=max(k)*(e[i+1][0])
  b=max(k)*(e[i+1][1])
print(a+b)

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

int main(){
    using namespace std;
    int N; cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    int r = 0;
    long long cnt = 0, sum = 0;
    for (int i = 0; i < N; i++)
    {
        while (r<N && ( (sum^v[r]) == sum+v[r]))
        {
            sum += v[r];
            r++;
        }
        cnt += r - i;
        if(i==r) r++;
        else sum -= v[i];
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long int mod=1000000007;
int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<long long int>>grid(H,vector<long long int>(W,0));
    char a;
    for(int i=0;i<H;i++)
     for(int j=0;j<W;j++)
     {
         cin>>a;
         if(a=='#')
          grid[i][j]=-1;
        //cout<<grid[i][j]<<" ";
     }
    
    for(int i=0;i<H;i++){
        if(grid[i][0]==-1)
         break;
     grid[i][0]=1;}
    for(int i=0;i<W;i++){
        if(grid[0][i]==-1)
         break;
     grid[0][i]=1;}
    grid[0][0]=1;
    for(int i=1;i<H;i++)
    {
        for(int j=1;j<W;j++)
        {  if(grid[i][j]!=-1){
            if(grid[i-1][j]!=-1 && grid[i][j-1]!=-1)
             {grid[i][j]=grid[i-1][j]+grid[i][j-1];
              if(grid[i][j]>mod)
               grid[i][j]%=mod;}
            else if(grid[i-1][j]!=-1 && grid[i][j-1]==-1)
             grid[i][j]=grid[i-1][j];
            else
             grid[i][j]=grid[i][j-1];}
        }
    }
    /*for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
         cout<<grid[i][j]<<" ";
        cout<<endl;
    }*/
    if(grid[H-1][W-1]==-1)
     cout<<0<<endl;
    else
    cout<<grid[H-1][W-1]%mod<<endl;

  

}

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

using ll=long long;
const ll INF=1LL<<60;
const ll MOD=1e9+7;

int n;
vector<int> S;

bool bin_search(int key, int left=0, int right=n-1){
    while(right-left >= 0){
        int mid=left+(right-left)/2;
        if(S[mid] == key) return true;
        else if(S[mid] < key) left=mid+1;
        else right=mid-1;
    }
    return false;
}

int main(){
    cin >> n;
    S.resize(n);
    for(auto &x: S) cin >> x;
    int q; cin >> q;
    vector<int> T(q);
    for(auto &x: T) cin >> x;
    int C=0;
    for(int i=0; i<q; i++){
        if(bin_search(T[i])) C++;
    }
    cout << C << endl;
    return 0;
}


Measured memory_bytes: 3268
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};
 
use proconio::input;

fn main() {
    input!{
        n: usize,
        k: usize,
    }

    let mut snuke = vec![false; n];

    for _ in 0..k {
        input!{
            d: usize,
            a: [usize; d],
        }

        for aa in a {
            snuke[aa-1] = true;
        }
    }

    let mut ans = 0;

    for s in snuke {
        if !s {
            ans += 1;
        }
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 2224
import java.util.Scanner;

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

        while (true) {

            int n = sc.nextInt();
            int[] sco = new int[n];
            int max = 0, min = 1000, sum = 0;
    
            if(n == 0) break;

            for(int i = 0; i < n; i++){
                sco[i] = sc.nextInt();
                sum += sco[i];

                if(min > sco[i]) min = sco[i];
                if(max < sco[i]) max = sco[i];
            }

            System.out.println((sum - min - max)/(n-2));
            
        
        }
    }
}


Measured memory_bytes: 29312
in1 = int(raw_input())
a = in1 // 100
b = (in1 - a * 100) // 10
c = in1 % 10

cnt = 0
if a == 1:
    cnt += 1
if b == 1:
    cnt += 1
if c == 1:
    cnt += 1

print cnt

Measured memory_bytes: 2568
N = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(N)]
x1 = sum(A)
for i in range(N):
    if i % 2 == 1:
        x1 -= 2 * A[i]
ans[0] = x1
for i in range(1, N):
    ans[i] = 2 * A[i-1] - ans[i-1]
print(*ans)

Measured memory_bytes: 14092
n = int(input())
s = [str(input()) for _ in range(n)]

dic = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for i in s:
    if i == 'AC':
        dic['AC'] += 1
    elif i == 'WA':
        dic['WA'] += 1
    elif i == 'TLE':
        dic['TLE'] += 1
    else:
        dic['RE'] += 1

for i in dic:
    # print(i)
    print("{0} x {1}".format(i, dic[i]))

Measured memory_bytes: 16368
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

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

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

string S;
string T;
long int num;
int main(){
    cin>>S>>T;
    for(int i=0;i<S.size();++i){
        if(S[i]!=T[i])num++;
    }
    cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

int main()
{
    long long n, w, i, j;
    cin >> n >> w;
    long long wts[n][2];

    for(i = 0; i < n; ++i)
        cin >> wts[i][0] >> wts[i][1];

    vector<vector<long long>> dp(n, vector<long long>(w + 1));

    for(i = 0; i <= w; ++i)
        dp[0][i] = (wts[0][0] <= i) ? wts[0][1] : 0;
    for(i = 0; i < n; ++i)
        dp[i][0] = 0;

    for(i = 1; i < n; ++i) {
        for(j = 1; j <= w; ++j) {
            dp[i][j] = (wts[i][0] <= j) ? max(dp[i - 1][j], wts[i][1] + dp[i - 1][j - wts[i][0]]) : dp[i - 1][j];
        }
    }
    cout << dp[n - 1][w] << "\n";
    return 0;
}

Measured memory_bytes: 79488
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}


int main() {
	ll X, A, B;
	int flag = 1;
	cin >> X;
	for(ll i=1;i<=(ll)sqrt(X)+1;i++) {
		if (X%i == 0) {
			A = -i;
			flag = 1;
			while(flag==1) {
				B = i + A;
			
				
				if ((B - A)*(A*A*A*A + A * A*A*B + A * A*B*B + A * B*B*B + B * B*B*B) == X) {
					cout << B << " " << A;
					return 0;
				}
				else if ((B - A)*(A*A*A*A + A * A*A*B + A * A*B*B + A * B*B*B + B * B*B*B) > X&&A>=0)
					flag = 0;
				A++;
				
			}
		}

	}
	
}

Measured memory_bytes: 3672
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
  return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int x = n % 1000;
  int res;
  if (x != 0) {
    res = 1000 - x;
  } else {
    res = 0;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3628
n,k,c=map(int,input().split())
s=[i for i in input()]
a=[0 for i in range(n)]
b=[0 for i in range(n)]
i=0
while i<n:
    if s[i]=="o":
        a[i]=1
        i+=c
    i+=1
s.reverse()
i=0
while i<n:
    if s[i]=="o":
        b[i]=1
        i+=c
    i+=1
b.reverse()
if sum(a)>k:
    quit()
for i in range(n):
    if a[i] and b[i]:
        print(i+1)

Measured memory_bytes: 65784
#include <bits/stdc++.h>
using namespace std;
int n,m,a,b,ans=0,z=0;
pair<int,int>p[100001];
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        p[i]=make_pair(b,a);
    }
    sort(p,p+m);
    for(int i=0;i<m;i++){
        if(!(p[i].first==p[i+1].first)&&!(p[i].first>z&&p[i].second<=z)){
            ans++;
            z=p[i].first-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main() {
	vector<int> a(3);
	int maxv = 0, minv = 101;
	for (int i = 0; i < 3; i++) cin >> a[i];

	for (int i = 0; i < 3; i++) {
		if (max(maxv, a[i]) == a[i]) {
			maxv = a[i];
		}
		if (min(minv, a[i]) == a[i]) {
			minv = a[i];
		}
	}
	cout << maxv - minv << endl;

	return 0;
}


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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n;
    cin >> n;

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

    int ans = 0;

    for(int i = n; i >= 1; i--) {

        int cnt = 0;
        for(int j = i + i; j <= n; j += i) {
            cnt += b[j];
        }

        if(a[i] == 1) {
            if(cnt & 1) b[i] = 0;
            else b[i] = 1, ans++;
        }
        else {
            if(cnt & 1) b[i] = 1, ans++;
            else b[i] = 0;
        }
    }

    cout << ans << endl;

    for(int i = 1; i <= n; i++) {
        if(b[i] == 1) {
            cout << i << " ";
        }
    }

    cout << endl;
}

/**
*/


Measured memory_bytes: 2560
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
#define out(x) cout << #x << " -> " << x << endl;
using namespace std;
const ll N = 300010, M = 2000005;
ll x, res, p, n,mn=MAX;
bool vis[300];
int solve()
{
	in2(x,n);
	for(int i=0;i<n;i++)
	{
		in1(p);
		vis[p]=1;
	}
	for(int i=0;i<=200;i++)
	{
		if(vis[i]==0 && abs(i-x)<mn)
		{
			res=i;
			mn=abs(i-x);
		}
	}
	printf("%lld\n", res);
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int ret = solve();
	return 0;
}
/*

*/


Measured memory_bytes: 3828
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  as <- getIntList
  putStrLn $ if sum as >= 22 then "bust" else "win"

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

int h,w;
char a[15][15];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> h >> w;
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			cin >> a[i][j];
		}
	}
	int ph=1,pw=1,ok=a[1][1]=='#';
	a[ph][pw]='.';
	while (ph<h||pw<w){
		int right=pw<w&&a[ph][pw+1]=='#';
		int down=ph<h&&a[ph+1][pw]=='#';
		if (right^down){
			ph+=down;
			pw+=right;
			a[ph][pw]='.';
		}else{
			ok=0;
			break;
		}
	}
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			ok&=a[i][j]=='.';
		}
	}
	cout << (ok?"P":"Imp") << "ossible\n";
}

Measured memory_bytes: 256
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {break;}
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn read_t<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_usize(&mut self) -> usize {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_u64(&mut self) -> u64 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
}
fn main() {
    use std::io;
    let stdin = io::stdin();
    let stdin = io::BufReader::new(stdin.lock());
    let read = Read::new(stdin);
    solve(read);
}

fn solve<R: std::io::BufRead>(mut r: Read<R>) {
    let n = r.read_usize();
    let mut a:Vec<i32> = Vec::new();
    for i in 0..n {
        a.push(r.read_i32());
    }
    a.sort();
    let mut suma = 0;
    let mut sumb = 0;
    for i in (0..n).into_iter().step_by(2) {
        suma+=a[i];
    }
    for i in (1..n).into_iter().step_by(2) {
        sumb+=a[i];
    }
    println!("{}",(suma-sumb).abs())
}


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

int main(){
	int h, w, k;
  	cin >> h >> w >> k;
	vector<string> s(h);
  	rep(i, h) cin >> s[i];
  	
  	int ans = 0;
  	rep(is, 1<<h)rep(js, 1<<w){
    	int cnt = 0;
      	rep(i, h)rep(j, w){
        	if(is>>i&1) continue;
            if(js>>j&1) continue;
          	if(s[i][j] == '#') cnt++;
        }
      	if(cnt == k) ans++;
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>

#define MYSCAN scanf

int main(void){
	int n, v;
	int ice[10] = { 0 };

	while (true){

		MYSCAN("%d", &n);
		if (n == 0){ break; }
		for (int i = 0; i < n; i++){
			MYSCAN("%d", &v);
			ice[v]++;
		}
		for (int i = 0; i < 10; i++){
			if (ice[i] == 0){
				printf("-\n");
			}
			else{
				for (int j = 0; j < ice[i]; j++){
					printf("*");
				}
				printf("\n");
				ice[i] = 0;
			}
		}

	}	
	return 0;
}

Measured memory_bytes: 1000
x, y = map(int, input().split())
if x == 1 and y == 1:
    print(10**6)
else:
    te = [0, 3*10**5, 2*10**5, 1*10**5]
    if x>3:
        x=0
    if y>3:
        y=0
    print(te[x]+te[y])

Measured memory_bytes: 3060
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            if((a+b) % 2 == 0){
              System.out.println((a+b)/2);
            } else {
              System.out.println((a+b)/2 + 1);
            }
            }
}

Measured memory_bytes: 21844
N = int(input())
lis = list(map(int,input().split()))
ans = 1
flag = True
if 0 in lis:
  print(0)
else:
  for i in range(N):
    ans = ans*lis[i]
    if ans > 1000000000000000000:
      print(-1)
      flag = False
      break
  if flag == True:
    print(ans)

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

#define INF (1<<30)

int shop[100][10];
int p[100][11];


int main(){
	int n;	cin>>n;
	//{{{ input
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin>>shop[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<=10;j++){
			cin>>p[i][j];
		}
	}
	//}}}

	int ans=-INF;
	for(int flag=1; flag<pow(2,10); flag++){

		int tmp=0;
		for(int i=0;i<n;i++){
			int count=0;
			for(int j=0;j<10;j++){
				if((flag>>j)&shop[i][j])count++;
			}
			tmp+=p[i][count];
		}
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x;
  int i,j,k,count=0;

  while(1){
  scanf("%d%d",&n,&x);
  if(n==0 && x==0) break;

  for(i=1;i<=n;i++)
    for(j=i+1;j<=n;j++)
      for(k=j+1;k<=n;k++)
	if(i+j+k==x) count++;
  printf("%d\n",count);
  count=0;
  }
  return 0;
}

Measured memory_bytes: 1820
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    string s;
    cin >> s;
    deque<char> que;
    for(int i = 0; i < s.size(); i++) {
        que.push_back(s[i]);
    }
    bool rev = false;
    int q;
    cin >> q;
    while(q--) {
        int ord;
        cin >> ord;
        if(ord == 1) {
            rev = !rev;
        }
        if(ord == 2) {
            int f;
            char c;
            cin >> f >> c;
            if(rev) {
                if(f == 1) {
                    que.push_back(c);
                } else {
                    que.push_front(c);
                }
            } else {
                if(f == 1) {
                    que.push_front(c);
                } else {
                    que.push_back(c);
                }
            }
        }
    }
    if(rev) {
        reverse(all(que));
    }
    for(auto e : que) {
        cout << e;
    }
    cout << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    map<int, int> mp;

    rep(i, N) {
        int a;
        cin >> a;
        mp[a]++;
    }

    int l=0, s=0;
    int res=0;
    for(auto &p: mp) {
        int a = p.fi;
        int n = p.se;
        if(n >= 2) {
            if(n >= 4) {
                if(a >= l) {l=a; s=a;}
                else if(a >= s) s=a;
            } else {
                if(a >= l) {s=l; l=a;}
                else if(a >= s) s=a;
            }
        }
        res = max(res, l*s);
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 6528
a=int(input())
Order = list(map(int, input().split()))
Happiness = list(map(int, input().split()))
Bonus = list(map(int, input().split()))
res = 0
mae = -1
for i in Order:
  res += Happiness[i-1]
  if mae == -1:
    pass
  elif mae == i-1:
    res += Bonus[i-2]
  mae = i
print(res)

Measured memory_bytes: 9148
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <utility>
#include <numeric>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i=0;(i)<(n);(i)++)
#define repi(i, n) for (int i=0;(i)<=(n);(i)++)
#define repr(i, n) for (int i=n;(i)>=0;(i)--)
#define print(x) (cout<<x<<endl)

int main() {
    int n; cin>>n;
    vi p(n); rep(i,n) cin>>p[i];
    rep(i,n) p[i]--;  // 0-origin

    int cnt=0;
    rep(i,n) {
        if (i==p[i]) {
            cnt++;
            if (i<n-1) swap(p[i], p[i+1]);
        }
    }
    print(cnt);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

struct SCC{//ant p.286
	int V;
	vector<vector<int>> G;
	vector<vector<int>> rG;
	vector<int> vs;
	vector<bool> used;
	vector<int> cmp;
	SCC(int v){
		V = v;
		G.resize(V);
		rG.resize(V);
		used.resize(V,false);
		cmp.resize(V);
	}

	void add_edge(int from,int to){
		G[from].push_back(to);
		rG[to].push_back(from);
	}
	void dfs(int v){
		used[v] = true;
		for(int i=0;i<G[v].size();i++){
			if(!used[G[v][i]])dfs(G[v][i]);
		}
		vs.push_back(v);
	}
	void rdfs(int v,int k){
		used[v] = true;
		cmp[v] = k;
		for(int i = 0; i < rG[v].size(); ++i){
			if(!used[rG[v][i]])rdfs(rG[v][i],k);
		}
	}
	int scc(){
		used = vector<bool>(V,false);
		vs.clear();
		for (int v = 0; v < V; ++v){
			if(!used[v])dfs(v);
		}
		used = vector<bool>(V,false);
		int k = 0;
		for (int i = vs.size() - 1; i >= 0 ; --i){
			if(!used[vs[i]])rdfs(vs[i],k++);
		}
		return k;
	}
	bool is_same(int v1,int v2){
		return cmp[v1]==cmp[v2];
	}
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int V,E,Q;
	cin >> V >> E;
	SCC g(V);
	FOR(i,0,E){
		int f,t;
		cin >> f >> t;
		g.add_edge(f,t);
	}
	g.scc();
	cin >> Q;
	FOR(i,0,Q){
		int a,b;
		cin >> a >> b;
		if(g.is_same(a,b))cout << 1 << endl;
		else 					cout << 0 << endl;
	}
}



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

struct fenwicktree {
	int n;
	vector<ll> a, t;
	fenwicktree(int N) {
		n = N;
		a.clear(); t.clear();
		a.resize(N + 1 , 0);
		t.resize(N + 1, 0);
	}
public:
	void update(int x, int val) { //val is added to the xth
		x++;
		while (x <= n) {t[x] += 1ll * val; x += (x & -x);}
	}
	ll query(int x) {
		x++;
		ll sum = 0;
		while (x > 0) {sum += 1ll * t[x]; x -= (x & -x);}
		return sum;
	}
	ll sum(int l, int r) {
		return query(r) - query(l - 1);
	}
};

void solve() {
	int n, q; cin >> n >> q;
	fenwicktree ans(n);
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		ans.update(i, 1ll * a);
	}
	while (q--) {
		int t, a, b; cin >> t >> a >> b;
		if (t == 0)ans.update(a, 1ll * b);
		else cout << ans.sum(a, b - 1) << endl;
	}

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();

}


Measured memory_bytes: 12172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll gcd(ll a, ll b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

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

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = lcm(a, b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
s=input().split()
r=int(s[0]);c=int(s[1])
a=[[0 for j in range(c)] for i in range(r)]
b=[[0 for j in range(c+1)]for i in range(r+1)]
for i in range(r):
    t=input().split()
    for j in range(c):
        a[i][j]=int(t[j])
        b[i][j]=a[i][j]
        b[r][j]+=a[i][j]
        b[i][c]+=a[i][j]
        b[r][c]+=a[i][j]
for i in range(r+1):
    for j in range(c+1):
        sys.stdout.write("{0}".format(b[i][j]))
        if j==c:
            sys.stdout.write("\n")
        else:
            sys.stdout.write(" ")

Measured memory_bytes: 6268
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var str = Console.ReadLine();
			Dictionary<char, int> dict = new Dictionary<char, int>();
			foreach (var c in str.ToCharArray())
			{
				if (dict.ContainsKey(c))
				{
					dict[c]++;
					if (dict[c] > 2)
					{
						Console.WriteLine("No");
						return;
					}
				}
				else
				{
					dict.Add(c, 1);
				}
			}
			if (dict.Keys.Count != 2)
			{
				Console.WriteLine("No");
			}
			else
			{
				Console.WriteLine("Yes");
			}
		}
	}
}


Measured memory_bytes: 13152
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int A = a * a;
			int B = b * b;
			int C = c * c;
			if (A + B == C || A + C == B || B + C == A ) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}


Measured memory_bytes: 23392
n = input()
lis=[]

for w in n:
    lis.append(int(w))

if lis[-1] == 2 or lis[-1] == 4 or lis[-1]== 5 or lis[-1]==7 or lis[-1]==9:
    print("hon")
elif lis[-1]==3:
    print("bon")
else:
    print("pon")

Measured memory_bytes: 9124
def solve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    B = sorted(A)
    m = B[-1]
    m2 = B[-2]
    ans = []
    for a in A:
        if a!=m:
            ans.append(m)
        else:
            ans.append(m2)
    return ans
print(*solve(),sep='\n')

Measured memory_bytes: 14752
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<int> G[SIZE];
int dp[SIZE][3];

int main() {
  int N, M, S, T;

  scanf("%d%d", &N, &M);

  for (int i=0; i<M; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--; v--;
    G[u].push_back(v);
  }

  scanf("%d%d", &S, &T);
  S--; T--;

  for (int i=0; i<N; i++)
    for (int j=0; j<3; j++)
      dp[i][j] = INF;

  queue<pair<int,int>> que1, que2;

  que1.push({S, 0});

  for (int i=0; que1.size(); i++) {
    while(que1.size()) {
      auto p = que1.front();
      que1.pop();

      int now = p.first;
      int step = p.second;

      if (dp[now][step] != INF) continue;
      dp[now][step] = i;

      for (int to : G[now]) {
        que2.push({to, (step + 1) % 3});
      }
    }
    swap(que1, que2);
  }

  int ans = dp[T][0];

  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans / 3 << endl;

  return 0;
}


Measured memory_bytes: 9600