akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll w, h, x, y; cin >> w >> h >> x >> y;
    
    cout << ((ld)(w*h)/(ld)2) << " " << !!(((ld)w/(ld)2)==x && ((ld)h/(ld)2)==y) << endl;

    return 0;
}

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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){
    int n;
    cin >> n;
    vector<pair<int,int> > red(n),blue(n);
    REP(i,n){
        int x,y;
        cin >> x >> y;
        red[i].first=x;
        red[i].second=y;
    }
    REP(i,n){
        int x,y;
        cin >> x >> y;
        blue[i].first=x;
        blue[i].second=y;
    }
    sort(All(red));
    sort(All(blue));

    vector<int> fr(n,0);
    int may,mi;
    REP(i,n){
        mi=-1;
        may=-1;
        int bx=blue[i].first;
        int by=blue[i].second;
        REP(j,n){
            int rx=red[j].first;
            int ry=red[j].second;
            if(bx>rx&&by>ry&&fr[j]==0){
                if(may<ry){
                    may=ry;
                    mi=j;
                }
            }
        }
        if(mi>=0){
            fr[mi]=1;
            //cout << red[mi].fr << red[mi].sc << " " <<bx<<by <<endl;
        }
    }

    //REP(i,n)cout << fr[i] << endl;
    int res=0;
    REP(i,n)res+=fr[i];
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1000005
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
using namespace std;
int fr[2020];
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s; cin>>s;
    reverse(all(s));
    int cu = 0;
    fr[0] = 1;
    int po = 1;
    for(int i=0;i<s.length();i++){
        int d = s[i]-'0';
        d*=po;
        if(d>=2019)d%=2019;
        cu += d;
        if(cu>=2019)cu-=2019;
        fr[cu]++;
        po*=10;
        if(po>=2019)po%=2019;
    }
    ll ans = 0;
    for(int i=0;i<2019;i++){
        ll j = fr[i];
        j *= (j-1ll);
        j/=2ll;
        ans+=j;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}

int main()
{
    int n; sc(n);
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            if(i*4+j*7 == n){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}




Measured memory_bytes: 256
l, r = map(int, input().split())
mod = 2019
lm, rm = l % mod, r % mod
if l + 2019 <= r:
    ans = 0
elif lm < rm:
    ans = 2019
    for i in range(lm, rm):
        for j in range(i+1, rm+1):
            ans = min(ans, i * j % mod)
elif lm > rm:
    ans = 2019
    for i in range(0, rm+1):
        for j in range(lm, 2019):
            ans = min(ans, i*j%mod)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  srep(i,l,r+1) {
    if(i%d==0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	data := make([]string, N)
	for i := 0; i < N; i++ {
		S := sc.NextLine()
		t := make([]int, len(S))
		for k, v := range S {
			t[k] = int(v)
		}
		sort.Ints(t)

		S = ""
		for _, v := range t {
			S += string(v)
		}
		data[i] = S

	}

	count := 1
	sort.Strings(data)

	ans := 0

	for i := 1; i < N; i++ {
		if data[i-1] == data[i] {
			ans += count
			count++
		} else {
			count = 1
		}
	}

	fmt.Println(ans)
}

func IsSameMap(A, B map[byte]int) bool {
	if len(A) != len(B) {
		return false

	}
	for k, v := range A {
		if B[k] != v {
			return false
		}
	}
	return true
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}

func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 7680
import itertools as iter

def main():
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    l = list(iter.permutations(range(1,n+1)))
    print(abs(l.index(p)-l.index(q)))

if __name__ == '__main__':
    main()

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

#define int long long

int arr[100005];
int dp[100005];

int f(int n)
{
	if(n==1)
	{
		return 0;
	}
	if(n<=0)
	{
	return INT_MAX;
	}
	if(dp[n]!=-1)
	{
		return dp[n];
	}
	int ans1 = INT_MAX, ans2= INT_MAX;
	ans1 = abs(arr[n] - arr[n-1]) + f(n-1);
	if(n>2)
	{
		ans2  = abs(arr[n]-arr[n-2])+f(n-2);
	}
	dp[n] =  min(ans1,ans2);
	return dp[n];
}

int32_t main()
{
	int n;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)	cin>>arr[i];
	cout<<f(n);
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int selected = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= sum/((double)4*m)) {
            selected++;
        }
    }
    if (selected >= m) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		///int N=sc.nextInt();
		String S=sc.next();
		int N=S.length();
		char[] a=new char[N];
		int r=0;
		int[] pos=new int [N];
		for(int i=0;i<N;i++) {
			pos[i]=0;
		}
		int p=0;
		int l=0;
		for(int i=0;i<N;i++) {
			a[i]=S.charAt(i);
			if(a[i]=='R') {
				r++;
				if(l!=0) {
					if(l%2==1) {
						pos[p]+=l/2;
						pos[p+1]+=l/2+1;
					}else {
						pos[p]+=l/2;
						pos[p+1]+=l/2;
					}
				}
				p=i;
				l=0;
			}else {
				l++;
				if(r!=0) {
					if(r%2==1) {
						pos[p]+=r/2+1;
						pos[p+1]+=r/2;
					}else {
						pos[p]+=r/2;
						pos[p+1]+=r/2;
					}
				}
				r=0;
			}
			/*for(int j=0;j<pos.length;j++) {
				System.out.print(pos[j]+" ");
			}
			System.out.println();*/
		}
		if(l%2==1) {
			pos[p]+=l/2;
			pos[p+1]+=l/2+1;
		}else {
			pos[p]+=l/2;
			pos[p+1]+=l/2;
		}
		for(int j=0;j<pos.length;j++) {
			System.out.print(pos[j]+" ");
		}
	}
}


