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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 1000


using namespace std;

using ll =long long;
using P = pair<int,int>;


 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


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


int main() {

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

int n;
long long int k;

cin>>n>>k;

int a[n];
int flag[n]={};


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

long long int haba1=0;

long long int haba2=0;
int beg=1;

vector<int> res;

while(true){
if(flag[beg-1]==2)break;
flag[beg-1]+=1;

if(flag[beg-1]==1)haba1++;
if(flag[beg-1]==2){
haba2++;
res.push_back(beg);
}
beg=a[beg-1];


}

haba1-=haba2;



if(haba1+haba2>k){
beg=1;
for(int i=0;i<k;i++){
beg=a[beg-1];

}
cout<<beg<<endl;
}else{
k-=haba1;
k=k%haba2;
cout<<res[k]<<endl;
}

}

//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;

Measured memory_bytes: 5772
H,W = map(int, raw_input().split())
S = [raw_input() for _ in range(H)]
D = [[H*W]*W for _ in range(H)]
D[0][0] = 0
Q = [(0,0)]
while len(Q)>0:
  cx,cy = Q.pop(0)
  for dx,dy in [(-1,0),(1,0),(0,-1),(0,1)]:
    x = cx+dx
    y = cy+dy
    if 0<=x<W and 0<=y<H and S[y][x]=='.' and D[cy][cx]+1<D[y][x]:
      D[y][x] = D[cy][cx]+1
      Q += [(x,y)]
if D[H-1][W-1]<H*W:
  print sum(s.count('.') for s in S)-D[H-1][W-1]-1
else:
  print -1


Measured memory_bytes: 2696
S=list(input())
N=len(S)
ans=[0]*N
i=0
t1=0
t2=0

while i<=(N-1):
  if S[i]=='R':
    t1+=1
    if S[i+1]=='L':
      ans[i]+=t1
      t1=0
      t1,t2=t2,t1
    elif S[i+1]=='R':
      t1,t2=t2,t1
  if S[i]=='L':
    ans[i]+=t1
    t1=0
    t1,t2=t2,t1
  i+=1
i=1
t1=0
t2=0
while i<=(N):
  if S[-i]=='L':
    t1+=1
    if S[-(i+1)]=='R':
      ans[-i]+=t1
      t1=0
      t1,t2=t2,t1
    elif S[-(i+1)]=='L':
      t1,t2=t2,t1
  if S[-i]=='R':
    ans[-i]+=t1
    t1=0
    t1,t2=t2,t1
  i+=1
print(' '.join([str(x) for x in ans]))

Measured memory_bytes: 11180
import sys
sys.setrecursionlimit(10**6)

class Node:
    def __init__(self):
        self.parent = -1
        self.left_child = None
        self.right_sibling = None

def get_children(node):
    c = node.left_child
    cs = []
    if c is not None:
        cs.append(c)
        c = nodes[int(node.left_child)]
        while c.right_sibling:
            c = c.right_sibling
            cs.append(c)
            c = nodes[int(c)]
    return cs

# def get_depth(index):
#     depth = 0
#     index = int(index)
#     while index:
#         index = int(nodes[index].parent)
#         depth += 1
#     return depth

def set_depth(i, depth):
    if depths[i] or i >= n:
        return
    depths[i] = depth
    node = nodes[i]
    if node.right_sibling:
        set_depth(int(node.right_sibling), depth)
    if node.left_child:
        set_depth(int(node.left_child), depth+1)

def get_root_index():
    for i, node in enumerate(nodes):
        if node.parent == -1:
            return i
            
def get_kind_of_tree(node):
    if node.parent == -1:
        return "root"
    if node.left_child:
        return "internal node"
    return "leaf"

if __name__ == "__main__":
    n = int(input())
    nodes = [Node() for _ in range(n)]
    depths = [None for _ in range(n)]
    for _ in range(n):
        data, number_of_children, *children = input().split()
        node = nodes[int(data)]
        for i, child_data in enumerate(children):
            if i == 0:
                node.left_child = child_data
            else:
                child.right_sibling = child_data
            child = nodes[int(child_data)]
            child.parent = int(data)
    root_node_index = get_root_index()
    set_depth(root_node_index, 0)
    for i, node in enumerate(nodes):
        children = get_children(node)
        print("node {}: parent = {}, depth = {}, {}, [{}]".format(i, node.parent, depths[i], get_kind_of_tree(node), ', '.join(children)))
        


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

int main() {
    int n, temp = 1, ans = 1;
    cin >> n;
    while(temp * 2 <= n) {
        temp = temp * 2;
        ans = temp;
    }
    cout << ans << endl;
}

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


