akhauriyash/Code-Regression huggingface dataset:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,m = get_nums_l()

if n == m:
    print("Yes")
else:
    print("No")

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))


def main():
    mod=10**9+7
    N,M=MI()
    
    def fact(n):
        temp=1
        for i in range(1,n+1):
            temp*=i
            temp%=mod
        return temp
    
        
    if abs(N-M)>=2:
        print(0)
    else:
        ans=fact(N)*fact(M)
        if N==M:
            ans*=2
        print(ans%mod)

main()


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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long long ,long long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin()
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin()
#define ct(i) cout<< i << "\n"
#define sv(v) sort(v.begin(),v.end())
#define mod 1000000007
#define M 100005
#define endl "\n"

void solve(){
    ll n,x=0,ans=0;
    string s,t;
    cin>>n;
    ll a[n],suf[n];
	for(int i=1;i<n+1;i++){
		cin>>a[i-1];
	}
	suf[n-1]=0;
	for(int i=n-2;i>=0;i--)
		suf[i]=(a[i+1]+suf[i+1])%mod;
	for(int i=0;i<n;i++){
		ll va=a[i];
		va=(va*suf[i])%mod;
		ans=(ans+va)%mod;
	}
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int q;
    //cin>>q; while(q--)
        solve();
    return 0;
}


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