Measured memory_bytes: 44180
def main():
    n, m = input().split()
    g1 = []
    g2 = []
    for _ in range(int(m)):
        x, y = input().split()
        if x == '1':
            g1.append(y)
        elif y == n:
            g2.append(x)
    sx = set(g1)
    sy = set(g2)
    sxy = sx.intersection(sy)
    if len(sxy):
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Measured memory_bytes: 26540
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) cin >> A[i];
    
    set<int> Aset;
    rep(i, N) {
        if (Aset.find(A[i]) != Aset.end()) {
            cout << "NO" << endl;
            return 0;
        }
        Aset.insert(A[i]);

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

Measured memory_bytes: 10368
/**
*    created: 01.07.2020 23:20:33
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int MOD = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int INF = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    int x;
    cin >> x;
    int cnt = 0;
    rep(i,a+1) rep(j,b+1) rep(k,c+1) {
        if (i == 0 && j == 0 && k == 0) continue;
        if (500 * i + 100 * j + 50 * k == x) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100005]={0};

int main(int argc, char* argv[])
{
    long n, q;
    scanf("%ld%ld", &n, &q);
    scanf("%s", str);

    vector<long> cnt(n);
    long i;
    cnt[0]=0;
    for(i=1; i<n; i++) {
        if(str[i-1]=='A' && str[i]=='C') {
            cnt[i]=cnt[i-1]+1;
        }
        else {
            cnt[i]=cnt[i-1];
        }
    }

    vector<long> l(q), r(q);
    for(i=0; i<q; i++) {
        scanf("%ld%ld", &l[i], &r[i]);
    }
    for(i=0; i<q; i++) {
        printf("%ld\n", cnt[r[i]-1]-cnt[l[i]-1]);
    }

    return 0;
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String d = sc.next();
		sc.close();
		for(int i = 0;i<n;i++){
			System.out.print(s.charAt(i));
			System.out.print(d.charAt(i));
		}
		System.out.println();
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static long arrayMax(long[] array) {
		long ans = Long.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}

	public static String[] arrayString(Scanner sc, int n) {
		String[] array = new String[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.next();
		}
		return array;
	}
	static String nextPermutation (String s) {

	ArrayList<Character> list = new ArrayList<>();
	for (int i=0; i<s.length(); i++) list.add(s.charAt(i));

	int pivotPos = -1;
	char pivot = 0;
	for (int i=list.size()-2; i>=0; i--) {
		if (list.get(i) < list.get(i+1)) {
			pivotPos = i;
			pivot = list.get(i);
			break;
		}
	}

	if (pivotPos==-1 && pivot==0) return "Final";

	int L = pivotPos+1, R = list.size()-1;
	int minPos = -1;
	char min = Character.MAX_VALUE;
	for (int i=R; i>=L; i--) {
		if (pivot < list.get(i)) {
			if (list.get(i) < min) {
				min = list.get(i);
				minPos = i;
			}
		}
	}

	Collections.swap(list, pivotPos, minPos);
	Collections.sort(list.subList(L, R+1));

	StringBuilder sb = new StringBuilder();
	for (int i=0; i<list.size(); i++) sb.append(list.get(i));

	return sb.toString();
}
}


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

using namespace std;

typedef long long ll;

ll solve(ll K) {
  ll lim = 10000000ll;
  ll cnt = 1ll;
  ll rem = 7ll;
  while(cnt < lim && rem % K != 0) {
    rem *= 10;
    rem += 7;
    rem %= K;
    ++cnt;
  }
  return cnt < lim ? cnt : -1;
}

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

  ll K;
  cin >> K;

  if(K % 2 == 0 || K % 5 == 0) cout << "-1\n";
  else cout << solve(K) << "\n";
  
  return 0;
}


Measured memory_bytes: 3620
n, k, q = map(int, input().split())
a = list(map(int, input().split()))
 
d = [a]
a = sorted(a)
ans = a[q - 1] - a[0]
 
while True:
    newd = list()
    li = list()
    for sub in d:
        for c in sub:
            if c != a[0]:
                li.append(c)
            else:
                newd.append(li)
                li = list()
        newd.append(li)
        li = list()
 
    d = list()
    a = list()
    for li in newd:
        if len(li) < k:
            continue
        else:
            d.append(li)
            li = sorted(li)
            a.extend(li[0:len(li) - k + 1])
 
    a.sort()
 
    if len(a) >= q:
        ans = min(a[q - 1] - a[0], ans)
    else:
        break
print(ans)

Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

int main(void) {

	vector<int> num = { 0, 0, 0 };
	int k = 0;
	int m_index = 0;
	int sum = 0;

	cin >> num[0];
	cin >> num[1];
	cin >> num[2];

	cin >> k;

	for (int j = 0; j < k; j++) {
		for (int i = 0; i < 3; i++) {
			if (num[m_index] < num[i]) {
				m_index = i;
			}
		}
		num[m_index] += num[m_index];
	}

	for (int i = 0; i < 3; i++) {
		sum += num[i];
	}

	cout << sum << endl;


	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
map< string , int > mp;
int main()
{
	dhoom;
	int n;
	cin >> n ;
	for(int i = 0 ; i <= 25 ; i++){
		for(int j = 0 ; j <= 25 ; j++)
			if(4 * i + 7 * j == n)
				return cout << "Yes" ,0;
	}
	cout << "No" << endl;
	return 0;
} 



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int i, n, cnt = 0, sum = 0;
    while(1){
        scanf("%d", &n);
        if( n == 0 ) break;

        for ( i = 0; i < n; i++ , sum = 0){
            int j = i + 1;
            while(sum < n){
                sum += j++;
            }
            if( sum > n ) continue;
            cnt++;
        }
        printf("%d\n", cnt - 1); //??£?¶???????????????????????????????????????????????????????n)
        cnt = 0;
    }
    return 0;
}

Measured memory_bytes: 1800
#include <iostream>
#include <string>

using namespace std;

// tenki
int main() {
	int cnt=0;
	char s[3],t[3];
	cin>>s;
	cin>>t;

	for(int i=0;i<3;i++){
		if(s[i]==t[i]) cnt++;
	}

	cout<<cnt<<endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector <int> x(N+1), y(M+1);
  x[0] = X;
  y[0] = Y;
  for (int i = 1; i <= N; i++) cin >> x[i];
  for (int i = 1; i <= M; i++) cin >> y[i];
  
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  
  if (x[N] < y[0]) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
int main(void)
{
  int a, b, v;
  int ret;
  ret = scanf("%d %d", &a, &b);
  v = (a*b)%2;
  
  if( ret < 2)
    return -1;
  else
    if( v == 0 )
    	printf("%s", "Even");
    else
    	printf("%s", "Odd");
  
  return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int f(string S) {
    S.push_back('!');
    int res = 0;
    for (int i = 1; i < S.length(); ++i) {
        if (S[i] == S[i - 1]) {
            res += 1;
            S[i] = S[i + 1] + 1;
        }
    }
    return res;
}


signed main() {
    string S;
    int K;
    cin >> S >> K;
    int a3 = f(S + S + S);
    int a2 = f(S + S);
    int a1 = f(S);
    cout << (a3 - a1) * ((K - 1) / 2) + (a2 - a1) * ((K - 1) % 2) + a1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int c[600],s[600],f[600];
    for(int i=0;i<n-1;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=0;i<n-1;i++){
        int ans=c[i]+s[i];
        for(int j=i+1;j<n-1;j++){
            if(ans>=s[j]&&ans%f[j]==0)ans+=c[j];
            else if(ans>=s[j]&&ans%f[j]!=0)ans+=f[j]-(ans%f[j])+c[j];
            else ans=s[j]+c[j];
        }
        cout<<ans<<endl;
    }
    cout<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> a(n + 1);
  for(int i = 0;i < n + 1;i++)cin >> a[i];
  if(n == 0){
    if(a[0] == 1)cout << 1 << endl;
    else cout << -1 << endl;
    return 0;
  }
  ll res = 0;
  //vector<ll> x(n + 1);
  vector<ll> y(n + 1);
  y[0] = 1;
  vector<ll> wa(n + 1);
  //x[0] = 0,y[0] = 0;
  if(a[0] != 0){
    cout << -1 << endl;
    return 0;
  }
  wa[n] = a[n];
  for(int i = n - 1;i >= 0;i--)wa[i] = wa[i + 1] + a[i]/*,cout << wa[i] << " "*/;
  //cout << endl;
  for(int i = 1;i < n + 1;i++){
    ll now = 0;
    now = y[i - 1] * 2 - a[i];
    //cout << y[i - 1] * 2 << " " << a[i] << endl;
    if(wa[i] - a[i] < 0 || now < 0){
      cout << -1 << endl;
      return 0;
    }
    now = min(now,wa[i] - a[i]);
    y[i] = now;
  }
  for(int i = 0;i < n + 1;i++)res += a[i] + y[i];
  cout << res << endl;
}

