akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

vector<int> color;
vector<bool> ver;
void dfs(const wgraph &g,int v){
  ver[v]=true;
  for(auto i:g[v]){
    if(color[i.first]!=0)continue;
    color[i.first]=i.second^color[v];
  }
  for(auto i:g[v]){
    if(ver[i.first]==true)continue;
    dfs(g,i.first);
  }
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  wgraph g(n);
  for(i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    g[a-1].push_back(pll(b-1,c%2));
    g[b-1].push_back(pll(a-1,c%2));
  }
  color.assign(n,0);
  ver.assign(n,false);
  color[0]=0;
  dfs(g,0);
  for(i=0;i<n;i++){
    cout<<color[i]<<endl;
  }
}


Measured memory_bytes: 9728
// Problem : B - Minor Change
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

string s,t;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<s.size();++i){
		if(s[i]!=t[i]){
			cnt++;
		}
	}
	
	cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int N;

int main(void)
{
	for (int i = 1; i <= 4; i++) {
		char c;
		scanf("%c", &c);

		c == '+' ? N++ : N--;
	}

	printf("%d\n", N);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define N 2000000
#define MAX 10000

int main(){
  unsigned short *A, *B;

  int C[MAX+1];
  int n, i, j;
  
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<=MAX;i++){
    C[i] = 0;
  }
  for(i=0;i<n;i++){
    scanf("%d", &A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=MAX;i++){
    C[i] = C[i] + C[i-1];
  }

  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1){
      printf(" ");
    }
    printf("%d", B[i]);
  }
  printf("\n");
  
  return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int a,b,k;
  cin>>a>>b>>k;
  
  if(a+b <= k)
  {
    cout<<"0 0"<<endl;
  }
  else if(k>=a)
  {
    cout<<"0 "<<a+b-k<<endl;
  }
  else
  {
    cout<<a-k<<" "<<b<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  long long int ma, mi;
  ma = 0LL;
  mi = 1000000000;
  for(int i = 0; i < N; i++){
    ma = max(ma,A[i]);
    mi = min(mi,A[i]);
  }
  cout << max(abs(ma - mi), abs(mi - ma));
}

Measured memory_bytes: 256
require 'set'

# Header {{{
def assert(p)
  raise 'Assertion Failed' unless p
end

# Constants {{{
INF = 10**9
# }}}

# IO {{{
class MyIO
  def initialize
    @input = $stdin
    @output = $stdout
  end

  # @param filename [String]
  def set_input(filename)
    @input = File.open(filename, 'r')
  end

  def set_output(filename)
    @output = File.open(filename, 'w')
  end

  def int
    gets.to_i
  end

  def ints
    split.map(&:to_i)
  end

  def split
    @input.gets.chomp.split(' ')
  end
  alias_method :strings, :split

  def gets
    @input.gets.chomp
  end

  def puts(*args)
    @output.puts(*args)
  end
end

io = MyIO.new
# }}}

# Algorithms {{{

def lower_bound(arr, val)
  assert(arr.is_a?(Array))
  low, high = 0, arr.size
  while high - low > 1
    mid = (low + high) / 2
    if arr[mid] < val
      low = mid
    else
      high = mid
    end
  end
  if arr[low] >= val
    low
  else
    high
  end
end

def upper_bound(arr, val)
  assert(arr.is_a?(Array))
  low, high = 0, arr.size
  while high - low > 1
    mid = (low + high) / 2
    if arr[mid] <= val
      low = mid
    else
      high = mid
    end
  end
  if arr[low] > val
    low
  else
    high
  end
end

# }}}

# }}}

# io.set_input('inputs/4.txt')

class Node
  attr_accessor :neighbors
  def initialize
    @neighbors = Set.new
  end

  def connect(n)
    @neighbors << n
  end
end

n, m, s, t = io.ints
s -= 1
t -= 1
nodes = Array.new(n) { Node.new }
m.times do
  x, y = io.ints
  x -= 1
  y -= 1
  nodes[x].connect(y)
  nodes[y].connect(x)
end

