akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int ans = 0;
    	int cnt = 0;
		int N = sc.nextInt();
		int M = sc.nextInt();
		int H[]=new int[(N+1)];
		for(int i=1;i<=N;i++){
			H[i]=sc.nextInt();
		}
		//N個の頂点がありu,vはi番目の辺が結ぶ頂点を意味するものとする場合の入力データを二次元Listに取り込む
		List<List<Integer>> edge = new ArrayList<>();
		for(int i=1;i<=N+1;i++){
		  edge.add(new ArrayList<>());
		}
		//初期化
		for(int i=1;i<=N;i++){
		  edge.get(i).add(0);
		}
		
		for(int i=1;i<=M;i++){
		  int a = sc.nextInt();
		  int b = sc.nextInt();
		  edge.get(a).add(b);
		  edge.get(b).add(a);		
		}
			
		for(int i=1;i<=N;i++){
			if (edge.get(i).size()-1==0) {
				ans=ans+1;		
			}
			else{
				cnt=0;	
				for(int j=1;j<=edge.get(i).size()-1;j++){
					if (H[i]>H[edge.get(i).get(j)]) {
						cnt=cnt+1;
					}
				}
				if (cnt==edge.get(i).size()-1) {
						ans=ans+1;
					}	
			}
		}
		System.out.println(ans);
		//System.out.print(ans);
		

    }
}

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

#define int long long int
#define MOD 1000000007

void solve()
{
    string s , t ;
    cin >> s >> t ;
    t += s ;
    cout << t << endl ;
}

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

    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        solve() ;
    }
    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

ll N,W;
vector<vector<ll>> dp(110,vector<ll>(100010,0));
int main() {
    cin >> N >> W;
    vector<ll> w(N),v(N);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            chmax(dp[i+1][j],dp[i][j]);
            if(j-w[i] >= 0) chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 87296
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	int packs[3];
	scanf("%d%d%d", &packs[0], &packs[1], &packs[2]);
	bool flag= 0;
	
	if((packs[0] == packs[1] + packs[2]) || (packs[1] == packs[0] + packs[2]) || (packs[2] == packs[0] + packs[1]))
	 	flag = 1;
	if(flag)
		 printf("Yes\n");
	else
		printf("No\n");
	
	
	return 0;
}

Measured memory_bytes: 128
using System;

namespace A___UOIAUAI
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = Console.ReadLine();
            var a = new string[] { "a", "e", "i", "o", "u" };
            for (var i = 0; i < 5; i++)
            {
                if (a[i] == c)
                {
                    Console.WriteLine("vowel");
                    return;
                }
            }
            Console.WriteLine("consonant");
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

using ip = pair<int, int>;

