akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

vector<string> card;
set<int> used;
set<int> ans;
int s[4];
int n,k;

void saiki(int t){
    if(t == k){
	string ss = "";
	REP(i,k) ss += card[s[i]];
	ans.insert(stoi(ss));
	return;
    }
    REP(i,n){
	if(used.find(i) == used.end()){
	    used.insert(i);
	    s[t] = i;
	    saiki(t+1);
	    used.erase(i);
	}
    }
}

int main(){
    while(true){
	cin >> n >> k;
	if(n==0&&k==0) break;
	card = vector<string>(n);
	REP(i,n){
	    cin >> card[i];
	}
	saiki(0);
	cout << ans.size() << endl;
	ans.clear();
	used.clear();
    }
    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
long long sod(long long n, long long b){
	if(b <= 1) return 0;
	long long ans = 0;
	while(n){
		ans += n % b;
		n /= b;
	}
	return ans;
}
int main(){
	long long n, s; cin >> n >> s;
	const int magic = 1'000'000;
	vector<long long> cand;
	auto check = [&](long long b){
		if(sod(n, b) == s){
			cand.push_back(b);
		}
	};
	for(int i = 2; i <= magic; i++){
		check(i);
	}
	if(n < s) return cout << -1 << endl, 0;
	if(n == s) return cout << n + 1 << endl, 0;
	for(int i = 1; i <= magic; i++){
		check(i + 1);
	}
	for(int i = 1; i <= magic; i++){
		check((n - s) / i + 1);
	}
	if(cand.empty()) cout << -1 << endl;
	else {
		sort(cand.begin(), cand.end());
		cout << cand[0] << endl;
	}
	return 0;
}


Measured memory_bytes: 8812
# input here
_INPUT = """\
6
1 1
2 2
3 3
4 4
5 5
6 6
"""
"""
K = int(input())
H, W, K = map(int, input().split())
a = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(N)]
p = tuple(map(int,input().split()))
"""
def main():
    N = int(input())
    D = [list(map(int, input().split())) for i in range(N)]

    count = 0
    for i in range(N):
        if count >= 3:
            break

        if D[i][0] == D[i][1]:
            count += 1
        else:
            count = 0

    if count >= 3:
        print("Yes")
    else:
        print("No")

            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 67244
#include <iostream>
#define MAX_N  101
#define MAX_W   100001
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
//dp retorna el mejor valor posible para el peso disponible y los articulos faltantes disponiles
int N;
int W;
long long  dp[MAX_N][MAX_W];
int pesos[MAX_N];
long long valores[MAX_N];
long long value(int peso_disponible,int  articulo){
	if(peso_disponible==0|| articulo==0)return 0;
	if(dp[articulo][peso_disponible]!=-1)
	return 	dp[articulo][peso_disponible];
	
	if(peso_disponible-pesos[articulo]>=0)
	return dp[articulo][peso_disponible]=max(value(peso_disponible-pesos[articulo],articulo-1)+valores[articulo],value(peso_disponible,articulo-1));
	return value(peso_disponible,articulo-1);
	}
void fillDp(){
	for(int i =0;i<MAX_N;i++)
{
	for (int j=0;j<MAX_W;j++){
		dp[i][j]=-1;
	}
	
	
	}	
}



int main(int argc, char** argv) {
	cin>>N>>W;
	for (int i =1;i<=N;i++){
	cin>>pesos[i]>>valores[i];
	
	}
	fillDp();
	
	cout<<value(W,N)<<endl;

	return 0;
}


Measured memory_bytes: 79104
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c,f[1005];
int main(){
	for(int i=1;i<=999;i++)
		f[i]=i+f[i-1];
	scanf("%d%d",&a,&b);
	c=b-a;
	printf("%d\n",f[c]-b);
}

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

#include<cmath>

int main()
{


    int a,b;
    cin>>a>>b;

  	int wk=(a+b)/2;
  	if(abs(a-wk)==abs(b-wk))
	    cout<<(a+b)/2<<endl;
	else
      	cout<<"IMPOSSIBLE"<<endl;
  
    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);
		while(true) {
			int n = sc.nextInt();
			if(n==1) break;
			boolean [] ms = new boolean[n+1];
			for(int i=2;i<=n/2;i++) {
				if(!ms[i]) {
					if(n%i == 0 && (i%7 == 1 || i%7 == 6)){
						ms[i] = true;
						for(int j = 2*i;j<=n;j += i) {
							ms[j] = true;
						}
					}
				}else {
					ms[i] = false;
				}
			}
			System.out.print(n+":");
			for(int i=2;i<=n/2;i++) {
				if(ms[i]) {
					System.out.print(" "+i);
				}
			}
			if(!ms[n]) {
				System.out.print(" "+n);
			}
			System.out.println();
		}
	}
}



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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


    int deg[100005];
    vector<int> to[100005];
