akhauriyash/Code-Regression huggingface dataset:
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in R(V)]
    FromStdin=True if ls==None else False
    for i in R(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

ans=0

l,r,d=LI()

for i in range(l,r+1):
    if i%d==0:
        ans+=1
        
    
print(ans)




Measured memory_bytes: 83320
/**
*   Author : Krishna Purohit
*/

#include "bits/stdc++.h"
#define sync ios_base::sync_with_stdio(false)
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define mod 10000000007
using namespace std;

ll t, n;

int main() {
    sync;
    cin >> t;
    cout << t*t << endl;
    return 0;
}


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

int main() {
    
    int n, d;
    cin >> n >> d;
    
    double x, y;
    int cnt=0;
    for(int i=0; i<n; i++){
        cin >> x >> y;
        double res;
        res = sqrt(x*x + y*y);
        
        if(res<=d) ++cnt;
    }
    
    cout << cnt << endl;
    
    
    
	return 0;
}

Measured memory_bytes: 3760
c = [[int(elem) for elem in input().split(' ')] for _ in range(3)]
assert len(c) == 3
assert len(c[0]) == 3

c_11 = c[0][0]
for a1 in range(c_11 + 1):
    b1 = c_11 - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    if (a2 + b2 != c[1][1]) or (a2 + b3 != c[1][2]) \
        or (a3 + b2 != c[2][1]) or (a3 + b3 != c[2][2]):
        print("No")
        break
    else:
        print("Yes")
        break


Measured memory_bytes: 3064
from operator import itemgetter
N, C = list(map(int, input().split()))

BA = []
for i in range(N):
  BA.append(list(map(int, input().split())))

BA.sort(key=itemgetter(2,0,1))

# 0.5刻みのIMOS
IMO = [0] * (200010)
prev_c = -1
prev_t = -1
tmax = 0
for i in range(N):
  s, t, c = BA[i]
  if prev_c == c and prev_t == s:
    IMO[2*s+1] += 1
    IMO[2*t+1] -= 1
  else:
    IMO[2*s-1] += 1
    IMO[2*t+1] -= 1
    
  prev_t, prev_c = t,c
  tmax = max(tmax, t)
  
for i in range(2*tmax+5):
  IMO[i+1] += IMO[i]
  
print(max(IMO[:2*tmax+5]))
#print(IMO[:2*tmax+5])

Measured memory_bytes: 37880
import java.util.Scanner;

public class Main {

	static int Merge(int A[],int left,int mid,int right){
		int n1=mid-left;
		int n2=right-mid;
		int i,j,k;
		int[] L=new int[n1+1];
		int[] R=new int[n2+1];

		for(i=0;i<n1;i++)L[i]=A[left+i];
		for(i=0;i<n2;i++)R[i]=A[mid+i];
		L[n1]=1000000000;
		R[n2]=1000000000;

		i=j=0;
		for(k=left;k<right;k++){
			if(L[i]<=R[j]){
				A[k]=L[i];
				i++;
			}else{
				A[k]=R[j];
				j++;
			}
		}
		return right-left;
	}

	static int Merge_Sort(int A[],int left,int right){
		int mid,res=0;
		if(left+1<right){
			mid=(left+right)/2;

			res+=Merge_Sort(A,left,mid);
			res+=Merge_Sort(A,mid,right);
			res+=Merge(A,left,mid,right);

		}
		return res;
	}

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			int[] S=new int[n+1];
			for(int i=0; i<n; i++) {
				S[i]=sc.nextInt();
			}
			int x=Merge_Sort(S,0,n);

			for(int i=0;i<n;i++){
				if(i>0) System.out.print(" ");
				System.out.print(S[i]);
			}
			System.out.println();
			System.out.println(x);
		}

	}
}


Measured memory_bytes: 170156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string S;
    cin >> S;
    int n = S.length();
    ll a[n + 1]{};
    ll ans = 0;
    int k = 0;
    for (int i = 0; i < n; i++) {
        if (S[i] == '<') {
            a[i + 1] = a[i] + 1;
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (S[i] == '>') {
            if (a[i + 1] >= a[i]) {
                a[i] = a[i + 1] + 1;
            }
        }
    }
    for (ll i : a) {
        ans += i;
    }
    // for (int i : a) {
    //     cout << i << " ";
    // }
    // cout << "\n";
    cout << ans << "\n";
    return 0;
}

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

long long n,h,w,d,x[100009],y[100009],dp[1000009];