min_dist = INF
nodes_by_dist_from_start = Hash.new { |h, k| h[k] = Set.new }
nodes_by_dist_from_end = Hash.new { |h, k| h[k] = Set.new }
[s, t].each do |start|
  visited = Array.new(n, false)
  q = []
  q << [start, 0]
  while !q.empty?
    i, d = q.shift
    next if visited[i]
    visited[i] = true
    min_dist = d if start == s && i == t
    nodes_by_dist_from_start[d] << i if start == s
    nodes_by_dist_from_end[d] << i if start == t
    nodes[i].neighbors.each do |j|
      q.push([j, d+1])
    end
  end
end

ans = 0
(0...min_dist).each do |i|
  j = min_dist - i - 2
  ans += nodes_by_dist_from_start[i].size * nodes_by_dist_from_end[j].size
end

puts ans

# vim: foldmethod=marker

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

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

using namespace std;

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

int main() {
  ll n, d;
  cin >> n >> d;
  vector<ll> x(n);
  vector<ll> y(n);
  rep(i, n) {
    ll xx, yy;
    cin >> xx >> yy;
    x.at(i) = xx;
    y.at(i) = yy;
  }
  ll res = 0;
  rep(i, n) {
    if ((x.at(i) * x.at(i) + y.at(i) * y.at(i)) <= d * d) {
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6360
a, b = gets.split.map(&:to_i)

n = b * 10

while n.to_f * 0.08 < a
  n += 1
end

if((n.to_f * 0.1).floor == b && (n.to_f * 0.08).floor == a)
  puts n
else
  puts -1
end

Measured memory_bytes: 1788
using System;

namespace ABC_101_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int a = 0;
            if (S[0] == '+') a += 1;
            if (S[1] == '+') a += 1;
            if (S[2] == '+') a += 1;
            if (S[3] == '+') a += 1;
            if (S[0] == '-') a -= 1;
            if (S[1] == '-') a -= 1;
            if (S[2] == '-') a -= 1;
            if (S[3] == '-') a -= 1;
            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 11092
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class UnionFind:
    def __init__(self, n: int):
        self.n = n
        self.parents = [-1] * n
    
    def find(self, x: int):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x: int, y: int):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        if self.parents[y] < self.parents[x]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x: int):
        return -self.parents[self.find(x)]
    
    def same(self, x: int, y: int):
        return self.find(x) == self.find(y)
    
    def members(self, x: int):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def solve():
    N = int(rl())
    x, y = [0] * N, [0] * N
    for i in range(N):
        x[i], y[i] = map(int, rl().split())
    MAX_N = 10 ** 5
    
    uf = UnionFind(2 * MAX_N + 1)
    for xi, yi in zip(x, y):
        uf.union(xi, MAX_N + yi)
    
    x_counter = defaultdict(int)
    y_counter = defaultdict(int)
    for xi in range(1, MAX_N + 1):
        if uf.parents[xi] == -1:
            continue
        x_counter[uf.find(xi)] += 1
    for yi in range(MAX_N + 1, 2 * MAX_N + 1):
        if uf.parents[yi] == -1:
            continue
        y_counter[uf.find(yi)] += 1
    
    united = defaultdict(int)
    for xi in x:
        united[uf.find(xi)] += 1
    
    ans = 0
    for key, val in united.items():
        ans += x_counter[key] * y_counter[key] - val
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 72412
import java.util.Scanner;

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

        int i;
        char [] text = sc.nextLine().toCharArray();

        for(i = 0; i < text.length; i++) {
            if(text[i] >= 'A' && text[i] <= 'Z'){
                text[i] = (char)(text[i] + 0x20);
            }else if(text[i] >= 'a' && text[i] <= 'z'){
                text[i] = (char)(text[i] - 0x20);
            }
        }



        System.out.printf("%s\n",new String(text));
    }
}



Measured memory_bytes: 26260
// -*- coding:utf-8-unix -*-