int main(){
    
    vector<int> d(4,-1);
    int n,m,k;
    cin >> n>> m >> k;

    UnionFind uf(n);

    repo(i,m){
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        deg[a]++;
        deg[b]++;
        uf.unite(a,b);
        
//         repo(j,n){
//             cout << deg[j] << " ";
//         }
//         cout << endl;
//
//
//         repo(j,n){
//             cout << uf.size(j) << " ";
//         }
//         cout << endl;
    }
    repo(i,k){
        int a,b;
        cin >> a>> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);

    }
    repo(i,n){
        int ans = uf.size(i) -1 -deg[i];
//         cout << i << "の答えは" << ans << endl;
        for(int u : to[i]){
            if(uf.same(i,u)){
                --ans;
//                 cout << i << "と" << u << "はおなじunateでした よってansは" << ans << endl;
            }
            
        }
                
//         cout << ans;
//         if(i < n-1) cout << " ";
//         else cout << endl;
        printf("%d%c", ans, i==n-1?'\n':' ');
    }
//     cout << endl;

    return 0;
}



Measured memory_bytes: 6784
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<climits>
#include<cfloat>
#include<sstream>
#define all(c) (c).begin(),(c).end()
#define INF (1<<29)

using namespace std;


double dist(double p,double q){
  double a=p+q,b=abs(p-q);
  return sqrt(a*a-b*b);
}

int count(int bits){
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits =(((bits >> 4) + bits) & 0x0f0f0f0f);
  bits += bits >> 8;
  return (bits + (bits >> 16)) & 0xff;
}

double dp[(1<<12)][12];