int main() {
	while(1) {
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0){break;}
		for (int i = 1; i <= h; i++) {
			if (i % 2 == 1){
				for (int j = 1; j <= w; j++) {
					if (j % 2 == 1){cout << "#";}
					else{cout << ".";}
				}
			}else if(i % 2 == 0){
				for (int j = 1; j <= w; j++) {
					if (j % 2 == 0){cout << "#";}
					else{cout << ".";}
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e3 + 5);
const int LOG = (int)(20);

int n, m;
char s[N][N], mark[N][N];

void f(int x, int y) {
	if(x == n && y == m) {
		bool fl = false;
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= m; j++)
				if(s[i][j] != mark[i][j]) {
					fl = true;
					break;
				}
		if(!fl) {
			cout << "Possible";
			exit(0);
		}
		return;
	}
	if(x + 1 <= n) {
		mark[x + 1][y] = '#';
		f(x + 1, y);
		mark[x + 1][y] = '.';
	}
	if(y + 1 <= m) {
		mark[x][y + 1] = '#';
		f(x, y + 1);
		mark[x][y + 1] = '.';
	}
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> s[i] + 1;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			mark[i][j] = '.';
	mark[1][1] = '#';
	f(1, 1);
	cout << "Impossible";
}

Measured memory_bytes: 256
def c(s):
    n = input()
    if n in s:
        s.remove(n)
    else:
        s.add(n)

def main():
    n = int(input())
    s = set()

    for i in range(n):
        c(s)

    print(len(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 19648
// http://agc010.contest.atcoder.jp/tasks/agc010_a
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("Failed to read line");
    io::stdin().read_line(&mut line).expect("Failed to read line");
    let mut vec: Vec<&str> = line.split_whitespace().collect();
    let n:u64 = vec.swap_remove(0).parse().expect("Failed to parse");
    let mut odd_cnt = 0;
    let mut i = 0;
    for s in vec {
        let n2:u64 = s.parse().expect("Failed to parse");
        if n2 % 2 != 0 { odd_cnt += 1; }
        i += 1;
        if n <= i { break; }
    }
    println!("{}", if odd_cnt % 2 == 0 { "YES" } else { "NO" });
}


Measured memory_bytes: 4476
def main():
    N = int(input())
    a = [input().split() for _ in range(N)]
    a = [(x, y, i+1) for (i, (x, y)) in enumerate(a)]
    a = sorted(a, key=lambda x: (x[0], -int(x[1])))
    # print(a)
    for _, _, i in a:
        print(i)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r, g, b := ReadInt(), ReadInt(), ReadInt()
	if (r*100+g*10+b)%4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


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

typedef long long ll;

int main(){
  ll x,y;
  cin >> x >> y;
  // 幅が2以上の時
  // 内: 9回 裏 
  // 辺: 6回
  // 角: 4回
  
  // 幅が1の時
  // 辺: 3回
  // 角: 2回 裏
  
  // 1x1の時: 裏 
  
  ll ans = 0;
  if(x == 1 && y == 1){
    ans = 1;
  }
  if(x == 1 && y > 1){
    ans = y-2;
  }
  if(x > 1 && y == 1){
    ans = x-2;
  }
  if(x > 1 && y > 1){
    ans = (x-2)*(y-2);
  }
  
  cout << ans << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int p[200010];

int main() {
	int N, K;
	cin >> N >> K;
	for(int i=0; i<N; ++i) cin >> p[i];
	int now=0;
	for(int i=0; i<K; ++i) now += p[i];
	int mx=now;
	for(int i=K; i<N; ++i){
		now += p[i]-p[i-K];
		mx=max(mx, now);
	}
	cout << setprecision(15) << (double) (mx+K)/2.0 << endl;
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  map<long long, long long> mp;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    mp[-a]++;
  }
  for (int i = 0; i < m; i++) {
    long long b, c;
    cin >> b >> c;
    mp[-c] += b;
  }
  long long need = n;
  long long ans = 0;
  for (auto i : mp) {
    long long have = min(need, i.second);
    ans += have * i.first;
    need -= have;
  }
  cout << -ans << endl;
  return 0;
}

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

int main(){
  int n,a[110000];
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i];
  int t=a[1],cnt=1;
  for(int i=0;i<n;i++){
    if(t==2){ cout<<cnt; return 0; }
    t=a[t];
    cnt++;
  }
  cout<<"-1";
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t;*/


	/*string s;
	cin >> s;
	int sum = 0;
	rep(i, s.size()) {
		sum += int(s[i] - '0');
	}
	if (sum % 9 == 0)puts("Yes");
	else puts("No");*/


	int n;
	cin >> n;
	ll a;
	ll ma = 0;
	ll ans = 0;
	rep(i, n) {
		cin >> a;
		if (a < ma)ans += ma - a;
		ma = max(ma, a);
	}
	cout << ans;



	return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		int[] pathnum = new int[4];
		for(int i=0; i<4; i++){
			pathnum[i] = 0;
		}
		
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<6; i++){
			int path = sc.nextInt();
			pathnum[path-1]++;
		}
		
		int num1 = 0;
		int num2 = 0;
		for(int i=0; i<4; i++){
			if(pathnum[i] == 1){
				num1++;
			}
			if(pathnum[i] == 2){
				num2++;
			}
		}
		
		if(num1 == 2 && num2 == 2){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
		
	}
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  int i = 1;
  while(i*i<=n) i++;
  i--;
  cout << i*i;

}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main(){
  int N,K,S;
  cin >> N >> K >> S;
  int count=0;
  int x;
  for(int i=1e9;i>=1;i--){
    if(i!=S){
      x=i;
      break;
    }
  }
  for(int i=0;i<N;i++){
    if(count>=K){
      cout << x;
    }else{
      cout << S;
      count++;
    }
    if(i==N-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main () {
  long long X;
  cin >> X;
  long long mi = 0;
  long long ma = 1e5;
  while (mi != ma) {
    long long mu = (mi + ma) / 2;
    if (mu * mu > X) ma = mu;
    else mi = mu + 1;
  }
  mi --;
  cout << mi * mi << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll x=0,y=0,z=0,k,n,m,h,w,sum=0,ans=0,Max=1,Min=1e9+1;
  string s,t,u;
  bool ok = true;
  cin >> n >> k;
  if(n>=10)
    cout << k << endl;
  else{
    x = (10-n)*100 ;
    cout << k + x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int> 
#define vll vector<ll> 
#define vpll vector<pair<ll ,ll>>
#define vvi vector<vector<ll>>
#define map map<ll ,ll>
#define umap unordered_map<ll , ll>
#define endl "\n"
#define set set<ll> 
#define setC set<char>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fastcout ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcases int tt = 1 ; cin >> tt ; for(int i = 1 ; i <= tt ; ++i)
#define codejam cout << "Case #"<<i <<": "; 
#define FOR(i,a,n) for(int i = a ; i < n ; ++i)
#define FORback(i,a,n) for(int i = n ; i >= a ; --i)

typedef long long int ll;

void solv(){
    ll n;
    cin >> n ;

    vi arr(n+1);
    FOR(i , 1 , n+1){
        cin >> arr[i];
    }

    vi dp(n+1 , 0);
    dp[1] = arr[1];
    dp[2] = abs(arr[2] -arr[1]);
    dp[3] = abs(arr[3] - arr[1]);
    FOR(i , 4 , n+1){
        dp[i]  = min(dp[i-1] + abs(arr[i]-arr[i-1]) , dp[i-2] + abs(arr[i] - arr[i-2]));
    }
    cout << dp[n] << endl;
    // FOR(i , 1 , n+1){
    //     cout << dp[i] << " ";
    // }
}

int main(){
    fast ;    
    // testcases{
        // codejam ;
        solv();
    // } 
}




Measured memory_bytes: 3984
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
int s[200005];
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int k, n;
	cin >> k >> n;
	int d=-1;
	for (int i = 0; i < n;i++) {
		cin >> s[i];
	}
	for (int i = 1; i < n;i++) {
		d = max(d, s[i] - s[i - 1]);
	}
	d = max(d, s[0] - s[n - 1] + k);
	cout << k - d << endl;
	return 0;
}


Measured memory_bytes: 1024
/***from dust i have come, dust i will be***/

#include<bits/stdc++.h>

typedef long long int ll;
typedef unsigned long long int ull;

#define dbg printf("in\n")
#define nl printf("\n");
#define N 210101
#define inf 1e9

#define sf(n) scanf("%d", &n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define sfl(n) scanf("%I64d", &n)
#define sffl(n,m) scanf("%I64d%I64d",&n,&m)

#define pf(n) printf("%d",n)
#define pff(n,m) printf("%d %d",n,m)
#define pffl(n,m) printf("%I64d %I64d",n,m)
#define pfl(n) printf("%I64d",n)
#define pfs(s) printf("%s",s)

#define pb push_back
#define pp pair<int, int>

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);

    int i, j, k;
    int n, m;
    string s, t;

    cin >> s >> t;
    cout << t << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
#include <vector>

using namespace std;

int main() {
	vector<int> m;
	vector<int> f;
	vector<int> r;
	bool isFin = false;

	while(!isFin){
		int min, fin, rin;

		cin >> min >> fin >> rin;

		if (min == -1 && fin == -1 && rin == -1) {
			break;
		}
		m.push_back(min);
		f.push_back(fin);
		r.push_back(rin);
	}

	for (int i = 0;i < m.size();++i) {
		if (m[i] == -1 || f[i] == -1) {
			cout << "F" << endl;
		}
		else if (m[i] + f[i] >= 80) {
			cout << "A" << endl;
		}
		else if (m[i] + f[i] >= 65) {
			cout << "B" << endl;
		}
		else if (m[i] + f[i] >= 50 || r[i] >= 50) {
			cout << "C" << endl;
		}
		else if (m[i] + f[i] >= 30) {
			cout << "D" << endl;
		}
		else {
			cout << "F" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3140
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a*b>=c*d){
		cout<<a*b<<endl;
	}
	else if(a*b<=c*d){
		cout<<c*d<<endl;
	}
	else{
		cout<<a*b<<endl;
	}
}

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

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

    return a;
}

ll lcm(ll a, ll b){
    if(a==0 or b==0) return 0;

    return a/gcd(a,b)*b;
}

int main(void){
    int N; cin >> N;
    vector<ll> T(N);
    for(int i=0; i<N; i++) cin >> T[i];

    ll ans=T[0];
    for(int i=1; i<N; i++) ans=lcm(ans,T[i]);

    cout << ans << endl;
}

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

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    for(;;){
        int n;
        cin >> n;
        if(n == 0)  return 0;
        vector<int> w(n);
        for(int i = 0; i < n; ++i)  cin >> w[i];
        vector<vector<int>> dp(n + 1, vector<int>(n + 1, -1));
        auto MemoRec = [&](auto&& self, int l, int r) -> int {
            if(dp[l][r] != -1)  return dp[l][r];
            if(r - l <= 1)  return dp[l][r] = 0;
            if(r - l == 2){
                if(abs(w[l] - w[r - 1]) <= 1)   return dp[l][r] = 2;
                else    return dp[l][r] = 0;
            }
            if(abs(w[l] - w[r - 1]) <= 1 && self(self, l + 1, r - 1) == r - l - 2){
                return dp[l][r] = r - l;
            }
            int res = 0;
            for(int m = l + 1; m < r; ++m){
                chmax(res, self(self, l, m) + self(self, m, r));
            }
            return dp[l][r] = res;
        };
        cout << MemoRec(MemoRec, 0, n) << '\n';
    }
}


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

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')

    #define I_int long long
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
        return x * f ;
    }
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int

}
using namespace io ;

using namespace std ;

#define N 200010
const ll mod = 1e9 + 7;

int n, c[N], cnt[N];
ll ans = 0, sum[N], inv[N];

ll power(ll a, ll b) { ll ans = 1;
	while(b) {
		if(b & 1) ans = ans * a % mod;
		a = a * a % mod; b >>= 1;
	} return ans;
}

ll f[N];
// f[i]到位置i的方案数 

int main() {
	in(n); int m = 0;
	for(int i = 1; i <= n; ++i) in(c[i]); 
	for(int i = 1; i <= n; ++i) {
		if(c[i] == c[i - 1]) continue;
		c[++m] = c[i];
	} 
	f[0] = 1;
	for(int i = 1; i <= m; ++i) {
		f[i] = f[i - 1];
		f[i] = (f[i] + sum[c[i]]) % mod;
		sum[c[i]] = (sum[c[i]] + f[i - 1]) % mod;
	}
	outn(f[m]);
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main()
{
    ll n, m;
    cin >> n >> m;
    ll x[n];
    ll y[n];
    ll z[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> z[i];
    }
    ll a[n];
    ll b[n];
    ll c[n];
    ll d[n];
    ll e[n];
    ll f[n];
    ll g[n];
    ll h[n];
    for (ll i = 0; i < n; i++)
    {
        a[i] = x[i] + y[i] + z[i];
        b[i] = x[i] + y[i] - z[i];
        c[i] = x[i] - y[i] + z[i];
        d[i] = x[i] - y[i] - z[i];
        e[i] = -x[i] + y[i] + z[i];
        f[i] = -x[i] + y[i] - z[i];
        g[i] = -x[i] - y[i] + z[i];
        h[i] = -x[i] - y[i] - z[i];
    }
    sort(a, a + n, greater<ll>());
    sort(b, b + n, greater<ll>());
    sort(c, c + n, greater<ll>());
    sort(d, d + n, greater<ll>());
    sort(e, e + n, greater<ll>());
    sort(f, f + n, greater<ll>());
    sort(g, g + n, greater<ll>());
    sort(h, h + n, greater<ll>());
    ll ans1 = 0, ans2 = 0, ans3 = 0, ans4 = 0, ans5 = 0, ans6 = 0, ans7 = 0, ans8 = 0;
    for (ll i = 0; i < m; i++)
    {
        ans1 += a[i];
        ans2 += b[i];
        ans3 += c[i];
        ans4 += d[i];
        ans5 += e[i];
        ans6 += f[i];
        ans7 += g[i];
        ans8 += h[i];
    }
    cout << max({ans1, ans2, ans3, ans4, ans5, ans6, ans7, ans8}) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) //これでiやjを定義しなくていいらしい
using namespace std;

int main(){
  string T;
  cin >> T;

  int pos = T.find("?");
  while(pos != string::npos){
    
      T.replace(pos,1,"D");
    

    pos = T.find("?");
  }
  cout << T << endl;

  return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std ;
int n , m , k ;
int jc[ 200005 ] ;
int ans = 0 ;
inline int qpow ( int a , int b ) {
    int res = 1 ;
    while ( b ) {
        if ( b & 1 ) res = 1LL * res * a % MOD ;
        b >>= 1 ;
        a = 1LL * a * a % MOD ;
    }
    return res % MOD ;
}
inline void init () {
    jc[ 0 ] = 1 ;
    for ( int i = 1 ; i <= n ; i ++ ) jc[ i ] = 1LL * jc[ i - 1 ] * i % MOD ;
}
inline int inv ( int a ) { return qpow ( a , MOD - 2 ) ; }
inline int C ( int n , int m ) { return 1LL * jc[ n ] * inv ( 1LL * jc[ m ] * jc[ n - m ] % MOD ) % MOD ; }
signed main () {
    scanf ( "%d%d%d" , &n , &m , &k ) ;
    init () ;
    for ( int i = 0 ; i <= k ; i ++ ) {
        ans = ( ans + 1LL * m * C ( n - 1 , i ) % MOD * qpow ( m - 1 , n - i - 1 ) % MOD ) % MOD ;
    }
    printf ( "%d\n" , ans % MOD ) ;
    return 0 ;
}
/*
题目简述：
给 n 个方格染 m 种颜色，要求最多有 k 组块相连且颜色相同，求方案数对 998244353 取模的结果。
*/


Measured memory_bytes: 4600
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(int argc, char const *argv[]){
    int n;
    cin >> n;

    map<string,int> anagram;

    for (int i=0;i<n;i++) {
        string word;
        cin >> word;
        sort(word.begin(),word.end());
        anagram[word]++;

    }

    long int sum = 0;
    for (auto itr = anagram.begin(); itr != anagram.end(); ++itr) {
        long int value = itr->second;
        sum += value*(value-1)/2;
    }

    cout << sum << endl;

    return 0;
}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#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

const int N = 512;
int dp[N * N];
int done[N * N];

int getInd(int i, int j){
	return i * N + j;
}
int vis[N * N], dist[N * N];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
	cin.tie(0);
	int n; cin >> n;
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
		dp[getInd(i, j)] = min(i, min(j, min(n - 1 - i, n - 1 - j))) + 1;
	}
	ll ans = 0;
	
	for(int i = 0; i < n * n; i++){
		int node; cin >> node; node--;
		node = getInd(node / n, node % n);
		int curr = dp[node] - 1;
		ans += curr;
		deque<int> q;
		q.push_front(node);
		dist[node] = 0; vis[node] = i + 1;
		while(!q.empty()){
			int V = q.front();
			q.pop_front();
			int u = V / N, v = V % N;
			int d = dist[V];
			for(int dir = 0; dir < 4; dir++){
				int _u = u + dx[dir], _v = v + dy[dir];
				if(min(_u, _v) >= 0 && max(_u, _v) < n){
					int V2 = getInd(_u, _v);
					if(vis[V2] != i + 1){
						int w = !done[V2];
						vis[V2] = i + 1;
						dist[V2] = d + w;
						// if(!done[V2])trace(V2, dist[V2]);
						if(curr + d + w < dp[V2]){
							dp[V2] = curr + d + w;
							if(w==0)q.push_front(V2);
							else q.push_back(V2);
						}
					}
				}
			}
		}
		done[node] = 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int k;cin>>k;
    ll res=0;
    rep1(i,k)rep1(j,k)rep1(l,k){
        int buf=gcd(i,j);
        int buf2=gcd(buf,l);
        res+=buf2;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	if( a == b && b == c ){
		cout << "No" <<endl;
	}
	else if( a != b && b != c && c != a ){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

int main() {
	int n, m; cin >> n >> m;
	vector<bool> ac(n);
	vector<int> wa(n);
	int ans1 = 0;
	int ans2 = 0;
	rep(i, 0, m) {
		int p;
		string s;
		cin >> p >> s;
		--p;
		if (s == "AC") {
			if (!ac[p]) {
				++ans1;
				ans2 += wa[p];
				ac[p] = true;
			}
		}
		else {
			if (!ac[p]) ++wa[p];
		}
	}
	cout << ans1 << " " << ans2;
	return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> ga[100010];
int x,y;
int dp[100010];
int dypr(int u){
	if(dp[u]!=-1)
	   return dp[u];
	for(int i=0;i<ga[u].size();i++){
		int v=ga[u][i];
		dp[u]=max(dp[u],dypr(v)+1);
	}
	return dp[u];
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		ga[y].push_back(x);
	}
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)
	   dp[i]=dypr(i);
	cout<<*(max_element(dp+1,dp+n+1))+1;
	return 0;
}


Measured memory_bytes: 10624
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
//Atcoder Educational DP
//M-Candies
/*
    I ♥ CLARICE STARLING

    EXPLAINATION BELOW->
    Dp  
    If you think in terms of Brute force 
    Ans can found by considering all subsequences for which sum of candies given is exactly == K
    and just go on adding up the count..
    But the Time Complexity will be around O(n!)
    
    Observation
    Let F(i,j) be number of ways to to distribute exactly i candies considering people from jth index to n;
    the F(i,j)=(jth distributed 0 candies)*F(i,j+1) + (jth  distributed 1 candy)*F(i-1,j+1) +....(to jth distributed k candies)*F(i-k,j+1)+..
    Hence from this we can clearly observe both properties
    1)Overlapping subproblems
    2)Optimal Substructure
    Time Complexity O(n^2)
*/
//Iterative Solution
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define MOD7 1000000007
const ll INF=(ll)1e18+5;
void solve()
{
   int n,k,i,j;cin>>n>>k;
   int ps[k+2][n],dp[k+1][n],A[n];
   
   fo(i,0,n)cin>>A[i];
   
   fo(j,0,n)ps[0][j]=0;
   foe(i,0,k){dp[i][n-1]=((i<=A[n-1])?1:0);ps[i+1][n-1]=ps[i][n-1]+dp[i][n-1];}
   for(j=n-2;j>=0;j--)
   {
       for(i=0;i<=k;i++)
       {
           int low,high;
           low=max(0,i-A[j]);high=i;
           dp[i][j]=(ps[high+1][j+1]-ps[low][j+1]+MOD7)%MOD7;
           ps[i+1][j]=(ps[i][j]+dp[i][j])%MOD7;
       }
       
       
   }
   cout<<dp[k][0]%MOD7<<"\n";

}
int main()
{
   fastio
   solve();
  return 0;
}



Measured memory_bytes: 78336
import collections

m = [0] * (10**6)
for i in range(1, len(m)):
    m[i] = m[i-1] + i

n = int(input())
s = [''.join(sorted(input())) for i in range(n)]

c = 0
for k, v in collections.Counter(s).items():
    if v <= 1:
        continue
    c += m[v-1]

print(c)


Measured memory_bytes: 66856
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int c = 0;
    for (int i = 1; i <= n; i++) {
        int p;
        cin >> p;
        if (i != p) {
            c++;
        }
    }
    if (c > 2) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    ans = 0
    for i in reversed(range(N+1)):
        if i == N:
            ans += min(B[i-1],A[i])
            B[i-1] = max(0,B[i-1]-A[i])
        elif i == 0:
            ans += min(A[i],B[i])
        else:
            ans += min(B[i],A[i])
            A[i] = max(0,A[i]-B[i])
            ans += min(B[i-1],A[i])
            B[i-1] = max(0,B[i-1]-A[i])
        ##print(*A)
        ##print(*B)


    print(ans)


if __name__=="__main__":
    main()

Measured memory_bytes: 18476
object Main {
  def main(args: Array[String]): Unit = {
    val input = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    val sum   = input(0) + input(1)

    if(sum%2 == 0) println(sum/2)
    else           println("IMPOSSIBLE")

  }
}

Measured memory_bytes: 25384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <deque>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

    
struct Node{
    ll cost;
    int parent;  // index of parent node
    int index;   // index in node list
    vector< int > connect;
    vector< int > edge_index; //　エッジが元々何番目のものか
};

ll connect_max = 0;
int reach[100001];
vector<int> edge_number(100001, -1);

void dfs(vector<Node> &node, int index, int use_number){

    if(reach[index] == 0){
        reach[index] = 1;
        connect_max = max( (ll)node[index].connect.size(), connect_max );
    }
    else return ;
    
    vector<bool> used( 100001, false );
    if(use_number != -1) used[use_number] = true;
    int min = 0;

    for(int i = 0; i < node[index].connect.size(); i++){
        int next_index = node[index].connect[i];
        if(reach[next_index] == 1 ) continue;
        if( edge_number[ node[index].edge_index[i] ] == -1 ){
            while( used[min] ){
                min ++;
            }
            edge_number[ node[index].edge_index[i] ] = min ;
            used[min] = true;
        }
        dfs(node, next_index, min);
    }

}
    
int main(){
    
    int N;
    cin >> N;
    
    vector<Node> node(N);
    for(int i = 0; i < N; i++){
        node[i].cost = 0;
        node[i].parent = -1;
        node[i].index = i;
    }
    for(int i = 0; i < N-1; i++){
        ll a, b;
        cin >> a >> b ;
        a --;
        b --;
        node[a].connect.push_back(b);
        node[b].connect.push_back(a);
        node[a].edge_index.push_back(i);
        node[b].edge_index.push_back(i);
    }
    
    dfs(node, 0, -1);
    cout << connect_max << endl;
    for(int i = 0; i < N-1; i++){
        cout << edge_number[i] + 1 << endl;
    } 
}

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

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

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

ll gcd(ll a, ll b) {
	while (b != 0) {
		a = a % b;
		swap(a, b);
	}
	return a;
}

int main()
{
	int n;
	ll tmp  =1,ans;
	cin >> n;

	for (int i = 0; i < n; i++) {
		ll t;
		cin >> t;

		ans = tmp / gcd(tmp, t) * t;
		tmp = ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

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

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}

int main() {
    int n; cin >> n;
    vector<P> red, blue;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        red.emplace_back(x, y);
    }

    rep(i, n) {
        int x, y;
        cin >> x >> y;
        blue.emplace_back(x, y);
    }

    sort(all(red));
    sort(all(blue), compare_by_second);

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = n - 1; j >= 0; --j) {
            if (blue[i].first > red[j].first && blue[i].second > red[j].second) {
                cnt++;
                red[j].second  = 201;
                break;
            }
        }
    }
    cout << cnt << endl;
}

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

using ll=long long;
#define int ll

#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>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	vvc<int> a(n+2,vi(n+2));
	rep(i,n)rep(j,n-1)
		cin>>a[i+1][j+(j>=i)+1];
	
	n++;
	const int inf=LLONG_MAX/3;
	vvc<int> dp(n,vi(n,inf));
	dp[0][0]=0;
	
	rng(i,1,n){
		vi x(i),y(i);
		rep(j,i){
			rng(k,i+1,n+1)
				x[j]+=a[k][j];
			if(j)x[j]+=x[j-1];
		}
		per(j,i){
			rng(k,j+1,i+1)
				y[j]+=a[j+1][k];
			if(j+1<i-1)
				y[j]+=y[j+1];
		}
		rep(j,i)
			rep(k,j+1)
				chmin(dp[i][j],dp[j][k]+x[j]-x[k]+y[j]);
	}
	
	cout<<*min_element(all(dp[n-1]))<<endl;
}


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

		System.out.print(a * b + " ");
		System.out.println(a * 2 + b * 2);
	}
}

