akhauriyash/Code-Regression huggingface dataset:
from collections import deque

class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n+1)]
    self.rank = [0] * (n+1)
  
  def find(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]

  def same_check(self, x, y):
    return self.find(x) == self.find(y)
 
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if self.rank[x] < self.rank[y]:
      self.par[x] = y
    else:
      self.par[y] = x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1


N,M = map(int,input().split())
P = [val-1 for val in map(int,input().split())]
ans = 0
uf = UnionFind(N)

for _ in range(M):
  x,y = map(int,input().split())
  if uf.same_check(x-1,y-1) is False:
    uf.union(x-1,y-1)

for i in range(N):
  if uf.same_check(i,P[i]):
    ans += 1
print(ans)

Measured memory_bytes: 107756
#include<cstdio>
int main() {
	int n;
	scanf("%d",&n);
	if (!(n&1)) printf("%.10lf",1.0/2);
	else {
		int m=n>>1;
		printf("%.10lf",1.0*(m+1)/n);
	}
	return 0;
} 

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

n = int(input())

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

used = [0]*n
tank = [0]
used[0] = 1
ca = 0
cb = 0
while tank:
    p = tank.pop()
    if used[p] > 0:
        ca += 1
    for e in edge[p]:
        if used[e] == 0:
            used[e] = -used[p]
            tank.append(e)
cb = n-ca
res = [0]*n
flag = [True]*(n+2)

if ca <= n//3:
    tmp = 0
    for i in range(n):
        if used[i] == 1:
            tmp += 3
            res[i] = tmp
            flag[tmp] = False
    tmp = 1
    for i in range(n):
        if used[i] != 1:
            res[i] = tmp
            flag[tmp] = False
            while not flag[tmp]:
                tmp += 1
    print(*res)
elif cb <= n//3:
    tmp = 0
    for i in range(n):
        if used[i] == -1:
            tmp += 3
            res[i] = tmp
            flag[tmp] = False
    tmp = 1
    for i in range(n):
        if used[i] != -1:
            res[i] = tmp
            flag[tmp] = False
            while not flag[tmp]:
                tmp += 1
    print(*res)
else:
    tmp = -2
    for i in range(n):
        if used[i] == -1:
            tmp += 3
            if tmp > n:
                tmp = 3
            res[i] = tmp
            flag[tmp] = False
    tmp = 2
    for i in range(n):
        if used[i] != -1:
            res[i] = tmp
            flag[tmp] = False
            while not flag[tmp]:
                tmp += 1
                if tmp > n:
                    tmp = 3
                    break
    print(*res)    


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