int main(void){

  string str;
  while(getline(cin,str)){
    int value;
    stringstream ss(str);
    vector<double>in;
    while(ss >> value)in.push_back(value);
    if(in.size()<1)break;
    double L=in[0];

    int m=in.size()-1;
    vector<double>p(m);
    for(int i=1;i<in.size();i++)p[i-1]=in[i];

    fill(dp[0],dp[1<<12],INF);
    for(int i=0;i<m;i++)dp[1<<i][i]=p[i];

    for(int S=0;S<(1<<m);S++){
      for(int v=0;v<m;v++){
	for(int u=0;u<m;u++){
	  if(S>>u&1 || !(S>>v&1))continue;
	  int nx=S;
	  nx|=(1<<u);
	  if(count(S)==m-1)dp[nx][u]=min(dp[nx][u],dp[S][v]+dist(p[v],p[u])+p[u]);
	  else dp[nx][u]=min(dp[nx][u],dp[S][v]+dist(p[v],p[u]));
	}
      }
    }
    double ans=INF;
    for(int i=0;i<m;i++)ans=min(ans,dp[(1<<m)-1][i]);
    if(ans<=L)cout << "OK" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1620
#include<iostream>
#include<algorithm>
using namespace std;
int x[200][200], y[200], z[200], n, i, a, j, k, b, s, c;
int main() {
	while (true) {
		cin >> n; b = 0;
		if (!n) { break; }
		for (i = 1; i <= n;i++){
			cin >> z[i];
			for (j = 0; j < z[i];j++){
				cin >> x[i][j];
			}
		}
		cin >> a;
		for (i = 0; i < a; i++) { cin >> y[i]; }
		for (i = 1; i <= n; i++) {
			s = 0;
			for (j = 0; j < a; j++) {
				for (k = 0; k < z[i]; k++) {
					if (x[i][k] == y[j]) {
						s++;
					}
				}
			}
			if (s == a) { c = i; b++; }
		}
		if (b - 1) { c = -1; }
		cout << c << endl;
	}
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define S second
using namespace std;
map<int, int> m;
signed main() {
	int n;
	cin >> n;
	f(i, n) {
		int c;
		cin >> c;
		m[c]++;
	}
	for (P p : m) {
		if (p.S >= 2) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}




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

#define N 100100

int n, a[N];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i ++) scanf("%d", &a[i]);
    int cnt = 0, mn = 1e9;
    long long sum = 0;
    for (int i = 0; i < n; i ++) {
        if (a[i] < 0) cnt ++;
        sum += abs(a[i]);
        mn = min(mn, abs(a[i]));
    }
    cerr << mn << endl;
    if (cnt & 1) sum -= 2 * mn;
    cout << sum << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 5;
//head
int a[256];
int main() {
    char ch;
    a['A'] = 'T';
    a['T'] = 'A';
    a['C'] = 'G';
    a['G'] = 'C';
    cin >> ch;
    cout << (char)a[ch] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<String, Integer>();
        String str1 = sc.next();
        for (int i = 0; i < str1.length(); i++) {
            String key = String.valueOf(str1.charAt(i));
            int val = map.getOrDefault(key, 0);
            map.put(key, ++val);
        }
        for (int i = 1; i < n; i++) {
            Map<String, Integer> maptmp = new HashMap<String, Integer>();
            String str = sc.next();
            for (int j = 0; j < str.length(); j++) {
                String key = String.valueOf(str.charAt(j));
                int val = maptmp.getOrDefault(key, 0);
                maptmp.put(key, ++val);
            }
            
            for (String key : map.keySet()) {
                int val = map.get(key);
                map.put(key, Math.min(val, maptmp.getOrDefault(key, 0)));
            }
        }
        
        int[] alphabet = new int[26];
        for (String key : map.keySet()) {
            int val = map.get(key);
            char c = key.charAt(0);
            int num = c - 'a'; // 'b' -> 1
            alphabet[num] = val;
        }
        
        boolean ng = true;
        for (int i = 0; i < 26; i++) {
            int max = alphabet[i];
            char c = (char)(i + 'a');
            for (int j = 0; j < max; j++) {
                System.out.print(c);
                ng = false;
            }
        }
        if (ng) return;
        System.out.println();
    }
}


Measured memory_bytes: 21716
n = int(input())
taro = 0
hana = 0

for i in range(n):
  tc, hc = input().split()
  
  if tc > hc:
    taro += 3
  elif tc < hc:
    hana += 3
  else:
    taro += 1
    hana += 1
    
print(taro, hana)


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

int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	vector<vector<int>> ans(H, vector<int>(W));
	for (int i = 0; i < A; i++) {
		for (int j = 0; j < B; j++) ans[j][i] = 1;
	}
	for (int i = A; i < W; i++) {
		for (int j = B; j < H; j++) ans[j][i] = 1;
	}
	for (vector<int>& i : ans) {
		for (int& j : i) cout << j;
		cout << endl;
	}
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n), a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        p[i]--;
        a[i] = 30000 * (i + 1);
        b[i] = 30000 * (n - i - 1) + 1;
    }
    for(int i=0; i<n; i++){
        a[p[i]]+=i;
    }
    for (auto &p : a)
        cout << p << " ";
    cout << endl;
    for (auto &p : b)
        cout << p << " ";
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
using namespace std;


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

	int ans = 0;
	int i=0,j=0,k=0;
	int temp;
	rep(i,a+1){
		temp = 500 * i;
		if(temp > x)
			break;
		/*
		if(temp == x){
			ans++;
			cout << i << j << k << endl;
			cout << "temp" << temp <<endl;
		}
		*/
		rep(j,b+1){
			temp = 500 * i + 100 * j;
			if(temp > x)
				break;
			/*
			if(temp == x){
				ans++;
				cout << "temp" << temp <<endl;
				cout << i << j << k << endl;
			}
			*/
			rep(k,c+1){
				temp = 500 * i + 100 * j + 50 * k;
				if(temp == x){
					ans++;
					break;
				}
			}
		}
	}

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