int main()
{
	ios::sync_with_stdio(false);
	
	cin>>h>>w>>d;
	
	for(int i=1;i<=h*w;i++)
	{
		int p;
		cin>>p;
		x[p]=(i-1)/w;
		y[p]=(i-1)%w;
	}
	
	n=h*w;
	
	for(int i=1;i<=n;i++)
	{
		if(i<=d)
			dp[i]=0;
		else
			dp[i]=dp[i-d]+fabs(x[i]-x[i-d])+fabs(y[i]-y[i-d]);
	}
	
	int q;
	cin>>q;
	
	for(int i=1;i<=q;i++)
	{
		int l,r;
		cin>>l>>r;
		cout<<dp[r]-dp[l]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4992
import queue
N, M = map(int, input().split())
l = [[] for i in range(N)]
for i in range(M):
        a, b = map(int, input().split())
        l[a - 1].append(b - 1)
        l[b - 1].append(a - 1)
c = [0] * N 
ans = 1
q = queue.Queue()
for j in range(N):
        q.put(l[j])
        u = 0 
        while not q.empty():
                temp = q.get()
                for k in temp:
                        if c[k]:
                                continue
                        c[k] = 1 
                        u += 1
                        q.put(l[k])
        ans = max(ans, u)
print(ans) 

Measured memory_bytes: 115452
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    
    int n,k;
    cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    Rort(v);
    rep(i,min(k,n))v[i]=0;
    ll ans=0;
    rep(i,n)ans+=v[i];
    fin(ans);
}



Measured memory_bytes: 1024
#include <stdio.h>
int main(){
	int a, b;
	scanf("%c %c", &a, &b);
	if(a=='D' && b=='H'){
		printf("D\n");
	}
	else if(a=='H' && b=='H'){
		printf("H\n");
	}
	else if(a=='H' && b=='D'){
		printf("D\n");
	}
	else if(a=='D' && b=='D'){
		printf("H\n");
	}
	return 0;	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define pb push_back
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fs(s) for(ll i=0;s[i]!='\0';i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define gcd(a,b) __gcd(a,b)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define c1(x) __builtin_popcountll(x)
#define setprs(x) cout << fixed << setprecision(x);
#define endl '\n'
const ll mod=1e9 + 7;
const ll sz=2e5 + 100;
const double PI =3.14159265;
ll power(ll a, ll b, ll m = mod){if(b==0)return 1;else if(b==1)return a%m;else{ll t=power(a,b>>1,m);t=((t%m)*(t%m))%m;if(b&1)return ((t%m)*(a%m))%m;else return t%m;}}
 
//--------------------------------------------------------

llu mulmod(llu a,llu b,llu mod=mod)
{
  llu res = 0;
  while(b)
  {
    if(b&1) res=(res+a)%mod;

    a = (a+a)%mod;
    b>>=1;
  }
  return res;
}

void solve()
{
    int n;
    cin >> n;
    llu sum = 0;
    int a[sz];
    f(i,0,n){
        cin >> a[i];
        sum = (sum + a[i]);
    }
    llu ans = 0;
    f(i, 0, n-1){
        sum = (sum - a[i]);
        ans = (ans%mod + (sum%mod * a[i]%mod)%mod)%mod;
    }
    cout << ans;

} 
 
int32_t main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 4412
iterate = int(input())
cnt = 0
for i in range(iterate):
  dice = list(map(lambda x: int(x), input().split()))
  if dice[0]==dice[1]:
    cnt += 1
  else:
    cnt = 0
  if cnt==3: break
    
if cnt!=3: print("No")
else: print("Yes")

Measured memory_bytes: 9212
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    let mut v:Vec<char>=Vec::new();
    for i in 0..a.len(){
        v.push(a[i]);
        if i==3 {v.push(' ')}
    }
    let v:String=v.iter().collect();
    println!("{}",v)
}

Measured memory_bytes: 2188
def combination(n, r):  # nCrを求める
    r = min(n - r, r)
    result = 1
    for i in range(n, n - r, -1):
        result *= i
    for i in range(1, r + 1):
        result //= i
    return result


n,a,b = map(int,input().split())
v = list(map(int,input().split()))
v.sort(reverse=True)
ans1 = sum(v[:a])/a
num1 = v[:a].count(v[a-1])
num2 = v[a:n].count(v[a-1])

ans2 = 0
if v[0] == v[a]:
    for i in range(a,n):
        if v[i] == v[a-1]:
            idx = i + 1
    for i in range(a,min(b,idx) + 1):
        ans2 += combination(num1 + num2, i)
else:
    ans2 = combination(num1 + num2,num1)

print(ans1)
print(ans2)

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


int main(){
string S;
int n,m=0;
cin >> S;
n=S.size();
for(int i=0;i<n/2;i++){
  if(S[i]!=S[n-1-i]){m++;}
}
for(int i=0;i<n/4;i++){
  if(S[i]!=S[(n-1)/2-1-i] || S[n-1-i]!=S[(n+1)/2+i] ){m++;}
}
if(m==0){
  cout << "Yes" << endl;
}else{
    cout << "No" << endl;
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <iterator>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
ll N;
ll A[200000];
ll S[200000];
int main(){
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  S[0]=A[0];
  FOR(i,1,N){
    S[i]=S[i-1]+A[i];
  }
  sort(S,S+N);
  ll ans=0;
  ll now=0;
  while(now<N&&S[now]!=0){
    now++;
  }
  ll c=0;
  while(now<N&&S[now]==0){
    now++;
    c++;
  }
  ans+=c;
  now=0;
  while(now<N){
    ll cnt=1;
    while(now<N-1&&S[now]==S[now+1]){
      now++;
      cnt++;
    }
    ans+=cnt*(cnt-1)/2;
    now++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3328
n500 = int(input())
n100 = int(input())
n50 = int(input())
p = int(input())
ans = 0

for i in range(n500+1):
    for j in range(n100+1):
        for k in range(n50+1):
            temp = i*500+j*100+k*50 
            if temp == p:
                ans+=1

print(ans)

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int k = s.size();
	string a = "";
	string b = "";
	
	int ana = 0;
	if (k == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		for (int i = 0; i < k; i++)
		{
			if (i % 2 == 0)
			{
				if (s.at(i) == '0')
				{
					ana++;

				}
			}
			else
			{
				if (s.at(i) == '1')
				{
					ana++;
				}
			}

		}
		int anb = k - ana;
		int ans = min(ana, anb);

		cout << ans << endl;
	}
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))

lis=[0]
for i in range(n-1):
    if a[i]<a[i+1]:
        lis.append(0)
    else:
        lis.append(lis[i]+1)

lis.sort()
print(lis[n-1])


Measured memory_bytes: 14252
#include<cstdio>
#include<vector>
using namespace std;

#define i64 long long int
#define ran 101101

int n;
vector<pair<int, int> > e[ran];
int ans[ran];

void dfs(int cur, int last, i64 d) {
	ans[cur] = d%2;
	for(int i=0;i<(int)e[cur].size();i++) {
		int nxt = e[cur][i].first, v = e[cur][i].second;
		if(nxt==last) continue;
		
		dfs(nxt, cur, d+v);
	}
}

int main() {
	scanf("%d", &n);
	for(int i=1;i<n;i++) {
		int x, y, v; scanf("%d%d%d", &x, &y, &v);
		e[x].push_back(make_pair(y, v));
		e[y].push_back(make_pair(x, v));
	}
	
	dfs(1, -1, 0);
	
	for(int i=1;i<=n;i++) printf("%d\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 9984
N, K = (int(x) for x in input().split())
def sumcount(l, r):
    return (l+r)*(r-l+1)//2
num = 0
for i in range(K, N+2):
  l = sumcount(0,i-1)
  r = sumcount(N-i+1,N)
  num += r-l+1
print(num%(10**9+7))



Measured memory_bytes: 9184
import java.util.*;

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

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int moti[] = new int[N];

		boolean insFlg = false;

		ArrayList<Integer> ansList = new ArrayList<Integer>();

		for (int i=0; i<N; i++) {
			moti[i] = sc.nextInt();
		}


		for (int i=0; i<N; i++) {
			insFlg = true;
			for (int k : ansList) {
				if (moti[i] == k) {
					insFlg = false;
				}
			}
			if (insFlg) {
				ansList.add(moti[i]);
			}
		}

		System.out.println(ansList.size());
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
using namespace std;
struct ac{int a, b, c;} *x;
int n, **mem;
int jump(int i = 0, int last = 0)
{
    if(i == n)
        return 0;
    if(last != 1 && !~mem[i][0])
        mem[i][0] = x[i].a + jump(i + 1, 1);
    if(last != 2 && !~mem[i][1])
        mem[i][1] = x[i].b + jump(i + 1, 2);
    if(last != 3 && !~mem[i][2])
        mem[i][2] = x[i].c + jump(i + 1, 3);
    if(last == 1)
        return max(mem[i][1], mem[i][2]);
    else if(last == 2)
        return max(mem[i][0], mem[i][2]);
    else if(last == 3)
        return max(mem[i][0], mem[i][1]);
    else
        return max(mem[i][1], max(mem[i][0], mem[i][2]));
}
int main()
{
    //cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #endif
    scanf("%d", &n);
    x = new ac[n];
    mem = new int*[n];
    for(int i = 0; i < n; i++)
    {
        mem[i] = new int[3];
        mem[i][0] = mem[i][1] = mem[i][2] = -1;
    }
    for(int i = 0; i < n; i++)
        scanf("%d %d %d", &(x[i].a), &(x[i].b), &(x[i].c));
    printf("%d", jump());
}


Measured memory_bytes: 11520
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-6
#define inf LLONG_MAX
using namespace std;

int main() {
	speed;
	int n;
	double s = 0;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		s += 1 / double(v[i]);
	}
	cout << 1 / s;
}

Measured memory_bytes: 384
N = int(input())
X = list(map(int, input().split()))

X.sort()
tairyoku = 0
HP = []
for p in range(100):
    
    for i in range(N):
        tairyoku += (X[i] - p)**2

    HP.append(tairyoku)
    tairyoku = 0

print(min(HP))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] left = in.nextLongArray(n);
			long[] center = in.nextLongArray(n);
			long[] right = in.nextLongArray(n);

			PriorityQueue<Long> f = new PriorityQueue<>((e1, e2) -> {return e1.compareTo(e2);});
			PriorityQueue<Long> b = new PriorityQueue<>((e1, e2) -> {return -e1.compareTo(e2);});

			for (int i = 0; i < n; i++) {
				f.add(left[i]);
			}

			for (int i = 0; i < n; i++) {
				b.add(right[i]);
			}

			long[] sumL = new long[n+1];
			long[] sumR = new long[n+1];

			sumL[0] = f.stream().mapToLong(i -> i).sum();
			sumR[0] = b.stream().mapToLong(i -> i).sum();

			for (int k = 0; k < n; k++) {
				f.add(center[k]);
				sumL[k+1] = sumL[k] - f.remove() + center[k];
			}

			for (int k = 0; k < n; k++) {
				b.add(center[n-1-k]);
				sumR[k+1] = sumR[k] - b.remove() + center[n-1-k];
			}

			long ans = Long.MIN_VALUE;
			for (int i = 0; i < n+1; i++) {
				ans = Math.max(ans, sumL[i]-sumR[n-i]);
			}

			out.println(ans);

		}

	}


	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 67940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll h[303];
ll dp[303][303];
const ll INF = 1e17;

int main() {
  int n,k;
  cin >> n >> k;
  for(int i = 1; i <= n; i++) cin >> h[i];

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

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      ll tmp = INF;
      for(int k = 0; k < j; k++) {
	tmp = min(tmp,dp[i-1][k] + max(0ll,h[j] - h[k]));
      }
      dp[i][j] = tmp;
    }
  }

  ll ans = INF;
  for(int i = 0; i <= n; i++) {
    ans = min(ans,dp[n-k][i]);
  }
  cout << ans << endl;
}
  
      
      


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &e : a)
    cin >> e;
  sort(a.begin(), a.end());
  ll sum = 0;
  vector<ll> small, big;
  for (int i = 0; i < n; ++i)
  {
    if (i < n / 2)
      small.push_back(a[i]);
    else
      big.push_back(a[i]);
  }
  reverse(big.begin(), big.end());
  for (int i = 0; i < n / 2; ++i)
  {
    if (i == 0)
      sum += abs(big[0] - small[0]);
    if (i < big.size() - 1)
      sum += abs(big[i + 1] - small[i]);
    if (i < small.size() - 1)
      sum += abs(big[i] - small[i + 1]);
  }
  ll ans = sum;
  small.clear();
  big.clear();
  sum = 0;
  for (int i = 0; i < n; ++i)
  {
    if (i < (n - 1) / 2 + 1)
      small.push_back(a[i]);
    else
      big.push_back(a[i]);
  }
  reverse(big.begin(), big.end());
  for (int i = 0; i < n / 2; ++i)
  {
    if (i == 0)
      sum += abs(big[0] - small[0]);
    if (i < big.size() - 1)
      sum += abs(big[i + 1] - small[i]);
    if (i < small.size() - 1)
      sum += abs(big[i] - small[i + 1]);
  }
  ans = max(ans, sum);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a[n];For(i,0,n) cin>>a[i];
	ll ans=0;
	For(i,1,n-1){
		if(a[i]>a[i-1] && a[i]<a[i+1]) ans++;
		else if(a[i]<a[i-1] && a[i]>a[i+1]) ans++;
	}
	cout<<ans<<endl;











	
}