Measured memory_bytes: 5564
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    from heapq import heappush, heappushpop, heappop
    Q = I()
    # highはそのままheapq
    high = []
    # lowは一番デカイのを取り出せるように符号逆転して、heapq
    low = []

    _, a, b = MI()
    heappush(low, -a)

    debug = [a]

    # debug用
    def solve(n):
        ans = 0
        for a in debug:
            ans += abs(a - n)

        return B + ans

    B = b
    ans = 0
    cnt = 1
    for _ in range(Q - 1):
        inp = input()
        if inp[0] == "1":
            _, a, b = map(int, inp.split())
            B += b
            debug.append(a)
            cnt += 1

            # 偶数なら答えを更新してから、heapqを更新
            if cnt % 2 == 0:
                ans += abs(-low[0]-a)
                even = True
            else:
                even = False

            # lowに入れるかhighに入れるか
            if a > -low[0]:
                heappush(high, a)
            else:
                heappush(low, -a)

            # 中央値がわかるように平衡化
            if len(low) < len(high):
                heappush(low, -heappop(high))
            elif len(low) > len(high) + 1:
                heappush(high, -heappop(low))

            # 奇数ならheapqを更新してから答えを更新
            if not even:
                ans += abs(-low[0] - a)

        else:
            print(-low[0], ans + B)
            #print(-low[0], solve(-low[0]))
        #print(sorted(debug), low, high, ans)
    # print(sorted(debug))


