akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        char a;
        cin>>a;
        if(isupper(a))cout<<'A'<<endl;
        else cout<<'a'<<endl;
    }

Measured memory_bytes: 3680
/* Aizu0002 Digit Number */

#include <stdio.h>

int sum_digits(int n, int base)
{
    int count = 0;

    while(n) {
        count++;
        n /= base;
    }

    return count;
}

int main(void)
{
    int a, b;

    while(~scanf("%d%d", &a, &b))
        printf("%d\n", sum_digits(a + b, 10));

    return 0;
}




Measured memory_bytes: 2680
/* Author rumoisen */
/* created 2018/11/07 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll) 1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    float t,a,h[1145];
    cin>>n>>t>>a;
    REP(i,n) cin>>h[i];
    float dif=1e9;
    int ans;
    REP(i,n){
        float yj=abs(a-(t-h[i]*0.006));
        dif=min(dif,yj);
        if(dif==yj){
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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

int main() {
    int a[3], n;
    cin >> n;
    rep(i,n) cin >> a[i];

    if(n==2) {
        for(int i=1; i <= min(a[0],a[1]); i++)
            if(a[0] % i == 0 and a[1] % i == 0)
                cout << i << "\n";
    } else {
        for(int i=1; i <= min(a[0],min(a[1],a[2])); i++)
            if(a[0] % i == 0 and a[1] % i == 0 and a[2] % i == 0)
                cout << i << "\n";
    }


    return 0;
}

Measured memory_bytes: 1164
package main

import (
    "bufio"
    "os"
    "strconv"
    "fmt"
    "container/heap"
)

const INF = 100000000000000


/*********** PriorityQueue ***********/
type PriorityQueue struct {
    arr []interface{}
    comp CompFunc
}

type CompFunc func(p, q interface{}) bool

func NewPriorityQueue() *PriorityQueue {
    return new(PriorityQueue)
}

func (pq PriorityQueue) Len() int {
    return len(pq.arr)
}

func (pq PriorityQueue) Swap(i, j int) {
    pq.arr[i], pq.arr[j] = pq.arr[j], pq.arr[i]
}

func (pq PriorityQueue) Less(i, j int) bool{
    return pq.comp(pq.arr[i], pq.arr[j])
}

func (pq *PriorityQueue) Push(x interface{}) {
    pq.arr = append(pq.arr, x)
}

func (pq *PriorityQueue) Pop() interface{} {
    n := pq.Len()
    item := pq.arr[n - 1]
    pq.arr = pq.arr[:n - 1]
    return item
}

func (pq *PriorityQueue) IsEmpty() bool {
    return pq.Len() == 0
}

/* type for edge */
type Edge struct {
    to int
    cost int
}

/* type for dijkstra */
type State struct {
    time int
    node int
}

/* dijkstra */

func dijkstra(start int, edges [][]Edge, n int, comp CompFunc) []int {
    var dist []int
    for i := 0; i < n; i++ {
        dist = append(dist, INF)
    }
    dist[start] = 0
    que := new(PriorityQueue)
    que.comp = comp
    heap.Push(que, State{time: 0, node:start})
    for !que.IsEmpty() {
        state := heap.Pop(que).(State)
        for _, edge := range edges[state.node] {
            newTime := state.time + edge.cost
            if dist[edge.to] > newTime {
                dist[edge.to] = newTime
                heap.Push(que, State{time: newTime, node: edge.to})
            }
        }
    }
    return dist
}
/* input */
var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
    return n
}

func main() {
    sc.Split(bufio.ScanWords)
    n := readInt()
    var edges [][]Edge
    for i := 0; i < n; i++ {
        edges = append(edges, make([]Edge, 0))
    }
    for i := 0; i < n - 1; i++ {
        a, b, c := readInt() - 1, readInt() - 1, readInt()
        edges[a] = append(edges[a], Edge{to: b, cost: c})
        edges[b] = append(edges[b], Edge{to: a, cost: c})
    }

    var comp CompFunc
    comp = func(p, q interface{}) bool {
        return p.(State).time < q.(State).time
    }
    
    q, k := readInt(), readInt() - 1
    dist := dijkstra(k, edges, n, comp)
    wtr := bufio.NewWriter(os.Stdout)
    for i := 0; i < q; i++ {
        x, y := readInt() - 1, readInt() - 1
        //fmt.Println(dist[x] + dist[y])
        fmt.Fprintln(wtr, dist[x] + dist[y])
        //wtr.Flush()
    }
    wtr.Flush()
}