Measured memory_bytes: 25824
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
//#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}
template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

signed main() {
  int h,w,d; cin >> h >> w >> d;
  vector<pair<int,int>> p(h*w+1);
  rep(i,h)rep(j,w) {
    int a; cin >> a;
    p[a] = {i,j};
  }


  auto power = [&](int from, int to) {
    return abs(p[from].first - p[to].first) + abs(p[from].second - p[to].second);
  };

  vector<int> dist(h*w+1);
  rep(i, h*w+1-d) dist[i+d] = dist[i] + power(i,i+d);

  int q; cin >> q;
  while(q--) {
    int l,r; cin >> l >> r;
    cout << dist[r] - (l>=d ? dist[l] : 0) << endl;
  }
}


Measured memory_bytes: 4316
s=input()
n=len(s)
s1=s[:(n-1)//2]
s2=s[n+3//2:]
def ispalindrome(str):
    if str==str[::-1]:
        s1=s[:(n-1)//2]
        if s1==s1[::-1]:
            s2=s[n+3//2:]
            if s2==s2[::-1]:
                return 'Yes'
            return 'No'
        return 'No'
    else:
        return 'No'
print(ispalindrome(s))

Measured memory_bytes: 9032
#![allow(unused_imports)]
#![allow(dead_code)]

use std::io::{ self, BufRead };
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;

fn sum(mut x: i64) -> i64 {
    let mut y = 0;
    while x > 0 {
        y += x % 10;
        x /= 10;
    }
    y
}

fn main() {
    let stdin = io::stdin();
    let mut cin = stdin.lock();

    let mut it = cin.lines()
    .map(|s| s.unwrap().parse::<i64>().unwrap());
    let n = it.next().unwrap();

    let mut d = it.take(n as usize).collect::<HashSet<_>>();

    let ans = d.len();
    println!("{}", ans);
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    cout << 0 << '\n';
    string s;
    cin >> s;
    if(s == "Vacant") return 0;
    string c = s;
    int l = 0, r = n - 1;
    while(s != "Vacant"){
        int mid = (l+r+1)/2;
        cout << mid << '\n';
        cin >> s;
        if(mid%2 == 0 && s == c) l = mid;
        if(mid%2 == 1 && s != c) l = mid;
        if(mid%2 == 0 && s != c) r = mid;
        if(mid%2 == 1 && s == c) r = mid;
    }
}

Measured memory_bytes: 852
x=input()
round = len(x)

ans = 0

for i in range(round):#10101...
    if i % 2 == 0:
        if x[i] == '0':
            ans = ans+1
            
    else:
        if x[i] =='1':
            
            ans = ans+1

if ans>round/2:
    print(round-ans)
else:
    print(ans)

Measured memory_bytes: 3188
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Deque<Integer> dc = new ArrayDeque<Integer>();
        
		while(scan.hasNext()) {
			String s = scan.next();
			if("+".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x+y);
			}
			else if("-".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(y-x);
			}
			else if("*".equals(s)) {
				int x = dc.pop();
				int y = dc.pop();
				dc.push(x*y);
			}
			else {
				dc.push(Integer.valueOf(s));
			}
		}
		System.out.println(dc.pop());
		scan.close();
	}
}


Measured memory_bytes: 26116
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define F first 
#define S second 

using namespace std;

void test(){
	ll n;
	cin>>n;
	string s = to_string(n);
	bool flag = false;
	f(i,3){
		if(s[i]-'0'==7)flag=true;
	}
	if(flag)cout<<"Yes\n";
	else cout<<"No\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

Measured memory_bytes: 3700
from enum import Enum
import sys
import math

# 0:上側 1:南 2:東 3:西 4:北 5:下側

class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.pattern = 'NNNNENNNENNNWNNNWNNNENNN'
        self.ret = 'No'
        
    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
        
    def roll(self, loc):
        for i in range(6):
            self.work[i] = self.number[i]
        
        if loc == 'E':
            self.setNumber(self.work[3], self.work[1], self.work[0], self.work[5], self.work[4], self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1], self.work[5], self.work[2], self.work[3], self.work[0], self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4], self.work[0], self.work[2], self.work[3], self.work[5], self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2], self.work[1], self.work[5], self.work[0], self.work[4], self.work[3])

    def match(self, Std):
        for i in range(6):
            self.work[i] = self.number[i]
        
        for i in range(len(self.pattern)):
            self.roll(self.pattern[i])
            if self.number == Std:
                self.ret = 'Yes'
                break
                
    def get_ret(self):
        return self.ret

