akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const int INF = 1e9;
const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

ll dp[205][205];

int main() {
   int N, M, R;
   cin >> N >> M >> R;
   vector<int> r(R);
   for (int i = 0; i < R; i++) {
      cin >> r[i];
      r[i]--;
   }
   sort(r.begin(), r.end());
   int A, B, C;
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
         if (i == j) dp[i][j] = 0;
         else dp[i][j] = INF;
      }
   }
   for (int i = 0; i < M; i++) {
      cin >> A >> B >> C;
      A--;
      B--;
      dp[A][B] = C;
      dp[B][A] = C;
   }

   for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
         for (int j = 0; j < N; j++) {
            dp[i][j] = llmin(dp[i][j], dp[i][k] + dp[k][j]);
         }
      }
   }
   /*
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
         cout << dp[i][j] << " ";
      }
      cout << endl;
   }
   */
   ll ans = INF;
   do {
      ll tmp = 0;
      for (int i = 1; i < (int)r.size(); i++) {
         // cout << r[i - 1] << " " << r[i] << " " << endl;
         tmp += dp[r[i - 1]][r[i]];
      }
      chmin(ans, tmp);
   } while (next_permutation(r.begin(), r.end()));
   cout << ans << endl;
   return 0;
}


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

using namespace std;

#define T top()

#define E end()

#define PS push

#define Q queue

#define PP pop()

#define V vector

#define ST stack

#define FI first

#define MAX 4e18

#define MIN -MAX

#define DQ deque

#define SZ size()

#define C clear()

#define B begin()

#define F front()

#define SE second

#define DL double

#define G getline

#define IN insert

#define endl "\n"

#define EM empty()

#define PSB push_back

#define PI acos(-1.00)

#define PPB pop_back()

#define PSF push_front

#define ub upper_bound

#define lb lower_bound

#define MOD 1000000007

#define PPF pop_front()

#define LL long long int

#define PQ priority_queue

#define N cout<<"NO"<<endl

#define VL V<LL>::iterator

#define Y cout<<"YES"<<endl

#define SL set<LL>::iterator

#define SS set<string>::iterator

#define MLL map<LL,LL>::iterator

#define MCL map<char,LL>::iterator

#define _max(a,b,c) max(a,max(b,c))

#define _min(a,b,c) min(a,min(b,c))

#define MSL map<string,LL>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C

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

#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

V<LL>v;

V<LL>w;

set<LL>uo;

map<LL,LL>u;

map<LL,LL>ww;

LL ar[500005];

LL br[500005];

LL cr[500005];

V<LL>uuu[500005];

V<pair<LL,LL> >uu;

map<pair<LL,LL>,LL> vo;

map<pair<LL,LL>,LL> vu;

int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>m;
        cout<<n*m<<endl;

    }
    return 0;
    //IN
    //AL
}


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

using namespace std;

int main(void) {

	int r = 0;

	cin >> r;

	if (r < 1200) {
		cout << "ABC" << endl;
	}
	else if (r >= 1200 && r < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    unordered_map<int, int> m;
    ll sum = 0;
    REP(i, 0, N) {
        int a; cin >> a;
        sum += a;
        m[a]++;
    }

    int Q; cin >> Q;
    REP(i, 0, Q) {
        int b, c; cin >> b >> c;
        sum -= (ll)b * m[b];
        sum += (ll)c * m[b];
        cout << sum << endl;
        m[c] += m[b]; m[b] = 0;
    }

    return 0;
}

Measured memory_bytes: 7092
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a,b,c,k; cin >> a >> b >> c >> k;
	cout << max(max(a,b),c)*pow(2,k) + a + b + c - max(max(a,b),c) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

void displayVector(vector<int> v, int n);

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

    vector<int> v;
    for(int i = 0; i < n; i++){
        int q;
        cin >> q;
        v.push_back(q);
    }

    sort(v.begin(), v.end());
    //displayVector(v, n);

    int sameSequence = 1, ans = 0;
    for(int i = 0; i < n - 1; i++){
        if(v[i] == v[i + 1]){
            sameSequence++;
        }else{
            ans += sameSequence % 2;
            sameSequence = 1;
        }
    }
    
    ans += sameSequence % 2;
    cout << ans << endl;
    return 0;
}