Measured memory_bytes: 20224
# coding: utf-8
# Your code here!

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
coupon = [list(map(int, input().split())) for _ in range(M)]
a_min, b_min = min(a), min(b)
discount = []
for i in range(M):
    discount.append(a[coupon[i][0] - 1] + b[coupon[i][1] - 1] - coupon[i][2])
if a_min + b_min < min(discount):
    print(a_min + b_min)
else:
    print(min(discount))

Measured memory_bytes: 42404
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int binarySearch(vector<int> &vec, int p){
    int start = 0, end = vec.size() - 1;
    int center = start + (end - start) / 2;

    while(true){
        if(vec[center] > p){
            end = center - 1;
        }else if(vec[center] < p){
            start = center + 1;
        }else{
            break;
        }
        if(end < start){
            return 0;
        }
        center = start + (end - start) / 2;
    }

         //   debug(vec[center])

    int upperBS = center, lowerBS = center;

    while(vec[upperBS] == p) upperBS++;
    while(vec[lowerBS] == p) lowerBS--;

    return upperBS - lowerBS - 1;
}

void devideLength(int inp[1505], int n, vector<int> &vec){
    rep(i,n + 1){
        range(j,i + 1,n + 1){
            vec.pb(inp[j] - inp[i]);
        }
    }
    if(n == 1) vec.pb(inp[0]);
}

void inputData(int inp[1505], int n){
    int beforeInput = 0;
    inp[0] = 0;
    range(i,1,n + 1){
        cin >> inp[i];
        inp[i]+=beforeInput;
        beforeInput=inp[i];
    }
}

int main(){
    int n;
    int m;
    while(cin >> n >> m,n||m){
        int h[1505], w[1505];
        vector<int> height;
        vector<int> width;

        height.pb(-1);
        height.pb(2000000000);
        width.pb(-1);
        width.pb(2000000000);

        inputData(h, n);
        inputData(w, m);
        devideLength(h, n, height);
        devideLength(w, m, width);
        sort(all(height));
        sort(all(width));

        int sum = 0;
        vector<int>::iterator it;
        for(it = width.begin(); it != width.end(); it++){
            if(*it == -1 or *it == 2000000000) continue;
            sum+=binarySearch(height, *it); 
        }
        cout << sum << endl;

        height.clear();
        width.clear();
    }
}

Measured memory_bytes: 21136
/*
I believe on myself and I will achieve
this->author = Fuad Ashraful Mehmet, CSE ,University of Asia Pacific
Todo:
https://codeforces.com/contest/920/problem/F
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;
#define pb push_back
using namespace std;

typedef long long ll;
const int N=2e5+5;
int q,k,m,n,cs=1;

void HalfDead()
{
      bool x;
      cin>>x;
      x^=1;
      cout<<x<<endl;
} // func

int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);  cout.tie(0);
      // cout<<setprecision(10)<<fixed;
      int tc=1;
     // cin>>tc;
      while(tc--)
      {   
            HalfDead();
      }
      return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,ans=1;
cin>>n>>k;
for(int i=0;i<n;i++)
{
if(ans>k)
{
ans+=k;
}
else
{
ans*=2;
}
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>

typedef long long ll;
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=100000;
int n,m;
vector<int> nei[N+1];
int f[N+1];
bool vis[N+1];
int ans;
void dp(int x){
	if(vis[x])return;
	vis[x]=true;
	for(int i=0;i<nei[x].size();i++)dp(nei[x][i]),f[x]=max(f[x],f[nei[x][i]]+1);
	ans=max(ans,f[x]);
}
int main(){
	cin>>n>>m;
	while(m--){
		int x,y;
		cin>>x>>y;
		nei[x].pb(y);
	}
	for(int i=1;i<=n;i++)dp(i);
	cout<<ans;
	return 0;
}
/*1
4 5
1 2
1 3
3 2
2 4
3 4
*/
/*2
6 3
2 3
4 5
5 6
*/
/*3
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
*/