if __name__ == '__main__':
    main()


Measured memory_bytes: 87896
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define s(n) scanf("%d", &n)
#define sc(n) scanf("%c", &n)
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define ss(n) scanf("%s", n)
#define INF (int)1e9
#define EPS 1e-9
#define bitcount __builtin_popcount
#define gcd __gcd
#define n_mod(a, k) ((a % k) + k) % k
#define mod(a, k) (a % k)
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
#define LSOne(S) (S & (-S))
#define repa(v) lpi(i, 0, sz(v)) lpi(j, 0, sz(v[i]))
#define P(x) cout << #x << " = { " << x << " }\n"
#define PB push_back
#define MP make_pair
#define M_PI 3.14159265358979323846
#define fast_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define file_IO                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<string> vs;
int dcmp(double x, double y)
{
    return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}
const int MAX = 3 * 1e3 + 10;
int memo[MAX][MAX];
string s, t;
int n, m;
int dp(int i, int j)
{
    if (i == n || j == m)
        return 0;
    int &ret = memo[i][j];
    if (ret != -1)
        return ret;
    if (s[i] == t[j])
        return ret = dp(i + 1, j + 1) + 1;
    else
    {
        return ret = max(dp(i + 1, j), dp(i, j + 1));
    }
}
void print_path(int i, int j)
{
    if (i == n || j == m)
        return;
    if (s[i] == t[j])
    {
        cout << s[i];
        print_path(i + 1, j + 1);
    }
    else
    {
        int path1 = dp(i + 1, j);
        int path2 = dp(i, j + 1);
        if (path1 >= path2)
        {
            print_path(i + 1, j);
        }
        else
        {
            print_path(i, j + 1);
        }
    }
}
int main()
{

    fast_IO;

    clr(memo, -1);
    cin >> s >> t;
    n = s.size();
    m = t.size();
    int tmp = dp(0, 0);
    print_path(0, 0);
}