int main(int argc, char* argv[])
{
    int n; ll k;
    scanf("%d%lld", &n, &k);

    vector<int> a(n*2);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        a[n+i]=a[i];
    }
    vector<int> next(n*2,INF);
    map<int,int> z;
    for(i=0; i<n*2; i++) {
        auto it=z.find(a[i]);
        if(it!=z.end()) {
            next[it->second]=i;
        }
        z[a[i]]=i;
    }

    map<int,ll> save;
    save[0]=0;
    ll num=0;
    int curr=0;
    while(num<k-2) {
        curr=next[curr]+1;
        while(curr>=n) {
            curr-=n;
            num++;
            if(curr<n) {
                auto it=save.find(curr);
                if(it!=save.end()) {
                    ll num0=it->second;
                    ll diff=num-num0;
                    assert(diff>0);
                    num = num0 + (k-1-num0)/diff*diff;
                }
                save[curr]=num;
            }
        }
    }
    assert(num==k-1 || num==k-2);
    ll n2=n*(k-num);
    for(i=curr; i<n2; i++) {
        if(next[i]<n2) {
            i=next[i];
        }
        else {
            printf("%d ", a[i]);
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 26240
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn dfs(x: usize, ans: &mut Vec<i32>, eg: &Vec<Vec<usize>>, og: &Vec<Vec<usize>>) {
    for i in 0..eg[x].len() {
        let y = eg[x][i];
        if ans[y] == -1 {
            ans[y] = ans[x];
            dfs(y, ans, eg, og);
        }
    }

    for i in 0..og[x].len() {
        let y = og[x][i];
        if ans[y] == -1 {
            ans[y] = (ans[x] + 1) % 2;
            dfs(y, ans, eg, og);
        }
    }
}

fn main() {
    let n:usize = read_line().trim().parse().unwrap();
    let mut og = vec![Vec::new(); n];
    let mut eg = vec![Vec::new(); n];
    for _ in 0..n-1 {
        let uvw: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let u = uvw[0]-1;
        let v = uvw[1]-1;
        let w = uvw[2]%2;
        if w==0 {
            eg[v].push(u);
            eg[u].push(v);
        } else {
            og[v].push(u);
            og[u].push(v);
        }
    }

    let mut ans = vec![-1; n];
    ans[0] = 0;
    dfs(0, &mut ans, &eg, &og);

    for i in 0..n {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 20732
/* Murad Eynizade */

#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 100001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);


using namespace std;



int main()
{
    FAST_READ;
    int n , m;
    cin>>n>>m;
    char a[n][m];
    int cor[n] , coc[m];
    memset(cor,0,sizeof(cor));
    memset(coc,0,sizeof(coc));
    for (int i = 0;i<n;i++) {
        for (int j = 0;j<m;j++) {
            cin>>a[i][j];
            if (a[i][j] == '.') {
                cor[i]++;
                coc[j]++;
            }
        }
    }
    for (int i = 0;i<n;i++) {
        if (cor[i] == m)continue;
        for (int j = 0;j<m;j++) {
            if (coc[j] == n)continue;
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;

int main(){
  double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  cout<<setiosflags(ios::fixed)<<setprecision(6)<<hypot(x1-x2,y1-y2)<<endl;
  return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int t[3][1000];
int memo[3][1000];
int n;

int dfs(int y,int x){
	//cout<<y<<" "<<x<<endl;
	if(memo[y][x]!=0)return memo[y][x];

	if(y==2&&x==n){
		return t[y][x];
	}
	int ret=0,ret1=0;
	if(y<2)ret=dfs(y+1,x)+t[y][x];
	if(x<n)ret1=dfs(y,x+1)+t[y][x];
	return memo[y][x]=max(ret,ret1);
}

int main(){
cin>>n;
rep(i,2){
	rep(j,n)cin>>t[i+1][j+1];
}	
	cout<<dfs(1,1)<<endl;
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll a, b, c;
    cin >> a >> b >> c;
    ll gedoku = a + b;
    c = min(c, gedoku + 1);
    cout << b + c << endl;
    return 0;
}


Measured memory_bytes: 768
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(s: String);
    let result = solve(s);
    println!("{:?}",result);
}

fn solve(s: String) -> usize {
    let mut current = 0;
    let mut op = 0;
    let mut chars: Vec<char>  = s.chars().collect();
    let len = s.len();

    while current + 1 < len {
        if chars[current] == '1' && chars[current] == chars[current + 1] {
            chars[current + 1] = '0';
            op += 1;
        } else if chars[current] == '0' && chars[current] == chars[current + 1] {
             chars[current + 1] = '1';
             op += 1;
        } 
        current += 1;
    };
    op
}


Measured memory_bytes: 4352
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          var n = int.Parse(ReadLine());
          int ans = 0;
          if(n % 2 != 0) ans += 1;

          ans += n / 2;
          WriteLine(ans);
      }
   }
}

Measured memory_bytes: 13140
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val v = List.fill(n)(sc.nextInt)
  var mOdd = Map(-1 -> 0)
  var mEven = Map(-1 -> 0)
  v.zipWithIndex.foreach{ case (x, idx) =>
    if (idx % 2 == 0) {
      mEven += x -> (mEven.getOrElse(x,0) + 1)
    } else {
      mOdd += x -> (mOdd.getOrElse(x,0) + 1)
    }
  }

  def cost(v1: Int, v2: Int): Int = {
    (n/2 - v1) + (n/2 - v2)
  }

  val mEvenSorted = mEven.toVector.sortBy(_._2).reverse
  val mOddSorted = mOdd.toVector.sortBy(_._2).reverse

  println((mEvenSorted(0), mOddSorted(0)) match { case ((e11,v11), (e12,v12)) =>
    if (e11 != e12) cost(v11,v12)
    else (mEvenSorted(1), mOddSorted(1)) match { case ((e21,v21), (e22,v22)) =>
      cost(v11,v22).min(cost(v12, v21))
    }
  })
}

Measured memory_bytes: 89976
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;  cin >> n;
    
    map<int,int> mp;
    rep(i,n) {
        int a; cin >> a;
        mp[a]++;
    }
    
    vector<int> c; //辺候補 
    for (auto p : mp) {
        if (p.second >= 4) {
            c.push_back(p.first);
            c.push_back(p.first);
        }
        else if (2 <= p.second) {
            c.push_back(p.first);
        }
    }
    
    sort(c.rbegin(),c.rend());
    int l = c.size();
    if (l < 2) cout << 0 << endl;
    else cout << c[0]*c[1] << endl;
    return 0;
}

Measured memory_bytes: 6528
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[]
for i in range(a[1]):
    if i==a[1]-1:
        if b[0]==0:
            b[0]=a[0]
            c.append(abs(b[i]-b[0]))
        else:
            c.append(abs(b[i]-(b[0]+a[0])))
    elif i!=a[1]-1:
        c.append(abs(b[i]-b[i+1]))
print(a[0]-max(c))

Measured memory_bytes: 26444
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	char G[12] = { 'A','C','A','B','A','B','A','A','B','A','B','A' };
	int x, y;
	cin >> x >> y;

	if (G[x - 1] == G[y - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

struct Node {
  Node *nxt[26], *par;
  int f[26];
};

const int M = 2e6;
Node cache[M];
int cidx = 0;
Node *new_node() {
  return &cache[cidx++];
}

Node *root;

bool pres[26];
void add(const string& s) {
  Node *cur = root;
  for (char c: s) {
    int idx = c - 'a';
    if (!cur->nxt[idx]) {
      cur->nxt[idx] = new_node();
      cur->nxt[idx]->par = cur;
    }
    cur = cur->nxt[idx];
  }

  memset(pres, 0, sizeof pres);
  const int n = s.size();
  for (int i = n - 1; i >= 0; i--) {
    int idx = s[i] - 'a';
    pres[idx] = true;

    cur = cur->par;
    for (int j = 0; j < 26; j++) {
      if (pres[j]) cur->f[j]++;
    }
  }
}

int solve(const string& s) {
  Node *cur = root;
  const int n = s.size();
  for (int i = 0; i < n - 1; i++) {
    cur = cur->nxt[s[i] - 'a'];
  }
  return cur->f[s.back() - 'a'];
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  root = new_node();

  int n; cin >> n;
  vector<string> vs(n);
  for (auto& s: vs) {
    cin >> s;
  }
  sort(vs.begin(), vs.end(), [](const string& a, const string& b) {
    return a.size() > b.size();
  });

  ll ans = 0;
  for (auto& s: vs) {
    reverse(s.begin(), s.end());
    add(s);
    ans += solve(s) - 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 316684
mod = 10**9+7
N, K = map(int, input().split())
cnt = [0]*(K+1)
ans = 0
for x in range(K, 1, -1):
    c = pow(K//x, N, mod)
    a = 2
    while a*x <= K:
        c -= cnt[a*x]
        a += 1
    ans = (ans+x*c%mod)%mod
    cnt[x] = c
ans = (ans+pow(K, N, mod)-sum(cnt))%mod
print(ans)

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

ll calc(ll a, ll b) {
    ll mn = a * b;
    ll t = a / 3;

    ll x = t * b;
    ll y = (a - t) * (b / 2);
    ll z = (a - t) * (b - b / 2);
    mn = min({mn, max({abs(x - y), abs(x - z), abs(y - z)})});
    x = (t + 1) * b;
    y = (a - (t + 1)) * (b / 2);
    z = (a - (t + 1)) * (b - b / 2);
    mn = min({mn, max({abs(x - y), abs(x - z), abs(y - z)})});

    return mn;
}

int main() {
    ll h, w;
    cin >> h >> w; 

    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << min({h, w, calc(h, w), calc(w, h)}) << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,l;cin>>n>>l;
    int sum = (l+l+n-1)*n/2;
    if(l<0&&0<l+n-1){cout<<sum<<endl; return 0;}
    else if(0<=l){cout<<sum-l<<endl; return 0;}
    else {cout<<sum-(l+n-1)<<endl;return 0;}
}


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


int main(){
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int dp[n]={};
	dp[0]=0;
	for(int i=1;i<n;i++)
		dp[i]=INT_MAX;
	
	for(int i=1;i<n;i++)
	{
		for(int j=max(0,i-k);j<i;j++)
		{
			dp[i]=min(dp[j]+abs(arr[i]-arr[j]),dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;
}

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

main()
{
    int s;
    int h = 0;
    int m = 0;
    cin>>s;
    while(s>0)
        {
            if (s>=3600)
                {
                ++h;
                s=s-3600;
                }
            else if (s>=60)
                {
                ++m;
                s=s-60;
                }
            else 
                break;
        }
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

Measured memory_bytes: 1168
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
unordered_map<ll, ll> max_map; 
  
// Function to find the smallest prime factors 
// of numbers upto MAX 
ll prime[1000005];
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < 1000005; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < 1000005; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  
signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      sieve();
      while(t--)
      { 
         
         ll n;
         cin>>n;
         ll a[n];
         for(int i=0;i<n;i++) cin>>a[i];
             for (int i = 0; i < n; i++) { 
        ll num = a[i]; 
        unordered_map<ll, ll> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            ll factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    ll ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.fr, it.se)) % mod; 
    } 
         ll ans1 =0;
         for(int i=0;i<n;i++){
            ans1+=(ans*power(a[i],mod-2))%mod;
            ans1%=mod;}
        cout<<ans1<<endl;
         

      }
      






}



























Measured memory_bytes: 8960
#include <bits/stdc++.h> 
using namespace std; 
int m(int y)
{
	if(y<0)
		y=y*(-1);
return y;}
  int fuc(int *a,int l,int k)
  {
	  int b[l];
	  int i,j;
	  b[0]=0;
	  b[1]=m(a[1]-a[0]);
	  for(i=2;i<l;i++)
	  {
		  b[i]=1000000000;
		  for(j=i-k>=0?i-k:0;j<i;j++)
		  {
			  if(b[j]+m(a[i]-a[j])<b[i])
			  { b[i]=m(a[i]-a[j])+b[j];
		  //cout<<b[i]<<endl;
		  }
		  }
	  }	  
  return b[l-1];		  
  }
  

int main() 
{   
ios::sync_with_stdio(false);
  cin.tie(0);
    //SieveOfEratosthenes(900000);
	int t,k,i;
	cin>>t>>k;
	int a[t];
	i=0;
	while(i<t)
	{
		cin>>a[i];
		i++;
	}
	int cost=fuc(a,t,k);
	cout<<cost<<endl;
    return 0; 
} 

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>

typedef long long ll;
using namespace std;

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

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

  cout<<a*b/gcd(a,b)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define inf 9223372036854775807;
#define pb push_back;
#define umap unordered_map;
#define uset unordered_set;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void solve(){
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll yes = c / b + ll(c%b !=0);
    ll no = a / d + ll(a%d!=0);
    if(yes<=no){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}
int main(){
    fast;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
}   

Measured memory_bytes: 3652
import collections
H, W, N = map(int, input().split())

delta = (-1, 0, 1)

ans = []
for i in range(N):
    a, b = map(int, input().split())
    for da in delta:
        for db in delta:
            if 1 <= a-1+da <= H-2 and 1 <= b-1+db <= W-2:
                ans.append((a-1+da, b-1+db))

cc = collections.Counter(collections.Counter(ans).values())
zc = (H-2)*(W-2)-sum(cc.values())
print(zc)
for i in range(1, 10):
    print(cc[i])


Measured memory_bytes: 198528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		
		sc.close();
		
		int ans = 0;
		
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != t.charAt(i)) {
				ans++;
			}
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 32080
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int n;
    long long int d, x, y, D, dis;
    int cout = 0;
    
    scanf("%d %lld", &n, &d);
    for (int i = 0; i < n; i++) {
        scanf("%lld %lld", &x, &y);
        D = d*d;
        dis = (x*x)+(y*y);
        if (D >= dis) {
            cout++;
        }
    }

    printf("%d", cout);

    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    int n,m,x;cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int> (m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    LL ans = LINF;
    for (int i = 0; i < 1<<n; i++) {
        LL sum = 0;
        vector<LL> s(m,0);
        for (int j = 0; j < n; j++) {
            if((i >> j) & 1){
                sum += c[j];
                for (int k = 0; k < m; k++) {
                    s[k] += a[j][k];
                }
            }
        }
        bool f = true;
        for (int j = 0; j < m; j++) {
            if(s[j] < x) f = false;
        }
        if(f) chmin(ans, sum);
    }
    if(ans == LINF) puts("-1");
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int n = in.nextInt();
        int a[] = new int[200009];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        a[n] = k + a[0];
        int ans = 1000000009;
        for (int i = 0; i < n; i++) {
            ans = Math.min(ans, k - (a[i+1] - a[i]));
        }
        System.out.println(ans);
    }
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve(){
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	sum += min(a, k) * 1;
	k -= a;
	k = max(k, (ll)0);
	sum += min(b, k) * 0;
	k -= b;
	k = max(k, (ll)0);
	sum += min(c, k) * -1;
	cout << sum;
}

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

	solve();
    
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main() {

    int x, n, t, qnt = 0, res = 0;

    scanf("%d %d %d", &x, &n, &t);

    while(1){

        qnt = qnt + n;

        res = res + t;

        if(qnt >= x)

            break;

    }

    printf("%d", res);

    return 0;

}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


const int N = 2e5+5;
int n,m;



int32_t main()
{
	IOS;
	cin>>n>>m;
	
	int ans=0;
	

	if(n>=2)
		ans+=(n* (n-1)) /2;
	if(m>=2)
		ans+= (m*(m-1))/2;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, i = 0, j = 0;
	if (scanf("%d", &n) == 1);

	if (n == 7)
	{
		printf("Yes\n");
		return 0;
	}

	while (i <= n)
	{
		i += 4;
		while (i + j <= n)
		{
			if (i + j == n)
			{
				printf("Yes\n");
				return 0;
			}
			j += 7;
		}
		j = 0;
	}
	printf("No\n");
	return 0;
}


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

constexpr ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<vector<ll>> dp(n + 1, vector<ll>(4));
    rep(i, 4) dp[0][i] = 0, dp[1][i] = 1;
    for (int i = 1; i < n; ++i)
    {
        ll t = 0;
        rep(j, 4) t += dp[i][j];
        dp[i + 1][0] = t % mod;
        dp[i + 1][1] = (t - dp[i - 1][0] + dp[max(i - 2, 0)][1] + 10 * mod) % mod;
        dp[i + 1][2] = (t - dp[i - 1][0] - dp[i - 1][1] - 3 * dp[max(i - 2, 0)][0] + 10 * mod) % mod;
        dp[i + 1][3] = t % mod;
    }
    ll ans = 0;
    rep(i, 4) ans += dp[n][i];
    cout << ans % mod << endl;
}

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

int main(){
    char **matrix = new char*[3];
    for(int i = 0; i < 3; i++){
        matrix[i] = new char[3];
    }
    scanf("%s", matrix[0]);
    scanf("%s", matrix[1]);
    scanf("%s", matrix[2]);

    cout << matrix[0][0] << matrix[1][1] << matrix[2][2] << endl;

    for(int i = 0; i < 3; i++){
        delete[] matrix[i];
    }
    delete[] matrix;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n; cin >> n;
  set<string> s;
  rep(i, n){
    string t; cin >> t;
    s.insert(t);
  }
  cout << s.size() << endl;
  system("pause");
}


Measured memory_bytes: 19212
s=input()
if len(s)==2:
  if s[0]==s[1]:
    print("1 2")
  else:
    print("-1 -1")
else:
  for i in range(len(s)-2):
    if s[i]==s[i+1] or s[i]==s[i+2] or s[i+1]==s[i+2]:
      print(i+1, i+3)
      exit()
  print("-1 -1")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {


	int x;
	cin>>x;
	    if(x>=400&&x<=599)
        cout<<"8";
        else if(x>=600&&x<=799)
        cout<<"7";
        else if(x>=800&&x<=999)
        cout<<"6";
        else if(x>=1000&&x<=1199)
        cout<<5;
        else if(x>=1200&&x<=1399)
        cout<<4;
        else if(x>=1400&&x<=1599)
        cout<<3;
        else if(x>=1600&&x<=1799)
        cout<<2;
        else
            cout<<1;


	return 0;
}


Measured memory_bytes: 3592
<?php
$N = int();
$A = ints();

for($i = 0; $i < $N; $i++){
  $dp[$i] = array_fill(0, $N-$i, 0);
}


for($i = $N-1; $i >= 0; $i--){//左から削る
  for($j = $N-$i-1; $j >= 0; $j--){//右から削る
    $isFirst = (($i+$j)&1) == 0;
    if($j == $N-$i-1){
      $dp[$i][$j] = $isFirst ? $A[$i] : -$A[$i];
    }else{
      if($isFirst){
        $dp[$i][$j] = max(
          $dp[$i][$j+1]+$A[$N-$j-1],
          $dp[$i+1][$j]+$A[$i]
        );
      }else{
        $dp[$i][$j] = min(
          $dp[$i][$j+1]-$A[$N-$j-1],
          $dp[$i+1][$j]-$A[$i]
        );
      }
    }
  }
}

echo $dp[0][0];

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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

inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define getchar gc
inline int read(){
	int x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for(;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}

inline void write(int x){
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);putchar(x%10+'0');
}

inline void writeln(int x){
	write(x);puts("");
}

int a,n,d,x;

int main(){
	n=read();
	d=read();x=read();
	for(int i=1;i<=n;i++){
		a=read();
		x+=(d-1)/a+1;
	}
	writeln(x);
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i];}cout << endl;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n){
        ans += a[i]-1;
    }
    cout << ans;
}

Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var s[3] string
  for i:=0; i<3; i++ {
    fmt.Scan(&s[i])
  }
  k:=0
  c:=[3]int{0,0,0}
  for i:=0; i<300; i++ {
    if c[k]>=len(s[k]) {
      fmt.Println(string(k+'A'))
      break
    }
    t:=s[k][c[k]]-'a'
    c[k]++
    k=int(t)
  }
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)


func main() {
	var a,b,c,d int
	fmt.Scan(&a,&b,&c,&d)


	max := max(a * c ,a * d ,b * c ,b * d)
	fmt.Println(max)
	return
}


func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		if res < nums[i] {
			res = nums[i]
		}
	}
	return res
}


