akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

struct dice{
	int top;
	int front;
	int left;
	int right;
	int back;
	int bottom;
};

int main(){
	//????????????????????¢?????°????????\?????????
	struct dice X;
	cin >> X.top;
	cin >> X.front;
	cin >> X.right;
	cin >> X.left;
	cin >> X.back;
	cin >> X.bottom;
	//?????¢??????????????\?????????
	string Rotation;
	cin >> Rotation;
	//????????????????????¢?????????
	for(int i = 0; i < Rotation.size(); i++){
		if(Rotation[i] == 'N'){
			struct dice Y;
			Y.top    = X.front;
			Y.front  = X.bottom;
			Y.left   = X.left;
			Y.right  = X.right;
			Y.back   = X.top;
			Y.bottom = X.back;
			X = Y;
		}
		if(Rotation[i] == 'E'){
			struct dice Y;
			Y.top    = X.left;
			Y.front  = X.front;
			Y.left   = X.bottom;
			Y.right  = X.top;
			Y.back   = X.back;
			Y.bottom = X.right;
			X = Y;
		}
		if(Rotation[i] == 'S'){
			for(int j = 0; j < 3; j++){
				struct dice Y;
				Y.top    = X.front;
				Y.front  = X.bottom;
				Y.left   = X.left;
				Y.right  = X.right;
				Y.back   = X.top;
				Y.bottom = X.back;
				X = Y;
			}
		}
		if(Rotation[i] == 'W'){
			for(int j = 0; j < 3; j++){
				struct dice Y;
				Y.top    = X.left;
				Y.front  = X.front;
				Y.left   = X.bottom;
				Y.right  = X.top;
				Y.back   = X.back;
				Y.bottom = X.right;
				X = Y;
			}
		}
	}
	//?????¢??????????????¨?????????
	cout << X.top << endl;
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;


//ユークリッドの互除法
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}