int main() {
    int n;
    cin>>n;
    long ans=0;
    rep(i,n){
        long y=n/i;
      	ans=ans+y*(y+1)*i/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
def main():
    S = list(input())
    lenS = len(S)
    pt1 = ['0', '1'] * (lenS//2) + ['0']*(lenS%2==1)
    pt2 = ['1', '0'] * (lenS//2) + ['1']*(lenS%2==1)
    cnt1 = 0; cnt2 = 0
    for i in range(lenS):
        cnt1 += (pt1[i]!=S[i])
        cnt2 += (pt2[i]!=S[i])
    print(min(cnt1, cnt2))

if __name__ == "__main__":
    main()


Measured memory_bytes: 6172
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>

using namespace std;

int main() {

    string input_str;
    cin >> input_str;

    int min_753 = 1000 ;
    for(unsigned int i = 0; i < input_str.size() - 2; i++ ) {
        int tmp = (input_str[i] - '0') * 100 + (input_str[i+1] - '0') * 10 + (input_str[i+2] - '0');

        min_753 = min(min_753, abs(tmp - 753));
    }

    cout << min_753 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();
        String result = (N / 2 + N % 2 >= K) ? "YES" : "NO";
        System.out.print(result);
    }
}

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll a,b,c;
    cin >> a >> b >> c;

    if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0){
        cout << 0 << endl;
        return 0;  
    }
    if(a == b && b == c){
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    while(1){
        if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0)break;
        ll a2 = a,b2 = b,c2 = c;
        a = (b2 + c2) / 2;
        b = (a2 + c2) / 2;
        c = (a2 + b2) / 2;
        ans++;
    }

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx") 
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

struct node {
	int a[26];  //=   // b
	
	node(){
		memset(a,0,sizeof(a));
	}
	
	bool operator < (const node & b)const {
		for(int i=0;i<=25;++i)if(a[i]!=b.a[i])return a[i]<b.a[i];
		return 0;
	}
};

map<node,int>mp;
int n;
char s[99];
long long ans;
int main()
{
	n=read();
	for(int i=1;i<=n;++i){
		scanf("%s",s+1);
		node a;//0??   //wu node()
//		cerr<<a.a[15]<<endl; //yangli
		
		for(int ii=1;ii<=10;++ii){
			++a.a[s[ii]-97];
		}
		ans+=mp[a];
		++mp[a];
	} 
	cout<<ans;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll n, k;
    cin >> n >> k;
    vector<double> logs(n, 0);
    for(auto& val: logs)
        cin >> val;
    double l = 1.0;
    double r = *max_element(logs.begin(), logs.end());
    auto bs = [&] (double chunk_size) {
        ll acc = 0;
        for(auto& val: logs) {
            acc += (ll(ceil(val / chunk_size))-1);
        }
        // cout << "size = " << chunk_size << ", cut " << acc << endl;
        return acc;
    };
    while (r - l > 1e-6) {
        double mid = (l + r) / 2;
        auto use = bs(mid);
        if (use <= k)
            r = mid;
        else
            l = mid;
    }
    cout << ll(ceil(l)) << endl;
    return 0;
}


Measured memory_bytes: 4740
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
const ll INF = 1e10;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
struct edge{
  ll to;
  double cost;
};
double calc_dist(ll x1,ll y1,ll x2,ll y2){
  return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
using vve = vector<vector<edge>>;
bool operator>(edge left,edge right){
  return left.cost > right.cost;
}
using vve = vector<vector<edge>>;
vl dijkstra(vve &gr,int st,int g){
  int n = gr.size();
  vl dist(n,INF);
  vl last(n);
  last[st] = -1;
  priority_queue<pii,vector<pii>,greater<pii>> q;
  dist[st] = 0;
  q.push(make_pair(dist[st]=0,st));
  while(!q.empty()){
    int now = q.top().second;
    q.pop();
    REP(i,gr[now].size()){
      edge &e = gr[now][i];
      if(dist[now]+e.cost<dist[e.to]){
        dist[e.to] = dist[now]+e.cost;
        last[e.to] = now;
        q.push({dist[e.to],e.to});
      }
    }
  }
  if(dist[g]<INF) return last;
  return vl(n,-2);
}
signed main(){
  int n;
  while(cin >> n,n){
    vl s(n),x(n),y(n);
    REP(i,n){
      cin >> s[i] >> x[i] >> y[i];
      --s[i];
    }
    vector<vector<edge>> gr(n);
    REP(i,n) REP(j,n){
      double r;
      if((r = calc_dist(x[i],y[i],x[j],y[j]))>50) continue;
      gr[s[i]].emplace_back(edge{s[j],r});
    }
    int m;
    cin >> m;
    REP(i,m){
      int t,g;
      cin >> t >> g;
      --t; --g;
      auto last = dijkstra(gr,t,g);
      if(last[g]==-2){
        cout << "NA" << endl;
        continue;
      }
      int id = g;
      vl ans;
      ans.eb(id);
      while(last[id]!=-1){
        ans.eb(id=last[id]);
      }
      reverse(ALL(ans));
      REP(i,ans.size()){
        if(i==(ll)ans.size()-1){
          cout << ans[i]+1 << endl;
          break;
        }
        cout << ans[i]+1 << " ";
      }
    }
  }
}


Measured memory_bytes: 3088
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut map = HashMap::new();
    for i in 0..s.len() {
        *map.entry(s[i]).or_insert(0) += 1;
    }
    for &key in map.keys() {
        if map[&key] != 2 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main(){
	int N;
	while( cin >> N && N ){
		vector< set<int> > member(N);
		for( int i = 0; i < N; i++ ){
			int M;
			cin >> M;
			for( int j = 0; j < M; j++ ){
				int m;
				cin >> m;
				member[i].insert( m );
			}
		}
		int K;
		cin >> K;
		set<int> list;
		for( int i = 0; i < K; i++ ){
			int l;
			cin >> l;
			list.insert( l );
		}
		int ans = -1;
		int f = 0;
		for( int i = 0; i < N; i++ ){
			set<int>::iterator it = member[i].begin();
			set<int>::iterator it2 = list.begin();
			for( ; it != member[i].end(); it++ ){
				if( *it2 == *it ){
					it2++;
				}
				if( *it2 < *it ){
					break;
				}
			}
			if( it2 == list.end() ){
				if( f == 0 ){
					f = 1;
					ans = i + 1;
				}else{
					ans = -1;
				}
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

#define mod 1000000007

int main() {
    int n,m;
    cin>>n>>m;
   	long long int f[100011];
   	f[1]=1;
   	f[0]=1;
   	for(int i=2;i<=100001;i++)
   	{
   		f[i] = (i*f[i-1])%mod;
   	}
    if(n>=m+2 || m >= n+2)
    {
    	cout<<"0\n";
    }
    else if(n==m)
    {
    	cout<<((f[n]*f[m])%mod*2)%mod<<"\n";
    }
    else
    {
    	cout<<(f[n]*f[m])%mod<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

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

int main() { 
        string s;
        cin >> s;
        int a = 0, b = 0, c = 0, d = 0;
        rep(i, s.size()) {
                if (s[i] == 'S') {
                        a = 1;
                } else if (s[i] == 'E') {
                        b = 1;
                } else if (s[i] == 'N') {
                        c = 1;
                } else {
                        d = 1;
                }
        }
        if (a * b * c * d || a * !b * c * !d || !a * b * !c * d) {
                D("Yes");
        } else {
                D("No");
        }
        return 0;
}



Measured memory_bytes: 256
n = int(input())
w = [input() for i in range(n)]
for i in range(n):
    flag = True
    for j in range(i):
        if w[i] == w[j]:
            flag = False
    if not flag:
        break
    elif i >= 1 and w[i-1][-1] != w[i][0]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 63672
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b = na()

print(max(a+b,a-b,a*b))

Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int X=in(),Y=in();

	cout << (X+Y/2) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn, mm;
	cin >> nn >> mm;
	vector<pair<int64, int64>> memo(mm), aa(mm);
	for(int64 ii = 0;ii < mm;ii++)
	{
		cin >> aa[ii].first >> aa[ii].second;
		memo[ii] = aa[ii];
	}
	sort(memo.begin(), memo.end());
	for(int64 ii = 0;ii < mm;ii++)
	{
		pair<int64, int64> tmp1 = make_pair(aa[ii].first, 0);
		auto tmp2 = lower_bound(memo.begin(), memo.end(), tmp1);
		tmp1.second = aa[ii].second;
		auto tmp3 = lower_bound(memo.begin(), memo.end(), tmp1);
		for(int64 jj = 0;jj < 5 - (int64)log10(aa[ii].first);jj++)
		{
			cout << '0';
		}
		cout << aa[ii].first;
		for(int64 jj = 0;jj < 5 - (int64)log10(distance(tmp2, tmp3) + 1);jj++)
		{
			cout << '0';
		}
		cout << (distance(tmp2, tmp3) + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 6424
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = c - a - b;
        if (d > 0 && d * d > 4 * a * b) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21844
n=int(input())
a=list(map(int,input().split()))
flag=0
ans=0
if 0 in a:
    flag=1
if flag==0:
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>1000000000000000000:
            flag=-1
            break
if flag==-1:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 84556
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

constexpr int N = 'z' - 'a' + 1;
constexpr int INF = 1e9;

int main() {
    int n; cin >> n;
    vstring S(n);
    rep(i, n) cin >> S[i];
    vint cnt(N, INF);
    rep(i, n) {
        vint cnt2(N, 0);
        for(char c: S[i]) cnt2[c - 'a']++;
        rep(i, N) chmin(cnt[i], cnt2[i]);
    }
    rep(i, N) rep(j, cnt[i]) cout << (char)('a' + i);
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int bubblesort(int *,int);

int main(){
  int i,j,tmp,n,count,sep;
  int in[N];

  /* input */
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&in[i]);
  }

  /* sort */
  count = bubblesort(in,n);
  
  /* output */
  for(i=0;i<n-1;i++){
    printf("%d ",in[i]);
  }
  printf("%d\n",in[i]);
  printf("%d\n",count);

  return 0;
}

int bubblesort(int *in,int n){
  int i,j,flag,tmp,count;
  flag = 1;
  count = 0;
  while(flag){
    flag = 0;
    for(j=n-1;j>0;j--){
      if(in[j-1] > in[j]){
	tmp = in[j-1];
	in[j-1] = in[j];
	in[j] = tmp;
	flag = 1;
	count++;
      }
    }
  }

  return count;
}

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
  ll dx = x2-x1; ll dy = y1-y2;
  
  cout << dy+x2 << ' ' << dx+y2 << ' ' <<
    dy+x1 << ' ' << dx+y1 << endl;
  
  
}

Measured memory_bytes: 3552
#include <stdio.h>

int main(int argc, char** argv)
{
	char s[101], p[100];
	int i, j, k;

	scanf("%s", s);
	scanf("%s", p);

	int isMatch = 0;
	i = j = k = 0;

	for (i = 0; s[i] != '\0'; i++) {
		if (s[i] == p[0]) {
			isMatch = 1;
			j = 1;
			k = i + j;

			while (p[j] != '\0') {
				if (s[k] == '\0' && p[j] != '\0') {
					k = 0;
				}

				if (s[k] == p[j]) {
					j++;
					k++;
				}
				else {
					isMatch = 0;
					break;
				}
			}

			if (isMatch) {
				break;
			}
		}
	}

	printf("%s\n", isMatch ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 524
# coding: utf-8
MOD = 1000000007
num = int(input())
says = list(map(int, input().split()))

ans = 0
colors = 0
sets = [0, 0, 0]
for i in range(num):
    if max(sets) < says[i]:
        ans = 0
        break
    if colors == 0:
        sets[0] += 1
        colors += 1
        ans = 3
    elif colors == 1:
        if says[i] == 0:
            sets[1] += 1
            colors += 1
            ans *= 2
        else:
            sets[0] += 1
    elif colors == 2:
        if says[i] == 0:
            sets[2] += 1
            colors += 1
        else:
            if sets[0] == says[i]:
                sets[0] += 1
                if sets[1] == says[i]:
                    ans *= 2
            elif sets[1] == says[i]:
                sets[1] += 1
            else:
                ans = 0
                break
    elif colors == 3:
        if sets[0] == says[i]:
            sets[0] += 1
            if sets[1] == says[i] and sets[2] == says[i]:
                ans *= 3
            elif sets[1] == says[i] or sets[2] == says[i]:
                ans *= 2
        elif sets[1] == says[i]:
            sets[1] += 1
            if sets[2] == says[i]:
                ans *= 2
        elif sets[2] == says[i]:
            sets[2] += 1
        else:
            ans = 0
            break
#print(sets)
print(ans % MOD)


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

int main(){
    map<string, ll> mp;
    ll q, c, x;
    string s;
    cin >> q;
    rep(i, q){
        cin >> c >> s;
        auto t = mp.find(s);
        switch(c){
            case 0:
                cin >> x;
                if(t == mp.end()){
                    mp.insert(make_pair(s, x));
                }else{
                    t->second = x;
                }
                break;
            case 1:
                cout << (t == mp.end() ? 0 : t->second) << endl;
                break;
            case 2:
                if(t != mp.end()){
                    mp.erase(t);
                }
        }
    }
    return 0;
}


Measured memory_bytes: 27664
import java.util.Scanner;

class Queue{
  Process[] a = new Process[100000];
  int head;
  int tail;

  Queue(){
    head = 0;
    tail = 0;
  }

  void enqueue(Process p){
    if(tail+1 == a.length)
      tail = 0;
    else
      tail++;

    a[tail] = p;
  }

  Process dequeue(){
    if(head+1 == a.length)
      head = 0;
    else
      head++;
    return a[head];
  }

  boolean isFull(){
    if(head == (tail+1) % a.length)
      return true;
    else
      return false;
  }

  boolean isEmpty(){
    if(head == tail)
      return true;
    else
      return false;
  }

}

class Process{
  String name;
  int time;
  Process(String name, int time){
    this.name = name;
    this.time = time;
  }
  Process(Process p){
    this.name = p.name;
    this.time = p.time;
  }
}

public class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int q = stdIn.nextInt();
    Queue queue = new Queue();

    for(int i = 0; i < n; i++){
      String name = stdIn.next();
      int time = stdIn.nextInt();
      queue.enqueue(new Process(name, time));
    }

    int time_sum = 0;
    while(!queue.isEmpty()){
      Process p = queue.dequeue();
      p.time -= q;
      if(p.time <= 0){
        time_sum += (q + p.time);
        System.out.println(p.name + " " + (time_sum));
      }
      else{
        queue.enqueue(p);
        time_sum += q;
      }
    }

  }
}

Measured memory_bytes: 76488
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	double x;
	cin>>x;
	printf("%.100lf",pow(x/3,3));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}
vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

signed main() {
    cin >> N;
    auto v = prime_factorize(N);
    dump(v);
    REP(i, v.size()) {
        ll y = sqrt(2 * v[i].second);
        ll tmp = 0;
        for (int j = y - 1; j < y + 1; j++) {
            if ((j * (j + 1)) / 2 <= v[i].second) {
                tmp = j;
            }
        }
        dump(y, tmp);
        ans += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3724
h,w,k = map(int, input().split())
import sys
c = [[str(a) for a in l.strip()] for l in sys.stdin]

ans = 0

b = 2 ** (h + w)
for i in range(b):
  for j in range(h):
    for q in range(w):
      if ((i >> j) & 1) and (i >> (q+h)) & 1:
        if c[j][q] == "#":
          sum += 1
  if sum == k:
    ans += 1
  sum = 0
    
print(ans)

Measured memory_bytes: 74112
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
    int N;
    cin >> N;
    if(N%2 == 0){
        cout << 0.5 << endl;
    }
    else{
        cout << (N+1)/(2.0*N) << endl;
    }
} 



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int N,p;
string s;
vector<pair<pair<string,int>,int>> P;
int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s >> p;
        P.push_back({{s,-p},i+1});
    }
    sort(P.begin(),P.end());
    for(int i = 0; i < N; i++){
        cout << P[i].second << endl;;
    }
}



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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int count = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');

            int[] arr = new int[count];

            for (int i = 0; i < count; i++)
            {
                arr[i] = int.Parse(input[i]);
            }


            int res = 0;
            var modNum = 2;
            var flag = true;

            while (true)
            {

                for(int i = 0; i < count; i++)
                {
                    if(arr[i] % modNum != 0)
                    {
                        flag = false;
                        break;
                    }
                }

                if (!flag)
                    break;

                res++;
                modNum *= 2;

            }

            //出力
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  string s;
  cin >> s;
  int c = s.find_first_of("C");
  int f = s.find_last_of("F");
  if (c!=string::npos && f!=string::npos && c<f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, x, t = map(int, input().split())
    print(((n - 1) // x + 1) * t)
resolve()

Measured memory_bytes: 61836
#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,m;
const int Maxn=1005;
string grid[Maxn];
bool vis[Maxn][Maxn];
pii C,D;

int belong[Maxn][Maxn];
int cpnCount;

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

void dfs(int x,int y){
	vis[x][y]=true;
	belong[x][y]=cpnCount;
	
	for(int d=0;d<4;d++){
		int nx=x+dx[d];
		int ny=y+dy[d];
		if(nx>=0&&nx<n&&ny>=0&&ny<m&&grid[nx][ny]!='#'&&!vis[nx][ny]){
			dfs(nx,ny);
		}
	}
}

vector<int>G[Maxn*Maxn];
int dist[Maxn*Maxn];

void bfs(){
	memset(dist,INF,sizeof(dist));
	int s=belong[C.first][C.second];
	int e=belong[D.first][D.second];
	queue<int>q;
	q.push(s);
	dist[s]=0;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		if(u==e){
			cout<<dist[u]<<endl;
			exit(0);
		}
		rep(i,SZ(G[u])){
			int to=G[u][i];
			if(dist[to]>dist[u]+1){
				dist[to]=dist[u]+1;
				q.push(to);
			}
		}
	}
}



int main(){
	cin>>n>>m;
	cin>>C.first>>C.second;
	C.first--;C.second--;
	cin>>D.first>>D.second;
	D.first--;D.second--;
	
	for(int i=0;i<n;i++)cin>>grid[i];
	
	memset(belong,-1,sizeof(belong));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(grid[i][j]!='#'&&!vis[i][j]){
				dfs(i,j);
				cpnCount++;
			}
		}
	}
	
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(grid[i][j]=='.'){
				for(int ii=max(i-2,0);ii<min(i+3,n);ii++){
					for(int jj=max(j-2,0);jj<min(j+3,m);jj++){
						if(grid[ii][jj]=='.'){
							if(belong[i][j]!=belong[ii][jj]){
								G[belong[i][j]].push_back(belong[ii][jj]);
								G[belong[ii][jj]].push_back(belong[i][j]);
							}
						}
					}
				}
			}
		}
	}
	
	bfs();
	
	cout<<-1<<endl;
	
	return 0;
}

Measured memory_bytes: 59956
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

string s, t;
vector <int> pos[123];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> s >> t;
   for (int i = 0; i < sz (s); i ++) pos[s[i]].pb (i);
   for (int i = 0; i < sz (t); i ++)
      if (!sz (pos[t[i]]))
         cout << -1, exit (0);
   int last = -1, it = 0, ans = 1;
   while (it != sz (t)) {
      if (pos[t[it]].back () <= last) {
         ans ++;
         last = -1;
      }
      last = *ub (all (pos[t[it]]), last);
      it ++;
   }
   cout << (ans - 1) * sz (s) + last + 1;
}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 1736
#include<stdio.h>


int main()
{
	int p = 0;
	int a = 0;
	int b = 0;
	int y = 0;
	int n = 0;
	int s = 0;
	
	scanf("%d",&p);
	scanf("%d",&a);
	scanf("%d",&b);

	if (a < b) {
		y = a;
	}
	else {
		y = b;
	}
	
	s = a + b;
	n = s - p;
	if (n < 0) {
		n = 0;
	}
	printf("%d %d\n", y, n);
}

Measured memory_bytes: 128
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>

int main(){
  
  int N;
  std::cin>>N;
  
  std::string result="";
  
  if(N==0)
    std::cout<<"0"<<std::endl;
  else{
    while(N!=0){
      int r=N%2;
      r=abs(r);
    
      N=(N-r)/(-2);
    
      result+=std::to_string(r);
    }
  
    std::reverse(result.begin(),result.end());
  
    std::cout<<result<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# N,M,Xを取得
a, b, x = map(int, input().split())

cost_idxs = map(int, input().split())

count_low, count_high = [0, 0]

for i in cost_idxs:
    if i < x:
        count_low += 1
    elif i > x:
        count_high += 1

min_cost = min(count_low, count_high)

# 結果を出力
print("{}".format(min_cost))


Measured memory_bytes: 3060
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, k) = input_tuple();
    let tmp = n % k;
    if tmp < k - tmp {
        println!("{}", tmp);
    } else {
        println!("{}", k - tmp);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void){
    ll n, m;
    cin >> n >> m;
    string s[n], t[m];
    for(ll i = 0; i < n; i++)
        cin >> s[i];
    for(ll i = 0; i < m; i++)
        cin >> t[i];
    bool ans = false;
    if(n!=m){
        for(ll i = 0; i < n-m; i++){
            for(ll j = 0; j < n-m; j++){
                bool check = true;
                for(ll x = 0; x < m; x++){
                    for(ll y = 0; y < m; y++){
                        //cout << s[i+x][j+y] << " " << t[x][y] << endl;
                        if(s[i+x][j+y]!=t[x][y]){
                            check = false;
                            break;
                        }
                    }
                }
                if(check==true)
                    ans = true;
            }
        }
    }
    else if(n==m){
        ans = true;
        for(ll i = 0; i < n; i++){
            for(ll j = 0; j < n; j++){
                if(s[i][j]!=t[i][j]){
                    ans = false;
                    break;
                }
            }
        }
    }
    if(ans==true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli solve(){
    lli n;
    cin>>n;
    vll A(n);
    lli sum = 0;
    loop(i, 0, n){
        cin>>A[i];
        sum += A[i];
    }
    umap<lli, lli> mp;
    loop(i, 0, n)
        mp[A[i]]++;
    lli q;
    cin>>q;
    loop(i, 0, q){
        lli b, c;
        cin>>b>>c;
        if(mp.find(b) == mp.end())
            cout<<sum<<"\n";
        else{
            mp[c] += mp[b];
            sum = sum - b*mp[b] + c*mp[b];
            mp.erase(b);
            cout<<sum<<"\n";
        }
    }
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 7416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

vector<int> e[100000];

void dfs(int v,int p,int* d){
    for(auto u:e[v]){
        if(u==p)continue;
        d[u]=d[v]+1;
        dfs(u,v,d);
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        --a,--b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int d[2][100000]={};
    dfs(0,-1,d[0]);
    dfs(n-1,-1,d[1]);
    int cnt=0;
    for(int i=0;i<n;i++){
        if(d[0][i]<=d[1][i])cnt++;
    }
    if(cnt>n-cnt)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}


Measured memory_bytes: 12800
#include<stdio.h>

int main()
{
    int n,i,flag,c,j;
    scanf("%d", &n);
    flag=0;
    for(i=105;i<=n;)
    {
        c=0;
        for(j=1;j<=n;j++)
        {
          if(i%j==0)
            {
                c++;
            }

        }
        i+=2;

        if(c==8)
        {
           flag+=1;
        }
    }
    printf("%d\n", flag);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool f(unsigned long long x,unsigned long long y){
  return x>y;
}
int main(){
 unsigned long long n,k,h;
  vector<unsigned long long> vec;
  cin>>n>>k;
  for(unsigned long long i=0;i<n;i++){
    cin>>h;
    vec.push_back(h);
  }  
 sort(vec.begin(),vec.end(),f);
  
   
     if(k>n){
       for(int i=0;i<n;i++){
         vec[i]=0;       
     }
     }
  else {
    for(int i=0;i<k;i++){
      vec[i]=0;
    }
  }
  
   unsigned long long sum=0;
   for(unsigned long long i=0;i<n;i++){
     sum=sum+vec[i];
   }
   cout<<sum;
   return 0;
 }
   
   
    
    


Measured memory_bytes: 2420
r, c = map(int,input().split())
A = [[0]*c for i in range(r)]
s = [0]*c

for i in range(r):
    A[i] = list(map(int,input().split()))
    A_str = [[str(x) for x in y] for y in A]
    
    l = A_str[i]
    print(" ".join(l) + " " + str(sum(A[i])))

for i in range(r):
    for j in range(c):
        s[j] += A[i][j]

sum_str = list(map(str,s))
print(" ".join(sum_str) + " " + str(sum(s)))



Measured memory_bytes: 7128
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

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

    vector<int> N;
    int size=S.size();
    for(int i=size-1;i>=0;i--){
        N.push_back((int)S[i]-'0');
    }
    N.push_back(0);
    size++;
    vector<vector<int>> dp(size+1,vector<int>(2,0));
    dp[0][0]=0;dp[0][1]=10;
    for(int i=0;i<size;i++){
        dp[i+1][0]=min(dp[i][0]+N[i],dp[i][1]+N[i]+1);
        dp[i+1][1]=min(dp[i][1]+9-N[i],dp[i][0]+10-N[i]);
    }

/*
    for(int i=0;i<size+1;i++){
        cout<<dp[i][0]<<" ";
    }
    cout<<endl;
    for(int i=0;i<size+1;i++){
        cout<<dp[i][1]<<" ";
    }
    cout<<endl;
    //*/
    

    cout<<dp[size][0]<<endl;

    return 0;
}

Measured memory_bytes: 62888
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;
int a[2020];
const LL mod = 1e9 + 7;

int main(){
	cin >> n >> k;
	REP(i, n){
		cin >> a[i];
	}
	LL ans = 0;
	REP(i, n){
		LL cnt = 0, cnt2 = 0;
		REP(j, n){
			if(a[i] > a[j]){
				cnt++;
				if(j < i)cnt2++;
			}
		}
		LL a = cnt*k - cnt2;
		LL b = cnt - cnt2;
		LL num = 0;
		if(k % 2 == 0){
			num = ((k / 2)%mod) * ((a + b)%mod);
		}else{
			num = (k % mod) * ((a + b)/2 % mod);
		}
		(ans += num) %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        Program p = new Program();
        var N = int.Parse(Console.ReadLine());
        var input = p.ConvertIntArray(p.ReadInput());
        Dictionary<int, int> dic = new Dictionary<int, int>();
        for(var i = 0; i<N; i++)
        {
            dic.Add(input[i], i);
        }

        StringBuilder sb = new StringBuilder();
        for(var i = 1; i<=N; i++)
        {
            sb.Append(dic[i] + 1);
            if(i != N)
            {
                sb.Append(" ");
            }
        }
        Console.WriteLine(sb.ToString());
    }


    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }

}


Measured memory_bytes: 32348
// https://atcoder.jp/contests/arc092/tasks/arc092_a

#include "algorithm"
#include "iostream"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

struct BipartiteMatching {
  vector<vector<ll>> edges;
  vector<ll> match;
  vector<bool> used;

  BipartiteMatching(ll n)
      : edges(vector<vector<ll>>(n)), match(vector<ll>(n, -1)) {}

  void add(ll from, ll to) {
    edges[from].push_back(to);
    edges[to].push_back(from);
  }

  bool dfs(ll v) {
    used[v] = true;

    for (auto u : edges[v]) {
      ll w = match[u];
      if (w == -1 || !used[w] && dfs(w)) {
        match[u] = v;
        match[v] = u;
        return true;
      }
    }

    return false;
  }

  ll call() {
    ll res = 0;

    rep(v, edges.size()) {
      if (match[v] == -1) {
        used = vector<bool>(edges.size());

        if (dfs(v)) {
          res++;
        }
      }
    }

    return res;
  }
};

void solve() {
  ll N;
  cin >> N;

  VPL reds(N);
  rep(i, N) {
    ll x, y;
    cin >> x >> y;
    reds[i] = {x, y};
  }

  VPL blues(N);
  rep(i, N) {
    ll x, y;
    cin >> x >> y;
    blues[i] = {x, y};
  }

  auto bm = BipartiteMatching(2 * N);

  rep(r, N) rep(b, N) {
    if (reds[r].first < blues[b].first && reds[r].second < blues[b].second) {
      bm.add(r, b + N);
    }
  }

  ll res = bm.call();
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int now_cnt = 0;
    for (int i = 0; i < N; i += 2) {
        now_cnt++;
    }
    if (now_cnt >= K) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256