Measured memory_bytes: 256
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)

    if op == "?":
        break

    elif op == "+":
        print(a + b)

    elif str(op) == "-":
        print(a - b)

    elif str(op) == "*":
        print(a * b)

    elif str(op) == "/":
        print(a // b)

    else:
        break


Measured memory_bytes: 5596
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
w=[input() for i in range(n)]
li=[]
for i in range(n):
    if w[i] in li:
        print("No")
        quit()
    elif i>0 and w[i][0]!=w[i-1][-1]:
        print("No")
        quit()
    else:
        li.append(w[i])
print("Yes")

Measured memory_bytes: 38512
s = input()
table = [0 for i in range(2019)]
table[0] = 1
num = 0
d = 1
for c in s[::-1]:
    num += (int(c) * d)
    num %= 2019
    d *= 10
    d %= 2019
    table[num] += 1

ans = 0
for cnt in table:
    ans += cnt * (cnt - 1) // 2

print(ans)

Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[100005] = {};
signed main() {
    int N;
    string S;
    int K;
    cin >> N >> S >> K;
    for(int i = 0; i < N; i++) {
        if(S[i] != S[K-1]) {
            cout << '*';
        }
        else {
            cout << S[i];
        }
    }
    cout << endl;
}


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

int H,W,K;
vector<string> field;

int mass[10];

ll wans = 1e9;

int calc(){
    //cout<<"A"<<endl;
    vector<vector<int>> div(1);
    for(int i = 0;i < H-1;i++){
        div.back().push_back(i);
        if(mass[i] == 1){
            div.push_back(vector<int>());
        }
    }
    div.back().push_back(H-1);
    set<int> ans;
    vector<int> cnts(div.size());
    vector<int> _cnts;
    for(int i = 0;i < W;i++){
        int idx = 0;
        _cnts.clear();
        bool f = false;
        for(auto a : div){
            int _cnt = 0;
            for(auto b : a){
                if(field[b][i] == '1'){
                    _cnt++;
                }
            }
            if(_cnt + cnts[idx] > K){
                if(_cnt > K){
                    return 1e9;
                }else{
                    f = true;
                }
            }else{
                cnts[idx] += _cnt;
            }
            _cnts.push_back(_cnt);
            idx++;
        }
        if(f){
            for(int j = 0;j < cnts.size();j++){
                cnts[j] = _cnts[j];
                ans.insert(i);
            }
        }
    }
    ll q = 0;
    vector<int> QQ;
    for(int i = 0;i < 10;i++){
        if(mass[i] == 1)q++, QQ.push_back(i);
    }
    /*
    if(wans > q + ans.size()){
        cout<<q + ans.size()<<endl;
        cout<<"H"<<endl;
        for(auto a : QQ)cout<<a<<endl;;
        cout<<"W"<<endl;
        for(auto a : ans)cout<<a<<endl;
    }
    */
    return q + ans.size();
}

void zrk(int i){
    if(i == H-1){
        ll ans = calc();
        //cout<<ans<<endl;
        wans = min(ans, wans);
        return;
    }
    mass[i] = 0;zrk(i+1);
    mass[i] = 1;zrk(i+1);
}

int main(){
    cin >> H >> W >> K;
    for(int i = 0;i < H;i++){
        string s;cin >> s;
        field.push_back(s); 
    }
    zrk(0);
    cout<<wans<<endl;
    return 0;
}


Measured memory_bytes: 256
s = list(input())

lenS = len(s)

def f(p,c,i):
  n = c+int(s[i])
  if i == lenS-1:
    return p+n
  else:
    return f(p+n,0,i+1)+f(p,n*10,i+1)
  
print(f(0,0,0))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll MOD = 1e9 + 7;

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

    ll n;
    cin >> n;
    ll a;
    vll one(62);
    REP(i, n) {
        cin >> a;
        ll d = 0;
        while (a) {
            one[d++] += (a & 1LL);
            a >>= 1;
        }
    }
    ll res = 0, k = 1;
    REP(i, 62) {
        res += (((k * one[i]) % MOD) * (n - one[i])) % MOD;
        res %= MOD;
        k = (2 * k) % MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
//
using namespace std;

#ifndef MYLIBRARY_DIJKSTRA_HPP
#define MYLIBRARY_DIJKSTRA_HPP 1

#include <utility>
#include <queue>
#include <vector>

struct dijk_graph {
  using Cap = long long int;
  public:
    dijk_graph() : _n(0) {}
    dijk_graph(int n) : _n(n), g(n), dist(n), prev(n) {}

    void add_edge(int from, int to, Cap cap){
      assert(0 <= from && from < _n);
      assert(0 <= to && to < _n);
      assert(0 <= cap);
      g[from].push_back(_edge{to, cap});
    }

    void make_table(int start){
      assert(0 <= start && start < _n);

      std::fill(dist.begin(), dist.end(), _inf);

      prev[0] = -1;
      Q.push(q_data(0, start));
      while (Q.size() != 0){
        auto p = Q.top();
        Q.pop();
        Cap ud = p.first;
        Cap u = p.second;
        if (dist[u] < ud){
          continue;
        }
        dist[u] = ud;

        for (auto t : g[u]){
          Cap v = t.to;
          Cap vd = ud + t.cap;
          if (dist[v] > vd){
            dist[v] = vd;
            Q.push(q_data(vd, v));
            prev[v] = u;
          }
        }
      }
    }

    Cap get_dist(int u){
      return dist[u];
    }

    int get_prev(int u){
      return prev[u];
    }

  private:
    int _n;
    struct _edge {
        int to;
        Cap cap;
    };
    std::vector<std::vector<_edge>> g;
    std::vector<long long int> dist;
    std::vector<int> prev;
    using q_data = std::pair<Cap, int>;
    Cap _inf = 1000000000000000000;
    std::priority_queue<q_data, std::vector<q_data>, std::greater<q_data>> Q;
};

#endif  // MYLIBRARY_DIJKSTRA_HPP

int main(void){
  
  ll n, m;
  cin >> n >> m;
  
  dijk_graph g(n);
  for (ll i = 0; i < m; i++){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    
    g.add_edge(a, b, 1);
    g.add_edge(b, a, 1);
  }
  g.make_table(0);

  cout << "Yes" << endl;
  for (ll i = 1; i < n; i++){
    cout << g.get_prev(i) + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 18956
#include <stdio.h>

int main() {
	int N;
	int a1, a2, a3;
	scanf("%d", &N);
	
	a1 = N / 100;
	a2 = (N - (a1 * 100)) / 10 ;
	a3 = N % 10;
	if(a1 == 7 || a2 == 7 || a3 == 7){
		puts("Yes");
	}
	else {
		puts("No");
	}
	return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    sort(s.begin(), s.end());

    cout << (s == "abc" ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

ll div2(ll d, ll cnt){
  if(d%2 == 0){
    ++cnt;
    div2(d/2, cnt);
  } else{
    return cnt;
  }

}

int main() {
  ll n;
  cin >>n;
  vector<ll> a(n);
  rep(i, n)
    cin >> a[i];
  ll cnt=0;
  rep(i, n){
    cnt += div2(a.at(i), 0);
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int C=sc.nextInt();
		int[][] iwakan=new int[C][C];
		for(int i=0; i<C; i++) {
			for(int j=0; j<C; j++) {
				iwakan[i][j]=sc.nextInt();
			}
		}
		int[] mod0_color=new int[C];
		int[] mod1_color=new int[C];
		int[] mod2_color=new int[C];
		for(int i=0; i<C; i++) {
			mod0_color[i]=0;
			mod1_color[i]=0;
			mod2_color[i]=0;
		}
		for(int i=0; i<N; i++) {
			for(int j=0; j<N; j++) {
				if((i+j)%3==0) {
					mod0_color[sc.nextInt()-1]++;
				}
				else if((i+j)%3==1) {
					mod1_color[sc.nextInt()-1]++;
				}
				else if((i+j)%3==2) {
					mod2_color[sc.nextInt()-1]++;
				}
			}
		}
		//mod 0 基準
		long sum_iwa=Long.MAX_VALUE;
		long tmp_iwa=0;
		for(int i=0; i<C; i++) {		//mod 0の色
			for(int j=0; j<C; j++) {	//mod 1の色
				for(int k=0; k<C; k++) {//mod 2の色
					tmp_iwa=0;
					if(i!=j && j!=k && k!=i) {
						for(int l=0; l<C; l++) {
							if(i!=l) {
								tmp_iwa+=mod0_color[l]*iwakan[l][i];
							}
						}
						for(int l=0; l<C; l++) {
							if(j!=l) {
								tmp_iwa+=mod1_color[l]*iwakan[l][j];
							}
						}
						for(int l=0; l<C; l++) {
							if(k!=l) {
								tmp_iwa+=mod2_color[l]*iwakan[l][k];
							}
						}
						sum_iwa=Math.min(tmp_iwa, sum_iwa);
					}
				}
			}
		}
		pl(sum_iwa);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 39780
N, M = map(int, (input().split()))
L1 = [0 for i in range(N)]
L2 = [0 for j in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        L1[b - 1] = 1
    elif b == N:
        L2[a - 1] = 1
for i in range(N):
    if L1[i] == L2[i] == 1:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


Measured memory_bytes: 6312
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    vector<int64_t> L(87);
    L.at(0)=2;
    L.at(1)=1;
    for(int i=0;i<85;i++){
        L.at(i+2)=L.at(i)+L.at(i+1);
    }
    cout<<L.at(N)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){

    int i;
    int week;
    int debt;

    while ( (fscanf(stdin, "%d", &week)) != EOF){
        debt = 100; // ??????1000???
        for (i=0; i < week; i++){
            debt += ceil(debt * 0.05);
        }
        printf("%d\n", debt * 1000); // ??????.
    }

    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005

int main(){

    int n,k;
    cin >> n >> k;
    vector<bool> forbid(10,true);//使えない:false;
    int tmp;
    REP(i,k){
        cin >> tmp;
        forbid[tmp] = false;
    }

    /*******************************/
    //n円以上を構築

    bool flag = true;
    while(flag){
        bool exist = true;
        string s = to_string(n);
        REP(i,s.length()){
            if(forbid[s[i]-'0'] == false){
                exist = false;
                break;
            }
        }
        if(exist){
            cout << s << endl;
            return 0;
        }else{
            n++;
        }
    }



    return 0;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/11/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int r;
    cin >> r;
    cout << r*r <<endl;
    return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#define input \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#else
#define debug(...) 4
#define input 4
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
#define int long long
int32_t main() {
    input;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    int cost[n];
    for(int i = 0; i < n; i++) {
        cin >> cost[i];
    }
    ll total_ans = LLONG_MIN;
    for (int i = 0; i < n; i++) {
        vector<int> vis(n);
        vector<int> costs;
        int x = i;
        long long sum = 0;
        while (!vis[x]) {
            vis[x] = 1;
            costs.push_back(cost[x]);
            sum += cost[x];
            x = p[x];
        }
        int sz = costs.size();
        if(sum > 0) {
            ll ans = 1ll * sum * ((k / sz) - 1);
            int rem = sz + (k % sz);
            for(int j = 0; j < rem; j++) {
                ans += costs[j % sz];
                total_ans = max(ans, total_ans);
            }
        }
        else {
            ll ans = 0;
            for(int j = 0; j < sz + k % sz; j++) {
                ans += costs[j % sz];
                total_ans = max(ans, total_ans);
            }
        }            
    }
    cout << total_ans;


}



Measured memory_bytes: 3880
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define MOD 1000000007

signed main() {
  int n, m;
  cin >> n >> m;
  int x[n + 1], y[m + 1];
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> y[i];
  }
  int xsum = 0, ysum = 0;
  for (int i = 1; i <= n; i++) {
    xsum += (i - 1) * x[i] - (n - i) * x[i];
    xsum %= MOD;
  }
  for (int i = 1; i <= m; i++) {
    ysum += (i - 1) * y[i] - (m - i) * y[i];
    ysum %= MOD;
  }
  cout << (xsum * ysum) % MOD << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

#define dog 1000000000000001

int main()
{
	int64 nn, hoge;
	cin >> nn;
	string ss = "";
	char cc;
	while(nn > 0)
	{
		hoge = nn % 26;
		nn /= 26;
		if(hoge)
		{
			cc = hoge - 1 + 'a';
			ss = cc + ss;
		}
		else
		{
			ss = 'z' + ss;
			nn--;
		}
	}
	cout << ss << endl;
	return 0;
}

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

int main()
{
  int k;
  cin >> k;
  int ans = -1;
  int n = 7;
  for (int i = 0; i < k; i++) {
    if (n % k == 0) {
      ans = i + 1;
      break;
    }
    n = (n * 10 + 7) % k;
  }
  cout << ans << endl;
}


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

int main() {
    int n, m, r;
    cin >> n >> m >> r;
    vector<vector<int>> adj(n, vector<int>(n, 1e9));
    vector<int> rs(r);
    rep(i, r) cin >> rs[i];
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        adj[a][b] = c;
        adj[b][a] = c;
    }
    rep(i, n) adj[i][i] = 0;

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
            }
        }
    }
    int ans = 1e9;
    sort(rs.begin(), rs.end());
    do {
        int score = 0;
        for (int i = 0; i < r - 1; i++) {
            score += adj[rs[i] - 1][rs[i + 1] - 1];
        }
        ans = min(ans, score);
    } while (next_permutation(rs.begin(), rs.end()));
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int R[60][60];
int S[31][31];

int main()
{
	int N, k, r, s, p, q, M, i, j, t, a, b, c, d;
	cin >> N;
	for ( k = 0; k < N; k++)
	{
        for ( r = 0; r < 60; r++)
        {
            for (s = 0; s < 60; s++)
            {
                R[r][s]=0;
            }
        }
		cin >> p >> q;
		cin >> M;
		if ( M != 0)
        {
            for ( i = 0; i < M; i++)
            {
                cin >> a >> b >> c >> d;
                if ( a == c) R[2*a][2*max(b,d)-1]=1;
                if ( b == d) R[2*max(a,c)-1][2*b]=1;
            }
        };
		S[0][0]=1;
		for ( j = 1; j < 31; j++)
		{
			for (t = 0; t < (j + 1); t++)
			{
				S[j-t][t]=0;
				if ( t == 0 && R[(j-t)*2-1][t*2] == 0) S[j-t][t]=S[j-t-1][t];
				if ( t == j && R[(j-t)*2][t*2-1] == 0) S[j-t][t]=S[j-t][t-1];
				if ( t != 0 && t != j && R[(j-t)*2-1][t*2] == 0 && R[(j-t)*2][t*2-1] == 0) S[j-t][t]=S[j-t-1][t]+S[j-t][t-1];
				if ( t != 0 && t != j && R[(j-t)*2-1][t*2] == 0 && R[(j-t)*2][t*2-1] == 1) S[j-t][t]=S[j-t-1][t];
				if ( t != 0 && t != j && R[(j-t)*2-1][t*2] == 1 && R[(j-t)*2][t*2-1] == 0) S[j-t][t]=S[j-t][t-1];
			}
		}
        if ( S[p][q] == 0) cout << "Miserable Hokusai!" << endl;
		if ( S[p][q] != 0) cout << S[p][q] << endl;
	}
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int N, C, K;
VI ts;

int solve() {
	int t = ts[0], res = 1, cnt = 1;
	REP (i, 1, ts.size()) {
		if (cnt == C || ts[i] - t > K) {
			cnt = 1;
			res++;
			t = ts[i];
		} else {
			cnt++;
		}
	}
	return res;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N >> C >> K;
	rep (i, N) {
		int t;
		cin >> t;
		ts.pb(t);
	}
	sort(all(ts));
	cout << solve() << endl;
	return 0;
}



Measured memory_bytes: 892
#include	<iostream>
#include	<cstdio>

using namespace std;

int main(void) {
	while(1) {
		double seq[10] = { 0.0 };
		double sum = 0;
		cin >> seq[0];
		
		if( cin.eof() )		break;
		sum += seq[0];
		for(int i = 1; i < 10; i++) {
			if(i % 2 == 1) {
				seq[i] = seq[i - 1] * 2;
			} else {
				seq[i] = seq[i - 1] / 3;
			}
			sum += seq[i];
		}
		printf("%.8f\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 1236
A = list(map(str,input().split(", ")))
for i in range(len(A)):
    A[i] = A[i].swapcase()

word = A[0]
for k in range(1,len(A)):
    if k < len(A):
        word = word +", "+str(A[k])
    else:
        word = word + str(A[k])
print(word)



Measured memory_bytes: 5564
import 'dart:io';

main(List<String> args) {
  var N = int.parse(stdin.readLineSync());
  String S = stdin.readLineSync();

  var t = new Map();
  t['R'] = new Set();
  t['G'] = new Set();
  t['B'] = new Set();
  for (var i = 0; i < N; i++) {
    t[S[i]].add(i);
  }
  var ans = 0;
  var L = t["B"].length;
  for (var x in t['R']) {
    for (var y in t['G']) {
      ans += L;
      if (t["B"].contains(2 * y - x)) {
        ans -= 1;
      }
      if (t["B"].contains(2 * x - y)) {
        ans -= 1;
      }
      if ((x + y) % 2 == 0 && t["B"].contains((x + y) ~/ 2)) {
        ans -= 1;
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 13420
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[200010], B[200010];
std::priority_queue<P> pque;
ll ans;

int main()
{
  std::cin >> N;

  rep( i, N )
    std::cin >> A[i];
  
  rep( i, N )
  {
    std::cin >> B[i];

    if( A[i] < B[i] )
      pque.emplace( B[i], i );
  }

  while( !pque.empty() )
  {
    P p = pque.top(); pque.pop();
    ll idx = p.second;

    ll mod = B[(idx-1+N)%N]+B[(idx+1)%N];

    if( B[idx]-A[idx] >= mod )
    {
      ans += (B[idx]-A[idx])/mod;
      B[idx] = A[idx] + (B[idx]-A[idx]) % mod;

      if( B[idx] > A[idx] )
        pque.emplace( B[idx], idx );
    }
  }

  rep( i, N ) if( A[i] != B[i] )
  {
    std::cout << -1 << std::endl;

    return 0;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 9072