void Main() {
	int H, W, D; cin >> H >> W >> D;
	vector<ip> point_v(H * W);
	REP(i, H) REP (j, W) {
		int a; cin >> a;
		--a;
		point_v[a] = make_pair(i, j);
	}
	vvi sum_d;
	REP(i, D) {
		vi sum;
		sum.push_back(0);
		int cur = i;
		int last_y = point_v[cur].first;
		int last_x = point_v[cur].second;
		int idx = 0;
		while (cur < H * W) {
			int cost = abs(point_v[cur].first - last_y) + abs(point_v[cur].second - last_x);
			sum.push_back(sum[idx] + cost);
			++idx;
			last_y = point_v[cur].first;
			last_x = point_v[cur].second;
			cur += D;
		}
		// debug(sum);
		sum_d.push_back(sum);
	}
	int Q; cin >> Q;
	REP(i, Q) {
		int l, r; cin >> l >> r;
		--l; --r;
		int d_idx = l % D;
		int l_idx = l / D;
		int r_idx = r / D;
		cout << sum_d[d_idx][r_idx + 1] - sum_d[d_idx][l_idx + 1] << endl;
		// debug(d_idx);
		// debug(l_idx);
		// debug(r_idx);
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

int modpow(int a,int b,int p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(3*n);
    vcin(a);
    sort(a);
    reverse(a);
    ll ans=0;
    rp(i,n){
        ans += a[2*i+1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(){
  int cnt=0, n, a[100];

  while(scanf("%d", &n) != EOF){
    if(n!=0){
      cnt++;
      a[cnt]=n;
    }else{
      printf("%d\n", a[cnt]);
      cnt--;
    }
  }

  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>

int main()
{
	long long N;
	scanf("%lld", &N);
	
	long long n, sum = 0;
	for (n = 1; n * n < N; n++) {
		if (N % n == 0 && N / (N / n - 1) == n) sum += N / n - 1;
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
K,N =map(int,input().split())
list_A =input().strip().split()
list_B=[]
list_B.append(int(list_A[0])+(K-int(list_A[-1])))
for i in range(N-1):
    list_B.append(int(list_A[i+1])-int(list_A[i]))
print(K-max(list_B))

Measured memory_bytes: 18548
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
MAX=10**5+5
tree=[[] for _ in range(MAX)]
ans = [-1]*(MAX)
def dfs(x,weight):
    if(ans[x]>=0):
        return
    ans[x]=weight&1
    for i,w in tree[x]:
        dfs(i,weight+w)

def resolve():
    n =int(input())
    for i in range(n-1):
        u,v,w = map(int,input().split())
        tree[u].append((v,w))
        tree[v].append((u,w))
    dfs(1,0)
    
    for i in range(1,n+1):
        print(ans[i])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 81944
#include <bits/stdc++.h>
int main()
{
    using namespace std;
    int N;
    long sum(0);
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    cout << sum << endl;
}

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

int main(void) {
  int N, current = 1;
  cin >> N;
  vector<int> a(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    current = a[current];
    if (current == 2) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
const char* d[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
int main() {
  map<string, int> mp;
  for (int i = 0; i < 7; ++i) mp[d[i]] = i;
  cin >> s;
  cout << 7 - mp[s] << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
L = input().rstrip().split()

for i in range(len(L)):
  L[i] = int(L[i])
L.sort()
maxl = L[len(L)-1]
leftl = sum(L[0:len(L)-1])

if maxl < leftl:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int n, a, c = 0;
	scanf("%d", &n);
	REP(i, n) for (scanf("%d", &a); a % 2 == 0; a /= 2) c++;
	printf("%d", c);
	return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		Deque<Character> deque=new LinkedList<>();
		String s=nextLine();
		int n=s.length();
		for(int i=n-1;i>=0;i--)
			deque.addFirst(s.charAt(i));
		int head=0;
		int q=nextInt();
		while(q-->0)
		{
			int t=nextInt();
			if(t==1)
			{
				head=1^head;
			}
			else
			{
				int f=nextInt();
				char c=nextToken().charAt(0);
				if(f==1)
				{
					if(head==0)
						deque.addFirst(c);
					else
						deque.addLast(c);
				}
				else
				{
					if(head==0)
						deque.addLast(c);
					else
						deque.addFirst(c);
				}
			}
		}
		while(!deque.isEmpty())
		{
			if(head==0)
				out.print(deque.removeFirst());
			else
				out.print(deque.removeLast());
		}
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 68360
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    ## comb
    mod = 1000000007

    def make_fact(n):
        fact = [1]*(n+1)
        ifact = [1]*(n+1)
        for i in range(1, n+1):
            fact[i] = fact[i-1]*i % mod
        ifact[n] = pow(fact[n], mod-2, mod)
        for i in range(n, 0, -1):
            ifact[i-1] = ifact[i]*i % mod
        return fact, ifact
    fact, ifact = make_fact(2000002)

    def comb(n, k):
        if k < 0 or k > n: return 0
        return fact[n]*ifact[k]*ifact[n-k] % mod

    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in range(N-1)]
    graph = [[] for _ in range(N + 1)]
    for a, b in AB:
        graph[a].append(b)
        graph[b].append(a)

    # dfs
    root = 1
    parent = [0] * (N + 1)
    order = []
    stack = [root]
    while stack:
        x = stack.pop()
        order.append(x)
        for y in graph[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            stack.append(y)

    # 方向ごと？
    size_d = [0] * (N + 1)
    dp_d = [1] * (N + 1)

    for v in order[::-1]:
        dp_d[v] *= fact[size_d[v]]
        dp_d[v] %= mod
        p = parent[v]
        s = size_d[v] + 1
        size_d[p] += s
        dp_d[p] *= ifact[s] * dp_d[v]
        dp_d[p] %= mod

    size_u = [N - 2 - x for x in size_d]
    dp_u = [1] * (N + 1)

    for v in order[1:]:
        p = parent[v]
        x = dp_d[p]
        x *= dp_u[p]
        x *= ifact[size_d[p]]
        x *= fact[size_d[v] + 1]
        x *= pow(dp_d[v], mod - 2, mod)
        x *= fact[size_u[v]]
        x *= ifact[size_u[p] + 1]
        dp_u[v] = x % mod

    for xd, xu, sd, su in zip(dp_d[1:], dp_u[1:], size_d[1:], size_u[1:]):
        su += 1
        x = xd * xu * comb(sd+su, su) % mod
        print(x)

main()



Measured memory_bytes: 245332
xs = gets.chomp.chars

ans = 0
gx, px = 0, 0
xs.each {|c|
    if c == 'g'
        if gx > px
            ans += 1
            px += 1
        else
            gx += 1
        end
    else
        if gx > px
            px += 1
        else
            ans -= 1
            gx += 1
        end
    end
}
p ans


Measured memory_bytes: 9468
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b,d,r;
    double f;
    
    cin >> a >> b ;
     
   d=a/b;
   r=a%b;
   f=(double)a/(double)b;
 
     
 
    cout << d<< " " << r <<" "<<flush;
    cout << fixed  << setprecision(6);
    cout << f << endl;
}


Measured memory_bytes: 3268
using System;
class Prpgram
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        string[] xs = Console.ReadLine().Split(' ');
        int[] x = new int[n];
        for (int i = 0; i < n; i++)
            x[i] = int.Parse(xs[i]);
        int sum = 0;
        for (int i = 0; i < n; i++)
            sum += Math.Min(x[i], Math.Abs(k - x[i]));
        Console.WriteLine(sum * 2);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
typedef long long ll;
using namespace std;

int main(){
	int N;
	cin>>N;
	vector<int> vt;
	REP(i,0,N) {
		int a;
		cin>>a;
		vt.push_back(a);
	}
	sort(vt.begin(),vt.end());
	ll ans=0;
	ll now=vt[0];
	REP(i,1,N){
		if(now*2<vt[i]) ans=i;
		now+=vt[i];
	}
	p(N-ans);
	return 0;
}


Measured memory_bytes: 892
from sys import stdin


def main():
    lines = stdin.readlines()
    S = lines[1]
    lr = [[int(j) - 1 for j in i.split()] for i in lines[2:]]
    AC = [0]
    pre = 0
    for c1, c2 in zip(S[:], S[1:]):
        if c1 == "A" and c2 == "C":
            pre += 1
        AC.append(pre)
    for l, r in lr:
        print(AC[r] - AC[l])
    return


main()


Measured memory_bytes: 31636
#include<bits/stdc++.h>
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (int i=(s); i<(e); i++)
#define Debug_array(a,n) for (int i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (int i=(s); i<=(e); i++)
#define Fod(i,s,e) for (int i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second

using namespace std;

typedef long long ll;
struct Z
{
	pii x,y;
	Z(pii a,pii b){
		x=a;
		y=b;
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	
	ll n,m;cin>>n>>m;
	ll a[n][m];
	For(i,0,n) For(j,0,m) cin>>a[i][j];

	vector<Z> ans;
	For(i,0,n){
		For(j,0,m){
			pii x(i,j);
			if(i<n-1 && a[i][j]%2!=0){
				pii y(i+1,j);
				Z z(x,y);
				ans.pb(z);
				a[i+1][j]++;
			}else if(j<m-1 && a[i][j]%2!=0){
				pii y(i,j+1);
				Z z(x,y);
				ans.pb(z);
				a[i][j+1]++;
			}
		}
	}
	cout<<ans.size()<<endl;
	For(i,0,ans.size()){
		cout<<ans[i].x.fi+1<<" "<<ans[i].x.se+1<<" "<<ans[i].y.fi+1<<" "<<ans[i].y.se+1<<endl;
	}



}

Measured memory_bytes: 9584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200000+7;
const ll INF=1E18+7;
ll arr[N];
ll mark[N];
int main(){
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)   cin>>arr[i];
    for(ll i=n;i>=1;i--)   mark[i]=mark[i+1]+arr[i];
    ll ans=INF;
    ll sum=0;
    for(ll i=1;i<=n-1;i++){
        sum+=arr[i];
        ans=min(ans,abs(mark[i+1]-sum));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch NiceShopping | diff NiceShopping.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address NiceShopping.cpp && ./a.out

/*
 
 3/8/2020
 
 11:20-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N],B[MAX_N],X[MAX_N],Y[MAX_N],C[MAX_N];
int M,AN,BN;

void solve() {
  LL res=*min_element(A,A+AN)+*min_element(B,B+BN);
  REP(i,M) {
    SMIN(res, A[X[i]]+B[Y[i]]-C[i]);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>AN>>BN>>M;
  REP(i,AN) cin>>A[i];
  REP(i,BN) cin>>B[i];
  REP(i,M) {
    cin>>X[i]>>Y[i]>>C[i];
    X[i]--,Y[i]--;
  }

  solve();
  
  return 0;
}


Measured memory_bytes: 13312
#include<stdio.h>
#include<math.h>
int main(){
    int n,a[100],i,min=101,max=-1,sum=0,c,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
    	scanf("%d",&a[i]);
		if(a[i]>max) max=a[i];
		if(a[i]<min) min=a[i];
	}
	for(i=0;i<n;i++)
		sum=sum+pow((a[i]-min),2);
	for(i=min+1;i<=max;i++){
		c=0;
		for(j=0;j<n;j++)
		c=c+pow((a[j]-i),2);
		if(c<sum) sum=c;
	}
	printf("%d",sum);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()



signed main(){
  int N;
  cin >> N;
  for(int i=1;i<10;i++)for(int j=1;j<10;j++){
    if(N==i*j){
      Yes
      return 0;
    }
  }

  No
  return 0;
}


Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
#include <functional>																							   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////

int A[1005][1005];
int B[1005];
int ans[1005];

///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n, m, c;
	cin >> n >> m >> c;
	
	for(int i = 0; i < m; i++){
		cin >> B[i];
	}
	//cout << endl; //ss
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
			ans[i] += A[i][j] * B[j];
		}
		//cout << "current first ans: " << ans[i] << endl;
		ans[i] += c;
	}
	
	//cout << "ans after: " << endl;
	//for(int i = 0; i < n; i++){
		//cout << ans[i] << endl;
	//}
	
	int licznik = 0;
	for(int i = 0; i < n; i++){
		if(ans[i] > 0){
			licznik++;
		}
	}
	
	cout << licznik << endl;
	
	
	
						
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),x;
		for (int a=3;a<=n;a++){
			if(a%3==0){System.out.print(" "+a);continue;}
			x=a;
			while(x!=0){
				if(x%10==3){System.out.print(" "+a);break;}
				x=x/10;
			}
		}
		System.out.println("");
	}
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, 0, n, 1) cin >> v[i];
  sort(all(v));
  int ans = 1;
  if (v[0] >= 0) {
    for (int i = 0; i < k; i++) ans = mod(ans * v[n - 1 - i]);
    cout << ans << endl;
    return;
  }
  if (v[n - 1] <= 0) {
    for (int i = 0; i < k; i++) {
      ans = mod(ans * v[(k % 2 ? n - 1 - i : i)]);
    }
    cout << ans << endl;
    return;
  }

  int l = 0, r = n - 1;
  if (k % 2) {
    ans = mod(ans * v[r]);
    r--;
    k--;
  }

  while (k > 0) {
    int ll = v[l] * v[l + 1];
    int rr = v[r] * v[r - 1];

    if (ll >= rr) {
      ans = mod(ans * mod(ll));
      l += 2;
    } else {
      ans = mod(ans * (mod(rr)));
      r -= 2;
    }
    k -= 2;
  }

  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long,int>;

int main() {
  int n,m,c = 0;
  ll ans = 0;
  cin >> n >> m;
  vector<P>data(n);
  for(int i = 0;i < n;i++) cin >> data[i].first >> data[i].second;
  sort(data.begin(),data.end());
  for(int i = 0;i < n;i++){
    if(data[i].second+c <= m){
      ans += data[i].first*data[i].second;
      c += data[i].second;
    }
    else{
      ans += data[i].first*(m-c);
      c += m-c;
    }
    if(c == m){
      cout << ans << endl;
      return 0;
    }
  }
}


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

using namespace std;

int n, a[1000005], cnt;

int main () {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] % 2 != 0) {
			cnt++;
		}
	}
	if(cnt % 2 == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

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

flag = True

for i in range(N):
    if A[i] % 2 == 0 and (A[i] % 3 != 0 and A[i] % 5 != 0):
        flag = False
        
if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
def main():
    N, M = (int(i) for i in input().split())
    ans = 0
    if N == M // 2:
        ans = N
    elif 2*N <= M:
        M -= 2*N
        ans += N
        if M >= 4:
            ans += M//4
            M //= 4
    elif N >= M//2 and M//2:
        ans += M//2
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int A, B, ans = 0;
  cin >> A >> B;

  while (A <= B) {
    to_string(A)[0] == to_string(A)[4] && to_string(A)[1] == to_string(A)[3] ? ans += 1 : 0;
    A += 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
const int MAXN = 1e6+10;
typedef long long LL;
LL cnt[MAXN];
int mu[MAXN],prime[MAXN];
int num[MAXN];
bool vis[MAXN];
int pcnt;

/*求解Mobinus函数*/
void Mobinus()
{
   // cout << 1 << "\n";
    memset(vis,0,sizeof(vis));

    pcnt=0;
    mu[1]=1;
    //printf("1\n");
    for(LL i=2; i<MAXN; i++)
    {
        if(!vis[i])
        {
            prime[pcnt++]=i;
            mu[i]=-1;
        }
       // printf("%lld\n",i);
        for(LL j=0; j<pcnt&&i*prime[j]<MAXN; j++)
        {
            vis[i*prime[j]]=1;
            if(i%prime[j])mu[i*prime[j]]=-mu[i];//i是素数的情况
            else
            {
                mu[i*prime[j]]=0;
                break;
            }
        }
    }
}
LL a[MAXN];
int main()
{
  //  cout << 1 << "\n";
    Mobinus();
    LL n;
    scanf("%lld",&n);
    LL Max=-99999999,ans=0;

    memset(cnt,0,sizeof(cnt));
    memset(num,0,sizeof(num));
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
        Max=max(a[i],Max);
    }
    for(int i=0; i<n; i++)
    {
        num[a[i]]++;
    }
    for(int i=1; i<=Max; i++)
    {
        for(int j=i; j<=Max; j+=i)
            cnt[i]+=num[j];
    }
    for(int i=1; i<=Max; i++)
    {
        ans+=(mu[i]*cnt[i]*(cnt[i]-1))>>1;
    }
    if(ans==n*(n-1)/2)
    {
        printf("pairwise coprime\n");
    }
    else
    {
        LL d = a[0];
        for(int i = 1;i<n;++i)
        {
            d = __gcd(d,a[i]);
        }
        if(d==1)
        {
            printf("setwise coprime\n");
        }
        else
            printf("not coprime\n");
    }
    return 0;
}


Measured memory_bytes: 28488
#include<stdio.h>
enum{up,right,down,left};
char *res="URDL";
int g[5][5][4],i,j,t,d=right;

void move(int dir)
{
	putchar(res[dir]);
	d=dir;
	switch(dir)
	{
	case up:i--;break;
	case right:j++;break;
	case down:i++;break;
	case left:j--;break;
	}
}

int main()
{
	for(i=0;i<9;i++,getchar())
	{
		if(i%2==0)
			for(j=0;j<4;j++)
			{
				scanf("%c",&t);
				if(t=='1')
					g[i/2][j][right]=g[i/2][j+1][left]=1;
			}
		else
			for(j=0;j<5;j++)
			{
				scanf("%c",&t);
				if(t=='1')
					g[i/2][j][down]=g[i/2+1][j][up]=1;
			}
	}
	for(i=0,j=0,t=0;!t;)
	{
		switch(d)
		{
s:		case right:if(g[i][j][up]){move(up);break;}
		case down:if(g[i][j][right]){move(right);break;}
		case left:if(g[i][j][down]){move(down);break;}
		case up:if(g[i][j][left]){move(left);break;}
		default:goto s;
		}
		if(i==0&&j==0)
			puts(""),t=1;
	}
	return 0;
}

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

using namespace std;

int main(){
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}



Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];

  sort(a.rbegin(), a.rend());
  vector<int> cnt(n,2);
  cnt[0]--;
  ll ans = 0;
  int now = 0;
  for(int i = n-1; i > 0; i--){
    if(!cnt[now]) now++;
    cnt[now]--;
    ans += a[now];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

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

const int MAX = 200101;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

template <class Abel>
struct BinaryIndexTree
{
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0; // to be set

    /* [1, n] */
    BinaryIndexTree(int n) { init(n); }
    void init(int n)
    {
        for (int iter = 0; iter < 2; ++iter)
            dat[iter].assign(n + 1, UNITY_SUM);
    }

    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x)
    {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x)
    {
        sub_add(0, a, x * -(a - 1));
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }

    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a)
    {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[p][i];
        return res;
    }

    inline Abel sum(int a, int b)
    {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }

    /* debug */
    void print()
    {
        for (int i = 1; i < (int)dat[0].size(); ++i)
            cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

//////////////////////////////////////////////////////////////////////////////////
int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);
    // for file input
    /* ifstream in("input.txt");
    ifstream in("input.txt"); */

    int n;
    cin >> n;
    llong k;
    cin >> k;
    vector<llong> A(n);
    rep(i, n) cin >> A[i];

    vector<llong> cumA(n + 1);
    cumA[0] = 0;
    rep(i, n) cumA[i + 1] = cumA[i] + A[i] - k;
    
    vector<llong> zaatsu = cumA;
    sort(all(zaatsu));
    zaatsu.erase(unique(all(zaatsu)), zaatsu.end());

    BinaryIndexTree<llong> BIT(n + 10);
    llong ans = 0;
    rep(i, n + 1) {
        int idx = lower_bound(all(zaatsu), cumA[i]) - zaatsu.begin();
        ans += BIT.sum(1, idx + 2);
        BIT.add(idx + 1, idx + 2, 1);
    }

    cout << ans << endl;

    return 0;
}
//////////////////////////////////////////////////////////////////////////////////

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

int main( void )
{
	vector <bool> isPrime( 50001 + 1 );
	isPrime[2] = true;
	for ( int i = 3; i < 50001; i += 2 )
	{
		isPrime[i] = true;
	}

	for ( int i = 3; i < 50001; i += 2 )
	{
		for ( int j = i + i; j < 50001; j += i )
		{
			isPrime[j] = false;
		}
	}

	int cnt = 1;
	vector <int> primes( 5500 );
	primes[0] = 2;
	for ( int i = 3; i < 50001; i += 2 )
	{
		if ( isPrime[i] )
		{
			primes[cnt] = i;
			cnt++;
		}
	}

	int n;
	while ( cin >> n && n != 0 )
	{
		int kotae = 0;
		for ( int i = 0; i < cnt; i++ )
		{
			if ( primes[i] <= n / 2 )
			{
				if ( isPrime.at( n-primes[i] ) )
					kotae++;
			}
		}
		cout << kotae << endl;
	}

	return 0;
}

Measured memory_bytes: 928
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  double l;
  cin>>l;
  double h = l / 3.0;
  double ans = h * h * h;
  cout<<fixed<<setprecision(7)<<ans<<endl;
  return 0;
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC   
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll n;
    cin >> n;
    n--;
    // if(n == 0) {
    // 	cout << "a\n";
    // 	return;
    // }
    string ans = "";
    while(n >= 0) {
    	ll num = n % 26;
    	ans += (char)'a' + num;
    	n/=26;
    	n--;
    }
    for(ll i=ans.size()-1;i>=0;i--) {
    	cout << ans[i];
    }
    cout << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        solve(i);
    }
}

Measured memory_bytes: 3652
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,m = LI()
    x = LI()
    y = LI()

    a = 0
    t = 0
    for i in range(1,n):
        sa = x[i] - x[i-1]
        t += sa * i
        t %= mod
        a += t
        a %= mod

    b = 0
    t = 0
    for i in range(1,m):
        sa = y[i] - y[i-1]
        t += sa * i
        t %= mod
        b += t
        b %= mod


    return a * b % mod



print(main())


Measured memory_bytes: 21772
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++) cin >> A[i];

  int ans = 0;
  while(1){
    bool abl = true;
    for(int i=0;i<N;i++){
      if(A[i]%2==1) abl = false;
      else A[i] /= 2;
    }
    if(abl) ans++;
    else break;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	while (N != 0) {
		vi A(N);
		int sum = 0;
		REP(i, N) {
			cin >> A[i];
			sum += A[i];
		}
		double ave = (double)sum / (double)N;
		int ans = 0;
		REP(i, N) {
			if (ave >= A[i]) {
				ans++;
			}
		}
		cout << ans << endl;
		cin >> N;
	}
	return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

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

	vector<int> l(N+1, 0);
	rep(i, N) {
		cin >> l[i+1];
	}

	vector<int> l2(N+1);
	rep_r(i, N) {
		int x = N/i;
		int sum = 0;
		rep(j, 1, x) {
			int idx = (j+1)*i;
			if (idx > N) continue;
			sum ^= l2[idx]; // 排他的論理和: XOR
		}
		l2[i] = sum ^ l[i];
	}

	vector<int> result;
	rep(i, N) {
		if(l2[i+1] == 1) result.push_back(i+1);
	}

	cout << result.size() << endl;
	rep(i, result.size()) {
		cout << result[i] << endl;
	}
  return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <sstream>

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
const int mod = 2019;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    ll x2 = 0;
    rep (i, n) {
        if (i%2) x2 -= a[i];
        else x2 += a[i];
    }
    vector<int> ans(n);
    ans[0] = x2 / 2;
    rep (i, n-1) {
        ans[i+1] = a[i] - ans[i];
    }
    rep (i, n) ans[i] *= 2;
    rep (i, n) cout << ans[i] << " ";
    cout << endl;
}



Measured memory_bytes: 2048
import java.util.*;

class Main{

    int T,P,R;
    int[][] wrong;
    int[] penalty;
    int[] correct;
    int[] tID,pID,time;
    String[] message;
    void solve(){
	Scanner sc = new Scanner(System.in);
	while(true){
	    T = sc.nextInt();
	    P = sc.nextInt();
	    R = sc.nextInt();
	    tID = new int[R];
	    pID = new int[R];
	    time = new int[R];
	    message = new String[R];
	    if(T==0 && P==0 && R==0) break;
	    for(int i=0; i<R; i++){
		tID[i] = sc.nextInt();
		pID[i] = sc.nextInt();
		time[i] = sc.nextInt();
		message[i] = sc.next();
	    }
	    wrong = new int[T][P];
	    penalty = new int[T];
	    correct = new int[T];
	    for(int i=0; i<R; i++){
		if(message[i].equals("WRONG")){
		    wrong[tID[i]-1][pID[i]-1]++;
		}else{
		    correct[tID[i]-1]++;
		    penalty[tID[i]-1] += wrong[tID[i]-1][pID[i]-1] * 1200 + time[i];
		}
	    }

	    for(int i=0; i<T; i++){
		int max = -1;
		int maxIdx = 0;
		for(int j=0; j<T; j++){
		    if(correct[j]==-1) continue;
		    if(correct[j] == max && penalty[maxIdx]>penalty[j]){
			max = correct[j];
			maxIdx = j;
		    }
		    if(max<correct[j]){
			max = correct[j];
			maxIdx = j;
		    }
		}
		System.out.println((maxIdx+1)+" "+correct[maxIdx]+" "+penalty[maxIdx]);
		correct[maxIdx] = -1;
	    }
	}
    }
    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 13000
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
int x;
  cin>>x;
  if(x>=30)cout <<"Yes";
  else cout<<"No";

return 0;
}






ll gcd(ll a, ll b){

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

}


Measured memory_bytes: 3596