Measured memory_bytes: 8192
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int MAX_N = 200000;

int N;
int P[MAX_N], p[MAX_N+2];

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", P+i ), p[P[i]] = i;

  int cnt = 0, len = 0, now = -1;
  repi( i, 1, N+2 )
  {
    if( now < p[i] )
      ++cnt, now = p[i];
    else
    {
      len = std::max( len, cnt );
      cnt = 1;
      now = p[i];
    }
  }

  printf( "%d\n", N-len );
  
  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
int main(void){
     int n,i,count1=0,count2=0,count3=0,count4=0,count5=0,count6=0;
     double height;
     scanf("%d",&n);
     for(i=1;i<=n;i++){
         scanf("%lf\n",&height);
         if(height<165){
             count1++;
         }if(height>=165&&height<170){
             count2++;
         }if(height>=170&&height<175){
             count3++;
         }if(height>=175&&height<180){
             count4++;
         }if(height>=180&&height<185){
             count5++;
         }if(height>=185){
             count6++;
        }
    }
       
         printf("1:");
         for(i=1;i<=count1;i++){
             printf("*");
         }
         printf("\n");
         
         printf("2:");
         for(i=1;i<=count2;i++){
             printf("*");
         }
         printf("\n");
         printf("3:");
         for(i=1;i<=count3;i++){
             printf("*");
         }
         printf("\n");
         printf("4:");
         for(i=1;i<=count4;i++){
             printf("*");
         }
         printf("\n");
         printf("5:");
         for(i=1;i<=count5;i++){
             printf("*");
         }
         printf("\n");
         
         printf("6:");
         for(i=1;i<=count6;i++){
             printf("*");
         }
         printf("\n");
       
}


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

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

ll l, r, d;