void displayVector(vector<int> v, int n){
    for(int i = 0; i < n; i++){
        char c = (i == n - 1)? '\n' : ' ';
        cout << v[i] << c;
    }
}

Measured memory_bytes: 892
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

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

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

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



	public void exec() throws Exception{
		final int N = sc.nextInt();
		final int[] P = new int[N];
		for(int i=0;i<N;i++) {
			P[i] = sc.nextInt();
		}
		int min = P[0];
		int cnt = 1;
		for(int i=1;i<N;i++) {
			if(P[i] <= min) {
				cnt++;
				min = Math.min(min, P[i]);
			}
		}
		out.println(cnt);
	}
}


Measured memory_bytes: 80940
#pragma GCC optimize("O3")
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FOR(i,l,r) for(int i = l ; i <= r ;++i )
#define ALL(T)  T.begin(),T.end()
#define lson(i)     i<<1
#define rson(i)     (i<<1|1)
#define ll long long 
#define pu push
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define is insert
#define se second
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define debug(x) cout << "[" << #x << ": " << (x) << "]" << endl
#define endl "\n"
#define in inline
using namespace std;
typedef pair<int,int> pii;
const int N = 1e5+10;
const int INF = 1<<30;
int a[N];
int dp[N];
int n;
int main(){
    ll n;
    cin >> n;
    ll ans = n/2*n;
    if(n%2==0)  ans-=n/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int n = (b - a) - 1;
	int x = (n + n * n) / 2 - a;
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi d(n);
	REP(i,n) cin>>d[i];
	
	int ans=0;
	REP(i,n-1)for(int j=i+1;j<n;++j){
		ans+=d[i]*d[j];
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i,c=0,ky=0,hn,wn,hw,hns,wns,bhw;
		int h=sc.nextInt();
		int w=sc.nextInt();
		int n=sc.nextInt();
		
		int [][] p =new int [n][2];
		
		
		
		
		for(i=0;i<n;i++){
			int hp  =sc.nextInt();
			p[i][0]=hp;
			int wp =sc.nextInt();
			p[i][1]=wp;
			
		}
		
		int [] nex=new int [2];
		
		
		for(i=1;i<n;i++){
			hn=p[i-1][0]-p[i][0];
			wn=p[i-1][1]-p[i][1];
			hns=hn;
			wns=wn;
			if(hn<0) hns=hn*-1;
			if(wn<0) wns=wn*-1;
			
			ky=hns+wns;
			
			if(hns>wns) hw=wns;
			else hw = hns;
			
			if((hn>0&&wn>0)|| (hn<0&&wn<0)){
					ky-=hw;
			}
			c+=ky;
			
		}
		
		
		System.out.printf("%d\n",c);
		sc.close();
		System.exit(0);
	}
}

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