tableStd = list(map(int, input().split()))
# dice1.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

dice = Dice()
table = list(map(int, input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

dice.match(tableStd)
print("%s"%(dice.get_ret()))



Measured memory_bytes: 6388
import java.util.*;
import java.io.*;

class Main
{
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            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;
        }
    }

	public static void main (String[] args)
	{
		FastReader reader = new FastReader();
		int n = reader.nextInt();
		String input = reader.nextLine();

		int[] east = new int[n+2];
		int[] west = new int[n+2];

		for (int i=1; i<=n; i++)
		{
			east[i] = east[i-1];
			west[i] = west[i-1];

			if (input.charAt(i-1) == 'E')
				east[i]++;
			else
				west[i]++;
		}

		east[n+1] = east[n];
		west[n+1] = west[n];

		int ans = Integer.MAX_VALUE;
		for (int i=1; i<=n; i++)
			ans = Math.min (ans, west[i-1] + east[n+1] - east[i]);

		System.out.println (ans);

	}
}


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

const int N = 200010;
const int MAX = 1 << 18;

int grow[N];
int a[N];
bool vis[N];
int seg[MAX << 1];
int seg1[MAX << 1];

int query(int l, int r){
    int ret = 0;
    for (l += MAX, r += MAX + 1; l < r; l >>= 1, r >>= 1){
        if (l & 1) ret = std::max(ret, seg[l ++]);
        if (r & 1) ret = std::max(ret, seg[-- r]);
    }
    return ret;
}