int main(void)
{
	scanf("%lld %lld %lld", &l, &r, &d);
	printf("%lld", r / d - (l - 1) / d);
	return 0;
}

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

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

	vector<int> h(N);
	for (int i = 0; i < N; ++i) {
		cin >> h.at(i);
	}
	int res = 0;
	int max = h.at(0);
	for (int i = 0; i < N; i++) {
		if (h.at(i) >= max) {
			max = h.at(i);
			res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int dp[10001][2];
int num[10001];
int main()
{
  int n;
  scanf("%d",&n);
  for(int i=1;i<n;i++)
    {
      scanf("%d",&num[i]);
    }
  for(int i=0;i<=10000;i++)
    {
      dp[i][0]=100000000;
      dp[i][1]=100000000;
    }
  dp[1][0]=0;
  for(int i=1;i<n;i++)
    {
      for(int j=1+i;j>=1;j--)
	{
	  dp[j][1]=min(dp[j][1],dp[j][0]+num[i]);
	  dp[j][0]=min(dp[j-1][0],dp[j-1][1]+num[i]);
	}
    }
  printf("%d\n",min(dp[n/2][0],dp[n/2][1]));
  return 0;
}

	    
  

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  rep (i, n) {
    int a;
    cin >> a;
    cnt += a % 2;
  }
  if (cnt % 2) {
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 2103
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int H, W, N;
	static char[][] cs = new char[22][22];
	static int[] dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};
	public static void main(String[] args) {
		int TC = sc.nextInt();
		for (int tc = 0; tc < TC; tc++) {
			if (tc != 0) System.out.println();
			H = sc.nextInt(); W = sc.nextInt();
			int x = 0, y = 0, d = 0;
			for (int i = 0; i < 22; i++) fill(cs[i], '#');
			for (int i = 1; i <= H; i++) {
				String s = sc.next();
				for (int j = 1; j <= W; j++) {
					char c = s.charAt(j - 1);
					cs[i][j] = c;
					if (c == '<' || c == '^' || c == 'v' || c == '>') { 
						x = j; y = i;
						switch (c) {
						case '^':
							d = 0;
							break;
						case '>':
							d = 1;
							break;
						case 'v':
							d = 2;
							break;
						case '<' :
							d = 3;
						}
					}
				}
			}
			
			N = sc.nextInt();
			String op = sc.next();
			for (int i = 0; i < N; i++) {
				char c = op.charAt(i);
				if (c == 'S') {
					int nx = x, ny = y;
					while (true) {
						nx += dx[d];
						ny += dy[d];
						char cc = cs[ny][nx]; 
						if (cc == '#') {
							break;
						} else if (cc == '*') {
							cs[ny][nx] = '.';
							break;
						}
					}
				} else {
					switch (c) {
					case 'U':
						d = 0;
						cs[y][x] = '^';
						break;
					case 'R':
						d = 1;
						cs[y][x] = '>';
						break;
					case 'D':
						d = 2;
						cs[y][x] = 'v';
						break;
					case 'L':
						d = 3;
						cs[y][x] = '<';
						break;
					}
					
					int nx = x + dx[d], ny = y + dy[d];
					if (cs[ny][nx] == '.') {
						cs[ny][nx] = cs[y][x];
						cs[y][x] = '.';
						x = nx; 
						y = ny;
					}
				}
			}
			for (int i = 1; i <= H; i++) {
				for (int j = 1; j <= W; j++) {
					System.out.print(cs[i][j]);
				}
				System.out.println();
			}
		}
	}	
}

Measured memory_bytes: 12000
#include<iostream>
#include<map>
#include<cctype>
#include<string>
using namespace std;


string s;
int p;
map<string,int> weight;

int calc(){
	if(p==s.size())return 0;
	char c=s[p++];
	if(c==')')return 0;
	if(c=='('){
		int w,n=0;
		w = calc();
		if(w==-1)return -1;	
		while(p<s.size() && isdigit(s[p])){
			n=n*10+s[p++]-'0';
		}
		int a=calc();
		if(a==-1)return -1;
		return w*n+a;
	}
	else {
		string atom;
		atom+=c;
		if(p<s.size() && islower(s[p])){
			atom+=s[p++];
		}
		if(weight.find(atom)==weight.end())return -1;	
		int n=1;
		if(p<s.size() && isdigit(s[p])){
			n=s[p++]-'0';
			if(p<s.size() && isdigit(s[p])){
				n=n*10+s[p++]-'0';
			}
		}
		int a=calc();
		if(a==-1)return -1;
		return weight[atom]*n+a;
	}
}

int main(){
	while(cin>>s,s!="END_OF_FIRST_PART"){
		int w;
		cin>>w;
		weight[s]=w;
	}
	while(cin>>s,s!="0"){
		int w;
		p=0;
		w=calc();
		if(w==-1)cout<<"UNKNOWN"<<endl;
		else cout<<w<<endl;
	}
	return 0;
}

Measured memory_bytes: 1236
MOD = 998244353
import bisect
import sys
input = sys.stdin.readline
N = int(input())
P = [list(map(int,input().split())) for i in [0]*N]

class SegmentTree:
    def __init__(self,data):
        N = len(data)
        self.l = 2**((N-1).bit_length())
        self.data = [0]*self.l + data + [0]*(self.l-N)
        for i in range(self.l-1,0,-1):
            self.data[i] = self.data[2*i] + self.data[2*i+1]

    def set(self,i,val):
        i += self.l
        self.data[i] = val
        i = i//2
        while i > 0:
            self.data[i] = self.data[2*i] + self.data[2*i+1]
            i = i//2

    def get(self,i,j):
        i += self.l
        j += self.l
        s = 0
        while j-i > 0:
            if i & 1:
                s += self.data[i]
                i += 1
            if j & 1:
                s += self.data[j-1]
                j -= 1
            i = i//2
            j = j//2
        return s

X,Y = map(list,zip(*P))
X.sort()
Y.sort()
compY = {y:cy for cy,y in enumerate(Y)}
Psorted = sorted(P)
compP = [[n,compY[y]] for n,(_,y) in enumerate(Psorted)]

n1s = []
seg = SegmentTree([0]*N)
for _,y in compP[::-1]:
    n1s.append(seg.get(y,N))
    seg.set(y,1)
n1s = n1s[::-1]

pows = [1]
for i in range(1,N):
    pows.append((pows[-1]*2) % MOD)

ans = (-4*sum(pows)- N + N * pow(2,N,MOD)) % MOD

for n,(x,y) in enumerate(Psorted):
    lower = bisect.bisect_left(Y,y)
    upper = N-1-lower
    left = n
    right = N-n-1
    n1 = n1s[n]
    n2 = upper - n1
    n3 = left - n2
    n4 = right - n1
    ans += pows[n1] + pows[n2] + pows[n3] + pows[n4]
    ans %= MOD

print(ans)


Measured memory_bytes: 140344
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 310;
const long long mod = 998244353;
long long power(long long x, long long k)
{
	long long ans = 1;
	while(k)
	{
		if(k & 1)
			(ans *= x) %= mod;
		k >>= 1;
		(x *= x) %= mod;
	}
	return ans;
}
int n, m;
bool v[maxn][maxn];
bool base[maxn][maxn] = {0};
int cnt = 0;
void out()
{
	cout << cnt << endl;
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= m; j ++)
			cout << base[i][j] << " ";
		cout << endl;
	}
}
void insert(int x)
{
	for(int i = 1; i <= m; i ++)
	{
		if(v[x][i])
		{
			if(!base[i][i])
			{
				for(int j = i; j <= m; j ++)
					base[i][j] = v[x][j];
				cnt ++;
				return ;
			}
			else
			{
				for(int j = i; j <= m; j ++)
					v[x][j] ^= base[i][j];
			}
		}
	}
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= m; j ++)
			cin >> v[i][j];
		insert(i);
	}
	
	cout << (power(2, n) - power(2, n - cnt) + mod) * power(2, m - 1) % mod << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

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

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			BigInteger A = new BigInteger(in.next());
			BigInteger B = new BigInteger(in.next());
			out.println(A.compareTo(B) > 0 ? "GREATER" : A.compareTo(B) == 0 ? "EQUAL" : "LESS");
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}

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

	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}