Measured memory_bytes: 256
#include <stdio.h>



int main(void){
	
    int x, y;
    while(1){
        scanf("%d%d", &x, &y);
        if(x==0){
            if(y==0){
                break;
            }
        }
        if(x<y){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}		  

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

vector<int> v;
int n, k, sm;

int main() {
#ifdef HOME
	freopen("agc018a.in", "r", stdin);
	freopen("agc018a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	v.resize(n);
	for (auto &i: v)
		cin >> i;

	sm = v[0];
	for (auto i: v)
		sm = gcd(sm, i);

	for (auto i: v)
		if (i >= k && (i - k) % sm == 0) {
			cout << "POSSIBLE\n";
			return 0; }
	cout << "IMPOSSIBLE\n";

	return 0; }



Measured memory_bytes: 640
#[allow(dead_code)]
fn main() {
    let buf = io::read_string();
    let mut sc = io::Scanner::new(&buf);
    let s: String = sc.read();
    let s = s.into_bytes();
    let mut f = true;
    let mut f2 = false;
    for i in 2..s.len() {
        if s[i] == b'C' && !f2 && i < s.len() - 1 {
            f2 = true;
        } else if (s[i] as char).is_uppercase() {
            f = false;
            break;
        }
    }

    println!(
        "{}",
        if s[0] == b'A' && (s[1] as char).is_lowercase() && f && f2 {
            "AC"
        } else {
            "WA"
        }
    );
}
#[allow(dead_code)]
mod io {
    use std;
    use std::io::Read;
    use std::str::{FromStr, SplitWhitespace};
    pub struct Scanner<'a> {
        pub iter: SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.iter
                .next()
                .unwrap()
                .parse()
                .ok()
                .expect("parsing failed")
        }
        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}


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

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

    ll n;
    cin >> n;
    vvll a(n, vll(n - 1));

    REP(i, n){
        REP(j, n - 1){
            cin >> a[i][j];
            a[i][j]--;
        }
        // pop back の方が早いので reverse しておくといいらしい
        reverse(ALL(a[i]));
    }
    // p : 試合リスト
    vector<P> p;
    // 試合リスト p の構築
    auto check = [&](ll i) {
        if (a[i].size() == 0) return;
        ll nxt = a[i].back();
        if (a[nxt].back() == i) {
            P x = P{i, nxt};
            if (i < nxt) swap(x.first, x.second);
            p.push_back(x);
        }
    };

    // 初期化
    REP(i, n){
        check(i);
    }

    // 試合ができるならば消化していく
    ll res = 0;
    while (p.size()) {
        res++;
        sort(ALL(p));
        p.erase(unique(ALL(p)), p.end());
        // 試合リストの次状態は check で p に格納
        vector<P> cur;
        swap(cur, p);
        for (auto x : cur) {
            ll s = x.first, t = x.second;
            a[s].pop_back();
            a[t].pop_back();
            check(s);
            check(t);
        }
    }

    REP(i, n){
        if(a[i].size()){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << res << endl;
    return 0;
}

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
template<class T> using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-10;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
char s[505][505];
void solve() {
    cin >> n;
    rep(i, n) rep(j, n) cin >> s[i][j];

    if (all_of(s, s + n, [](auto& x) {return all_of(x, x + n, [](auto& x) {return x == '.'; }); })) {
        cout << -1 << endl;
        return;
    }

    int res = iinf;
    rep(i, n) {
        int cnt = count_if(s[i], s[i] + n, [](auto& x) {return x == '.'; }) + 1;
        rep(j, n) {
            if (s[j][i] == '#') {
                cnt -= 1;
                break;
            }
        }
        mins(res, cnt);
    }

    int res2 = 0;
    rep(j, n) rep(i, n) {
        if (s[i][j] == '.') { ++res2; break; }
    }
    cout << res + res2 << endl;
}

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


Measured memory_bytes: 892
import std.string;
import std.stdio;
import std.conv;
import std.algorithm;

int[] nums = [0,1,2,3,4,5,6,7,8,9];
int n,s;

int saiki(int x,int m,int item){

    if(m == s && item == n) return 1;
    if(x == 10) return 0;
    return saiki(x+1,m+nums[x],item+1) + saiki(x+1,m,item);
}


void main(){

    while(true){
	auto ss = split(readln());
	n = to!int(ss[0]);
	s = to!int(ss[1]);
	if(n == 0 && s == 0) break;
	writeln(saiki(0,0,0));
    }
}

Measured memory_bytes: 2448
fun main(args:Array<String>):Unit {
    while(true){
        val (n, m) = readLine()!!.split(' ').map(String::toInt)
        if (n == 0 && m == 0) return
        val heights = Array(n){readLine()!!.toInt()}
        val widths = Array(m){readLine()!!.toInt()}
        for (i in 1 until n) heights[i] += heights[i - 1]
        for (j in 1 until m) widths[j] += widths[j - 1]
        val memoHeight = Array(1000 * n + 1){0}
        val memoWidth = Array(1000 * m + 1){0}
        for (height in heights) memoHeight[height]++
        for (width in widths) memoWidth[width]++
        for (i in 0 until n) for (j in (i + 1) until n) memoHeight[heights[j] - heights[i]]++
        for (i in 0 until m) for (j in (i + 1) until m) memoWidth[widths[j] - widths[i]]++
        println(
                memoHeight.zip(memoWidth).map{(a, b) -> a * b}.sum()
        )
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int n;
    cin >> n;

    vi time(n);
    int sum=0;
    for (int i = 0; i < n; i++) {
        cin >> time[i];
        sum += time[i];
    }

    int m;
    cin >> m;
    vvi drink(m, vi(2,0));
    for (int i = 0; i < m; i++) {
        cin >> drink[i][0];
        drink[i][0]--;
        cin >> drink[i][1];
    }

    for (int i = 0; i < m; i++) {
        cout << sum - time[drink[i][0]] + drink[i][1] << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

Measured memory_bytes: 256
//
//  Stable sort
//
//
//  Description:
//
//      In the case when sorting cards by using
//      bubble sort and selection sort, bubble
//      sort can sort the cards correctly, but
//      selection sort sometimes fails to sort
//      them correctly.
//
//  Complexity of is Stable:
//
//  O(n)
//

#include<iostream>
using namespace std;

struct Card { char suit, value;};

void bubble(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N - 1; j >= i; j--) {
            if (A[j].value < A[j - 1].value) {
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if ( i > 0 ) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for (int i = 0; i < N; i++) C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>
#include <chrono>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)



using namespace std;


char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };


void solve() {

    int n;
    cin >> n;
    
    cout<<(n+1)%2<<endl;
}

int main() {

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

    
        solve();


    return 0;
}


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

int main() {
    int N;
    cin >> N;
    //入力
    int v_arr[N];

    int i;
    vector<int> ans;
    double sum;
    //入力
    for (i =0;i<N; i++){
        cin >> v_arr[i];
    }
    sort (v_arr,v_arr+N);

    
    for (i=0;i<N;i++){
        if (i==0){
            sum=v_arr[i];
        }
        if (i !=0){
            sum=(sum+v_arr[i])/2;
        }
    }

    cout << sum << endl;
    return 0;
}



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

int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    
    if(a>b){
        int x=a-b;
        if(x>c){
            cout<<0<<endl;
        }
        else
        cout<<c-x<<endl;
    }
    else{
        int x=b-a;
        if(x>c){
            cout<<0<<endl;
        }
        else
        {
            cout<<c-x<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

int n;

int a[200005];
int l[200005];
int nxt[200005];

int memo[200005];

int dp(int pos) {
	if (pos == -1) return 0;
	if (pos == n) return 1;
	if (memo[pos] != -1) return memo[pos];
	return memo[pos] = (dp(pos+1) + dp(nxt[pos]) * (nxt[pos] > pos+1)) % MOD;
}

int main() {
	memset(memo, -1, sizeof memo);
	memset(nxt, -1, sizeof nxt);
	memset(l, -1, sizeof l);
	scanf("%d", &n);
	for (int i=0 ; i<n ; i++) {
		scanf("%d", a+i);
		if (l[a[i]] != -1) {
			nxt[l[a[i]]] = i;
		}
		l[a[i]] = i;
	}
	printf("%d\n", dp(0));
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		if (b)cout << endl;
		int c;
		cin >> c;
		bool d[100][100]{};
		int x = c - 1, y = 0;
		for (int i = 0;i<10000; i++) {
			while (1) {
				d[x][y] = true;
				if (x + dx[i%4] < 0 || x + dx[i%4] >= c || y + dy[i%4] < 0 || y + dy[i%4] >= c)break;
				int sum = 0;
				for (int p = 0; p < 4; p++) {
					if (x + dx[i % 4] + dx[p] >= 0 && x + dx[i % 4] + dx[p] < c && y + dy[i % 4] + dy[p] >= 0 && y + dy[i % 4] + dy[p] < c&&d[x + dx[i % 4] + dx[p]][y + dy[i % 4] + dy[p]]) {
						sum++;
					}
				}
				if (sum > 1)break;
				x += dx[i % 4]; y += dy[i % 4];
			}
		}
		for (int k = 0; k < c; k++) {
			for (int l = 0; l < c; l++) {
				if (d[k][l])cout << "#";
				else cout << " ";
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 4;
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

int main () {
	boost;
	int r;
	cin >> r;
	cout << r * r;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
fn main() {
    let s: String = read();
    let ss: String = read();
    let n = ss.len();
    if n >= 2 && s[..] == ss[..n - 1] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ld d, t, s; cin >> d >> t >> s;
  ld time = d / s;

  if (time <= t) cout << "Yes\n";
  else cout << "No\n";
  
  return (0);
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int dp[102][4][2];

int main()
{
  long long ans = 0, temp, down;
  int K, ketasu;
  string S;
  cin >> S >> K;
  ketasu = S.size();
  dp[0][0][0] = 1;
  for(int i = 0; i < ketasu; i++)for(int j = 0; j <= K; j++)for(int k = 0; k < 2; k++){
    int nd = S[i] - '0';
    int ni = i+1;
    for(int d = 0; d < 10; d++){
      int nj = j, nk = k;
      if(d != 0) nj++;
      if(nj > K) continue;
      if(nk == 0){
        if(d > nd) continue;
        if(d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  ans = dp[ketasu][K][0] + dp[ketasu][K][1];
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
std::string winner(int alice, int bob) {
alice = (alice + 11) % 13;
bob = (bob + 11) % 13;
return (alice == bob) ? "Draw" : (alice > bob) ? "Alice" : "Bob";
}
int main() {
	int a, b;
	std::cin >> a >> b;
	std::cout << winner(a, b) << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<complex>
#include<algorithm>
using namespace std;

typedef complex<int> P;

int n;
P p[3000];

int comp(P a,P b){
  if(a.real()<b.real())return -1;
  if(a.real()==b.real()){
    if(a.imag()<b.imag())return -1;
    else if(a.imag()==b.imag())return 0;
  }
  return 1;
}

bool exist(P a){
  int lb = -1,ub = n;
  while(ub-lb>1){
    int mid = (ub+lb)/2;
    if(comp(p[mid],a)==0)return true;
    if(comp(p[mid],a)>0)ub = mid;
    else lb = mid;
  }
  return false;
}

int main(){
  while(scanf("%d",&n) && n){
    for(int i=0;i<n;i++)scanf("%d %d",&p[i].real(),&p[i].imag());

    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
	if(comp(p[i],p[j])>0)swap(p[i],p[j]);

    int ans = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j)continue;
	P n = (p[j]-p[i])*P(0,-1);
	if(exist(p[i]+n) && exist(p[j]+n))ans = max(ans,real(conj(n)*n));
      }
    }
    printf("%d\n",ans);
  }
}

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

int main(){
    string s; getline(cin, s);
    for (int i = 0; i < s.size(); i++){
        if (isalpha(s[i])){
            if (isupper(s[i])) s[i] = tolower(s[i]);
            else s[i] = toupper(s[i]);
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define fast ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define umll unordered_map<ll,ll>
#define mll map<ll,ll>
#define forr(i,p,n) for(ll i=p;i<(ll)n;i++)
#define fore(i,n,k) for(ll i=n-1;i>=k;i--)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a, ll b, ll p = MOD) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = MOD) {return (a % p + b % p) % p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD) {ll m0 = m; ll y = 0, x = 1; if (m == 1)return 0; while (a > 1) {ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t;} if (x < 0)x += m0; return x;}
using namespace __gnu_pbds;
typedef tree<ll, null_type, less< ll>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
long double dp[5001][5001];
void functiontosolve()
{
    ll n;
    cin >> n;
    long double  a[n + 1];
    forr(i, 1, n + 1) cin >> a[i];
    memset(dp, 0, sizeof(dp));
    forr(i, 0, n + 1) {
        forr(j, 0, n + 1) {
            if (i == 0 and j == 0) dp[i][j] = 1;
            else if (i == 0) dp[i][j] = 0;
            else {
                if (j > i) dp[i][j] = 0;
                else dp[i][j] = dp[i - 1][j - 1] * a[i] + dp[i - 1][j] * (1 - a[i]);
            }
        }
    }
    long double ans = 0;
    forr(i, n / 2 + 1, n + 1) {
        ans += dp[n][i];
    }
    //cout << "\n";
    cout << prec(10) << ans << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int test;
    test  = 1;
    forr(i, 1, test + 1) {
        functiontosolve();
    }
    return 0;
}

Measured memory_bytes: 394644
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var b = Sarray().Where(x=>x%2==0).All(y=>y%3==0||y%5==0);
            WriteLine(b ? "APPROVED" : "DENIED");
        }
    }
}


Measured memory_bytes: 18952
from collections import Counter
x = int(input())

def judge(n):
    ok = True
    a = Counter()
    i = 2
    num = 0
    while(n>i):
        if n%i == 0:
            while(n%i==0):
                a[i] += 1
                n //= i
            num = a[i]
        i += 1
    if n > 1:
        a[n] += 1
    for p in a:
        if a[p] != num or num == 1:
            ok = False
    return ok

for i in range(1,x+1)[::-1]:
    if judge(i):
        print(i)
        break


Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputNum = br.readLine().split(" ");
		//?¨????
		int W =Integer.parseInt(inputNum[0]);
		//??????
		int H =Integer.parseInt(inputNum[1]);
		//????????????????¨????
		int x =Integer.parseInt(inputNum[2]);
		//?????????????????????
		int y =Integer.parseInt(inputNum[3]);
		//?????????????????????
		int r =Integer.parseInt(inputNum[4]);

		if (x-r >= 0 && y-r >=0 && x+r <= W && y+r <= H){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}



	}

}

Measured memory_bytes: 17084
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
	//static final long MOD = 998244353;
	static final long MOD = 1000000007;
	static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A <= 9 && B<= 9)
			System.out.println(A*B);
		else
			System.out.println(-1);
	}
    
    public static long power(long x, long y, long p) { 
        // Initialize result
        long res = 1;
         
        // Update x if it is more   
        // than or equal to p 
        x = x % p;  
      
        while (y > 0) 
        { 
            // If y is odd, multiply x 
            // with result 
            if((y & 1)==1) 
                res = (res * x) % p; 
      
            // y must be even now 
            // y = y / 2 
            y = y >> 1;  
            x = (x * x) % p;  
        } 
        return res; 
    }
    
    public static long dist(int[] point, int[] point2) {
    	return (long)(Math.pow((point2[1]-point[1]),2)+Math.pow((point2[0]-point[0]),2));
    }
    
    public static long gcd(long a, long b) {
    	if (b == 0)
    		return a;
    	else
    		return gcd(b,a%b);
    }
    
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr2[1]-arr1[1];
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define ii pair<int,ll>
using namespace std;

int n;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    vector<int>a(n);
    for(int i= 0;i<n;i++){
        cin>>a[i];
    }
    int ans = 0;
    int j = -1;
    for(int i = 0;i<n-1;i++){
        if(a[i]>=a[i+1]){
            if(j ==-1){
                j = i;
            }
        }
        else{
            j = -1;
        }
        if(j!= -1){
            ans = max(ans,i-j+1);
        }
    }
    cout<<ans;
}

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

int main(){
  int h,n; cin >> h >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    h -= a.at(i);
  }
  if(h <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,x;sc(n);sc(x);
 ll a[n+10];
 rep(i,0,n)sc(a[i]);
  
 ll now=0,before=0;ans=1;
 for(i=0;i<n;i++){
  now=before+a[i];
  before=now;
 // pr(before);
  if(before<=x)ans++;
 }
 pr(ans);
return 0;}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
string s;
cin >> s;
if(s.size()==2) cout << s << endl;
else{
  reverse(s.begin(),s.end());
  cout << s << endl;
}
}


Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int[] a = new int[h];
		int[] b = new int[h];
		for (int i = 0; i < h; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]) - 1;
			b[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		TreeMap<Integer, Integer> map = new TreeMap<>();
		MultiTreeSet<Integer> set = new MultiTreeSet<>();
		for (int i = 0; i < w; i++) {
			map.put(i, i);
			set.add(0);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < h; i++) {
			SortedMap<Integer, Integer> sub = map.subMap(a[i], b[i]);
			for (Integer key : sub.keySet()) {
				set.remove(key - sub.get(key));
			}
			if (!map.containsKey(b[i]) && !sub.isEmpty() && b[i] < w) {
				int s = sub.get(sub.lastKey());
				map.put(b[i], s);
				set.add(b[i] - s);
			}
			sub.clear();
			if (set.size == 0) {
				pw.println(-1);
			} else {
				pw.println(set.first() + i + 1);
			}
		}
		pw.flush();
	}

	static class MultiTreeSet<T> {
		TreeMap<T, Integer> map = new TreeMap<>();
		int size = 0;

		void add(T e) {
			map.put(e, map.getOrDefault(e, 0) + 1);
			size++;
		}

		void remove(T e) {
			if (e != null && map.containsKey(e)) {
				int val = map.get(e);
				if (val == 1) {
					map.remove(e);
				} else {
					map.put(e, val - 1);
				}
				size--;
			}
		}

		T first() {
			return map.firstKey();
		}
	}
}


Measured memory_bytes: 77364
#include <stdio.h> 
 #define _USE_MATH_DEFINES 
 #include <math.h> 
  
  
 int main(){ 
     int a, b, angle; 
     double s, l, h; 
  
  
     scanf("%d %d %d", &a, &b, &angle);  
     h=b*sin(angle*M_PI/180.0); 
     s=a*h/2; 
     l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0))); 
     printf("%f\n", s); 
     printf("%f\n", l); 
     printf("%f\n", h); 
  
  
     return 0; 
 }


Measured memory_bytes: 2140
def li():
    return [int(x) for x in input().split()]


import itertools as it
from collections import defaultdict

N, M = li()
G = defaultdict(list)

for _ in range(M):
    a, b = li()
    G[a].append(b)
    G[b].append(a)

L = range(2, N+1)

# 順列列挙
p = it.permutations(L)
cnt = 0
for t in p:
    b = 1
    ok = True
    for i in range(len(t)):
        a, b = b, t[i]
        if b not in G[a]:
            ok = False
            break
    if ok:
        cnt += 1

print(cnt)

Measured memory_bytes: 72148
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int num =r*100+g*10+b;
        if(num%4==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }


    }

}


Measured memory_bytes: 20052
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to count all possible 
// triangles with arr[] elements 
int findNumberOfTriangles(int arr[], int n) 
{ 
    // Count of triangles 
    int count = 0; 
  
    // The three loops select three 
    // different values from array 
    for (int i = 0; i < n; i++) { 
        for (int j = i + 1; j < n; j++) { 
  
            // The innermost loop checks for 
            // the triangle property 
            for (int k = j + 1; k < n; k++) 
  
                // Sum of two sides is greater 
                // than the third 
              if(arr[i]!=arr[j]&&arr[i]!=arr[k]&&arr[j]!=arr[k]){
                if ( 
                    arr[i] + arr[j] > arr[k] 
                    && arr[i] + arr[k] > arr[j] 
                    && arr[k] + arr[j] > arr[i]) 
                    count++; 
              }
        }
    } 
    return count; 
} 
  
// Driver code 
int main() 
{ 
   int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  cout<< findNumberOfTriangles(arr, n); 
  
    return 0; 
} 

Measured memory_bytes: 3612