akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{	
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
         StringBuilder sb=new StringBuilder();
         BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
         int n=s.nextInt(),w=s.nextInt();
        int[][] arr=new int[n+1][2];
        long[] dp=new long[100001];
        Arrays.fill(dp,(long)1e13); dp[0]=0;
        //dp[i] hold- minimum wt needed to get i values 
        for(int i=1;i<=n;i++){
            arr[i][0]=s.nextInt(); arr[i][1]=s.nextInt();
        }

        for(int i=1;i<=n;i++){
            for(int j=100000;j>=1;j--){
                if(arr[i][1]<=j){
                    dp[j]=Math.min(dp[j],arr[i][0]+dp[j-arr[i][1]]);
                }
                //else{dp[j]=(long)1e13;}
            }
        }
        int res=0;
        for(int i=1;i<100001;i++){
            if(dp[i]<=w){res=i;}
        }       
        System.out.println(res);
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;

ll a, b, c;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
using ll = long long;

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

ll lcm(ll a,ll b){
  ll g = gcd(a,b);
  return a/g*b;
}

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll cd = lcm(c,d);
  ll above_a = (a-1)/cd+1;
  ll under_b = b/cd;
  ll count = under_b-above_a;
  ll ans = count*(cd/c+cd/d-1)+1;
  ans+=(b/c-(under_b*cd)/c);
  ans+=(b/d-(under_b*cd)/d);
  ans+=((above_a*cd-1)/c-(a-1)/c);
  ans+=((above_a*cd-1)/d-(a-1)/d);
  cout<<b-a+1-ans<<endl;
  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int A,B; cin>>A>>B;
  int ans=-1;
  REP(i,0,2000){
    int X=i*8/100,Y=i*10/100;
    if(X==A&&Y==B){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--;t--;

	V<V<P>> yen(n);
	V<V<P>> snk(n);

	rep(i, m) {

		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--;v--;
		yen[u].push_back(P(a, v));
		yen[v].push_back(P(a, u));
		snk[u].push_back(P(b, v));
		snk[v].push_back(P(b, u));

	}

	V<ll> dyen(n, LINF), dsnk(n, LINF);
	dyen[s] = 0;
	dsnk[t] = 0;

	priority_queue<P, V<P>, greater<P>> pq;

	pq.push(P(0, s));

	while (!pq.empty()) {

		P p = pq.top();pq.pop();
		int v = p.second;
		ll vd = p.first;
		if (vd > dyen[v])continue;

		rep(i, yen[v].size()) {
			int vv = yen[v][i].second;
			int vvd = yen[v][i].first;
			if (dyen[vv] <= dyen[v] + vvd)continue;
			dyen[vv] = dyen[v] + vvd;
			pq.push(P(dyen[vv], vv));
		}

	}

	pq.push(P(0, t));

	while (!pq.empty()) {

		P p = pq.top();pq.pop();
		int v = p.second;
		ll vd = p.first;
		if (vd > dsnk[v])continue;

		rep(i, snk[v].size()) {
			int vv = snk[v][i].second;
			int vvd = snk[v][i].first;
			if (dsnk[vv] <= dsnk[v] + vvd)continue;
			dsnk[vv] = dsnk[v] + vvd;
			pq.push(P(dsnk[vv], vv));
		}

	}
	

	V<ll> ans(n + 1, LINF);

	rep(i, n)ans[n - 1 - i] = min(ans[n - i], dyen[n - 1 - i] + dsnk[n - 1 - i]);
	rep(i, n)cout << (ll)1e15 - ans[i] << endl;

}

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

const int N = 1e4 + 5;
const int D = 105;
const int MOD = 1e9 + 7;

string k;
int d;
int dp[N][D][2];

int solve(int pos, int modd, int kurang) {
  if (pos == -1) {
    return modd == 0;
  }

  int &ret = dp[pos][modd][kurang];
  if (ret != -1) return ret;
  ret = 0;

  if (kurang) {
    for (int i = 0 ; i < 10 ; i++) {
      ret = (ret + solve(pos-1, (modd + i) % d, kurang)) % MOD;
    }
  } else {
    for (int i = 0 ; i <= k[pos]-'0' ; i++) {
      ret = (ret + solve(pos-1, (modd + i) % d, i < k[pos] - '0')) % MOD;
    }
  }

  // printf("pos %d modd %d kurang %d -> %d\n", pos, modd, kurang, ret);
  return ret;
}

int main() {
  cin >> k >> d;
  reverse(k.begin(), k.end());

  memset(dp, -1, sizeof dp);
  int ret = (solve(k.length()-1, 0, 0) + MOD - 1) % MOD;
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int a,b,c; cin >> a >> b >> c;
  int ans;
  if (a == b && b == c) ans = 1;
  else if (a != b && b != c && c != a) ans =3;
  else ans =2;
  cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  rep(i,s.size()){
    if(s[i]=='1') cout << 9;
    else cout << 1;
  }
  return 0;
    

}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

class Node(var key:Int, var par:Node?, var lef: Node?,var rig:Node?) {
    fun find(value :Int) : Node? = when {
        this.key > value -> lef?.find(value)
        this.key < value -> rig?.find(value)
        this.key == value -> this
        else -> null
    }

    fun insert(value :Int) {
        if(this.key > value){
            if(this.lef == null){
                this.lef = Node(value, this, null, null)
            }else{
                this.lef!!.insert(value)
            }
        }else{
            if(this.rig == null){
                this.rig = Node(value, this, null, null)
            }else{
                this.rig!!.insert(value)
            }
        }
    }
}

val root = Node(-1, null, null, null)

fun main(args: Array<String>) {
    val n = nextInt()
    for(i in 0 until n) {
        val command = next()
        if (command == "print") {
            inOrder(root)
            print("\n")
            preOrder(root)
            print("\n")
        } else {
            val key = command.split(" ")[1].toInt()
            if (root.key == -1) {
                root.key = key
                continue
            }
            root.insert(key)
        }
    }

}

fun preOrder(d :Node?) {
    if (d == null) return
    print(" ${d.key}")
    preOrder(d.lef)
    preOrder(d.rig)
}

fun inOrder(d :Node?) {
    if(d == null) return
    inOrder(d.lef)
    print(" ${d.key}")
    inOrder(d.rig)
}


fun abc000a() {
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }


Measured memory_bytes: 189504
x, k, d = [int(e) for e in input().split()]

if x < 0:
    x = -x

a = x // d

if k <= a:
    print(x - k * d)
else:
    b = k - a
    if b % 2 == 0:
        print(x - a * d)
    else:
        print( -(x - (a + 1) * d))
    

Measured memory_bytes: 9096
use std::io::{Read, StdinLock};
use std::str::{from_utf8, FromStr};
use std::vec::Vec;

const EPS: f64 = 1e-6;

struct StdinReader<'a> { reader: StdinLock<'a> }

impl<'a> StdinReader<'a> {
    pub fn new(reader: StdinLock<'a>) -> StdinReader { StdinReader { reader: reader } }
    pub fn read<T: FromStr>(&mut self) -> T {
        fn is_space(ch: u8) -> bool { ch == 0x20 || ch == 0x0a || ch == 0x0d }
        let b: Vec<u8> = self.reader.by_ref().bytes().map(|ch| ch.unwrap())
            .skip_while(|ch| is_space(*ch)).take_while(|ch| !is_space(*ch)).collect();
        let s = from_utf8(&b).unwrap();
        s.parse().unwrap_or_else(|_| panic!(format!("failed to parse: {}", s)))
    }
}

fn distance(p1: (f64, f64), p2: (f64, f64)) -> f64 {
    let dx = p1.0 - p2.0;
    let dy = p1.1 - p2.1;
    (dx * dx + dy * dy).sqrt()
}

fn dfs(visited: u32, p: (f64, f64), t: f64, crystals: &[(f64, f64)]) -> bool {
    let n = crystals.len();
    if visited == (1 << n) - 1 {
        return true;
    }

    // すべての頂点に到達可能かどうかをチェック
    for v in 0..n {
        if visited & (1 << v) != 0 { continue; }
        let q = crystals[v];
        let d = distance(p, q);
        if t + d >= distance(q, (0.0, 0.0)) - EPS {
            return false;
        }
    }

    for v in 0..n {
        if visited & (1 << v) != 0 { continue; }
        let q = crystals[v];
        let d = distance(p, q);
        if dfs(visited ^ (1 << v), q, t + d, crystals) {
            return true;
        }
    }
    false
}

fn main() {
    let stdin = std::io::stdin();
    let mut reader = StdinReader::new(stdin.lock());

    loop {
        let n: usize = reader.read();
        let hx: f64 = reader.read();
        let hy: f64 = reader.read();
        let dx: f64 = reader.read();
        let dy: f64 = reader.read();
        let start = (hx - dx, hy - dy);
        if n == 0 { break; }

        let mut crystals: Vec<(f64, f64)> = Vec::new();
        for _ in 0..n {
            let cx = reader.read::<f64>() - dx;
            let cy = reader.read::<f64>() - dy;
            crystals.push((cx, cy));
        }

        let ok = dfs(0, start, 0.0, &crystals);

        println!("{}", if ok { "YES" } else { "NO" });
    }
}



Measured memory_bytes: 5040
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 10000001

LL divi[MAX];

void pre() {

	int i, j;

	divi[1] = 1;
	divi[2] = 2;

	for(i = 2; i <= MAX/2 ; i++) {
		for(j = 2*i; j < MAX; j+=i) {
			divi[j]++;
		}
	}
}

int main() {

	LL n, i, ans = 0;
	
	pre();
	//cout<<divi[3]<<endl;
	cin>>n;

	for(i = 1 ; i <= n; i++) {
		ans += (i* ( i == 1 || i == 2 ?  divi[i] : divi[i] + 2));
	}

	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 81668
#include <iostream>
#include <math.h>
#include <stdio.h>
#define inf 1e9
#define eps 1e-9

using namespace std;

struct vec2d{
  double x, y;
  vec2d(){}
  vec2d(double x, double y){
    this->x = x , this->y = y;
  }
  double add(double a, double b){
    if(fabs(a+b) < eps*(fabs(a)+fabs(b))) return 0.0;
    return a+b;
  }
  vec2d operator+(vec2d ope){
    return vec2d(add(x, ope.x), add(y, ope.y));
  }
  vec2d operator-(vec2d ope){
    return vec2d(add(x, -ope.x), add(y, -ope.y));
  }
  vec2d operator*(double t){
    return vec2d(x*t, y*t);
  }
  vec2d operator/(double t){
    return vec2d(x/t, y/t);
  }
  double dot(vec2d ope){
    return add(x*ope.x, y*ope.y);
  }
  double cross(vec2d ope){
    return add(x*ope.y, -y*ope.x);
  }
  double norm(){
    double d2 = dot(*this);
    if(d2 > 0) return sqrt(d2);
    return 0.0;
  }
};

void getCrossPointCC(vec2d c1, double r1, vec2d c2, double r2, vec2d &lp, vec2d &rp)
{
  vec2d v = c2 - c1, n;
  double d = v.norm();
  double x = (r1*r1-r2*r2+d*d)/(2*d);

  v = v * (x/d);
  n = vec2d(-v.y, v.x);
  if(x >= 0){
    n = n * (sqrt(r1*r1-x*x) / n.norm());
    lp = c1 + v - n, rp = c1 + v + n;
  }
  else{
    n = n * (sqrt(r2*r2-(d-x)*(d-x))) / n.norm();
    lp = c1 + v + n, rp = c1 + v - n;
  }
}

double distPP(vec2d p, vec2d q){
  return (p-q).norm();
}

int n;
vec2d p[15];
double h[15], r[15];
bool used[15];

bool check(double m)
{
  for(int i = 1; i <= n; i++){
    double d = h[i]*h[i] - m*m;
    if(d < 0) return false;
    r[i] = sqrt(d);
  }
  /*cout << n << endl;
  for(int i = 1; i <= n; i++){
    cout << p[i].x << " " << p[i].y << " " << r[i] << endl;
  }*/

  for(int i = 1; i <= n; i++) used[i] = false;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(i == j) continue;
      if(used[i] || used[j]) continue;
      if(distPP(p[i], p[j]) + r[j] <= r[i]) used[i] = true;
    }
  }
  int cnt = 0;
  for(int i = 1; i <= n; i++) if(!used[i]) cnt++;
  if(cnt == 1) return true;

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(i >= j) continue;
      if(used[i] || used[j]) continue;
      if(distPP(p[i], p[j]) > r[i] + r[j]) return false;
      vec2d u, v;
      getCrossPointCC(p[i], r[i], p[j], r[j], u, v);

      bool flag = true;
      for(int k = 1; k <= n; k++){
        if(used[k] || i == k || j == k) continue;
        if(distPP(u, p[k]) > r[k]) flag = false;
      }
      if(flag) return true;

      flag = true;
      for(int k = 1; k <= n; k++){
        if(i == k || j == k) continue;
        if(distPP(v, p[k]) > r[k]) flag = false;
      }
      if(flag) return true;
    }
  }
  return false;
}