int main(){
  int X,A;
  cin >> X >> A;
  
  if(X < A) cout << 0 << endl;
  else cout << 10 << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x[] = new int[m];
        for (int i = 0; i < m; i++) {
            x[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        int sum = Arrays.stream(x).max().getAsInt() - Arrays.stream(x).min().getAsInt();
        if (n >= m) {
            System.out.println(0);
            return;
        } else if (n == 1) {
            System.out.println(sum);
            return;
        }
        Arrays.sort(x);
        Integer y[] = new Integer[m - 1];
        for (int i = 0; i < m - 1; i++) {
            y[i] = x[i + 1] - x[i];
        }
        Arrays.sort(y, Comparator.reverseOrder());
        for (int i = 0; i < n - 1; i++) {
            sum -= y[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 51028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int H, W, K;
  cin >> H >> W >> K;
  string S[6];
  for(int i=0; i<H; i++) cin >> S[i];
  int ans = 0;
  for(int i=0; i < 1<<H; i++) {
    for(int j=0; j < 1<<W; j++) {
        int cnt = 0;
      	for(int a=0; a<H; a++) {
          for(int b=0; b<W; b++) {
            if(!(i>>a & 1) && !(j>>b & 1)) cnt += S[a][b] == '#';
          }
        }
      	ans += cnt == K;
    }
  }
  cout << ans << endl;
}

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

int main(){
	int ans=0;
	int n;	cin>>n;
	int x;
	for(int i=1;i<=n;i++){
		x=1;
		int digit=0;
		while(i>=x){
			digit++;
			x*=10;
		}
		if(digit%2)ans++;
	}
	cout<<ans<<endl;


	return 0;
}


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

using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    for(ll i = 0; i < a; i++)cin >> p[i];
    for(ll i = 0; i < b; i++)cin >> q[i];
    for(ll i = 0; i < c; i++)cin >> r[i];
    sort(p.begin(), p.end(), greater<ll>()); sort(q.begin(), q.end(), greater<ll>()), sort(r.begin(), r.end(), greater<ll>());
    vector<ll> cost;
    for(ll i = 0; i < x; i++)cost.push_back(p[i]);
    for(ll i = 0; i < y; i++)cost.push_back(q[i]);
    sort(cost.begin(), cost.end());
    ll ans = 0;
    ll sum = accumulate(cost.begin(), cost.end(), 0LL);
    vector<ll> sr(c + 1);
    vector<ll> sc(x + y + 1);
    for(ll i = 0; i < c; i++)sr[i + 1] = r[i] + sr[i]; //先頭からr個取り出す
    for(ll i = 0; i < x + y; i++)sc[i + 1] = cost[i] + sc[i]; 

    //cerr << "sum : " << sum << endl;
    //costを入れ替える数
    for(ll i = 0; i <= x + y && i <= c; i++){
        ll cur = sum - sc[i];
        cur += sr[i];
        ans = max(cur, ans);
        //cerr << cur << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{
    private:
        int i;
    public:
        mint() : i(0){}
        mint(int i):i((i%m+m)%m){}
        mint operator+(const mint& o){return o.i+i;}
        mint operator*(const mint& o){return o.i*i;}
        mint operator-(){return -i;}operator int() {return i;}
        mint& operator+=(const mint& o){
            i = ((i + o.i)%m + m)%m;
            return *this;
        }
        mint& operator-=(const mint& o){
            i = ((i - o.i)%m + m)%m;
            return *this;
        }
};

//}

//typedef mint<1234567> itn;

int p,q,r,s;

main(){
    cin>>p>>q>>r>>s;
    dump(r+q-s,s+r-p,p+q-s,q+r-p);
}




Measured memory_bytes: 256
#include"bits/stdc++.h"
 
using namespace std;
 
typedef pair<int, int> P;
typedef long long int ll;
 
 
 
int main() {
	//union_find a(5);
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 1; i < 4; i++) {
		if (S[i] == S[i - 1]) { ans = 1; }
	}
	if (ans == 0) {
		cout << "Good" << endl;
	}
	else {
		cout << "Bad" << endl;
	}
 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  //入力
  int n;
  cin>>n;
  vector<int> a(n+2);
  a[0]=0,a[n+1]=0;
  for(int i=1;i<=n;i++) cin>>a[i];

  //全箇所回る場合の費用
  int sum=0;
  for(int i=1;i<=n+1;i++)
  {
    sum+=abs(a[i]-a[i-1]);
  }

  //i番目の場所を取りやめた場合
  for(int i=1;i<=n;i++)
  {
    int ans=sum-(abs(a[i+1]-a[i])+abs(a[i]-a[i-1]))+abs(a[i+1]-a[i-1]);
    cout<<ans<<endl;
  }


}

Measured memory_bytes: 1664
<?php
$n = trim(fgets(STDIN));
$a[0] = 0;
while($n > 0){
$a[] = trim(fgets(STDIN));
--$n;
}

$ans = 1;
$c = 1;
while($c != 2){
$c = $a[$c];
if($c == 2){
echo $ans;
}else{
++$ans;
}
if($ans >= 100000){
echo -1;
break;
}
}

Measured memory_bytes: 21236
using System;

namespace rensyuu1
{
    class Program
    {
        static void Main(string[] args)
        {
            string xx = Console.ReadLine();
            double r = double.Parse(xx);
            double S = r * r * 3.141592653589;
            double L = 2 * r * 3.141592653589;
            Console.WriteLine("{0} {1}", S, L);
        }
    }
}


Measured memory_bytes: 17956
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

struct mint {
  ll x;
  mint(ll x = 0) : x(x % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

class combination {
 private:
  vector<mint> fact, finv;

 public:
  combination(int N) {
    fact = finv = vector<mint>(N + 1);
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    for (ll i = 2; i <= N; i++) {
      fact[i] = fact[i - 1] * i;
      finv[i] = fact[i].inv();
    }
  }
  mint f(int i) { return fact[i]; }
  mint comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * finv[k] * finv[n - k];
  }
  mint hcomb(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return comb(n + k - 1, k);
  }
};

int main() {
  //
  ll n, m, k;
  cin >> n >> m >> k;
  mint ans(0);
  combination comb(n * m);
  REP(d, 1, n) {
    mint tmp(1);
    tmp *= d;
    tmp *= (n - d);
    tmp *= (m * m);
    tmp *= comb.comb(n * m - 2, k - 2);
    ans += tmp;
  }
  REP(d, 1, m) {
    mint tmp(1);
    tmp *= d;
    tmp *= (m - d);
    tmp *= (n * n);
    tmp *= comb.comb(n * m - 2, k - 2);
    ans += tmp;
  }
  cout << ans.x << endl;
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int hn[300100], wn[300100];
set<int> ms[300100];
random_device _rnd;
int rnd(int n) {
  return ((double)_rnd() / UINT_MAX) * n;
}
int main() {
  ll H, W, M;
  cin >> H >> W >> M;
  repi(M) {
    int h, w;
    cin >> h >> w;
    --h;
    --w;
    ++hn[h];
    ++wn[w];
    ms[h].insert(w);
  }
  int hnmax = -1, wnmax = -1;
  repi(H) updatemax(hnmax, hn[i]);
  repi(W) updatemax(wnmax, wn[i]);
  vector<int> hms, wms;
  repi(H) if (hn[i] == hnmax) hms.push_back(i);
  repi(W) if (wn[i] == wnmax) wms.push_back(i);
  int result = hnmax + wnmax - 1;
  if (M < H * W) {
    ll hmsl = hms.size(), wmsl = wms.size();
    if (hmsl * wmsl <= 1e5 * 3) {
      repi(hmsl) repj(wmsl) {
        int h = hms[i], w = wms[j];
        if (ms[h].find(w) == ms[h].end()) {
          ++result;
          goto end;
        }
      }
    } else {
      repi(1e5) {
        int h = hms[rnd(hmsl)], w = wms[rnd(wmsl)];
        if (ms[h].find(w) == ms[h].end()) {
          ++result;
          goto end;
        }
      }
    }
  }
end:
  cout << result << endl;
}


Measured memory_bytes: 37932
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
c=sum(B)
for i in range(n-1):
    if A[i+1]-A[i]==1:c += C[A[i]-1]
print(c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> used(n, 0);
    while (k--) {
        int a;
        cin >> a;
        for (int i = 0; i < a; ++i) {
            int b;
            cin >> b;
            used[b - 1] = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (used[i] == 0) ++ans;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#define rep(i, k, n) for (int i = k; i < n; ++i)

using namespace std;

template<class T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

int main(){
  // prepare
  vector<vector<int>> dp(100100, vector<int>(3, -1));
  rep(i, 0, 3) dp[0][i] = 0;

  //input 
  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(3));
  rep(i,0,N) cin >> A[i][0] >> A[i][1] >> A[i][2];

  // dp
  rep(i,0,N) {
    rep (j, 0, 3) {
      rep (k, 0, 3) {
        if (j == k) continue;
        chmax(dp[i + 1][j], dp[i][k] + A[i][j]);
      }
    }
  // cout << dp[i + 1][0] << " " << dp[i + 1][1] << " " << dp[i + 1][2] << endl;
  }

  // output
  int ans = -1;
  rep(i, 0, 3) chmax(ans,dp[N][i]);
  cout << ans << endl;
  return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (b % a == 0) cout << a + b << endl;
	else cout << b - a << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)

RL = []
r = 0
l = 0
for i in range(N):
    if S[i] == "R":
        r += 1
    elif S[i] == "L":
        l += 1
    if i >= 1:
        if S[i-1]=="R" and S[i] == "L":
            RL.append([i-1,r,0])
            r = 0
        if S[i-1]=="L" and S[i] == "R":
            RL[-1][2] += l
            l = 0
    if i == N-1:
        RL[-1][2] += l
#print(RL)

res = [0]*N
for x in RL:
    #print(x)
    i = x[0]
    s = x[1] + x[2]
    if (x[1]-x[2])%2 == 0:
        res[i] = s//2
        res[i+1] = s//2
    else:
        if (x[1]>x[2] and x[1]%2 == 0) or (x[1]<x[2] and x[2]%2 == 1):
            res[i] = (s-1)//2
            res[i+1] = (s+1)//2
        else:
            res[i+1] = (s-1)//2
            res[i] = (s+1)//2
for x in res:
    print(x,end=" ")

Measured memory_bytes: 11408
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(x) fprintf(stderr, "[%s = %d]\n", #x, x)
#else
	#define errp(...)
	#define dbg(x) 
#endif

int n, c[25], v[25], p[25];

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &v[i]);
	for (int i = 0; i < n; i++) scanf("%d", &c[i]);
	for (int i = 0; i < n; i++) p[i] = v[i] - c[i];
	sort(p, p + n);
	reverse(p, p + n);
	for (int i = 1; i < n; i++) p[i] += p[i - 1];
	int ans = 0;
	for (int i = 0; i < n; i++) ans = max(ans, p[i]);
	printf("%d\n", ans);
}

Measured memory_bytes: 128
use std::io::Read;
use std::cmp::{max, min};

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let mut l_max: usize = 1;
    let mut r_min: usize = n;
    for _i in 0..m {
        let l: usize = iterator.next().unwrap().parse().unwrap();
        let r: usize = iterator.next().unwrap().parse().unwrap();

        l_max = max(l_max, l);
        r_min = min(r_min, r);
    }

    let ans = if r_min >= l_max {
        r_min - l_max + 1
    } else {
        0
    };
    return format!("{}", ans);
}


Measured memory_bytes: 6396
#include <queue>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
const int INF=0x3f3f3f3f;
using namespace std;
struct edge{
    int to,cost,w;
};
int V,d[10005],dis[10005];
vector<edge> G[20005];
typedef pair<int,int> P;
void dijkstra(int s){
    int i,v;
	priority_queue<P,vector<P>,greater<P> >que;
	fill(d,d+V+1,INF);
	fill(dis,dis+V+1,INF);
	d[s]=dis[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p=que.top(); que.pop();
		v=p.second;
		if(d[v]<p.first)
        continue;
		for(i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
                dis[e.to]=e.w;
				que.push(P(d[e.to],e.to));
			}
			else if(d[e.to]==d[v]+e.cost)
            dis[e.to]=min(dis[e.to],e.w);
		}
	}
}
int main(){
    int m,st,en,i,j,x,y,z,q,ans;
    edge temp;
    while(scanf("%d%d",&V,&m)!=EOF&&(V||m)){
        for(i=0;i<=V;i++)
        G[i].clear();
        for(i=0;i<m;i++){
            scanf("%d%d%d%d",&x,&y,&z,&q);
            temp.to=y;temp.cost=z;temp.w=q;
            G[x].push_back(temp);
            temp.to=x;
            G[y].push_back(temp);
        }
        dijkstra(1);
        ans=0;
        for(i=1;i<=V;i++)
        ans+=dis[i];
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 5364
#include<bits/stdc++.h>
using namespace std;
int read(){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	return res*f;
}
int main(){
	int a=read(),x=read();
	a*=500;
	if(a>=x) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  string a,b;
  cin >> a >> b;
  int na=a.size(),nb=b.size();
  REP(i,na+nb) {
    if(i%2==0) {
      cout << a[i/2];
    } else {
      cout << b[(i-1)/2];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3588
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;
void trace(int a[], int n)
{
	for (int i = 0; i < n; i++)
	{
		if (i)
		{
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
}
void insertionSort(int a[], int n) 
{
	for (int i = 1; i < n; i++)
	{
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v)
		{
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		trace(a, n);
	}
}

int main()
{
	int a[100], n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	trace(a, n);
	insertionSort(a, n);
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#define X first
#define Y second
#define clr(u,v); memset(u,v,sizeof(u));
#define in() freopen("data","r",stdin);
#define out() freopen("ans","w",stdout);
#define Clear(Q); while (!Q.empty()) Q.pop();
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
int N[maxn];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &N[i]);
    int odd = 0, even = 0;
    for (int i = 0; i < n; i++)
        if (N[i] & 1) odd++;
        else even++;
    if (odd) puts(odd & 1 ? "NO" : "YES");
    else puts(even & 1 ? "NO" : "YES");
    return 0;
}


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

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

int next(int u){
  for(int v = nt[u]; v < n; v++){
    nt[u] = v + 1;
    if( M[u][v] )return v;
  }
  return -1;
}

void dfs_visit(int r){
  for(int i = 0; i<n;i++)nt[i] = 0;

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while( !S.empty()){
    int u = S.top();
    int v = next(u);
    if( v != -1 ){
      if( color[v] == WHITE){
      color[v] = GRAY;
      d[v] = ++tt;
      S.push(v);
      }
    }else{
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs(){
  for(int i = 0;i < n; i++){
    color[i] = WHITE;
    nt[i] = 0;
  }
  tt = 0;

  for(int u = 0; u < n;u++){
    if(color[u] == WHITE)dfs_visit(u);
  }
  for( int i = 0;i < n;i++){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}

int main(){
  int u,k,v;

  cin >> n;
  for(int i = 0;i < n;i++){
    for(int j = 0; j < n; j++)M[i][j] = 0;
  }

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
 
int main() {
    char order[3];
    cin >> order;
    ans = 700;
    REP(i,3){
        if(order[i] == 'o')ans+=100;
    }
    cout << ans << endl;
    return 0;
}

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

class B
{
	static void Main()
	{
		Console.ReadLine();
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var x = (a[0] - a[1]) / 0.006;
		Console.WriteLine(Console.ReadLine().Split().Select((s, i) => new { i, h = int.Parse(s) }).OrderBy(_ => Math.Abs(_.h - x)).First().i + 1);
	}
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	string S; cin >> S;
	ll K; cin >> K;
	int p = 0;
	rep(i, S.size()) if (S[i] != '1') {p = i; break;}
	cout << (K <= p ? S[0] : S[p]) << endl;
}


Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()]

ans = 0
max = 0
T = H[0]
for i in range(N-1):
    if H[i] >= H[i+1]:
        ans += 1
        if ans >= max :
            max = ans
    
    else:
        ans = 0
        

print(max)
    

Measured memory_bytes: 14252
s = input()
t = input()

s1 = len(s)
t1 = len(t)

if t1 > s1:
    print("UNRESTORABLE")
    exit(0)

res = ""
for i in range(s1):
    u = s[i:i + t1]
    if len(u) != t1: continue
    ok = True
    for j in range(t1):
        if u[j] != '?' and u[j] != t[j]:
            ok = False
    if ok:
        tmp = (s[:i] + t + s[i+t1:]).replace("?", "a")
        if res == "" or tmp < res:
            res = tmp

if res: print(res)
else  : print("UNRESTORABLE")


Measured memory_bytes: 3064
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
map <int, char> m;
void solve () {
    int n;
    cin >> n;
	string a;
	cin >> a;
	int  x = 0;
	for (int i = 'A'; i <= 'Z'; i ++) {
		m[x] = char (i);
		x ++;
	}
	for (int i = 0; i < sz (a); i ++) {
		cout << m[(a[i] - 'A' + n) % 26] ; 
	}
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//	cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

int n;
int d[110][2];
int zoro[110];

void solve(){
    cin >> n;
    rep(i,n){
        cin >> d[i][0] >> d[i][1];
        if(d[i][0]==d[i][1]){
            zoro[i]=1;
        }
    }

    Rep(i,2,n){
        if(zoro[i-2]==1 && zoro[i-1]==1 && zoro[i]==1){
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

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

const int MAX_N = 1e5 + 5;
int n, ans;
string s;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++)
        s[i] = (s[i] - 'A' + n) % ('Z' - 'A' + 1) + 'A';

    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int S,W;
int main () {
    ios_base::sync_with_stdio(false);
    cin>>S>>W;
    if(S>W) {
        cout<<"safe"<<"\n";
    }
    else {
        cout<<"unsafe"<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3652
antinas = 5.times.map{gets.to_i}
k=gets.to_i
nonSendflag = false
(0..3).each do |index|
  p = antinas[index]
  antinas[(index+1)..4].each do |q|
    if k < q-p
      nonSendflag = true
      break
    end
  end
  break if nonSendflag
end
puts nonSendflag ? ":(" : "Yay!" 

Measured memory_bytes: 1788
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>

using namespace std;

int main()
{
  long long N,K;
  scanf ("%lld %lld", &N, &K);
  vector<pair<long long int, long long int>> V;
  V.reserve(N);
  for (long long int i = 0; i < N; i++) {
    int a,b;
    scanf("%d %d", &a, &b);
    V.push_back({a, b});    
  }
  sort(V.begin(), V.end());
  for (auto v : V) {
    K -= v.second;
    if (K <= 0) {
      printf("%lld\n", v.first);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    ll a,b; cin>>a>>b;
    if(a>b) cout<<a-1;
    else cout<<a;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    double temp,ans=0,min=1000000001;
    int n,i,negcnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lf",&temp);
        if(temp<0){
            temp=temp*-1;
            negcnt++;
        }
        if(temp<min){
            min=temp;
        }
        ans+=temp;
    }
    if(negcnt%2==1){
        ans-=min*2;
    }
    printf("%.0lf\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int n,a[500010],num[500010];
vector<int> vec[2000010];

inline void add(int &x,int y)
{
	x+=y;
	if(x>=MOD) x-=MOD;
}

signed main()
{
	//freopen("b.in","r",stdin);
	//freopen("b.out","w",stdout);
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) num[i]=num[i-1]^a[i];
	if(num[n]>0){
		vector<int> v;
		for(int i=1;i<=n;i++) if(num[i]==0||num[i]==num[n]) v.push_back(i);
		int sum1=1,sum2=0;
		if(v.size()>1){
			for(int i=v.size()-2;i>=0;i--){
				if(num[v[i]]==0) add(sum2,sum1);
				else add(sum1,sum2);
			}
		}
		cout<<sum1<<endl;
	}
	else{
		vector<int> v;
		int k=1;
		for(int i=1;i<=n;i++) if(num[i]==0) v.push_back(i);
		for(int i=1;i<v.size();i++) add(k,k);
		for(int i=1;i<=n;i++) if(num[i]!=0) vec[num[i]].push_back(i);
		int ans=k;
		for(int i=1;i<=(1<<20);i++) if(!vec[i].empty()){
			int sum1=1,sum2=1;
			if(vec[i].size()>1){
				for(int j=vec[i].size()-2;j>=0;j--){
					int pos1=upper_bound(v.begin(),v.end(),vec[i][j+1])-v.begin();
					int pos2=upper_bound(v.begin(),v.end(),vec[i][j])-v.begin();
					int num=int(((long long)(pos1-pos2)*(long long)(sum1))%(long long)MOD);
					add(sum2,num);
					add(sum1,sum2);
				}
			}
			add(ans,sum1);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 63616
// Problem : C - : (Colon)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		long double a,b,h,m;
		cin>>a>>b>>h>>m;
		long double ang = (60*h-11*m)/2.0;
		ang*=(acos(-1));
		ang/=180;
		//cout<<cos(ang)<<"\n";
		long double xxx  = a*a + b*b - 2*a*b*(cos(ang))  ;
		xxx = sqrtl(xxx);
		cout<<fixed<<setprecision(20)<<xxx;  	
    }
    return 0;
}


Measured memory_bytes: 4180
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    long long N; cin >> N;
    vector<long long>A(N), B(N), C(N);
    rep(i, N) cin >> A.at(i);
    rep(i, N) cin >> B.at(i);
    rep(i, N) cin >> C.at(i);
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    long long ans = 0;
    rep(i, N) {
        ans += (lower_bound(A.begin(), A.end(), B.at(i)) - A.begin()) * (C.end() - upper_bound(C.begin(), C.end(), B.at(i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
a,b,c,d=[int(x) for x in input().split()]
mn1=a
mx1=b
mn2=c
mx2=d
prod=a*c
prod=max(prod,b*d)
prod=max(prod,a*d)
prod=max(prod,b*c)
if(a<=0 and b>=0):
    prod=max(prod,0)
if(c<=0 and d>=0):
    prod=max(prod,0)
print(prod)


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

class unionfind {
	vector<int> par, rank;

public:
	void init(int n) {
		par.resize(n);
		rank.resize(n);

		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return ;

		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
		}
	}

	bool same(int x, int y) { return (find(x) == find(y)); }
} uf;

const int SZ = 1 << 20;

template<class T>
struct segtree {
	vector<pair<T,int>> dat;

	const T INF = numeric_limits<T>::max();

	void init() {
		dat.resize(SZ * 2);
		rep(i, SZ * 2) dat[i] = mp(INF, -1);
	}

	void update(int pos, T x) {
		pos += SZ - 1;
		dat[pos] = mp(x, pos - (SZ - 1));

		while (pos > 0) {
			pos = (pos - 1) / 2;
			dat[pos] = min(dat[pos * 2 + 1], dat[pos * 2 + 2]);
		}
	}

	pair<T,int> get(int a, int b, int k = 0, int l = 0, int r = SZ) {
		if (b <= l || r <= a) return mp(INF, -1);
		if (a <= l && r <= b) return dat[k];
		return min(get(a, b, k * 2 + 1, l, (l + r) / 2), get(a, b, k * 2 + 2, (l + r) / 2, r));
	}
};

int main() {
	int N, D; cin >> N >> D;
	V<int> A(N);
	rep(i, N) cin >> A[i];

	segtree<ll> segl, segr;
	segl.init(); segr.init();

	V<pii> vec(N);
	rep(i, N) vec[i] = mp(A[i], i);
	sort(ALL(vec));

	V<pair<ll, pii>> edges;

	for (auto pr : vec) {
		int p = pr.se;
		auto tl = segl.get(0, p);
		if (tl.fi != segl.INF) {
			edges.eb(A[p] + (ll)D * p + tl.fi, mp(p, tl.se));
		}
		auto tr = segr.get(p+1, N);
		if (tr.fi != segr.INF) {
			edges.eb(A[p] - (ll)D * p + tr.fi, mp(p, tr.se));
		}

		segl.update(p, A[p] - (ll)D * p);
		segr.update(p, A[p] + (ll)D * p);
	}

	sort(ALL(edges));
	uf.init(N);
	ll ans = 0;
	for (auto e : edges) {
		if (!uf.same(e.se.fi, e.se.se)) {
			uf.unite(e.se.fi, e.se.se);
			ans += e.fi;
		}
	}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 78444