int main() {
	ll A, B;
	cin >> A >> B;
	char c[A + 10][B + 10];
	for (ll i = 0; i < A; i++) {
		for (ll j = 0; j < B; j++) {
			cin >> c[i][j];
		}
	}
	string ans = "Yes";
  for (ll i = 0; i < A; i++) {
		for (ll j = 0; j < B; j++) {
          	ll cnt=0;
          	if (c[i][j] != '#')continue;
			for (ll k = 0; k < 4; k++) {
				ll x = i + dx[k];
				ll y = j + dy[k];
              	if (c[x][y]=='#') {
					cnt++;
                }
            }
                  	if(cnt==0){
                      ans="No";
                    }
        }
  }
	cout << ans << endl;
}



Measured memory_bytes: 256
import bisect,copy,heapq,itertools,math,string
from collections import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = deque()

for i in range(n):
    if(i%2==0):
        b.append(i)
    else:
        b.appendleft(i)

if(n%2==1):
    b.reverse()

c = [a[b[i]] for i in range(n)]
print(*c)

Measured memory_bytes: 32500
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    char s[h][w];
    rep(i,h)rep(j,w)cin >> s[i][j];
    int ans = INF;
    rep(bits,1<<(h-1)){
        int g[h];
        g[0]=0;
        int c = 0;
        rep(i,h-1){
            if((bits>>i)&1){
            g[i+1]=g[i]+1;
            c++;
            }else{
                g[i+1]=g[i];
            }
        }
        int now = 0;
        int g_size = g[h-1]+1;
        vector<int> v(g_size,0);
        int d = 0;
        bool able = 1;
        while(now<w){
            rep(i,h)if(s[i][now]=='1')v[g[i]]++;
            bool ok = 1;
            rep(i,g_size)if(v[i]>k)ok = 0;
            if(ok){
                now++;
                d++;
            }else{
                if(d==0){
                    able = 0;
                    break;
                }else{
                    rep(i,g_size)v[i]=0;
                    d=0;
                    c++;
                }
            }
        }
        if(able)chmin(ans,c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)
  val positions = io.StdIn.readLine().split(' ').map(_.toInt)


  def calcMinDist(n: Int, k: Int, xs: Seq[Int]): Int = {
    import scala.math._
    // 左右に行ったり来たりせず、折り返しは最大一回までにするのが最短経路になる。   
    // N本のうち連続するK本のろうそくを選ぶ方法は、"N - K + 1"通りなので、
    // 全てのパターンに対して経路を計算して、最小値を探す。
    // 経路の一番左の座標をxl, 一番右の座標をxrとすると、
    // 左 -> 右の順に訪れる場合は: |xl| + |xr - xl|
    // 右 -> 左の順に訪れる場合は: |xr| + |xr - xl|
    // が最小値となる。
    List.range(0, n-k+1).foldLeft(Int.MaxValue){(acc, l) =>
        val r = l + k - 1
        min(acc, abs(xs(r) - xs(l)) + min(abs(xs(l)), abs(xs(r))))
      }
  }

  println(calcMinDist(n, k, positions))
}