int query1(int l, int r){
    int ret = INT_MAX;
    for (l += MAX, r += MAX + 1; l < r; l >>= 1, r >>= 1){
        if (l & 1) ret = std::min(ret, seg1[l ++]);
        if (r & 1) ret = std::min(ret, seg1[-- r]);
    }
    return ret;
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++ i){
        scanf("%d", &a[i]);
        seg[i + MAX] = a[i];
        seg1[i + MAX] = a[i];
    }
    for (int i = MAX - 1; i; -- i){
        seg[i] = std::max(seg[i << 1], seg[i << 1 | 1]);
        seg1[i] = std::min(seg1[i << 1], seg1[i << 1 | 1]);
    }
    for (int i = n; i >= 1; -- i){
        if (i < n && a[i] < a[i + 1]){
            grow[i] = grow[i + 1] + 1;
        }
        else{
            grow[i] = 1;
        }
    }
    int ans = 0;
    for (int i = 1; i + k - 1 <= n; ++ i){
        if (grow[i] >= k){
            vis[i] = true;
            ans = 1;
        }
    }
    for (int i = 1; i + k - 1 <= n; ++ i){
        if (vis[i]){
            continue;
        }
        if (i + k - 1 == n || vis[i + 1]){
            ++ ans;
        }
        else{
            int p = query(i + 1, i + k - 1);
            int p1 = query1(i + 1, i + k - 1);
            if (a[i] < p1 && p < a[i + k]){
            }
            else{
                ++ ans;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 5888
#include <iostream>
using namespace std;
int main ()
{
    double ax1, ax2, ay1, ay2, bx1, bx2, by1, by2;
    while (cin >> ax1 >> ay1 >> ax2 >> ay2 >> bx1 >> by1 >> bx2 >> by2)
        if (ax1 <= bx2 && by1 <= ay2 && bx1 <= ax2 && ay1 <= by2) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <map>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  map<char,bool> mp;
  for(int i=1;i<n-1;i++){
    int cnt = 0;
    for(int j=0;j<i;j++){
      mp.insert(make_pair(s[j],false));
    }

    for(int k=i;k<n;k++){
      auto itr = mp.find(s[k]);
      if(itr != mp.end()){
        if(itr->second == false){
          itr->second = true;
          cnt++;
        }
      }
    }

    ans = max(ans,cnt);
    mp.clear();
  }

  cout << ans << endl;
}


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

int main(){
  long long n;
  cin >> n;
  long long a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  unsigned long long ans=1;
  
  for(int j=0; j<n; j++){
    if(a[j]<=1000000000000000000/ans){
    ans*=a[j];
  } else {
    cout << -1 << endl;
    return 0;
  }
  }
cout << ans << endl;  
}


Measured memory_bytes: 4320