Measured memory_bytes: 35968
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int h, w, k, ans = 0;
    cin >> h >> w >> k;

    vector<string> s(h);
    rep(i, h) cin >> s[i];

    rep(bith, 1 << h) rep(bitw, 1 << w) {
        int count = 0;
        rep(i, h)rep(j, w) {
            if(bith >> i&1) continue;
            if(bitw >> j&1) continue;
            if(s[i][j] == '#') ++count;
        }
        if(count == k) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x,y;
    for (int i=1;i<=5;i++){
        cin>>x;
        if (!x)
            y=i;
    }
    cout<<y;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>

using namespace std;


int main()
{
	int n;
	int ans;

	for(;cin >> n;)
	{
		ans=0;
		
		for(int i=0;i<10;i++)
		{
			for(int j=0;j<10;j++)
			{
				for(int k=0;k<10;k++)
				{
					for(int l=0;l<10;l++)
					{
						if(i+j+k+l==n)
							ans++;
					}
				}
			}
		}
	
	cout << ans << endl;
	
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll h,w;
    cin>>h>>w;
    if(w>=h)putout("unsafe");
    else putout("safe");
    return 0;
}


Measured memory_bytes: 3636
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    d1 = {}
    d2 = {}
    for i in range(n):
        if i + a[i] not in d1:
            d1[i + a[i]] = 1
        else:
            d1[i + a[i]] += 1
    s1 = set(d1.keys())
    for i in range(n):
        if i - a[i] not in d2:
            d2[i - a[i]] = 1
        else:
            d2[i - a[i]] += 1
    s2 = set(d2.keys())
    s = list(s1 & s2)
    c = 0
    for i in s:
        c += d1[i] * d2[i]
    print(c)

main()

Measured memory_bytes: 75996
#include <iostream>

using namespace std;

int main() {
    long int n, r;
    long int ans = 0;

    cin >> n >> r;
    if (n > 9){
        cout << r <<"\n";
        return 0;
    }
    else{
        cout << r + (100*(10-n))<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  let  n:number = next();
  let  morty:number[] = nexts(n);
  let rick:number[] = [];
  let tmp:nember = morty[0];
  let i ;
  for(i = 1;i<morty.length;i++){
    
  	tmp^=morty[i];
  }
  for( i  = 0;i<morty.length;i++){
    
    let x = morty[i]^tmp;
    rick.push(x)
  }
  return rick.join(" ");
}


Measured memory_bytes: 69144
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
inline LL in()
{
    LL x = 0, flag = 1; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') flag = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * flag;
}
char ch[200];
LL len, m;
LL K = 5000000000000000 - 1;
LL fastpow(LL a, LL b)
{
    LL ret = 1;
    while (b) 
    {
        if (b % 2 == 1) b --, ret *= a;
        else b /= 2, a *= a;
    }
    return ret;
}
int main()
{
    scanf("%s", ch + 1);
    scanf("%lld", &m);
    len = strlen(ch + 1);
    LL pos = 0;
    for (int i = 1; i <= len; i ++)
    {
        if (ch[i] == '1') pos = i;
        else break;
    }
    if (pos >= m) printf("1");
    else printf("%c", ch[pos + 1]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

struct State { int cnt, marg; };
bool operator>(const State& a, const State& b) {
    return tie(a.cnt, a.marg) > tie(b.cnt, b.marg);
}

int h, w;

int area(int hi, int hl, int wi, int wl, vector<vector<int>>& S) {
    if (hi > 0 && wi > 0) {
        return S[hi+hl-1][wi+wl-1] - S[hi+hl-1][wi-1] - S[hi-1][wi+wl-1] + S[hi-1][wi-1];
    }
    if (hi > 0) {
        return S[hi+hl-1][wi+wl-1] - S[hi-1][wi+wl-1];
    }
    if (wi > 0) {
        return S[hi+hl-1][wi+wl-1] - S[hi+hl-1][wi-1];
    }
    return S[hi+hl-1][wi+wl-1];
}

const int INF = 1<<29;
State dp[33][33][33][33];

int main()
{
    while (1) {
        fill(dp[0][0][0], dp[32][32][32]+33, State{ 0, 0 });
        int s; cin >> h >> w >> s;
        if (!h) break;

        vector<vector<int>> U(h, vector<int>(w));
        loop (h, i) loop (w, j) cin >> U[i][j];
        vector<vector<int>> S = U;
        loop (h, i) loop (w-1, j) S[i][j+1] += S[i][j];
        loop (w, j) loop (h-1, i) S[i+1][j] += S[i][j];
        int sum = S[h-1][w-1];

        for (int hl = 1; hl <= h; hl++) for (int wl = 1; wl <= w; wl++)
        loop (h, hi) loop (w, wi) {
            if (hi + hl > h || wi + wl > w) continue;

            State crr;
            int marg = s - (sum - area(hi, hl, wi, wl, S));
            if (marg >= 0) crr = { 1, marg };
            else crr = { 0, 0 };

            for (int i = 1; hi + i < h && hl - i > 0; i++) {
                auto a = dp[hi][i][wi][wl];
                auto b = dp[hi+i][hl-i][wi][wl];
                auto s = State{ a.cnt + b.cnt, min(a.marg, b.marg) };
                if (s > crr) crr = s;
            }
            for (int i = 1; wi + i < w && wl - i > 0; i++) {
                auto a = dp[hi][hl][wi][i];
                auto b = dp[hi][hl][wi+i][wl-i];
                auto s = State{ a.cnt + b.cnt, min(a.marg, b.marg) };
                if (s > crr) crr = s;
            }
            dp[hi][hl][wi][wl] = crr;
        }

        auto ans = dp[0][h][0][w];
        cout << ans.cnt << " " << ans.marg << endl;
    }
    return 0;
}

Measured memory_bytes: 12384
if __name__ == '__main__':
    a = int(input())
    b = [int(i) for i in input().split()]
    ans = 1
    b.sort(reverse=True)
    if 0 in b:
        ans = 0
    else:
        for i in range(len(b)):
            ans *= b[i]
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)

Measured memory_bytes: 88624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20190304_03 {
    class Program {
        static void Main(string[] args) {
            var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var a = line[0];
            var b = line[1];
            var c = line[2];
            var n = b / a > c ? c : b / a;
            Console.WriteLine(n);
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>  
#include <algorithm>
using namespace std;  
int main() { 	
	int a,b,c;
	int d;
	scanf("%1d%1d%1d", &a,&b,&c);
	if(a==9){
		a=1;
	}
	else if(a==1){
		a=9;
	}
	if(b==9){
		b=1;
	}
	else if(b==1){
		b=9;
	}
	if(c==1){
		c=9;
	}
	else if(c==9){
		c=1;
	}
	printf("%d%d%d", a , b, c);

	
	
}






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

/* {{{ */
#define CL(N) cout << N << endl
#define DCT(N) cout << "debug " << N << endl
#define REP(i, N) for (int i = 0; i < N; i++)
/* }}} */

int main()
{
    int a, b, c;

    while (cin >> a >> b >> c, a || b || c){

        int n, m[1000][4], q[300];

        fill(q, q + 300, 2);

        cin >> n;

        REP(i, n){
            cin >> m[i][0] >> m[i][1] >> m[i][2] >> m[i][3];
            m[i][0]--;
            m[i][1]--;
            m[i][2]--;
            if (m[i][3] == 1){
                q[m[i][0]] = q[m[i][1]] = q[m[i][2]] = 1;
            }
        }

        REP(i, n){ 
            int onec = 0;
            if (m[i][3] == 0){
                REP(j, 3){
                     if (q[m[i][j]] == 1) onec++;
                }
            }
            if (onec == 2){
               REP(j, 3){
                   if (q[m[i][j]] == 2){
                       q[m[i][j]] = 0;
                   }
               }
            }
        }

        REP(i, a + b + c){
            CL(q[i]);
        }
    }

	return (0);
}

Measured memory_bytes: 3092
#import<bits/stdc++.h>
using namespace std;main(){int x1,y1,x2,y2,n,xf=1,yf=1,x,y;scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&n);if(x1>x2)swap(x1,x2),xf=-1;if(y1>y2)swap(y1,y2),yf=-1;vector<pair<int,int>>v;for(;n--;)if(scanf("%d%d",&x,&y),x1<=x&&x<=x2&&y1<=y&&y<=y2)v.emplace_back(x*xf,y*yf);sort(v.begin(),v.end());vector<int>d(v.size(),1<<30);for(auto&e:v)n=e.second,*lower_bound(d.begin(),d.end(),n)=n;n=lower_bound(d.begin(),d.end(),1<<30)-d.begin();printf("%.9f\n",100.0*(x2-x1+y2-y1)-20*n+5*(n+(n>min(x2-x1,y2-y1)))*3.1415926536);}

Measured memory_bytes: 2544
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        int z = Y/1000;
        for(int x = 0;z-5*x >= 0;x++){
            for(int y = 0;z-5*x-10*y >= 0;y++){
                if(z-4*x-9*y == N){
                    System.out.println(y+" "+x+" "+(z-5*x-10*y));
                    return;
                }
            }
        }
        System.out.println(-1+" "+-1+" "+-1);
    }
}

Measured memory_bytes: 21844
from collections import deque

def min_coin_select(C, m, n):
    DP = [float('inf')] * (n+1)
    DP[0] = 0
    # Cのindexが合わないので左をゼロ埋め。Cはdequeとする。
    C.appendleft(0)

    for i in range(1, m+1):
        for j in range(1, n+1):
            if j >= C[i]:
                DP[j] = min(DP[j-C[i]] + 1, DP[j])

    return DP[n]

def read_and_print_results():
    n, m = [int(i) for i in input().split()]
    C = deque([int(i) for i in input().split()])
    print(min_coin_select(C, m, n))

read_and_print_results()


Measured memory_bytes: 7924
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next; //番兵の次の要素からたどる
    while( cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while ( 1 ){
        if ( cur == nil ) break;
        if ( isf++ > 0 ) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}





void deleteNode(Node *t){
    if( t == nil) return;//tが番兵の場合は処理しない
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    x->next->prev = x;
    x->prev = nil;
    nil->next = x;
}

int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for ( i = 0; i < n; i++){
        scanf("%s%d", com, &key);
        if (com[0] == 'i'){insert(key); np++; size++;}
        else if(com[0] == 'd'){
            if ( strlen(com) > 6){
                if (com[6] =='F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            }
            else{
                deleteKey(key);
                nd++;
            }
            size++;
        }
    }
    printList();
    return 0;

}


Measured memory_bytes: 33920
#include<iostream>

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main()
{
    int a, b;   cin >> a >> b;

    if((a + b) % 2){
        cout << "IMPOSSIBLE";
    }
    else{
        cout << (a + b) / 2;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
/*配列の要素を順番に出力*/
void trace(int A[], int N) {
	int i;
	for (i = 0;i < N;i++) {
		if (i > 0)printf(" ");/*隣接する要素の間に1つの空白を出力*/
		printf("%d", A[i]);
	}
	printf("\n");
}


/*挿入ソート(0オリジン配列*/
void insertionSort(int A[], int N) {
	int j, i, v;
	for (i = 1;i < N;i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}
int main() {
	int N, i, j;
	int A[100];

	scanf("%d", &N);
	for (i = 0;i < N;i++)scanf("%d", &A[i]);

	trace(A, N);
	insertionSort(A, N);

	return 0;


}


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

int d[55];
int main(void)
{
  ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>d[i];
  int sum=0;
  for(int i=1;i<n;i++)
    for(int j=i+1;j<=n;j++)
      sum+=d[i]*d[j];
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}

ll mulmod(ll a, ll b, ll mod){ 
    ll res = 0; 
    a = a % mod; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % mod;
        }
        a = (a * 2) % mod; 
        b /= 2; 
    } 
    return res % mod; 
} 

 
int main()
{
	ios_base::sync_with_stdio(false);
    int mis = 0;
    int n;
    cin >> n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin >> a[i];
        if(a[i]!=i){
            mis++;
        }
    }
    if(mis<=2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;


typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(){}
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

pair<Weight, Edges> VoronoiMST(const Graph &G1,const vint &S,Graph &G2){
  int N = S.size();
  G2.resize(N);
  Weight total=0;
  Edges F;
  priority_queue<Edge> Q;
  vint dist(G1.size(),0),used(G1.size(),0),from(G1.size(),-1);
  repeat(i,N){
    Q.push({-1,S[i],0});
    from[S[i]]=i;
  }
  int cnt=1;
  while(!Q.empty()){
    Edge e=Q.top();Q.pop();
    int v = e.dst;
    if(used[v]){
      if(used[v]>used[e.src]){
        total += dist[v]+e.weight;
        F.push_back({from[v],from[e.src],dist[v]+e.weight});
        G2[from[v]].push_back({from[v],from[e.src],dist[v]+e.weight});
        G2[from[e.src]].push_back({from[e.src],from[v],dist[v]+e.weight});
      }
      continue;
    }
    used[v]=cnt;
    cnt++;
    dist[v] = e.weight;
    from[v] = from[e.src];
    for(Edge f:G1[v]){
      Q.push({v,f.dst,dist[v]+f.weight});
    }
  }
  return make_pair(total,F);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  Graph G(N*2);
  repeat(i,N){
    Weight x;cin>>x;
    G[i].push_back({(int)i,(int)(N+i),x});
    G[N+i].push_back({(int)(N+i),(int)i,x});
  }
  repeat(i,N-1){
    int A,B;Weight C;
    cin>>A>>B>>C;
    A--;B--;
    G[A].push_back({A,B,C});
    G[B].push_back({B,A,C});
  }
  vint S(N);
  repeat(i,N){
    S[i]=N+i;
  }
  Graph g;
  cout << VoronoiMST(G,S,g).first << endl;
  return 0;
}


Measured memory_bytes: 78696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

ll solve(){
    ll n,m,k;
    cin >>n >>m >>k;

    n %= 10;

    if(m == 0) return n*k;

    vector<int> v;
    bool u[10]={};
    ll t = n;
    while(!u[t]){
        u[t] = true;
        v.pb(t);
        t = (t*n)%10;
    }

    // dbg(v);
    int V = v.size();
    ll mul = v[(m-1)%V];

    v.clear();
    rep(i,10) u[i] = false;
    t = n;
    while(!u[t]){
        u[t] = true;
        v.pb(t);
        t = (t*mul)%10;
    }

    // dbg(v);
    V = v.size();

    ll sv = 0;
    for(ll i:v) sv += i;

    ll ans = sv*(k/V);
    rep(i,k%V) ans += v[i];
    return ans;
}

int main(){
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3160
import java.util.Scanner;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main (String[] args) {
		int n = sc.nextInt();	
		int A [] = new int [n+1];
		for (int i=1; i<=n; i++){
			A[i]=sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		int diff= Integer.MIN_VALUE;
		for (int j=1; j<n; j++){
			min = Math.min(min, A[j]);
			diff = Math.max(diff, A[j+1]-min);
		}
		System.out.println(diff);
	}
}

Measured memory_bytes: 101304