Measured memory_bytes: 42444
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = n - 1; 0 <= i; i--) {
            if (i > 0) {
                System.out.print(a[i] + " ");
            } else {
                System.out.print(a[i]);
            }
        }
        System.out.print("\n");
        sc.close();
    }
}


Measured memory_bytes: 26200
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int gcd(int a,int b) {
	return b==0?a:gcd(b,a%b);
}
int main()
{
	//cwk;
	int k;
	cin>>k;
	int ans=0;
	for(int a=1;a<=k;a++) {
		for(int b=1;b<=k;b++) {
			for(int c=1;c<=k;c++) {
				ans+=gcd(gcd(a,b),c);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3556
#pragma GCC Optimize("Ofast")
#pragma GCC Optimize "trapv"
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 

using namespace std;
//using namespace boost::multiprecision; 

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 2*acos(0.0)
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

const ll Inf=1e9+5;

ll a[100005],freq[1000006],mx=INT_MIN;

namespace funset{
bool checkvow(char x){
	return ((0x208222)>>(x&(0x1f)))&1;
	}
ll highpow2(ll x){
	return (x&~(x-1));
	}
bool chk2(ll x){
		return (x&(x-1));
	}	
}

using namespace funset;

ll n, w;
ll wei[101],val[101],dp[1001][10001];

string s;


void solve(){
	ll x;
	cin >> x;
	if(x>=30){
		cout << "Yes" << endl;
		return ;
	}
	cout << "No" << endl;
}

int main(){
	auto beg=clock();
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
	FAST
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
	auto ted=clock();
	#ifndef ONLINE_JUDGE
	cout << (double)(ted-beg)/CLOCKS_PER_SEC << endl;
	#endif
	ret 0;
}

Measured memory_bytes: 3648
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF = 1e9;
#define MOD = 1e9+7;
#define INF64 = 1e18;


using namespace std;

int main() {

	SINT32 A,B,C;
	SINT32 N;
	SINT32 ANS;
	cin >> A >> B >> C;
	cin >> N;
	
	if (A >= B) {
		if (A >= C) {
			ANS = B + C + A*pow(2,N);
		} else {
			ANS = A + B + C*pow(2,N);
		}		
	} else {
		if (B >= C) {
			ANS = A + C + B*pow(2,N);
		} else {
			ANS = A + B + C*pow(2,N);
		}
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n, x;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  mllll m;
  fi(0, n) {
    cin >> x;
    m[x]++;
  }

  if(m.size() > 3) {
    cout << "No\n";
  } else if(m.size() == 1) {
    if(m[0])
      cout << "Yes\n";
    else
      cout << "No\n";
  } else {
    vllll v;
    for(auto y: m) {
      v.push_back(y);
    }
    if(m.size() == 2) {
      if(v[0].first == 0 && v[0].second * 2 == v[1].second && (v[1].first ^ v[1].first) == 0)
        cout << "Yes\n";
      else
        cout << "No\n";
    }
    else {
      if(v[0].second == v[1].second && v[0].second && v[2].second && v[1].second && v[2].second && (v[0].first ^ v[1].first) == v[2].first) 
        cout << "Yes\n";
      else
        cout << "No\n";
    }
  }
  // cout << ans << endl;
  return 0;
}



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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> Pair;
typedef vector<Pair> VP;

#define MOD 1000000007
#define times(n) rep(_idx, n)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mk make_pair
#define out(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;

template <typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}

int main() {
    int N;
    VI A;

    cin >> N;
    times(N) { int val; cin >> val; A.pb(val); }

    double ans = 0;
    for(int val: A) ans += 1 / (double)val;
    out(1 / ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int INF = (int)1e9 + 7;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x <<
//cin,coutより遅いので注意
template <class T = int>
void in() //in<string>();とか書く intのときはそのままin();
{
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T &x) { cout << x << "\n"; }

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

    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << "\n";
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	input := scanIntNum()
	fmt.Println(fatCalc(input))
}

// example
func calc(target int) (pn int) {
	pn = target
	return pn
}

func fatCalc(target int) int {
	for i := target; ; i++ {
		if fatCheck(i) {
			return i
		}
	}
}

func fatCheck(target int) bool {
	limit := int(math.Sqrt(float64(target)))

	for i := 2; i <= limit; i++ {
		if target%i == 0 {
			return false
		}
	}

	return true
}

func scanIntNum() (num int) {
	sc.Scan()

	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return num
}

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

using namespace std;

const long long MOD = 1e9 + 7;

long long last2(vector<long long> &a) {
    int n = a.size();
    return a[n-1]*a[n-2];
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<long long> pos, neg;
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        if (v >= 0) {
            pos.push_back(v);
        } else {
            neg.push_back(-v);
        }
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    auto ans = 1ll;
    if (k%2 == 1) {
        if (pos.size() > 0) {
            ans = pos.back();
            pos.pop_back();
            k--;
        } else {
            for (int i = 0; i < k; i++) {
                ans = (ans*neg[i])%MOD;
            }
            ans = MOD - ans;
            k = 0;
        }
    }
    for (int i = 0; i < k; i += 2) {
        bool takeNeg = false;
        if (pos.size() == 1 && neg.size() == 1) {
            ans = (MOD - (pos[0] * neg[0])%MOD*ans%MOD)%MOD;
            break;
        } else if (pos.size() < 2) {
            takeNeg = true;
        } else if (neg.size() < 2) { 
            takeNeg = false;
        } else {
            takeNeg = last2(pos) < last2(neg);
        }
        if (takeNeg) {
            ans = (last2(neg)%MOD*ans)%MOD;
            neg.pop_back();
            neg.pop_back();
        } else {
            ans = (last2(pos)%MOD*ans)%MOD;
            pos.pop_back();
            pos.pop_back();
        }
    }
    cout << ans << endl;
}


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

long long n, k, sum;
long long cnt[100001];
const long long MOD = 1e9+7;

long long bigmod(long long a, long long n, long long m){
    if (n == 1)
        return a % m;
    long long t = bigmod(a, n / 2, m);
    if (n % 2 == 1)
        return ((t * t) % m * a % m) % m;
    return (t * t) % m;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= k; i++)
        cnt[i] = bigmod(k / i, n, MOD);
    sum = 0;
    for (int i = k; i >= 1; i--){
        // cout << "before:" << cnt[i] <<"\n";
        for (int j = 2 * i; j <= k; j += i){
            cnt[i] -= cnt[j];
            if (cnt[i] < 0)
                cnt[i] += MOD;
        }
        // cout << "after: "<< cnt[i] <<"\n";
        sum += (cnt[i] * i) % MOD;
        sum %= MOD;
    }
    cout << sum <<"\n";
    return 0;
}

Measured memory_bytes: 4408
import java.util.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
            int n = Integer.parseInt(sc.next());

            ArrayList<Integer> list = new ArrayList<>(n);

            for(int j = 0; j < n; j++)list.add(0);

            for(int i = 0; i < n - 1; i++){
                int joshi = Integer.parseInt(sc.next());
                list.set(joshi - 1, list.get(joshi - 1) + 1);
            }

            for(int k: list){
                System.out.println(k);
            }

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 60640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    int N,K;
    int[] A;

    public int gcd(int x,int y){
        return y == 0 ? x : gcd(y,x%y);
    }

    public void solve() {
        N = nextInt();
        K = nextInt();

        A = new int[N];
        for(int i = 0;i < N;i++){
            A[i] = nextInt();
        }

        int max = 0;
        for(int a : A){
            max = Math.max(max,a);
        }

        if(K > max){
            out.println("IMPOSSIBLE");
            return;
        }

        int g = A[0];
        for(int i = 0;i < N;i++){
            if(A[i] == K){
                out.println("POSSIBLE");
                return;
            }

            g = gcd(g,A[i]);
        }

        if(K % g == 0) {
            out.println("POSSIBLE");
        } else {
            out.println("IMPOSSIBLE");
        }


    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

Measured memory_bytes: 37096
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		 Scanner scn = new Scanner(System.in);
		    int a = scn.nextInt();
		    int b = scn.nextInt();
		if(a<b) {
			System.out.println("a < b");
		}
		else if(a>b) {
			System.out.println("a > b");
		}
		else if(a==b) {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26356
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  int answer; // to output 
  int n; // to input 
  int m; // to input 
  int *times;
  int home;

  home = 0;
  scan = scanf("%d", &n);
  scan = scanf("%d", &m);
  times = (int *)malloc(sizeof(int) * m);
  for (int i = 0; i < m; i++) {
    scan = scanf("%d", &times[i]);
  }

  for (int i = 0; i < m; i++) {
    home += times[i];
  }

  if (home > n) {
    answer = -1;
  } else {
    answer = n - home;
  }  

  printf("%d", answer);
  return (0);
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
/////////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    if(n&1) print(2*n);
    else print(n);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(input())
    answers = solve(N, S)
    print('\n'.join(answers))


def solve(N, S):
    counter = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE':0}
    for judge in S:
        counter[judge] += 1

    return [f'{k} x {v}' for k, v in counter.items()]


if __name__ == "__main__":
    main()


Measured memory_bytes: 16192
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int N;
  cin >> N;
  int res = N;
  for (int i=0; i<=N; i++) {
    int tmp = 0, t = i;
    while (t>0) {
      tmp += t%6;
      t /= 6;
    }
    t = N-i;
    while (t>0) {
      tmp += t%9;
      t /= 9;
    }
    res = min(res, tmp);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
 
using namespace std;
 
typedef long long tnum;
 
tnum* getNumsStdin(int);
 
int main() {
	tnum n, m, k, v, total;
	tnum* a;
	scanf("%lld %lld", &n, &m);
	a = getNumsStdin(n);
 
	sort(a, a+n, std::greater<tnum>());
 
	total = 0;
	for (int i = 0; i < n; i++) {
		total += a[i];
	}
 
	v = a[m-1];
 
	if (total > 4 * m * v) {
		printf("No");
	}
	else {
		printf("Yes");
	}
	
	free(a);
	return 0;
}
 
//have to be free()
tnum* getNumsStdin(int num) {
	tnum* buf;
	tnum* tmp;
	buf = (tnum*)malloc(num * sizeof(tnum));
	for (int i = 0; i < num; i++) {
		scanf("%lld", &buf[i]);
	}
 
	return buf;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256