int main(void)
{
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i = 1; i <= n; i++){
      cin >> p[i].x >> p[i].y >> h[i];
    }

    double ub = 1000, lb = 0, mid;
    for(int i = 0; i < 100; i++){
      mid = (ub+lb)/2;
      if(check(mid)) lb = mid;
      else ub = mid;
    }
    printf("%.11f\n", lb);
  }

  return 0;
}



Measured memory_bytes: 3192
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    def root(x):
        if par[x] == x:
            return par[x]
        r = root(par[x])
        d[x] += d[par[x]]
        par[x] = r
        return par[x]
    def same(x,y):
        return root(x) == root(y)
    def weight(x):
        root(x)
        return d[x]
    def unite(x,y,w):
        w += weight(x)
        w -= weight(y)
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
            d[x] = -w
        else:
            par[y] = x
            d[y] = w
            if rank[x] == rank[y]:
                rank[x] += 1

    n,m = LI()
    par = [i for i in range(n)]
    rank = [0 for i in range(n)]
    d = [0 for i in range(n)]
    for i in range(m):
        x,y,w = LI()
        x -= 1
        y -= 1
        if same(x,y):
            if weight(y)-weight(x) != w:
                print("No")
                quit()
        else:
            unite(x,y,w)
    print("Yes")
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 122912
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;
const int n_max=101000;
ll dp[n_max];
ll h[n_max];
 