use proconio::input;
use ascii::AsciiString;
use ascii::AsciiChar;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        s :AsciiString,
        t :AsciiString,
    }

    let slen :usize = s.len();
    let tlen :usize = t.len();

    let mut skip_table :Vec<Vec<isize>> = vec![vec![-1;slen];26];
    for i in 0..26 {
        let mut last_match :isize = -1;
        for j in 0..slen {
            if (s[slen-1-j].as_byte() - AsciiChar::from_ascii('a').unwrap().as_byte()) as usize == i {
                last_match = (slen-1-j) as isize;
            }
            if last_match != -1 {
                skip_table[i][slen-1-j] = last_match - ((slen-1-j) as isize);
            }
        }
        for j in 0..slen {
            if (s[slen-1-j].as_byte() - AsciiChar::from_ascii('a').unwrap().as_byte()) as usize == i {
                last_match = (slen-1-j) as isize;
            }
            if (last_match != -1) && (last_match < ((slen-1-j) as isize)) {
                skip_table[i][slen-1-j] = last_match + (slen as isize) - ((slen-1-j) as isize);
            }
        }
    }
    let mut i :usize = 0;
    for j in 0..tlen {
        let nowchar = (t[j].as_byte() - AsciiChar::from_ascii('a').unwrap().as_byte()) as usize;
        if skip_table[nowchar][i%slen] == -1 {
            println!("-1");
            return;
        }
        i += skip_table[nowchar][i%slen] as usize;
        i += 1;
    }
    println!("{}", i);
}


Measured memory_bytes: 22744
N,Y=map(int,input().split())
a=0
b=0
c=0

for i in range(2001):
    for j in range(2001):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y and k>=0:
            
            a=i
            b=j
            c=N-i-j
        else:
            pass

if a==0 and b==0 and c==0:
    print(-1,-1,-1)