int main(){
    int K; cin>>K;
    ll ans = 0;
    for(int a = 1; a<=K ; a++){
        for(int b=1;b<=K;b++){
            for(int c=1;c<=K;c++){
                ans += gcd(a,gcd(b,c));
            }
        }
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long ll;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

void solve_case() {
  int n, r;
  cin >> n >> r;
  if(n >= 10){
    cout << r;
  }
  else{
    cout << r + 100 * (10 - n) ;
  }
}

/**************/


int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int tt = 1;
  // cin >> tt;
  while (tt--) {
    solve_case();
  } 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long int a , b , cnt;
    cin >> a >> b;
    a = __gcd(a , b);
    vector<long long int> v;
    if(a % 2 == 0){
        v.push_back(2LL);
        while(a % 2 == 0){
            a /= 2;
        }
    }
    for(long long int i = 3 ; i * i <= a ; i += 2){
        if(a % i == 0){
            v.push_back(i);
            while(a % i == 0){
                a /= i;
            }
        }
    }
    if(a > 1)
        v.push_back(a);
    cnt = v.size() ;
    cnt  = cnt + 1;
    cout << cnt ;
    return 0;
}

Measured memory_bytes: 256
def solve():
    from bisect import bisect_left
    import sys
    n, *s = map(int, sys.stdin.read().split())
    t = sorted(s)
    for ss in s:
        x = bisect_left(t, ss)
        if x == n - 1:
            print(t[-2])
        else:
            print(t[-1])



solve()

Measured memory_bytes: 32336
#include <iostream>
using namespace std;
static const int mod = 2019;

int main() {
  long long l, r;
  cin >> l >> r;
  long long cnt = 0;
  long long ans = 2018;
  r = min(r, l + mod * 2);
  for (long long i = l; i <= r-1; i++) {
    for (long long j = l+1; j <= r; j++) {
      long long x = i*j%mod;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() {	

	ll N,S=0,tmp;
	cin >> N;
	tmp = N;
	for(ll i = 0; i < 10; i++) {
		S += tmp % 10;
		tmp /= 10;
		if(N < 10) {
          	S += tmp;
			break;
		}
	}

	if(N % S) {
		cout << "No" << endl;
	}else {
		cout << "Yes" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int n,p,c[100010];
char a[100010];
int change(char k)
{
	if(k=='b') return 1;
	else if(k=='d') return -1;
	else if(k=='p') return 2;
	else return -2;
}
int main()
{
	scanf("%s",a);
	n=strlen(a)-1;
	for(int i=0;i<=n/2+1;i++)
	{
		int x=change(a[i]),y=change(a[n-i]);
		if(x+y!=0) {p=1;break;}
	}
	if(!p) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int h, w, g;
int dp[101][10];

int main(){
	cin >> h >> w >> g;
	
	dp[0][0] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			for(int k = 0; k < (1 << w-1); k++){
				bool b = 0;
				for(int jj = 1; jj < w; jj++){
					if((k >> jj) & (k >> (jj-1))) b = 1;
				}
				if(b) continue;
				
				if(j!=w-1 && (k >> j) & 1){
					dp[i+1][j+1] += dp[i][j];
					dp[i+1][j+1] %= INF;
				}
				else if(j!=0 && (k >> j-1) & 1){
					dp[i+1][j-1] += dp[i][j];
					dp[i+1][j-1] %= INF;
				}
				else{
					dp[i+1][j] += dp[i][j];
					dp[i+1][j] %= INF;
				}
			}
		}
	}
	cout << dp[h][g-1] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define	MAX 44

int fibonacci(int);

int F[MAX];

int main()
{
  int n,i;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    F[i] = 0;
  }

  printf("%d\n",fibonacci(n));
  return 0;
}

int fibonacci(int n){
  if(n == 0||n == 1) return F[n] = 1;
  if(F[n] != 0)	return F[n];
  return F[n] = fibonacci(n-2)	+ fibonacci(n-1);
}

Measured memory_bytes: 596
program kadai
implicit none
integer  ::  size,ans
integer  ::  n
character(100001)  :: num

read(*,*) n

if (n<10) then
    write(*,*) n
    stop
end if

if (n<100) then
    write(*,*) 9
    stop
end if

if (n<1000) then
    write(*,*) 9+n-99
    stop
end if

if (n<10000) then
    write(*,*) 909
    stop
end if

if (n<100000) then
    write(*,*) 9+900+n-9999
    stop
end if

if (n==100000) then
    write(*,*) 90909
    stop
end if


stop

end program kadai

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long sum[200020] = { 0 };
vector<pair<long long,long long>> vec;
long long here[200020];
int main() {
	long long n, d, a, x, h;
	cin >> n >> d >> a;
	for (int i = 0; i < n; i++) {
		cin >> x >> h;
		vec.emplace_back(make_pair(x, h));
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < n; i++) {
		pair<long long, long long> p = make_pair(vec[i].first + 2 * d, 1000000007);
		auto itr = upper_bound(vec.begin(), vec.end(), p);
		here[i] = itr - vec.begin();
	}
	long long num = 0;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		num += sum[i];
		if (vec[i].second - num > 0) {
			long long co = ((vec[i].second - num) + a - 1) / a;
			ans += co;
			num += co * a;
			sum[here[i]] -= co * a;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;
int rec(int n, VI &a, VI &b) {
  if (n < 6) return n;
  int i = 0;
  while (a[i] > n) i++;
  int j = 0;
  while (b[j] > n) j++;
  return min(rec(n - a[i], a, b), rec(n - b[j], a, b)) + 1;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  VI a, b;
  int t = 1;
  while (t <= 1e5) {
    a.push_back(t);
    t *= 6;
  }
  t = 1;
  while (t <= 1e5) {
    b.push_back(t);
    t *= 9;
  }
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  // int res = 0;
  // t = 0;
  // while (n) {
  //   if (a[t] <= n) {
  //     n -= a[t];
  //     res++;
  //   } else {
  //     t++;
  //   }
  // }
  cout << rec(n, a, b) << '\n';
  return 0;
}

Measured memory_bytes: 256
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N int
  NextInt(&N)
  A := make([]int, N + 1)
  for x := 1; x < 100; x++ {
    for y := 1; y < 100; y++ {
      for z := 1; z < 100; z++ {
        c := x*x + y*y + z*z + x*y + y*z + z*x
        if c <= N { A[c]++ }
      }
    }
  }
  for _, a := range A[1:] { Write(a) }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  Write(B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 1968
#include <bits/stdc++.h>
const int INF =1e9+5;
using  namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,k;cin>>n>>k;
    vector<int> c(n);
    for(int& x:c)
        cin>>x;
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;++j){
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(c[i]-c[j]));
        }
    }    
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int main(void)
{
  int n,i;
  long  s; 
  scanf("%d",&n);
  i=n;
  s=1;
  while(i>0){
    s*=i--;
  }
  printf("%lu\n",s);
  return 0;
}

Measured memory_bytes: 596
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 100000001
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int dp[120][1050];
bool my_compare(pair<ll, string> a, pair<ll , string> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         //return a.first < b.first; // 昇順
        return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    int maxi=0,f=0,sum=0,mini=INF;
    string str,str1,str2;
ll m;
    ll n;
    int a,b,d,c;
    int e,weight;
    cin>>m;
    n=m;
    ll saijoui;
    while(m){
        saijoui=m;
        if(m%10!=9) f=1;
        m/=10;
        sum++;
    }
    sum--;
    if(f==0){
        cout<<(sum+1)*9<<endl;
    }else{
        f=0;
        ll u=sum;
        //sum++;
        while(sum){
            if(n%10!=9) f=1;
            sum--;
            n=n/10;
        }
        if(f==1){
        cout<<9*u+saijoui-1<<endl;
        }else{
            cout<<9*u+saijoui<<endl;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ )
    for ( int j = 1; j <= n; j++ ) {
      if ( X[i] == Y[j] )
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


Measured memory_bytes: 7060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t,u;
	int sc,tc;
	cin>>s>>t>>sc>>tc>>u;
	if(u==s)
		sc--;
	else if(u==t)
		tc--;
	cout<<sc<<" "<<tc<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn=100000;

int main(){
    
    int w,h,x,y;
    cin >>w>>h>>x>>y;
    cout << float(h)*float(w)/float(2)<<' ';
    
        if(x+x==w&&y+y==h){
            cout << 1<<endl;
        }else{
            cout << 0<<endl;
        }
    
    return 0;
}


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

void solve(string& s1, string& s2)
{
  vector<vector<int>> dp(s1.length() + 1,
      vector<int>(s2.length() + 1, 0));
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());

  for (size_t i = 1; i <= s1.length(); i++)
  {
    for (size_t j = 1; j <= s2.length(); j++)
    {
      if (s1[i - 1] == s2[j - 1])
        dp[i][j] = dp[i - 1][j - 1] + 1;
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }

  // Print the vector.
  size_t i = s1.length(), j = s2.length();
  string longestSubSeq = "";
  while(i > 0 && j > 0)
  {
    if (s1[i - 1] == s2[j - 1])
    {
      longestSubSeq += s1[i - 1];
      i--;
      j--;
    }
    else if (dp[i][j - 1] <= dp[i - 1][j])
      i--;
    else
      j--;
  }
  
  cout << longestSubSeq << endl;
}

void GetString(string& s)
{
  while (s.length() == 0)
    getline(cin, s);
  return;
}

int main()
{
  string s1, s2;
  GetString(s1);
  GetString(s2);
  solve(s1, s2);
  return 0;
}

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

void solve(long long X, long long t){
    if (t > X) cout << 0 << '\n';
    else cout << X - t << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long X;
    scanf("%lld",&X);
    long long t;
    scanf("%lld",&t);
    solve(X, t);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        TreeMap<Long,Integer> map = new TreeMap<Long,Integer>(Comparator.reverseOrder());
        int n = sc.nextInt();
        long[] al = new long[n+2];
        long[] ans = new long[n+1]; 
        long max = 0;
        for(int i = 1; i <= n+1; i++){
            if(i != n+1) al[i] = sc.nextLong();
            max += Math.abs(al[i]-al[i-1]);
        }
        for(int i = 1; i <= n; i++){
            System.out.println(max - Math.abs(al[i] - al[i-1]) - Math.abs(al[i+1] - al[i]) + Math.abs(al[i+1] - al[i-1]));
        }
    }
}

Measured memory_bytes: 71664
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main(void){
	string str;
	map<string, int> num;
	num.insert( map<string,int>::value_type("I",1));
	num.insert( map<string,int>::value_type("II",2));
	num.insert( map<string,int>::value_type("III",3));
	num.insert( map<string,int>::value_type("IV",4));
	num.insert( map<string,int>::value_type("V",5));
	num.insert( map<string,int>::value_type("VI",6));
	num.insert( map<string,int>::value_type("VII",7));
	num.insert( map<string,int>::value_type("VIII",8));
	num.insert( map<string,int>::value_type("IX",9));
	num.insert( map<string,int>::value_type("X",10));
	num.insert( map<string,int>::value_type("XI",11));
	num.insert( map<string,int>::value_type("XII",12));
	num.insert( map<string,int>::value_type("XIII",13));
	num.insert( map<string,int>::value_type("XIV",14));
	num.insert( map<string,int>::value_type("XV",15));
	num.insert( map<string,int>::value_type("XVI",16));
	num.insert( map<string,int>::value_type("XVII",17));
	num.insert( map<string,int>::value_type("XVIII",18));
	num.insert( map<string,int>::value_type("XIX",19));
	num.insert( map<string,int>::value_type("XX",20));
	num.insert( map<string,int>::value_type("XXX",30));
	num.insert( map<string,int>::value_type("XL",40));
	num.insert( map<string,int>::value_type("L",50));
	num.insert( map<string,int>::value_type("LX",60));
	num.insert( map<string,int>::value_type("LXX",70));
	num.insert( map<string,int>::value_type("LXXX",80));
	num.insert( map<string,int>::value_type("XC",90));
	num.insert( map<string,int>::value_type("C",100));
	num.insert( map<string,int>::value_type("CD",400));
	num.insert( map<string,int>::value_type("D",500));
	num.insert( map<string,int>::value_type("CM",900));
	num.insert( map<string,int>::value_type("M",1000));
	while(cin >> str){
		int ans=0;
		string s;
		for(int i=0;i<str.size();i++){
			string ss=s;
			s+=str[i];
			if(num[s]==0){
				if(num[ss]>0){
					ans+=num[ss];
					s=str[i];
				}
			}
			if(i==str.size()-1){
				ans+=num[s];
			}
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    String t = scanner.next();
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    String u = scanner.next();
    if (u.equals(s)) a--;
    else b--;
    System.out.printf("%d %d\n", a, b);
  }
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------
int main(void) {
  int s;
  cin >> s;
  cout << s/3600 << ':' << (s%3600)/60 << ':' << (s%60) << "\n";
}



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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)

ll X[200020];
ll Y[200020];
ll N;

int main(void)
{
    ll m1, m2;

    cin >> N;
    REP(i, N) { cin >> X[i]; Y[i] = X[i]; }
    sort(X,X+N);
    m1 = X[N/2-1];
    REP(i, N) {
        if(Y[i] > m1) {
            cout << X[N/2-1];
        } else {
            cout << X[N/2];
        }
        cout << endl;
    }
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll X = 1000;

ll h(vec<int> C){
    ll res = 0,r = 1;
    for(int i=0;i<4;i++){
        res += C[i]*r;
        r *= X;
    }
    return res;
}

void set_hash(vec<int> C,unordered_map<ll,ll>& mp,int d){
    for(int i=0;i<4;i++){
        ll c = h(C);
        mp[c] += d;
        int a = C[0];
        C.erase(C.begin());
        C.push_back(a);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    unordered_map<ll,ll> mp;
    vvec<int> C(N,vec<int>(4));
    for(int i=0;i<N;i++){
        for(int k=0;k<4;k++) cin >> C[i][k];
        set_hash(C[i],mp,1);
    }
    ll ans = 0;
    for(int i=0;i<N;i++){
        ll c0 = h(C[i]);
        ll now = 1;
        set_hash(C[i],mp,-1);
        for(int j=i+1;j<N;j++) for(int b=0;b<4;b++){
            ll c1 = h(C[j]);
            ll val = now;
            set_hash(C[j],mp,-1);
            for(int l=0;l<4;l++){
                vec<int> D = {C[j][(4-l)%4],C[j][(4-l+3)%4],C[i][(l+1)%4],C[i][l]};
                ll v = h(D);
                val *= mp[v];
                set_hash(D,mp,-1);
            }
            for(int l=0;l<4;l++){
                vec<int> D = {C[j][(4-l)%4],C[j][(4-l+3)%4],C[i][(l+1)%4],C[i][l]};
                set_hash(D,mp,1);
            }
            set_hash(C[j],mp,1);
            int x = C[j][0];
            C[j].erase(C[j].begin());
            C[j].push_back(x);
            ans += val;
        }
        set_hash(C[i],mp,1);
    }
    cout << ans/3 << "\n";
}

Measured memory_bytes: 242424
def main():
    n = int(input())
    L = list(map(int, input().split()))
    ans = 0
    L.sort()
    for i, li in enumerate(L[:-2]):
        for j, lj in enumerate(L[i+1:-1], i+1):
            if li == lj:
                continue
            for k, lk in enumerate(L[j+1:], j+1):
                if lk == lj:
                    continue
                if li + lj > lk:
                    ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n,ans=0;
    cin>>n;
    vector<int> l(n,0);
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]){
                    int maxv=max(l[i],max(l[j],l[k]));
                    if(l[i]+l[j]+l[k]-maxv*2>0){
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

ll solve(string a, string N){
    int n = N.size();
    int fr = a[0] - '0';
    int ba = a[a.size()-1] - '0';
    ll dp[6][2][2];
    dp[0][0][0] = 1;
    rep(i,n)rep(smaller,2)rep(flag,2){
        int d = N[i] - '0';
        for(int j = 0; j <= (smaller ? 9:d); j++){
            dp[i+1][smaller || j < d][flag] += dp[i][smaller][flag];
        }
    }
    return dp[n][0][1] + dp[n][1][1];
}

int main(){
    int N;
    cin >> N;
    vector<vector<int>> c(10,vector<int>(10,0));
    for(int i = 1; i <= N; i++){
        int now = i;
        int d = 1;
        while(now >= 10){
            now /= 10;
            d*=10;
        }
        c[i/d][i%10]++;
    }
    ll ans = 0;
    rep(i,10)rep(j,10) ans += c[i][j] * c[j][i];
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    ll a, b, x;
    cin >> a >> b >> x;
    ll c = a/x;
    ll d = b/x;
    ll ans = d-c;
    if (a % x == 0 || a == 0) ans = d-c+1;
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200 + 50;
const int INF = 1000000000;
int n, m, r;
int R[maxn];
int g[maxn][maxn];
vector<int> G[maxn];
struct edge{
    int u, v;
    int cost;
    bool friend operator < (edge a, edge b){
        return a.cost < b.cost;
    }
}e[1000];
int p[maxn];
int find(int  x){return p[x] == x? x : p[x] = find(p[x]);}
int main(){
 //   freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> r;
    for(int i = 0; i < r; i++)
        cin >> R[i];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++) g[i][j] = INF;
            g[i][i] = 0;
    }
    for(int i = 0; i < m; i++){
        int u, v, c;
        cin >> u >> v >> c;
        g[u][v] = g[v][u] = c;
    }
    for(int k = 1; k <= n; k++)
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                g[i][j] = min(g[i][j] ,g[i][k] + g[k][j]);
    sort(R, R+r);
    int ans = INF;
    do{
        int sum = 0;
        for(int i = 1; i < r; i++) sum += g[R[i-1]][R[i]];
        ans = min(ans, sum);
    }while(next_permutation(R,R+r));
    cout << ans << endl;
    return 0;
}

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

public class Main {
    static Set<Integer> primes = new HashSet<>();
    static{
        for(int i=2; i<=1000; i++){
            if(isprime(i))
                primes.add(i);
        }
    }
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
       String s = sc.next();
       for(int i=0; i<s.length();i++){
           if(s.charAt(i)=='7')
           {
               out.println("Yes");
               return;
           }
       }
       out.println("No");
    }
    private static boolean isprime(int x){
        if(x==2)
            return true;
        int sqs = (int)Math.sqrt(x);
        for(int i=2; i<=sqs; i++){
            if(x%i==0)
                return false;
        }
        return true;
    }

    private static int gcd (int a, int b) {
        if (b == 0)
            return a;
        else
            return gcd (b, a % b);
    }
    private static long helper(long x){
        long ans = (x * (x-1))/2;
        return ans;
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair {
    int x;
    long y;

    Pair(int x, long y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        Pair pair = (Pair) o;
        return this.x < pair.x && this.y==pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

Measured memory_bytes: 33092
from fractions import gcd
A, B, C, D = map(int, input().split())
BdivC, BdivD = B // C, B // D
AdivC, AdivD = (A - 1) // C, (A - 1) // D
GCD = gcd(C, D)
BdivCD, AdivCD = B // ((C * D) // GCD), (A - 1) // ((C * D) // GCD)
N1 = BdivC + BdivD - BdivCD
N2 = AdivC + AdivD - AdivCD
ans = (B - (A - 1)) - (N1 - N2)
print(ans)


Measured memory_bytes: 5716
N, M = map(int, input().split())
num = [x for x in str(10**(N - 1))]
confirmed_or_not = [False] * N

for _ in range(M):
    s, c = map(int, input().split())
    
    if s == 1 and c == 0:
        if N > 1:
            num = ['-1']
            break
        
    if confirmed_or_not[s-1] and num[s-1] != str(c):
        num = ['-1']
        break
        
    num[s - 1] = str(c)
    confirmed_or_not[s - 1] = True


if N == 1 and not confirmed_or_not[0]:
    num = ['0']

print(*num, sep='')

Measured memory_bytes: 3064
//    >File Name: 057B.cpp
//    > Author: Webwei

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

struct node{
	int a;
	int b;
	int c;
};
node v[100010],w[100010];

int cc[100010];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>v[i].a>>v[i].b;
	}
	for(int i=0;i<m;i++){
		cin>>w[i].a>>w[i].b;
	}
	int z=0,e=0;
	for(int i=0;i<n;i++){
		int mx=1e9;
		for(int j=0;j<m;j++){
			v[i].c=abs(v[i].a-w[j].a)+abs(v[i].b-w[j].b);
			if(v[i].c<mx){
				mx=v[i].c;
				e=j+1;
			}
		}
		cc[z]=e;
		z++;
	}
	for(int i=0;i<z;i++){
		cout<<cc[i]<<endl;
	}
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n,m;
  cin >> n >> m;
  vector<int> v(n+10);
  int aacc = 0;
  int wwaa = 0;
  for(int i = 0;i < m;i++){
  int j;
  cin >> j;
  string n;
  cin >> n;
  if(n == "AC"){
    if(v.at(j) >= 0){ wwaa += v.at(j);
                    aacc++;
                   v.at(j) -= 1000000;}
  }
    else{v.at(j)++;}
  }
  cout << aacc << ' ' << wwaa << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const bool DEBUG = 0;
const int MAXN = 200005;

int n;
ii a[MAXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n;
	forn(i,0,n) cin>>a[i].F>>a[i].S;
	
	sort(a,a+n);
	
	ll ans=0;
	
	priority_queue<ll,vector<ll>> mx;
	priority_queue<ll,vector<ll>> mn;
	forn(i,0,n)
	{
		if(i)
		{
			ans=max(ans, a[i].F+a[i].S+mn.top());
			ans=max(ans, a[i].F-a[i].S+mx.top());
		}
		
		mx.push(a[i].S-a[i].F);
		mn.push(-a[i].S-a[i].F);
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 9772
var key = {
    a: 1,
    b: 1,
    c: 1,
    d: 1,
    e: 1,
    f: 1,
    g: 1,
    h: -1,
    i: -1,
    j: -1,
    k: -1,
    l: -1,
    m: -1,
    n: -1,
    o: -1,
    p: -1,
    q: 1,
    r: 1,
    s: 1,
    t: 1,
    u: -1,
    v: 1,
    w: 1,
    x: 1,
    y: -1,
    z: 1
};


function Main(input){
    input = input.split("\n");
    k = 0;
    while(1){
        if(input[k] == "#")
            break;
        var pre = key[input[k][0]],ans = 0;
        for(var i = 1;i < input[k].length;i++){
            if(pre != key[input[k][i]]){
                pre *= -1;
                ans++;
            }
        }
        console.log(ans);
        k++;
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 16892
def main():
    import sys
    input = sys.stdin.readline
    def gcd(a,b):
        if b == 0:
            return a
        else:
            return gcd(b,a%b)
    #[p,q)のgcd
    def query(p,q):
        if p>n-1 or q<1:
            return 0
        if abs(q-p)<=1:
            return a[p]
        p += num-1
        q += num-2
        res=0
        while q>p:
            if p&1 == 0:
                res = gcd(res,seg[p])
            if q&1 == 1:
                res = gcd(res,seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        res = gcd(res,seg[p])
        return res

    n = int(input())
    a = tuple(map(int,input().split()))
    #num:n以上の最小の2のべき乗
    num =2**(n-1).bit_length()
    seg=[0]*2*num

    for i in range(n):
        seg[i+num-1]=a[i]    
    for i in range(num-2,-1,-1) :
        seg[i]=gcd(seg[2*i+1],seg[2*i+2]) 

    ans = -1
    for i in range(n):
        ans = max(ans,gcd(query(0,i),query(i+1,n)))
    print(ans)
if __name__=='__main__':
    main()

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
const int N = 1e5 + 5;

int n;
int a[N], b[N], c[N];
int val[N];

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false);   cout.tie(0);

    cin >> n;

    int suma = 0, sumb = 0;
    FOR(i, 1, n) cin >> a[i], suma += a[i];

    int ans = 0, sum = 0, cnt = 0;
    FOR(i, 1, n)    {
        cin >> b[i]; sumb += b[i];
        if(a[i] < b[i]) ans ++, sum += b[i] - a[i];
        if(a[i] > b[i]) val[++cnt] = a[i] - b[i];
    }

    if(suma < sumb) return cout << "-1", 0;
    if(sum == 0) return cout << "0", 0;

    sort(val + 1, val + cnt + 1);
    for(int i = cnt; i >= 1; --i)   {
        val[i] += val[i + 1];
        ans ++;
        if(val[i] >= sum) return cout << ans, 0;
    }
}


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

const int NMAX = 1e5 + 5;
int n, m, sol;
bool vis[NMAX];
vector<int> graf[NMAX];

void dfs(int x) {
    vis[x] = 1;
    for(int i = 0; i < (int)graf[x].size(); i++) {
        if(!vis[graf[x][i]]) {
            dfs(graf[x][i]);
        }
    }
}
int main() {
    
    cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        graf[x].push_back(y);
        graf[y].push_back(x);
    }
    for(int i = 1; i <= n; i++) {
        if(!vis[i]) {
            dfs(i);
            sol++;
        }
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 12292
import java.util.*;
import java.awt.geom.*;
public class Main {
	boolean [][] clocktable;
	int ansclock, n;
	int [] inputxpos, inputypos;
	
	private void dfs(int deep, int startpos, int nowclock){
		if(deep == 9){
			
			nowclock += n;
			ansclock = Math.min(ansclock, nowclock);
			//System.out.println(nowclock +" "+startpos);
			//disp();
			return;
		}
		for(int i = 1; i <= n; i++){
			//System.out.println("deep = " + deep +" " + i);
			//disp();
			boolean isarranged = true;
			ArrayList<Integer> setxpos = new ArrayList<Integer>(), setypos = new ArrayList<Integer>();
			for(int j = 0; j < n; j++){
				int xpos = startpos + i + inputxpos[j];
				int ypos = inputypos[j];
				if(!clocktable[ypos][xpos]){
					clocktable[ypos][xpos] = true;
					setxpos.add(xpos);
					setypos.add(ypos);
				}
				else{
					isarranged = false;
					break;
				}
			}
			
			//dfs
			if(isarranged){
				int nextstartpos = startpos + i;
				int nextclock = nowclock + i;
				dfs(deep + 1, nextstartpos, nextclock);
			}
			//reset operation
			for(int j = 0; j < setxpos.size(); j++){
				int nowx = setxpos.get(j);
				int nowy = setypos.get(j);
				clocktable[nowy][nowx] = false;
			}
		}
	}
	
	private void disp(){
		for(int i = 0; i < 5; i++){
			for(int j = 0; j < clocktable[i].length; j++){
				if(clocktable[i][j]){
					System.out.print("X");
				}
				else{
					System.out.print(".");
				}
			}
			System.out.println();
		}
		System.out.println();
	}

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n == 0) break;
			inputxpos = new int[n];
			inputypos = new int[n];
			clocktable = new boolean[5][n * 10 + 1];
			int inputind = 0;
			for(int i = 0; i < 5; i++){
				String inputline = sc.next();
				for(int j = 0; j < inputline.length(); j++){
					char now = inputline.charAt(j);
					if(now == 'X'){
						inputxpos[inputind] = j;
						inputypos[inputind++] = i;
						clocktable[i][j] = true;
					}
				}
			}
			ansclock = 1 << 24;
			dfs(0, 0, 0);
			System.out.println(ansclock);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {

    vector<int> N(4);
    rep(i, 4) {
        cin >> N[i];
    }
    sort(N.begin(), N.end());

    int x[4] = {1, 4, 7, 9};

    rep(i, 4) {
        if(N[i] != x[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cout << ", "; cetak(v...);}
 
#define debug(x...) cout << '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())


const int MOD = 1e9 + 7;

int add(int x, int y){
    int ret = x + y;
    if(ret >= MOD) ret -= MOD;
    return ret;
}
int sub(int x, int y){
    int ret = x - y;
    if(ret < 0) ret += MOD;
    return ret;
}
int mul(int x, int y){
    return (long long)x * y % MOD;
}

int POW(int a, int b){
    int ret = 1;
    while(b > 0){
        if(b & 1) ret = mul(ret, a);
        b >>= 1;
        a = mul(a, a);
    }
    return ret;
}

int inv(int x){
    return POW(x, MOD - 2);
}

const int mx = 1e5 + 10;

void solve(int n, vector<int> x){
    vector<int>fak(n);
    fak[0] = 1;
    for(int i = 0; i < n; i++){
        if(i) fak[i] = mul(fak[i - 1], i);
    }
    int total = 0;
    for(int i = 0; i < n - 1; i++){
        total = add(total, sub(x[n - 1], x[i]));
    }
    vector<int> pref(n);
    for(int xx = 0; xx < n; xx++){
        if(xx == 0) pref[xx] = mul(fak[n - 1], mul(xx, inv(xx + 1)));
        else pref[xx] = add(pref[xx - 1], mul(fak[n - 1], mul(xx, inv(xx + 1))));
    }
    total = mul(total, fak[n - 1]);
    for(int i = 0; i < n - 1; i++){
        // for(int j = i; j >= 0; j--){
        //     int xx = i - j;
        //     total = sub(total, mul(mul(fak[n - 1], sub(x[i + 1], x[i])), mul(xx, inv(xx + 1))));
        // }
        total = sub(total, mul(pref[i], sub(x[i + 1], x[i])));
    }
    // debug(total);
    cout << total << endl;
}

void brute(int n, vector<int> x){
    vector<int> ve(n - 1);
    iota(ALL(ve), 0);
    int total = 0;
    do{
        set<int> ini;
        for(int i = 0; i < n; i++) ini.insert(i);
        for(int i = 0; i < n - 1; i++){
            auto it = ini.upper_bound(ve[i]);
            int xx = ve[i];
            total = add(total, sub(x[*it], x[xx]));
            ini.erase(xx);
        }
    }while(next_permutation(ALL(ve)));
    debug(total);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> x(n);
        for(int i = 0; i < n; i++) cin >> x[i];
        solve(n, x);
        // brute(n, x);
    }
}


Measured memory_bytes: 1792
/*
	0161:Spoot Meet
*/
#include	<iostream>
#include	<vector>
#include	<algorithm>

using namespace std;

int main(void) {
	int n;
	while(1) {
		cin >> n;
		if(n == 0) { break; }
		vector< pair<int, int> > total(n);
		for(int i = 0; i < n; i++) {
			int c, m1, s1, m2, s2, m3, s3, m4, s4, ts1, ts2, ts3, ts4;
			cin >> c >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			ts1 = 60 * m1 + s1;
			ts2 = 60 * m2 + s2;
			ts3 = 60 * m3 + s3;
			ts4 = 60 * m4 + s4;
			total[i] = make_pair(ts1 + ts2 + ts3 + ts4, c);
		}
		sort( total.begin(), total.end() );
		cout << total[0].second << endl << total[1].second << endl << total[n-2].second << endl;
	}
}

Measured memory_bytes: 1236
# -*- coding: utf-8 -*-

sx,sy,tx,ty = list(map(int, input().rstrip().split()))
#-----

h = ty-sy
w = tx-sx

st1 = "U"*h + "R"*w
ts1 = "D"*h + "L"*w

st2 = "L" + "U"*(h+1) + "R"*(w+1) + "D"
ts2 = "R" + "D"*(h+1) + "L"*(w+1) + "U"

ans = st1 + ts1 + st2 + ts2
print(ans)


Measured memory_bytes: 3064
<?php
$n=trim(fgets(STDIN));
$c=strlen($n);
if($n[$c-1]==3){
  echo "bon";
  exit;
}
if($n[$c-1]==0){
  echo "pon";
  exit;
}
if($n[$c-1]==1){
  echo "pon";
  exit;
}
if($n[$c-1]==6){
  echo "pon";
  exit;
}
if($n[$c-1]==8){
  echo "pon";
  exit;
}
echo "hon";

Measured memory_bytes: 16180
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int n;
	cin>>n;
	cout<<(n-2)*180<<endl;
	rt0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    map<string,int> prize;
    int sum = 0;
    string s;
    for(int i = 0; i < n; i++) {
        cin >> s;
        if(prize.count(s) == false) {
            prize[s] = i;
            sum ++;
        }
    }
    cout << sum;
}

Measured memory_bytes: 19204
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int X,Y,Z;

int main()
{
  cin>>X>>Y>>Z;
  
  cout<<Z<<" "<<X<<" "<<Y;
  
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

class union_find
{
private:
	std::vector<int>parent;
	std::vector<int>rank;
public:
	union_find(int siz)
	{
		parent.resize(siz);
		rank.resize(siz);
		for (int i = 0; i < siz; ++i)
		{
			parent[i] = i;
			rank[i] = 0;
		}
	}
	void unite(int x, int y)
	{
		int xr = find(x);
		int yr = find(y);
		if (xr == yr)return;
		if (rank[xr] < rank[yr])
		{
			parent[xr] = yr;
		}
		else
		{
			parent[yr] = xr;
			if (rank[xr] == rank[yr])rank[xr]++;
		}
	}
	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}
	bool check(int x, int y)
	{
		return find(x) == find(y);
	}
};


#include <unordered_set>
#include <unordered_map>

union_find *road, *rail;

int n, k, l;
int dict[234567];

map<pair<int, int>, int>hashtag;

/*
int par[234567];
unordered_set<int>parse[234567];
void transfer(int dex)
{
	if (par[dex] >= 0)return;
	auto tmp = parse[road->find(dex)];
	for (auto i : parse[road->find(dex)])
	{
		if (road->check(dex, i) && rail->check(dex, i))
		{
			par[i] = dex;
			tmp.erase(i);
		}
		else
		{
			par[i] = i;
			tmp.erase(i);
		}
	}
}
*/

int main(void)
{
	scanf("%d %d %d", &n, &k, &l);
	auto a = union_find(n);
	auto b = union_find(n);
	road = &a;
	rail = &b;
	for (int i = 0; i < k; ++i)
	{
		int p, q;
		scanf("%d %d", &p, &q);
		road->unite(p - 1, q - 1);
	}
	for (int j = 0; j < l; ++j)
	{
		int r, s;
		scanf("%d %d", &r, &s);
		rail->unite(r - 1, s - 1);
	}
	for (int a = 0; a < n; ++a)
	{
		auto index = make_pair(road->find(a), rail->find(a));
		hashtag[index]++;
	}
	for (int a = 0; a < n; ++a)
	{
		auto index = make_pair(road->find(a), rail->find(a));
		printf("%d", hashtag[index]);
		if (a != n - 1)printf(" ");
	}
	printf("\n");
	return 0;
}


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

#define INF 214000000
#define MOD 998244353
#define MaxN 1005

using namespace std;

/*#ifdef INFOARENA
FILE* IN=fopen("bacterii2.in","r"), *OUT=fopen("bacterii2.out","w");
#else
FILE* IN=fopen("test.in","r"), *OUT=fopen("test.out","w");
#endif*/

long long N,M;
string a,b;

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

int main()
{
    cin>>N>>M>>a>>b;
    long long L=1LL*N*M/gcd(N,M);
    long long G=gcd(N,M);
    for(long long i=0;i<G;i++)
    {
        if(a[i*N/G]!=b[i*M/G])
        {
            cout<<-1;
            return 0;
        }
    }
    cout<<L;
    return 0;
}


Measured memory_bytes: 512