int main() {

    int n;
    cin >> n;
    int k;
    cin >> k;
    rep(i,n)    cin >> h[i];
    rep(i,n_max) {
        dp[i]=INF;
    }
    dp[0]=0;

    rep(i,n) {
        for(int j=1;j<=k;j++) {
            chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    
    cout << dp[n-1] << endl;

 return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
 
int main() {
 
int al[30] = {0};
char b[2000]= {0};
int i,j,n;
 
i=0;
 
while( scanf("%c",&b[i]) != EOF) {
 
if (b[i] >= 'A' && 'Z' >= b[i] ) {
n = b[i] - 'A';
al[n] += 1;
 
} else if(b[i] >=  'a' && b[i] <= 'z' ) {
n = b[i] - 'a';
al[n] += 1;
}
i=i+1;
}
 
for(j=97; j<=122; j++) {
n = j - 'a';
printf("%c : %d\n",j,al[n]);
}
 
return 0;
 
}


Measured memory_bytes: 2052
#include <bits/stdc++.h> 
     
    using namespace std; 
    #define ll long long
    #define ld long double
   ll gcd(ll a,ll b)
   {
    if(b==0)
        return a;
    return gcd(b,a%b);
   }
    int main()
    {
        ll x;
        cin >> x;
        if(x>=30)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    

Measured memory_bytes: 3632
def main():
    e=enumerate
    n,m,*u=map(int,open(0).read().split())
    dp=[[1]*(m+1)for _ in range(n+1)]
    dpi=dp[0]
    for i,s in e(u[:n]):
        dpi1=dp[i+1]
        for j,t in e(u[n:]):
            dpi1[j+1]=(dpi[j+1]+dpi1[j]-dpi[j]*(s!=t))%(10**9+7)
        dpi=dpi1
    print(dpi[m])
main()

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

#define endl '\n'

void solvetask(){
    int n; cin >> n;
    map<string, int> a = {{"AC", 0}, {"WA", 1}, {"TLE", 2}, {"RE", 3}};
    vector<int> cnt(4);
    vector<string> sla = {"AC", "WA", "TLE", "RE"};
    for (int i=0; i<n; i++){
        string s; cin >> s;
        cnt[a[s]]++;
    }
    for (int i=0; i<4; i++){
        cout << sla[i] << " x " << cnt[i] << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;// cin >> t;
    while(t--) solvetask();
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline

def ans(x):
    ANS=0
    while x:
        x%=bin(x).count("1")
        ANS+=1
    return ANS

LEN=int(input())
S=input().strip()
ONE=S.count("1")

ONEP=ONE+1
ONEM=ONE-1

PANS=0
MANS=0
for i in range(LEN):
    if S[i]=="1":
        PANS+=pow(2,LEN-1-i,ONEP)
        if ONEM<=0:
            continue
        MANS+=pow(2,LEN-1-i,ONEM)

for i in range(LEN):
    if S[i]=="0":
        print(ans((PANS+pow(2,LEN-1-i,ONEP))%ONEP)+1)
    else:
        if ONEM==0:
            print(0)
        else:
            print(ans((MANS-pow(2,LEN-1-i,ONEM))%ONEM)+1)
        
    


Measured memory_bytes: 9560
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n, k;
	cin >> n >> k;
	long long ans = 0;
	for (int b = k + 1; b <= n; b++) {
		ans += n / b * (b - k);
		ans += max(0, n % b - k + 1);
		ans -= k == 0 ? 1 : 0;
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
N = int(input())
primes = {}
for num in range(2, int(N**0.5)+1):
  while N%num == 0:
    if num in primes:
      primes[num] += 1
    else:
      primes[num] = 1
    N //= num
ans = 0
for p in primes.values():
  n = 1
  while n*(n+1)//2 <= p:
    n += 1
  ans += n-1
if N > 1:
  ans += 1
print(ans)

Measured memory_bytes: 63456
#include<iostream>
using namespace std;
int main()
{ string S,T,U;
cin>>S>>T;
 int a,b;
 cin>>a>>b;
 
 cin>>U;
 if(U==S)
 cout<<a-1<<" "<<b;
 else
 {
    cout<<a<<" "<<b-1;
 }
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char in[1001];
	int out, i;
	for (;;) {
		scanf("%s", in);
		if (in[0] == '0') {
			return 0;
		}
		out = 0;
		for (i = 0; in[i] != '\0'; i++) {
			out += in[i] - '0';
		}
		printf("%d\n", out);
	}
}

Measured memory_bytes: 536
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

map<pair<int, int>, ll> DP;

int main() {
  int N;
  cin>>N;
  for(int i=0;i<N;++i) {
    DP[mp(i, i/2)] = -big;
    DP[mp(i, i/2+1)] = -big;
  }
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  DP[mp(0, 1)] = A[0];
  DP[mp(1, 1)] = A[1];
  map<pair<int, int>, int> amap;
  amap[mp(0, 1)] = 1;
  amap[mp(1, 1)] = 1;
  for(int i=2;i<N;++i) {
    if(amap[mp(i-2, i/2-1)]>0 && amap[mp(i-3, i/2-1)]>0) {
      DP[mp(i, i/2)] = max(DP[mp(i, i/2)], A[i] + max(DP[mp(i-2, i/2-1)], DP[mp(i-3, i/2-1)]));
    }
    else if(amap[mp(i-2, i/2-1)]>0) {
      DP[mp(i, i/2)] = max(DP[mp(i, i/2)], A[i] + DP[mp(i-2, i/2-1)]);
    }
    else if(amap[mp(i-3, i/2-1)]>0) {
      DP[mp(i, i/2)] = max(DP[mp(i, i/2)], A[i] + DP[mp(i-3, i/2-1)]);
    }
    else {
      DP[mp(i, i/2)] = max(DP[mp(i, i/2)], A[i]);
    }
    amap[mp(i, i/2)] = 1;
    if(amap[mp(i-2, i/2)]>0 && amap[mp(i-3, i/2)]>0) {
      DP[mp(i, i/2+1)] = max(DP[mp(i, i/2+1)], A[i] + max(DP[mp(i-2, i/2)], DP[mp(i-3, i/2)]));
    }
    else if(amap[mp(i-2, i/2)]>0) {
      DP[mp(i, i/2+1)] = max(DP[mp(i, i/2+1)], A[i] + DP[mp(i-2, i/2)]);
    }
    else if(amap[mp(i-3, i/2)]>0) {
      DP[mp(i, i/2+1)] = max(DP[mp(i, i/2+1)], A[i] + DP[mp(i-3, i/2)]);
    }
    else {
      DP[mp(i, i/2+1)] = max(DP[mp(i, i/2+1)], A[i]);
    }
    amap[mp(i,  i/2+1)] = 1;
  }
  cout<<max(DP[mp(N-1, N/2)], DP[mp(N-2, N/2)])<<endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);

    for (int i = 0; i < n; i++)cin >> a[i];
    for (int i = 0; i < n; i++)cin >> b[i];

    long long suma = 0, sumb = 0;
    for (int i = 0; i < n; i++)
    {
        suma += a[i];sumb += b[i];
        
    }

    if(suma > sumb)
    {
        cout << "No" << endl;
    }
    else
    {
        string ans = "Yes";
        long long ca = 0, cb = 0;
        for (int i = 0; i < n; i++)
        {
            if(a[i] > b[i])cb += a[i] - b[i];
            else if(a[i] < b[i])
            {
                if((b[i] - a[i]) % 2 == 0)ca += (b[i] - a[i]) / 2;
                else
                {
                    ca += (b[i] - a[i]) / 2 + 1;
                    cb ++;
                }
            }
        }
        //cout << ca  << " " << cb << " " << sumb - suma << endl;
        if(max(cb, ca) > sumb - suma)ans = "No";
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <chrono>
using namespace std;

class Timer {
	chrono::high_resolution_clock::time_point start, end;
	double limit;

public:
	Timer() {
		start = chrono::high_resolution_clock::now();
	}
	Timer(double l) {
		start = chrono::high_resolution_clock::now();
		limit = l;
	}

	double getTime() {
		end = chrono::high_resolution_clock::now();
		return chrono::duration<double>(end - start).count();
	}

	bool Over() {
		if (getTime() > limit) {
			return true;
		}
		return false;
	}

	void setLimit(double l) {
		limit = l;
	}
	void setStart() { start = chrono::high_resolution_clock::now(); }
	double getLimit() { return limit; }
};

typedef long long ll;



int N;
ll L;
vector<ll>X;

ll solve(vector<ll>&X)
{
	vector<ll>Sum(N + 2);
	for (int i = 0; i < N; i++)
	{
		Sum[i + 1] += Sum[i] + X[i];
	}
	Sum[N + 1] += Sum[N] + L;

	ll ans = 0;

	for (int i = 0; i < N; i++)
	{
		ll tmp = 0;
		int x = N - i - 1;
		int l = i + 1 + x / 2;
		tmp = 2 * (Sum[l] - Sum[i]) + 2 * ((N - l)*L - (Sum[N] - Sum[l]));
		if (x % 2)tmp -= L - X[l];
		else tmp -= X[l - 1];

		ans = max(ans, tmp);
	}

	return ans;
}

int main() {
	cin>>L>>N;
	X.resize(N);
	for (int i = 0; i < N; i++)
	{
		cin >> X[i];
	}

	ll tmp1,tmp2;

	tmp1 = solve(X);

	reverse(X.begin(), X.end());
	for(int i=0;i<N;i++)X[i] = L-X[i];

	tmp2 = solve(X);

	cout << max(tmp1, tmp2) << endl;

	return 0;
}

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

signed main() {
  int n; cin >> n;
  vector<complex<double>> town(n);
  rep(i,n) {
    double x,y; cin >> x >> y;
    town[i] = complex<double>(x,y);
  }
  vector<int> s(n);
  rep(i,n) s[i]=i;
  double ans = 0;
  int count = 0;
  do {
    count++;
    rep(i,n-1) ans += abs(town[s[i]] - town[s[i+1]]);
  } while(next_permutation(s.begin(), s.end()));
  cout << fixed << setprecision(10) << ans / count << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	//0250 start
	//0315 acording end
	//0342 samplematched 
	int INF = 1 << 24;
	
	class State {
		int step, time, pos, bal;
		int dis;
		public State(int step, int time,int pos, int dis, int bal) {
			this.step = step;
			this.time = time;
			this.pos = pos;
			this.dis = dis;
			this.bal = bal;
		}
		@Override
		public String toString() {
			return "State [step=" + step + ", time=" + time + ", pos=" + pos
					+ ", bal=" + bal + ", dis=" + dis + "]";
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if (n == 0 ) break;
			int [] pos = new int[n+1];
			int [] time = new int[n+1];
			int maxtime = 0;
			for(int i = 1; i < n+1; i++){
				pos[i] = sc.nextInt();
				time[i] = sc.nextInt();
				maxtime = Math.max(maxtime, time[i]);
			}
			if(pos[1] > time[1]){
				System.out.println("NG 1");
				continue;
			}
			
			LinkedList<State> open = new LinkedList<Main.State>();
			open.add(new State(1, time[1], pos[1], pos[1], 1));
			double [][] close = new double[n+1][n+1];
//			double [][][] close = new double[n+1][n+1][maxtime + 1];
			for(int i = 0 ; i < n + 1; i++){
				Arrays.fill(close[i], INF);
			}
			
			int ansstep = 0;
			int ansdis = INF;
			while(! open.isEmpty()){
				State now = open.poll();
				//System.out.println(now);
				ansstep = Math.max(ansstep, now.step);
				if(n == now.step){
					//かえる
					ansdis = Math.min(ansdis, now.dis + now.pos);
					continue;
				}
				//ハウスに戻る
				int nextstep = now.step + 1;
				int nextpos =  pos[nextstep];
				int nextdis = now.pos + now.dis + nextpos;
				int nexttime = now.time + now.pos * (now.bal + 1) + nextpos;
				
				if(nexttime <= time[nextstep]){
					if(close[nextstep][1] > nextdis){
						open.add(new State(nextstep, time[nextstep], nextpos, nextdis, 1));
						close[nextstep][1] = nextdis;
					}
				}
				
				//そのまま
				if(now.bal == 3) continue;
				nextdis = now.dis + Math.abs(now.pos - nextpos);
				nexttime = now.time + Math.abs(now.pos - nextpos) * (now.bal + 1);
				if(nexttime <= time[nextstep]){
					if(close[nextstep][now.bal + 1] > nextdis){
						open.add(new State(nextstep, time[nextstep], nextpos, nextdis, now.bal + 1));
						close[nextstep][now.bal + 1 ] = nextdis;
					}
				}
			}
			if(ansdis == INF){
				System.out.println("NG " + (ansstep + 1));
			}
			else{
				System.out.println("OK " + ansdis);
			}
		}
	}
	
	
	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 12000
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int ans=inf;
  int k,n; cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n){
    int ans1;
    if(i==0){
      ans1=a[n-1]-a[0];
    }
    else{
      ans1=k-a[i];
      ans1+=a[i-1];
    }
    int ans2;
    if(i==n-1){
      ans2=a[n-1]-a[0];
    }
    else{
      ans2=a[i];
      ans2+=k-a[i+1];
    }
    chmin(ans,min(ans1,ans2));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(int i = (int)(a); i <= (int)(b); i++)
#define rf(i,a,b)    for(int i = (int)(a); i >= (int)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    ll N;rd(N);;
    if(N%1000==0)pp(0);
    else pp(1000-N%1000);   
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
  
int main(void){
  int N, count = 0, temp;
  scanf("%d", &N);
  int a[N+2], b[N+2];
  for(int i=1; i<=N; i++){
    scanf("%d", &a[i]);
    b[i] = 0;
  }
  for(int i=N; i>=1; i--){
    temp = 0;
    for(int j=1; j*i<=N; j++){
      if(b[i*j]==1) temp++;
    }
    if((a[i] == 1 && temp%2 == 0)||(a[i] == 0 && temp%2 == 1)){
      b[i] = 1;
    }
    else if((temp%2==1&&a[i]==1)||(temp%2==0&&a[i]==0)){
      b[i]=0;
    }
  }
  for(int i=1; i<=N; i++){
    if(b[i] == 1) count++;
  }
  printf("%d\n", count);
  for(int i=1; i<=N; i++){
    if(b[i] == 1) printf("%d ", i);
  }
  return 0;

}


Measured memory_bytes: 2432
a=int(input())
lis=list(map(int,input().split()))
lis=sorted(lis)
i=0
while i<=a-2 and lis[i]<0:
  if lis[i]<=0 and lis[i+1]>=0:
    if -1*lis[i]>lis[i+1]:
      lis[i],lis[i+1]=-lis[i],-lis[i+1]
  elif lis[i]<=0 and lis[i+1]<=0:
    lis[i],lis[i+1]=-lis[i],-lis[i+1]
  i+=2
print(sum(lis))

Measured memory_bytes: 14464
#include<iostream>
#include<string>
#include<utility>
#include<map>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  map<string,int> m;
  int a,b;cin >> a >> b;
  m.insert(make_pair(s,a));
  m.insert(make_pair(t,b));
  string p;
  cin >> p;
  m[p]--;
  cout << m[s] << " " << m[t] << endl;
}

Measured memory_bytes: 256
// This template code suggested by KT BYTE Computer Science Academy
//   for use in reading and writing files for USACO problems.

// https://content.ktbyte.com/problem.java

import java.util.*;
import java.io.*;

public class Main {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    static String next() throws IOException {
        in.nextToken();
        return in.sval;
    }

    static String text1;
    static String text2;

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        text1 = next();
        text2 = next();

        out.println(longestCommonSubsequence());
        out.close();
    }

    public static String longestCommonSubsequence() {
        int[][] max = new int[text1.length() + 1][text2.length() + 1];

        for (int i = 1; i <= text1.length(); i++) {
            for (int j = 1; j <= text2.length(); j++) {
                if (text1.charAt(i - 1) == text2.charAt(j - 1)) {
                    max[i][j] = 1 + max[i-1][j-1];
                }

                else {
                    max[i][j] = Math.max(max[i-1][j], max[i][j-1]);
                }
            }
        }

        int indexText1 = text1.length();
        int indexText2 = text2.length();

        StringBuilder sb = new StringBuilder();

        while (indexText1 >= 1 && indexText2 >= 1) {
            if (areEqual(indexText1, indexText2)) {
                sb.append(text1.charAt(indexText1 - 1));
                indexText1--;
                indexText2--;
            }

            else {
                if (max[indexText1 - 1][indexText2] > max[indexText1][indexText2 - 1]) {
                    indexText1--;
                }

                else {
                    indexText2--;
                }
            }
        }

        return sb.reverse().toString();
    }

    static boolean areEqual(int index1, int index2) {
        return text1.charAt(index1 - 1) == text2.charAt(index2 - 1);
    }
}




Measured memory_bytes: 84160
h, w = gets.chomp.split(' ').map{|i| i.to_i}
s = Array.new(h + 2)
s[0] = Array.new(w + 2)
s[h + 1] = Array.new(w + 2)
s[0].fill(".")
s[h + 1].fill(".")
1.upto(h) do |i|
        s[i] = ("." + gets.chomp + ".").split('')
end
1.upto(h) do |i|
        1.upto(w) do |j|
                if s[i][j] == "#"
                        if s[i - 1][j] == "." && s[i + 1][j] == "." &&
                        s[i][j - 1] == "." && s[i][j + 1] == "." then
                                puts "No"
                                exit
                        end
                end
        end
end
puts "Yes"


Measured memory_bytes: 2044
//
//	Created by shamim_nik
//

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

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

#define br printf("\n")

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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe\n";
	} else {
		cout << "safe\n";
	}
	return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int[] counts = new int[26];
		for (char c : arr) {
			counts[c - 'A']++;
		}
		if (((counts['N' - 'A'] != 0 && counts['S' - 'A'] != 0) ||
			(counts['N' - 'A'] == 0 && counts['S' - 'A'] == 0)) &&
			((counts['E' - 'A'] != 0 && counts['W' - 'A'] != 0) ||
			(counts['E' - 'A'] == 0 && counts['W' - 'A'] == 0))) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}
	}
}


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

int main(){
  string S;
  int64_t K;
  cin >> S >> K;
  int64_t retu1 = 0;
  string ans;
  for(int i=0;i<S.size();i++){
    if(S[i] == '1') retu1++;
    else {
      ans = S[i];
      break;
    }
  }
  if(retu1 == S.size()) cout << 1 << endl;
  else if(K <= retu1) cout << 1 << endl;
  else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include <string.h>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int main() {
	string S, T;

	cin >> S >> T;

	if (!(S.length() >= 1 && S.length() <= 10) ||
		T.length() != S.length() + 1) {
		goto NO;
	}
	for (int ii = 0; ii < T.length(); ii++) {
		if (!(T[ii] >= 'a' && T[ii] <= 'z')) {
			goto NO;
		}
		if (ii == T.length() - 1) {
			continue;
		}
		if (T[ii] != S[ii]) {
			goto NO;
		}
	}

	cout << "Yes" << endl;
	return 0;
	
NO:	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3548
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))


#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import sys
sys.setrecursionlimit(10000)
def rec(keta,num,val,cache):
    if keta==0:
        #print(val)
        cache.append(val)
        return None

    #"""
    if num!=0:
        tmp=val+(num-1)*10**(keta-1)
        rec(keta-1,num-1,tmp,cache)
    if num!=9:
        tmp=val+(num+1)*10**(keta-1)
        rec(keta-1,num+1,tmp,cache)

    #"""
    tmp=val+(num)*10**(keta-1)
    #print(keta)
    #print(tmp)
    rec(keta-1,num,tmp,cache)
    


ans=[]
#rec(n,1,1*(10**n),ans)
for n in range(10):
    for i in range(10):
        rec(n,i,i*(10**(n)),ans)


ans=set(ans)
ans=list(ans)
ans.sort()
n=int(input())
print(ans[n])


Measured memory_bytes: 24716
import math
a, b, h, m = map(int, input().split())

hour_angle = h * 30 + ((m/60)*30)
# print(hour_angle)
minute_angle = (m//5)*30 + ((m - ((m//5)*5))/5 * 30)
angle = max(hour_angle, minute_angle) - min(hour_angle, minute_angle)
# print(math.pi *2)
if angle == 0:
  print(abs(a-b))
elif angle == 180:
  print(a+b)
else:
  print(math.sqrt(a**2 + b**2 - (2*b*a*math.cos(angle*math.pi/180))))

Measured memory_bytes: 9592
def dps(now,i,j,arr,node):
    for x in arr[now]:
        if (now==i and x==j) or (now==j and x==i):
            continue
        if node[x]==0:
            node[x]=1
            dps(x,i,j,arr,node)

N,M=list(map(int,input().split()))
arr=[[] for i in range(N)]

for i in range(M):
    a,b=list(map(int,input().split()))
    arr[a-1].append(b-1)
    arr[b-1].append(a-1)

ans=0
for i,x in enumerate(arr):
    for j in x:
        node=[0 for _ in range(N)]
        dps(0,i,j,arr,node)
        if sum(node)!=N:
            ans+=1
print(ans//2)

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

int main() {
  int A, B;
  cin >> A >> B;
  if ( A % 2 == 0 || B % 2 == 0 ) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const ll d= 12810;
const ll d2= 25620;

	bitset<d2>dp[82][82];
	ll h,w,ch[82][82];	
int main() {

	cin>>h>>w;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			ll x;
			cin>>x;
			ch[i][j]=x;
		}
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			ll y;
			cin>>y;
			ch[i][j]=abs(ch[i][j]-y);
		//	cout <<ch[i][j];
		}
	//	cout <<endl;
	}
	
	dp[0][0][d-ch[0][0]]=1;
	dp[0][0][d+ch[0][0]]=1;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(i){
			dp[i][j] |=dp[i-1][j]<<ch[i][j];
			dp[i][j] |=dp[i-1][j]>>ch[i][j];
			}
			if(j){
			dp[i][j] |=dp[i][j-1]<<ch[i][j];
			dp[i][j] |=dp[i][j-1]>>ch[i][j];
			}
		}
	}
	ll ans=d2;
//	cout << ans<<endl;
	for(ll i=0;i<d2;i++){
		if(dp[h-1][w-1][i]){
		//	cout <<i ;
			ans=min(ans,abs(i-d));
		//	cout <<" "<<d<<" "<<ans<<endl;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 20864
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int fiveCount = 0, sevenCount = 0;
  rep(i, 3) {
    int x;
    cin >> x;
    if (x == 5) fiveCount++;
    if (x == 7) sevenCount++;
  }
  if (fiveCount == 2 and sevenCount == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct unionfind{
  vector<int> p;
  unionfind(int n){
    p = vector<int>(n, -1);
  }
  int root(int x){
    if (p[x] == -1){
      return x;
    } else {
      p[x] = root(p[x]);
      return p[x];
    }
  }
  void unite(int x, int y){
    x = root(x);
    y = root(y);
    p[x] = y;
  }
};
int main(){
  while (1){
    int N, Q;
    cin >> N >> Q;
    if (N == 0 && Q == 0){
      break;
    }
    vector<int> p(N, -1);
    for (int i = 1; i < N; i++){
      cin >> p[i];
      p[i]--;
    }
    vector<pair<char, int>> query(Q);
    vector<int> m(N, 0);
    m[0]++;
    for (int i = 0; i < Q; i++){
      char c;
      int v;
      cin >> c >> v;
      v--;
      query[i] = make_pair(c, v);
      if (c == 'M'){
        m[v]++;
      }
    }
    unionfind UF(N);
    for (int i = 1; i < N; i++){
      if (m[i] == 0){
        UF.unite(i, p[i]);
      }
    }
    long long ans = 0;
    for (int i = Q - 1; i >= 0; i--){
      char c = query[i].first;
      int v = query[i].second;
      if (c == 'Q'){
        ans += UF.root(v) + 1;
      } else {
        m[v]--;
        if (m[v] == 0){
          UF.unite(v, p[v]);
        }
      }
    }
    cout << ans << endl;
  }
}


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

int main()
{
    int h,m,s;
    
    cin >> s;
    
    h = s / 3600;   s %= 3600;
  	m = s / 60;		s %= 60;
  
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
using namespace std;

typedef long long ll;

int main(){
  ll h,n;
  cin >> h>>n;
  ll m[n][2];
  for(ll i=0;i<n; i++){
  	cin >> m[i][0] >> m[i][1];
  }
  //jへｒすときの魔力最小値
  ll dp[h+1];
  dp[0]=0;
  ll mini;
  for(ll i=1;i<h+1;i++){
      mini=1000000000000000;
	  for(ll j=0;j<n;j++){
        if(i-m[j][0]>0){
      		mini = min(mini, m[j][1]+ dp[ (i-m[j][0]) ]);
        }else{
        	mini= min( mini, m[j][1]);
        }
      }
      dp[i]=mini;
  }

  cout << dp[h];
  
  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int N,X,T;
int main(){
	cin>>N>>X>>T;
	cout<<(N+X-1)/X*T<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    vector<int> x;
    vector<int> y;
    int xx,yy;

    while(1){
        cin >> xx >> yy;
        if(xx==0&&yy==0){
            break;
        }
        x.push_back(xx);
        y.push_back(yy);
    }
    for(int i=0; i<x.size(); i++){
        if(x[i]<y[i]) cout << x[i] << ' ' << y[i] << endl;
        else cout << y[i] << ' ' << x[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
int n;
int a[maxx];
map <int, int> mp;
map <int, int> vis;

int main() {
	mp.clear();
	vis.clear();
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		vis[a[i]]++;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		mp[a[i]] = vis[a[i]] + vis[a[i] - 1] + vis[a[i] + 1];
	}
	for(int i = 1; i <= n; i++) ans = max(ans, mp[a[i]]);
	cout << ans << endl;
}

Measured memory_bytes: 8064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, A[100010][3];
ll dp[100010][3];

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) rep(j, 3) scanf("%d", A[i] + j);
	for(int i=1;i<=N;i++) rep(j, 3) rep(k, 3) if(k != j) dp[i][j] = max(dp[i][j], dp[i-1][k] + A[i][j]);
	printf("%lld\n", max({dp[N][0], dp[N][1], dp[N][2]}));
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string S;
  
  cin >> S;
  
  int num = 16;
  int num2;
  
  if(S[0] == 'C'){
    num--;
  }
  if(S[1] == 'O'){
    num--;
  }
  if(S[2] == 'D'){
    num--;
  }
  if(S[3] == 'E'){
    num--;
  }
  if(S[4] == 'F'){
    num--;
  }
  if(S[5] == 'E'){
    num--;
  }
  if(S[6] == 'S'){
    num--;
  }
  if(S[7] == 'T'){
    num--;
  }
  if(S[8] == 'I'){
    num--;
  }
  if(S[9] == 'V'){
    num--;
  }
  if(S[10] == 'A'){
    num--;
  }
  if(S[11] == 'L'){
    num--;
  }
  if(S[12] == '2'){
    num--;
  }
  if(S[13] == '0'){
    num--;
  }
  if(S[14] == '1'){
    num--;
  }
  if(S[15] == '6'){
    num--;
  }
  
  cout << num << endl;
       
  
}


Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

p = [k-q] * n

for a_ in a:
    p[a_ - 1] += 1

for p_ in p:
    if p_ > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10472