else:
    print(a,b,c)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void){
    char S[101];
    char T[101];
    scanf("%s", S);
    scanf("%s", T);
    int n = strlen(S);
    int count = 0;
    for(int i = 0; i < n ; i++){
         if(count != -1 && S[i] == T[0]){
            count = 0;
            for(int j = 0; j < n; j++){
                if(S[(i + j) % n] == T[j]){
                    count += 1;
                }
                if (count == n){
                    count = -1;
                    break;
                }
            }
         }
    }
    printf("%s\n", (count == -1) ? "Yes" : "No");
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;

int main()
{
	int i,s=0,v[100],wt,n,m=-1,j; ll w[100];
	cin>>n>>wt;
	for(i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
		s+=v[i];
	}
	ll dp[n][s+1];
	for(i=0;i<n;i++)
	{
		for(j=0;j<=s;j++) dp[i][j]=-1;
	}
	dp[0][0]=0; dp[0][v[0]]=w[0];
	for(i=1;i<n;i++)
	{
		for(j=0;j<=s;j++)
		{
			if(dp[i-1][j]!=-1)
			{
//				cout<<dp[i-1][j]<<" ";
				if(dp[i-1][j+v[i]]!=-1)
				dp[i][j+v[i]]=min(dp[i-1][j+v[i]],dp[i-1][j]+w[i]);
				else dp[i][j+v[i]]=dp[i-1][j]+w[i];
				if(dp[i][j]==-1) dp[i][j]=dp[i-1][j];
			}
//			dp[i][j]=dp[i-1][j];
		}
	}
//	for(i=0;i<n;i++)
//	{
//		for(j=0;j<=s;j++) cout<<dp[i][j]<<" ";
//		cout<<"\n";
//	}
	for(j=0;j<=s;j++)
	{
		if(dp[n-1][j]!=-1 && dp[n-1][j]<=wt)
		m=j;
		
	}
	cout<<m;
	return 0;

}

Measured memory_bytes: 78336
#include<iostream>
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m){
		int a[n][m];
		int b[m];
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
				cin>>a[i][j];
		}
		for(int i=0;i<m;i++)
			cin>>b[i];
		int c[n];
		for(int i=0;i<n;i++)
			c[i]=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				c[i]+=a[i][j]*b[j];
			} 
		}
		for(int i=0;i<n;i++){
			cout<<c[i]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//

vector<bool> sieve(long long max){ // 0 <= x <= max までの素数を調べ、返す。
    vector<bool> isPrime;
    
    if(max+1 > isPrime.size()){     // resizeで要素数が減らないように
        isPrime.resize(max+1,true); // isPrimeに必要な要素数を確保
    } 
    isPrime[0] = false; // 0は素数ではない
    isPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる (i*iで実現している)
        if(isPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                isPrime[i*j] = false;      // 素数ではない
    
    return isPrime;
}

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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int q;
    cin >> q;
    vector<bool> primes = sieve(MAX);
    
    vector<int> primeCnt(MAX);
    rep(i, MAX){
        if(i == 0) continue;
        primeCnt[i] = (primes[i] && primes[(i+1)/2]) + primeCnt[i-1];
    }

    rep(i, q){
        int l, r;
        cin >> l >> r;
        print(primeCnt[r] - primeCnt[l-1]);
    }
    
    
    return 0;
}


Measured memory_bytes: 1024
using System;

class program
{

    public static void Main()
    {
        string str = Console.ReadLine();
        var q = int.Parse(Console.ReadLine());

        for (int i = 0; i < q; i++)
        {
            var query = Console.ReadLine().Split(' ');
            int a,b;

            switch (query[0])
            {
                case "replace":
                    string rep = "";
                    a = int.Parse(query[1]);
                    b = int.Parse(query[2]);
                    string p = query[3];
                    for (int l = 0, n = 0; l < str.Length; l++)
                    {
                        if (a <= l && b >= l)
                        {
                            rep += p[n];
                            n++;
                        }
                        else
                        {
                            rep += str[l];
                        }
                    }
                    str = rep;
                        break;
                case "reverse":
                    string restr = "";
                    a = int.Parse(query[1]);
                    b = int.Parse(query[2]);
                    for (int j = 0, k = b; j < str.Length; j++)
                    {
                        if (a <= j && b >= j)
                        {
                            restr += str[k];
                            k--;                           
                        }
                        else
                        {
                            restr += str[j];
                        }
                    }
                    str = restr;
                        break;
                case "print":
                        Console.WriteLine(str.Substring(int.Parse(query[1]) , int.Parse(query[2]) - int.Parse(query[1]) + 1));
                    break;
            }
        }
    }
}

Measured memory_bytes: 6048
#include <iostream>
#include <cmath>
#include <cctype>
#include<cstdio>
#include <string>
#include<algorithm>
using namespace std;
int main(){
    string s;
    cin>>s;
    transform(s.begin(),s.end(),s.begin(),::tolower);
    int ans=0;
    while(true){
        string u;
        cin>>u;
        if(u=="END_OF_TEXT")break;
        transform(u.begin(),u.end(),u.begin(),::tolower);
        if(s==u)ans++;
        
        
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////
#define N 500004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return po(mod(mod(i)*mod(i)),p/2);
    else  return mod(mod(i)*po(i,p-1));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    else if(n==0)return 1;
    else return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}
ll bunbo(ll n){
    return po(n,i_5);
}


int main(){fastio
    calc();
    ll n,m,k;cin>>n>>m>>k;
    ll last=kai2[k-2];
    ll nowu=mod(n*m-2);
    rep(i,1,k-2){
        last=mod(last*nowu);
        nowu--;
        if(nowu<0)nowu=mod(nowu);
    }
    ll s[N];s[0]=0;rep(i,1,N-1)s[i]=s[i-1]+i;
    ll sum1=0,sum2=0;
    rep(i,1,m){
        sum1+=s[i-1]+s[m-i];
    }
    sum1=mod(mod(sum1*n)*n);
    rep(i,1,n){
        sum2+=s[i-1]+s[n-i];
    }
    sum2=mod(mod(sum2*m)*m);
    
    //cout<<sum1<<" "<<sum2<<endl;
    sum1=mod(sum1+sum2);
    last=mod(last*sum1);
    last=mod(last*bunbo(2));
    cout<<last<<endl;
    
    return 0;
}




Measured memory_bytes: 15384
//2019年12月8日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElms(&a[0], a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


ll alist[100005];
ll blist[100005];


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

	//{b+a,a,ind}
	priority_queue<
		array<ll,3>
	> q;
	rep(i,n){
		ll a,b;
		cin >> a >> b;
		q.push({b+a,a,i});
		alist[i] = a;
		blist[i] = b;
	}

	ll ans = 0;
	bool flag = false;
	while(!q.empty()){
		array<ll,3> tmp = q.top();
		q.pop();
		if(flag){
			ans-=blist[tmp[2]];
		}
		else{
			ans+=alist[tmp[2]];
		}
		flag = !flag;
	}

	prints(ans);


	return 0;
}



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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


void solve(string b){
    if (b == "A") cout << 'T' << endl;
    if (b == "C") cout << 'G' << endl;
    if (b == "G") cout << 'C' << endl;
    if (b == "T") cout << 'A' << endl;
}

int main() {
  string b;
    cin >> b;
  solve(b);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = ReadLongs();
            var A = inputs[0];
            var B = inputs[1];

            for (int i = 0; ; i++)
            {
                if (i == 0 && B == 1)
                {
                    return 0;
                }
                else if (i == 1 && A >= B)
                {
                    return 1;
                }
                else if ((A - 1) * i + 1 >= B)
                {
                    return i;
                }
            }
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 11348
# ARC069D - Menagerie (ABC055D)
def check(a: int, b: int, S: str) -> list:
    ret, cur, prev = [], a, b
    for i in S:
        ret += [cur]
        if cur ^ (i == "o"):  # oSo or oWx
            prev, cur = cur, prev ^ 1  # both neighbors are different
        else:  # oSx or oWo
            prev, cur = cur, prev  # both are the same
    flg = cur == a and prev == b  # check the consistency of input and result
    return ret if flg else []


def main():
    N = int(input())
    S = input().rstrip()
    for a in range(2):
        for b in range(2):
            ans = check(a, b, S)
            if ans:
                print("".join("S" if i else "W" for i in ans), sep="")
                return
    print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

int t[MAXN];

signed main(){
	
	int n,c,k;cin >>n>>c>>k;
	
	int ans = 0;
	int cnt = 0;
	int pret = 0;
	
	rep(i,n) cin>>t[i];
	sort(t,t+n);
	
	rep(i,n)
	{
		int tt;tt = t[i];
		if(pret == 0)
		{
			pret=tt;
			cnt++;
			if(cnt == c)
			{
				ans++;
				cnt = 0;
				pret = 0;
			}
			continue;
		}
		
		if(tt-pret<=k) cnt++;
		else
		{
			ans++;
			cnt = 1;
			pret = tt;
		}
		
		if(cnt == c)
		{
			ans++;
			cnt = 0;
			pret = 0;
		}
	}
	
	if(cnt) ans++;
	
	cout << ans << endl;
		
	
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    double x, h;
    cout << setprecision(6) << setiosflags(ios::fixed);
    while (cin >> x >> h, x || h) {
        cout << (x * x + 2 * sqrt(h * h + x * x / 4) * x) << endl;
    }

    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, Q; cin >> N >> Q;
	vector<tuple<int, int, int>> dats(N);
	for (auto &dat : dats) {
		int s, t, x; cin >> s >> t >> x;
		dat = tie(s, t, x);
	}
	vint D(Q); cin >> D;
	vvint inst(Q+1);
	for (auto &dat : dats) {
		int s, t, x;
		tie(s, t, x) = dat;
		int l = lower_bound(begin(D), end(D), s-x) - begin(D);
		int r = lower_bound(begin(D), end(D), t-x) - begin(D);
		inst[l].push_back(x);
		inst[r].push_back(-x);
	}

	multiset<int> cur;
	for (int i = 0; i < Q; i++) {
		for (auto &in : inst[i]) {
			if (in < 0) cur.erase(cur.find(-in));
			else cur.insert(in);
		}
		cout << (cur.size() == 0 ? -1 : *begin(cur)) << el;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}

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

class C
{
	static void Main()
	{
		n = int.Parse(Console.ReadLine());
		f = new int[n + 1];
		f[0] = 1;
		for (int i = 1; i <= n; i++) f[i] = i * f[i - 1];

		Console.WriteLine(Math.Abs(Order() - Order()));
	}

	static int n;
	static int[] f;

	static int Order()
	{
		var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var l = Enumerable.Range(1, n).ToList();
		var r = 0;
		for (int i = 0; i < n; i++)
		{
			r += l.IndexOf(p[i]) * f[n - 1 - i];
			l.Remove(p[i]);
		}
		return r;
	}
}


Measured memory_bytes: 13280
N = int(input())
A = input()
w = [A[0] == "W"]
for i in range(1, N):  w.append(w[-1] + (A[i] == "W"))
e = [A[0] == "E"]
for i in range(1, N):  e.append(e[-1] + (A[i] == "E"))
ans = min(e[-1] - e[0], w[-2])
for i in range(1, N - 1):  ans = min(ans, w[i - 1] + e[-1] - e[i])
print(ans)

Measured memory_bytes: 101308
chomp($N=<>);
@a=split/ /,<>;for($i=0;$i<$N-1;$i++){push @b,$a[$i] if($a[$i]+1==$a[$i+1])}
$s+=$_ for split/ /,<>;
@c=split/ /,<>;
foreach $i(@b){$s+=$c[$i-1]}
print $s;

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        int ans=0;
        for (int i=0; i<N; i++) {
            ans = ans + (L+i);
        }
        
        if (L >= 0) {
            ans = ans - L;
        } else if (L+N <= 0) {
            ans = ans - (L+N-1);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
const int MOD = 1e9 + 7;
int mod(long long x){return (x % MOD + MOD ) % MOD;}
int main(){
    long long sum = 0 , ans = 0;
    int N;
    cin >> N;
    int arr[N];
    for (int i = 0 ; i < N ; i++)
        cin >> arr[i] , sum += arr[i];

    for (int i = 0 ; i < N - 1 ; i++){
        sum = mod(sum - arr[i]);
        ans = (ans + sum * arr[i] % MOD) % MOD;
    }
    cout << ans << endl;
}


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

char const* data1[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int data2[] = {3, 6, 0, 3, 5, 1, 3, 6, 2, 4, 0, 2};

int main(void)
{
    int m, d;
    while (cin >> m >> d && m!=0 && d!=0) {
        int a = (data2[m-1] + d-1)%7;
        cout << data1[a] << endl;;
    }
    return 0;
}



Measured memory_bytes: 2972
#include<stdio.h>
#include <string>
#include <iostream>

int main(){
  char s[10*10*10*10*10];
  char jo;
	int kai = 0;
  scanf("%s",&s);
  jo = s[0];
	int i = 1;
  while( s[i] == '0' || s[i] == '1'){
    if(s[i] == jo){
      kai++;
      if(jo == '0'){
        jo = '1';
      }else if (jo == '1'){
        jo = '0';
      }
    }else{
      jo = s[i];
    }
    i++;
  }
 
  printf("%d",kai);
}

  

Measured memory_bytes: 384
h,w = map(int,input().split())
C = [list(input()) for i in range(h)]

queue = []
visited = [] 
visited = [[0 for i in range(w)] for i in range(h)]
ans = 0

for i in range(h):
    for j in range(w):
        if C[i][j] == '.':
            queue.append([i,j])
            visited[i][j] = 1

            dy_dx = [[1,0],[0,1],[-1,0],[0,-1]]

            while len(queue) > 0:
                now = queue.pop(0)
                for k in range(4):
                    y = now[0]+dy_dx[k][0]
                    x = now[1]+dy_dx[k][1]
                    if 0 <= y < h and 0 <= x < w:
                        if C[y][x] != '#' and visited[y][x] == 0:
                            visited[y][x] = visited[now[0]][now[1]]+1 #移動回数のカウント
                            queue.append([y,x])
                    
        for l in range(h):
            for m in range(w):
                ans = max(ans,visited[l][m])
            
        queue = []
        visited = [[0 for i in range(w)] for i in range(h)]              
        
print(ans-1)

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

int main() {
  long n,k,ans=-1000000000000000000;
  cin >> n >> k;
  vector<long> p(n),c(n),lpsum,lpnum(n,-1),lpnum2(n);
  vector<vector<long>> lp;
  for(long i=0;i<n;i++) cin >> p[i];
  for(long i=0;i<n;i++) cin >> c[i];
  for(long i=0;i<n;i++) {
    if(lpnum[i]==-1) {
      long j=i;
      lp.push_back({});
      lpsum.push_back(0);
      long aaa=0;
      while(lpnum[j]==-1) {
        lpnum[j]=lp.size()-1;
        lpnum2[j]=aaa;
        lp.back().push_back(j);
        lpsum.back()+=c[j];
        j=p[j]-1;
        aaa++;
      }
    }
  }
  for(long i=0;i<n;i++) {
    if(lp[lpnum[i]].size()<=k) {
      if(lpsum[lpnum[i]]<=0) {
        long x=0;
        for(long j=1;j<=lp[lpnum[i]].size();j++) {
          x+=c[lp[lpnum[i]][(lpnum2[i]+j)%lp[lpnum[i]].size()]];
          ans=max(ans,x);
        }
      } else {
        long x=lpsum[lpnum[i]]*(k/lp[lpnum[i]].size());
        ans=max(ans,x);
        for(long j=1;j<lp[lpnum[i]].size();j++) {
          x+=c[lp[lpnum[i]][(lpnum2[i]+j)%lp[lpnum[i]].size()]];
          if(j<=k%lp[lpnum[i]].size()) ans=max(ans,x);
          else ans=max(ans,x-lpsum[lpnum[i]]);
        }
      }
    } else {
      long x=0;
      for(long j=1;j<=k;j++) {
        x+=c[lp[lpnum[i]][(lpnum2[i]+j)%lp[lpnum[i]].size()]];
        ans=max(ans,x);
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
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;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;

int main(){
    ll n, ans = -1; cin >> n;
    map<ll, ll> mp;
    rep(i, n){
        ll a; cin >> a;
        mp[a]++, mp[a-1]++, mp[a+1]++;
    }
    for(auto p: mp){
        chmax(ans, p.second);
    }
    cout << ans << endl;
}


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

const int MOD = 1000000007;
const int N = 1000001;

long long dp[N][4];

void solve() {
  int n;
  cin >> n;
  
  if (n == 1) {
    cout << 0 << '\n';
    return;
  }
  memset(dp, -1, sizeof(dp));
  
  function<long long(int, int)>
  f = [&](int i, int b) -> long long {
    if (i <= 0) return b == 3;
    if (dp[i][b] != -1) return dp[i][b];
    long long ret = 0;
    ret += f(i - 1, b) * 8 % MOD;
    ret %= MOD;
    ret += f(i - 1, b | 1) % MOD;
    ret %= MOD;
    ret += f(i - 1, b | 2) % MOD;
    ret %= MOD;
    return dp[i][b] = ret;
  };
  
  cout << f(n, 0) << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 144204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,sum;
  cin>>a>>b;
  sum=0;
  
  for(;a<=b;a++){
    int x,y,z,w;
    w=a%10;
    z=a%100/10;
    y=a%10000/1000;
    x=a/10000;
    
    if(x==w && y==z)
      sum++;
  }
  cout << sum <<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll a,b;
  cin >> a >> b;
  if(a%b==0)printf("-1");
  else printf("%lld",a);
}

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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define EPS (1e-7)
#define INF ((ll)1e9+7)
#define PI (acos(-1))
#define c(a) cout<<a<<"\n";
using namespace std;

int main() {
	speed;
	int n;
	vector<string>w;
	cin >> n;
	rep(i, n) {
		string a;
		cin >> a;
		w.push_back(a);
	}
	bool flag = true;
	ffor(i,0, n) {
		ffor(j, i+1, n) {
			if (w.at(i).compare(w.at(j)) == 0) {
				flag = false;
			}
		}
	}
	rep(i, n - 1) {
		if (w.at(i)[w.at(i).size()-1]!=w.at(i+1)[0]) {
			flag = false;
		}
	}
	if (flag) { c("Yes"); }
	else { c("No"); }
	ed;
	return 0; 
}



Measured memory_bytes: 256
n=int(input())
h=[int(i) for i in input().split()]
ans=chk=1
t=h[0]
for i in range(1,n):
    if h[i]<=t:
        chk+=1
        ans=max(ans,chk)
    else:
        chk=1
    t=h[i]
print(ans-1)

Measured memory_bytes: 63984
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int[] x = new int[5];
		int index = 0;
		for(int i = 0; i < 5; i++) {
			x[i] = s.nextInt();
			if(x[i] == 0) {
				index = i + 1;
			}
		}
		System.out.println(index);
	}
}

Measured memory_bytes: 35740
import java.util.Scanner;

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

		int n = scanner.nextInt();

		String a = scanner.next();

		String b = scanner.next();

		StringBuilder sb = new StringBuilder();

		for(int i=0; i<n; i++) {
			sb.append(a.charAt(i));
			sb.append(b.charAt(i));
		}

		System.out.println(sb.toString());		

	}

}

Measured memory_bytes: 21332
unittest
{
	assert( [ "5" ].parse.expand.solve == "YES" );
	assert( [ "6" ].parse.expand.solve == "NO" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.strip.to!( long );
	return tuple( x );
}

auto solve( long x )
{
	return ( x == 7 || x == 5 || x == 3 ) ? "YES" : "NO";
}


Measured memory_bytes: 256
debug = 0

if debug == 1:
	N,M=5,3
	w=[]
	w.append([1,-2,3])
	w.append([-4,5,-6])
	w.append([7,-8,-9])
	w.append([-10,11,-12])
	w.append([13,-14,15])

	x = [0]*N
	y = [0]*N
	z = [0]*N
	for i in range(N):
		x[i],y[i],z[i] = map(int, w[i])
else:
	N,M = map(int, raw_input().split())
	x = [0]*N
	y = [0]*N
	z = [0]*N
	for i in range(N):
		x[i],y[i],z[i] = map(int, raw_input().split())

ans = -10000000000*N

for xs in [-1,1]:
	for ys in [-1,1]:
		for zs in [-1,1]:
			T = []
			for i in range(N):
				T += [[x[i]*xs+y[i]*ys+z[i]*zs, x[i]*xs, y[i]*ys, z[i]*zs]]
			T = sorted(T)[::-1]
			a = 0
			xt = 0
			yt = 0
			zt = 0
			for j in range(M):
				a += T[j][0]
				xt += T[j][1]
				yt += T[j][2]
				zt += T[j][3]
			if xt>=0 and yt>=0 and zt>=0:
				ans = max(ans, a)
print ans


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

using namespace std;

int main()
{
    ///{}
    /**ios_base::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);*/
    long long k;
    cin>>k;
    vector<long long>v(50ll,49ll+k/50ll);
    long long m=k%50ll;
    long long mo=0;
    for(int i=0;i<m;i++){
        v[i]+=50ll-mo-m+1ll;
        mo++;

    }
    for(int i=m;i<50;i++){
        v[i]+=-m;

    }
    cout<<50<<'\n';
    for(int i=0;i<50;i++)
        cout<<v[i]<<' ';
    return 0;
}
/**
10
0 1 1 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 1 1 1 1
1 1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 1 1 0 1
1 1 1 1 1 1 1 1 1 0
*/


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

	ll x = tx - sx;
	ll y = ty - sy;

	ll X = ((x < 0) ? -x : x);
	ll Y = ((y < 0) ? -y : y);
	rep(i, 0, X) {
		cout << ((x > 0) ? "R" : "L");
	}
	rep(i, 0, Y) {
		cout << ((y > 0) ? "U" : "D");
	}
	rep(i, 0, X) {
		cout << ((x > 0) ? "L" : "R");
	}
	rep(i, 0, Y + 1) {
		cout << ((y > 0) ? "D" : "U");
	}
	/////////////////
	rep(i, 0, X + 1) {
		cout << ((x > 0) ? "R" : "L");
	}
	rep(i, 0, Y + 1) {
		cout << ((y > 0) ? "U" : "D");
	}
	cout << ((x > 0) ? "L" : "R");
	cout << ((y > 0) ? "U" : "D");
	rep(i, 0, X + 1) {
		cout << ((x > 0) ? "L" : "R");
	}
	rep(i, 0, Y + 1) {
		cout << ((y > 0) ? "D" : "U");
	}
	cout << ((x > 0) ? "R" : "L");
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class BIMissYou {
public:
	void solve(std::istream& in, std::ostream& out) {
        string S;
        in >> S;
        int n = S.size();
        string ans = "";
        REP(i, n) {
            ans += 'x';
        }
        out << ans << '\n';
	}
};


int main() {
	BIMissYou solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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;
}

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

  int ans = H * W - h * W - H * w + h * w;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        ll tmp;
        cin >> tmp;
        a[i] = tmp-i-1;
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    rep(i, n){
        ans += abs(a[i] - a[n/2]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792