// func max(a, b int) int {
// 	if a > b {
// 		return a
// 	}
// 	return b
// }


Measured memory_bytes: 1772
package main

import "fmt"

func maxs(x ...int) int {
	mv := x[0]
	for _, v := range x[1:] {
		if v > mv {
			mv = v
		}
	}
	return mv
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	m := maxs(a, b, c)
	if m%2 == 0 {
		fmt.Println(0)
	} else {
		if a == m {
			fmt.Println(b * c)
		} else if b == m {
			fmt.Println(a * c)
		} else {
			fmt.Println(a * b)
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  for(int i=0; ; i++){
    if(i%2==0){
      C -= B;
      if(C <= 0){
        cout << "Yes" << endl;
        return 0;
      }
    }else{
      A -= D;
      if(A <= 0){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  return 0;
}


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

int main(int argc, char const *argv[])
{
	int d, t, s;
	cin >> d >> t >> s;
	if (t*s >= d) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3668
#lines = <<'EOS'
#0 0 1 1
#EOS

lines = $stdin.read

array = lines.split("\n")

str = array[0]
x1  = str.split(" ")[0].to_f
y1  = str.split(" ")[1].to_f
x2  = str.split(" ")[2].to_f
y2  = str.split(" ")[3].to_f

diff = ((x1-x2)**2).abs + ((y1-y2)**2).abs
d    = Math.sqrt(diff)
puts "#{d}"

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

int main(){
  int N=10,K;
  cin >> N >> K;
  int p[N], r=0;
  for(int i=0;i<N;i++)
    cin >> p[i];
  sort(p,p+N);
  for(int i=0;i<K;i++) r+=p[i];
  cout << r << endl;
}

Measured memory_bytes: 3608
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
c = 0
for i in range(N):
    s = 0
    A = list(map(int, input().split()))
    for j in range(M):
        s += A[j] * B[j]
    s += C
    if s > 0:
        c += 1
print(c)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    string S;
    cin >> S;

    ll w = 0;
    ll score = 0;

    REP(i,S.size()) {
        if (S[i] == 'W') {
            score += i-w;
            w++;
        }
    }
    cout << score << endl;
    return 0;
}


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

using ll = long long;
using llu = long long unsigned;

int main(void) {
    int n;
    scanf("%d", &n);
    int unit=n%10;
    if (unit == 2 ||
    unit == 4 ||
    unit == 5 ||
    unit == 7 ||
    unit == 9)
        printf("hon\n");
    else if (unit == 0 ||
    unit == 1 ||
    unit == 6 ||
    unit == 8)
        printf("pon\n");
    else
        printf("bon\n");

    // scanf("%llu", );
    // scanf("%ll", );
    // printf("%d");
    // printf("%lli");
    // printf("%llu");

    return 0;
}


Measured memory_bytes: 1648
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char[] array = s.toCharArray();
		
		for(int i=0;i<array.length;i++){
			if(array[2]==array[3]&&array[4]==array[5]){
				System.out.print("Yes");
				break;
			}
			else {
				System.out.print("No");
				break;
			}
		}
	}
}

Measured memory_bytes: 35748
N, M = map(int, input().split())

grid = []

for i in range(M):
    array = list(map(str, input().strip().split()))
    grid.append(array)

ac_list = [0] * N
wa_list = [0] * N

for a in grid:
    if a[1] == 'AC':
        ac_list[int(a[0]) - 1] = 1
    elif a[1] == 'WA' and ac_list[int(a[0]) - 1] == 0:
        wa_list[int(a[0]) - 1] += 1

for b in range(len(wa_list)):
    if ac_list[b] == 0:
        wa_list[b] = 0

print(str(sum(ac_list)) + ' ' + str(sum(wa_list)))

Measured memory_bytes: 33704
#include <stdio.h>

int main(){

int n;
scanf("%d\n", &n);

int a[n];
int tmp,i;
char dummy;

for (i =0 ; i < n; i++){

scanf("%d%c", &tmp, &dummy);
a[n - 1 - i] = tmp;

}

for (i = 0; i < n; i++){
printf("%d", a[i]);
if (i == n - 1) printf("\n");
else printf(" ");
}

}


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

#define INF 1 << 30

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)

using namespace std;

int main()
{
  int n, W; cin >> n >> W;
  vector<int> v(n);
  vector<int> w(n);
  REP(i,n) cin >> v[i] >> w[i];
  // vector<int> dp(10001,0);
  // REP(i,n) DOWN(j, W, w[i])
  //   dp[j] = max(dp[j],dp[j-w[i]] + v[i]);
  // cout << *max_element(dp.begin(),dp.begin()+W+1) << endl;
  vector<int> dp(100001,INF);
  dp[0] = 0;
  REP(i,n) DOWN(j,100000,v[i])
    dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
  DOWN(i,100000,0) if(dp[i] <= W)
  {
    cout << i << endl;
    break;
  }
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD = 1e9 + 7;
ll INF = 1e18;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main(){
    int n; cin>>n;
    string s; cin>>s;

    int sum1=0, sum2=0;
    for(int i=0; i<n; i++){
        if(s[i] == '(') sum1++;
        else{
            if(sum1 > 0) sum1--;
            else sum2++;
        }
    }

    cout << string(sum2, '(') << s << string(sum1, ')') << endl;
}

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

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> sc(M);

    if(M==0){
        if(N==1){
            cout << 0 << endl;
        }else{
            cout << pow(10,N-1) << endl;
        }
        return 0;
    }

    for(int i=0;i<M;i++){
        cin >> sc[i].first >> sc[i].second;

        if(sc[i].first==1 && sc[i].second==0 && N!=1){
            cout << -1 << endl;
            return 0;
        }
    }

    if(N==1){
        for(int i=pow(10,N-1)-1;i<pow(10,N);i++){
            string S = to_string(i);
            for(int j=0;j<M;j++){
                if(S[sc[j].first-1]-'0'!=sc[j].second){
                    break;
                }

                if(j==M-1){
                    cout << i << endl;
                    return 0;
                }
            }
        }
    }else{
        for(int i=pow(10,N-1);i<pow(10,N);i++){
            string S = to_string(i);
            for(int j=0;j<M;j++){
                if(S[sc[j].first-1]-'0'!=sc[j].second){
                    break;
                }

                if(j==M-1){
                    cout << i << endl;
                    return 0;
                }
            }
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 256
from itertools import permutations


def warshall_floyd(v_count: int, matrix: list) -> list:
    """ ワーシャルフロイド
    v_count: 頂点数
    matrix: 隣接行列(到達不能はfloat("inf"))
    """
    for i in range(v_count):
        for j, c2 in enumerate(row[i] for row in matrix):
            for k, (c1, c3) in enumerate(zip(matrix[j], matrix[i])):
                if c1 > c2+c3:
                    matrix[j][k] = c2+c3
    return matrix


INF = 10 ** 9
N, M, R = map(int, input().split())
m = [[INF for i in range(N)] for j in range(N)]
for i in range(N):
    m[i][i] = 0
r = list(map(lambda x: int(x) - 1, input().split()))
for i in range(M):
    a, b, c = map(int, input().split())
    m[a - 1][b - 1] = c
    m[b - 1][a - 1] = c
m = warshall_floyd(N, m)
ans = INF
for path in permutations(r, R):
    tmp = 0
    for i in range(len(path) - 1):
        tmp += m[path[i + 1]][path[i]]
    ans = min(ans, tmp)
print(ans)


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int dp[22][22],a,b,c;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> a >> b >> c;
  cout << c - min(c, a - b) << endl;
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

s = x / a
if 2 * s < a * b:
    h = 2 * s / b
    print(90 - math.degrees(math.atan(h / b)))
else:
    w = 2 * s / a - b
    print(math.degrees(math.atan((b - w) / a)))

Measured memory_bytes: 3060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

  ll N, X, Y;
  cin >> N >> X >> Y;
  vector<vector<ll>> G(N);

  for (ll i = 0; i < N - 1; i++) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[X - 1].push_back(Y - 1);
  G[Y - 1].push_back(X - 1);

  vector<ll> ans(N - 1, 0);
  vector<vector<bool>> visited(N, vector<bool>(N, false));

  for (ll i = 0; i < N; i++) {
    vector<ll> D(N, -1);

    queue<ll> q;
    q.push(i);
    D[i] = 0;

    while (!q.empty()) {
      ll v = q.front();
      q.pop();

      for (auto nv : G[v]) {
        if (D[nv] != -1) {
          continue;
        }

        D[nv] = D[v] + 1;
        if (i < nv) {
          if (visited[i][nv] == false) {
            ans[D[nv] - 1]++;
            visited[i][nv] = true;
          }
        } else {
          if (visited[nv][i] == false) {
            ans[D[nv] - 1]++;
            visited[nv][i] = true;
          }
        }

        q.push(nv);
      }
    }

    // for (auto d : D) {
    //   cout << d << endl;
    // }
  }

  for (auto d : ans) {
    cout << d << endl;
  }

  return 0;
}


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

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll st = 100,x;cin>>x;
	for(int i = 0;; ++i){
		st += st/100;
		if(st >= x){
			cout<<i+1<<endl;
			return 0;
		}
	}

	return 0;
}




Measured memory_bytes: 3616
#include<stdio.h>
int main(void)
{
	int i,a[4],sum;
	sum=0;
	for(i=0;i<4;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	printf("%d\n",sum/60);
	printf("%d\n",sum%60);
	return 0;
}
	


Measured memory_bytes: 2756
#include <vector>
#include <iostream>

using namespace std;

static const int N = 51;
int n, a[N];
vector <pair <int, int> > ans;

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++ i) cin >> a[i];
  int mx = -1, p = -1;
  for (int i = 1; i <= n; ++ i)
    if (abs(a[i]) > mx) mx = abs(a[p = i]);
  for (int i = 1; i <= n; ++ i) ans.push_back(make_pair(p, i));
  if (a[p] > 0) {
    for (int i = 2; i <= n; ++ i) ans.push_back(make_pair(i - 1, i));
  } else {
    for (int i = n; i > 1; -- i) ans.push_back(make_pair(i, i - 1));
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++ i) cout << ans[i].first << ' ' << ans[i].second << endl;
  return 0;
}


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

struct Edge {
    long long from;
    long long to;
    long long cost;
};
using Edges = vector<Edge>;
using Graph = vector<vector<int>>;
vector<int> seen;
vector<int> path;
vector<ll> disb;
vector<int> negative;
const long long INF = 1LL << 60;

/* bellman_ford(Es,s,t,dis)
    入力: 全ての辺Es, 頂点数V, 開始点 s, 最短経路を記録するdis
    出力: 負の閉路が存在するなら ture
    計算量：O(|E||V|)
    副作用：dis が書き換えられる
*/
bool bellman_ford(const Edges &Es, int V, int s, vector<long long> &dis) {
    dis.resize(V, INF);
    for(int i=0;i<V;i++){
        dis[i]=INF;
    }
    dis[s] = 0;
    int cnt = 0;
    while (cnt < V-1) {
        for (auto e : Es) {
            if (dis[e.from] != INF && dis[e.from] + e.cost < dis[e.to]) {
                dis[e.to] = dis[e.from] + e.cost;
            }
        }
        cnt++;
    }
    cnt = 0;
    while (cnt < V) {
        for (auto e : Es) {
            if (dis[e.from] != INF && dis[e.from] + e.cost < dis[e.to]) {
                dis[e.to] = dis[e.from] + e.cost;
                negative[e.to]=1;
            }
            if(negative[e.from]==1){
                negative[e.to]=1;
            }
        }
        cnt++;
    }
    return (cnt == V);
}

void dfs(const Graph &G, int s){
    seen[s]=1;
    for(int v:G[s]){
        if(seen[v]==0){
            dfs(G,v);
        }
    }
}

int main(){
    int n,m;
    ll p;
    cin>>n>>m>>p;
    Edges Es(m);
    Graph G1(n);
    Graph G2(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        c-=p;
        c*=-1;
        Es.push_back({a,b,c});
        G1[a].push_back(b);
        G2[b].push_back(a);
    }
    disb.resize(n,0);
    negative.resize(n,0);
    path.resize(n,0);
    seen.resize(n,0);
    dfs(G1,0);
    for(int i=0;i<n;i++){
        path[i]+=seen[i];
    }
    fill(seen.begin(),seen.end(),0);
    dfs(G2,n-1);
    for(int i=0;i<n;i++){
        path[i]+=seen[i];
    }
    vector<ll> dis;
    bellman_ford(Es,n,0,dis);
    ll zero=0;
    if(negative[n-1]!=0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<min(zero,dis[n-1])*-1<<endl;
}

Measured memory_bytes: 4160