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

typedef long long ll;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back

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

const int MOD = 1000000007;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    int n, m, c; cin >> n >> m >> c;
    
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) rep(k, m) cin >> a[i][k];
    
    int result = 0;
    
    rep(i, n) {
        int sum = 0;
        rep(k, m) {
            sum += a[i][k]*b[k];
        }
        if (sum + c > 0) {
            result++;
        }

    }
    cout << result << endl;
} 


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_N = 2e5 + 5;

int arr [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int k, n;
  cin >> k >> n;

  int ans = k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  for (int i = 0; i < n - 1; i++) {
    ans = min(ans, k - (arr[i + 1] - arr[i]));
  }
  ans = min(ans, k - (k + arr[0] - arr[n - 1]));

  cout << ans << endl;
}


Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.readline

    s = input()
    s = s[0:len(s)-1]
    Q = int(input())
    head = []
    tail = []

    flg = 0 # 0:sonomama 1:gyakuten
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            if flg == 0:
                flg = 1
            else:
                flg = 0
        elif q[0]=="2":
            index,tmp = q[1],q[2]
            if (index == "1" and flg ==0) or (index == "2" and flg ==1):
                head.append(tmp)
            elif (index == "2" and flg == 0) or (index == "1" and flg == 1):
                tail.append(tmp)

    s1 = "".join(head)
    s1 = s1[::-1]
    s2 = "".join(tail)
    ans = s1 + s + s2
    if flg == 1:
        ans = ans[::-1]

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5916
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {
	int n;
	vector<int> x;
	cin >> n;
	rep(i, n) {
		int q;
		cin >> q;
		x.push_back(q);
	}
	int ans = 0, con = 0;
	for (int i = 0; i < n-1; ++i) {
		if (i == n - 1 && i == x[i] - 1) {
			
		}
		if (i == x[i] - 1 && i + 1 == x[i + 1] - 1) {
			con++;
			i++;
		}
	}

	rep(i, n) {
		if (i == x[i] - 1) ans++;
	}

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


Measured memory_bytes: 892
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if x == i * 500 + j * 100 + k * 50:
        count += 1

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
#define inf 1e12+7
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int x[n], y[n];
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }

    double sum = 0;
    double kaijo = 1;
    for(int i = 1; i <= n; i++) kaijo *= i;
    int pattern = 2 * kaijo / n;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            sum += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])) * pattern;
        }
    }
    cout << fixed << setprecision(10) << sum / kaijo << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef pair<int, int>P;

int main(){
	int m, n, x, y, i;
	P a[200], b[1000];
	scanf("%d", &m);
	if (!m)return 0;
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &x, &y);
		a[i] = P(x, y);
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &x, &y);
		b[i] = P(x, y);
	}
	sort(a, a + m);
	sort(b, b + n);
	for (int i = 1; i < m; i++)
		a[i] = P(a[i].first - a[0].first, a[i].second - a[0].second);
	for (i = 0; i < n; i++) {//??????????????????
		bool flag = true;
		for (int j = 1; j < m; j++) {
			if (!binary_search(b, b + n, P(b[i].first + a[j].first, b[i].second + a[j].second)))
				flag = false;
		}
		if (flag)break;
	}
	printf("%d %d\n", b[i].first - a[0].first, b[i].second - a[0].second);
	main();
}

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


int main(){
	int N;
	cin>>N;
	string s;
	cin>>s;
	int cnt = 0;
	for(int i=0;i<N;i++){
		if(s[i]=='R')cnt++;
	}
	if(cnt>N-cnt){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(n) for(int i=0;i<n;++i)
#define Fj(n) for(int j=0;j<n;++j)
const int MOD=1e9+7;

int main(){
    long n;
    cin >> n;
    double tax=1.08;
    for(int i=n*0.8;i<n*1.2;++i){
        if(floor(i*tax)==n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<stdio.h>
int main(void){
    int a=0,i;
    char s[4];
    scanf("%s",s);
    for(i=0;i<4;i++){
        if(s[i]== '+') a++;
        if(s[i]== '-') a--;
    }
    //printf("%",);
    printf("%d\n",a);
    return 0;
}

Measured memory_bytes: 128
n = gets.chomp.to_i

m = {}
1.upto(n) do |i|
  l = gets.chomp.split()
  k = l[0]
  item = [i, l[1].to_i]
  if m.has_key?(k)
    items = m[k]
    # items.append(item)
    items << item
  else
    m[k] = [item]
  end
end

ks = m.keys.sort
ks.each do |k|
  items = m[k].sort_by{|x| x[1]}.reverse
  items.each do |item|
    puts(item[0])
  end
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

int gcd(int a, int b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

int lcm(int a, int b) { //最小公倍数
  return a * b / gcd(a, b);
}


int main()
{
  ll n,a[100010];
  cin>>n;
  rep(i,n)cin>>a[i];
  sort(a,a+n,greater<ll>());

  ll tate=0,yoko=0,cnt=0;

  rep(i,n-1){
    if(cnt==0&&a[i]==a[i+1]){
      tate=a[i];
      cnt=1;
      i++;
    }else if(cnt==1&&a[i]==a[i+1]){
      yoko=a[i];
      cnt=2;
    }
  }

  if(tate==0||yoko==0){
    cout<<0<<endl;
  }else{
    cout<<tate*yoko<<endl;
  }

  return 0;
}


Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD = 1000000009;
const int INF = INT_MAX / 3;

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main() {
	int n, r;
	while (cin >> n >> r, n) {
		vi st(n);
		REP(i, n)
			st[i] = n-i ;

		REP(i, r) {
			vi sw(n);
			REP(i, n)
				sw[i] = st[i];
			int p, c;
			cin >> p >> c;
			REP(j, c)
				sw[j] = st[p-1  + j];
			REP(j, p-1)
				sw[j + c] = st[j];


			REP(i, n)
				st[i] = sw[i];

		}

		cout << st[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 3096
import sys
sys.setrecursionlimit(10 ** 7)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def main():
    n, m = map(int, input().split())
    s = input()
    t = input()
    g = gcd(n, m)
    n1 = n // g
    m1 = m // g

    b = True
    for i, v in enumerate(s[::n1]):
        if v != t[m1*i]:
            b = False
            break
    print(n * m1 if b else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

k = inp()
s = input()
n = len(s)
if n <= k:
    print(s)
else:
    print(s[:k] + '...')

Measured memory_bytes: 10516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  int ma=a[n-1];
  int b=0,c=ma;
  rep(i,0,n){
    if(a[i]<=ma/2){
      b=a[i];
    }
  }
  rep(i,0,n){
    if(a[n-1-i]>=(ma+1)/2){
      c=a[n-1-i];
    }
  }
  if(ma/2-b<=c-(ma+1)/2){
    cout<<ma<<' '<<b<<endl;
  }
  else{
    cout<<ma<<' '<<c<<endl;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int w,d;
    while(cin >> w >>d){
        if((w|d)==0){
            return 0;
        }
		int t,ans=0;
		vector<int> a,b;
		for(int i=0;i<w;i++){
			cin >> t;
			a.push_back(t);
		}
		for(int i=0;i<d;i++){
			cin >> t;
			b.push_back(t);
		}

		for(int i=0;i<w;i++){
			for(int j=0;j<d;j++){
				if(a[i]==b[j]){
					b[j]=0;
					break;
				}
			}
		}

		for(int i=0;i<w;i++){
			ans+=a[i];
		}
		for(int i=0;i<d;i++){
			ans+=b[i];
		}
		cout << ans << endl;
    }
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    ll A[N],B[N];
    map<ll,ll> S;
    rep(i,N) {
        int a;
        cin >> a;
        if (i==0) {
            A[i] = a;
            B[i] = a;
            S[a]++;
        }
        else {
            A[i] = a;
            B[i] = B[i-1] + a;
            S[B[i]]++;
        }
    }

    ll ans = 0;
    rep(i,N) {
        ll a = B[i];
        ll tmp = B[i]-A[i];
        ll s = S[tmp];
        ans += s;
        S[a]--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 19032
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define pb push_back
#define forf(i,a,b) for(i = a; i< b; i++)
#define forb(i,a,b) for(i = b; i>=a; i--)
using namespace std;
const int mod = 1e9+7;
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

ab = b - a
vw = v - w
if a == b:
    print('YES')
    exit()

if ab <= 0:
    ab = -ab
if vw <= 0:
    print('NO')
else:
    k = ab/vw
    if k <= t:
        print('YES')
    else:
        print('NO')







Measured memory_bytes: 9192
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    m = II()
    print(48-m)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
int K= scan.nextInt();

        int A= scan.nextInt();

        int B= scan.nextInt();

        int N=A%K;
        if((N+B-A>=K)||(N==0)){System.out.println("OK");}
        else {System.out.println("NG");};



        // write your code here
    }
}

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

int main() {
  int N, M, D;
  cin >> N >> M >> D;
  vector<string> space(N);
  for (int i = 0; i < N; ++i)
    cin >> space[i];

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M - D + 1; ++j) {
      int none = 0;
      for (int k = j; k < D + j; ++k)
        if (space[i][k] == '.')
          ++none;
      if (none == D)
        ++ans;
    }
  }

  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N - D + 1; ++j) {
      int none = 0;
      for (int k = j; k < D + j; ++k)
        if (space[k][i] == '.')
          ++none;
      if (none == D)
        ++ans;
    }
  }

  cout << ans << endl;
}


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

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

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

class DSU{
    public:
    vi Parent, Size;
    int Cnt;
    DSU(int N){
        Cnt = N;
        Parent.resize(N);
        Size.resize(N, 1);
        for(int x = 0; x < N; x++) Parent[x] = x;
    }
    int FindParent(int x){
        return (Parent[x] == x) ? x : Parent[x] = FindParent(Parent[x]);
    }
    void MergeUnion(int x, int y){
        x = FindParent(x), y = FindParent(y);
        if(x == y) return;
        Cnt--;
        Parent[x] = y;
        Size[y] += Size[x];
        return;
    }
};

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

    int N, M, K; cin >> N >> M >> K;
    DSU F(N);
    vi B(N, 1);

    while(M--){
        int u, v; cin >> u >> v;
        u--, v--;
        F.MergeUnion(u, v);
        B[u]++, B[v]++;
    }

    while(K--){
        int u, v; cin >> u >> v;
        u--, v--;

        if(F.FindParent(u) == F.FindParent(v)){
            B[u]++, B[v]++;
        }
    }

    for(int x = 0; x < N; x++){
        int s1 = F.Size[F.FindParent(x)] - B[x];
        cout << s1 << " ";
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
int h,w,k;
int INFp=1000000007;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c;cin>>a>>b>>c;
    cout << min(a*b,c) << ednl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main(){
    int n; cin>>n;
    int ans=0;
    for(int i=1;i<=n;i=i+2){
        int count=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) count++;
        }
        if(count==8) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
#include <bitset>
#include <cstring>
using namespace std;

#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
ll arr[(int)1e5 + 9], dp[(int)1e5 + 9];
int x;
ll f(int i) {
	if (i == x - 1)
		return 0;
	else if (i == x - 2)
		return abs(arr[x - 2] - arr[x - 1]);
	else if (dp[i] != -1)
		return dp[i];
	else
		return dp[i] = min(f(i+1)+abs(arr[i] - arr[i + 1]),f(i+2)+abs(arr[i] - arr[i + 2]));
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> x;
	for (int i = 0; i < x; i++)
		cin >> arr[i];
	memset(dp, -1, sizeof(dp));
	cout << f(0) << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,i;
    cin >> n >> k;
    vi p(n); cin >> p;
    sort(all(p));
    int sm = 0;
    for(i=0;i<k;i++) sm += p[i];
    cout << sm << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int a[505][505],b[505][505],i,j,n,m;
char cc;
int main()
{
 //   freopen("C.in","r",stdin);
   // freopen("C.out","w",stdout);
    scanf("%d%d\n",&n,&m);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%c",&cc);
            if(cc=='#')a[i][j]=1;
            else a[i][j]=0;
        }
        scanf("\n");
    }
    for(i=1;i<=n;i++)
    {
        if(i%2==1)
        {
            for(j=1;j<m;j++)
                b[i][j]=1;
        }
        else b[i][1]=1;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        if(a[i][j]==1)b[i][j]=1;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(b[i][j]==1)printf("#");
            else printf(".");
        }
        printf("\n");
    }
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            if(a[i][j]==1)b[i][j]=0;
    printf("\n\n");
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(b[i][j]==0)printf("#");
            else printf(".");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		long A, B, C, D;
		for (int i = 0; i < n; i++) {
			A = scn.nextLong();
			B = scn.nextLong();
			C = scn.nextLong();
			D = scn.nextLong();
			boolean can = true;
			if (A < B) {
				can = false;
			} else {
				if (D < B) {
					can = false;
				}else {
					if (D % B == 0) {
						if (A % B > C)
							can = false;
					} else {
						long a = A % B;
						long b = D % B;
						b = yu(B,b);
						long buf = (B-a-1)/b;
						if((b * buf + a > C && B > b * buf + a) || b * (buf-1) + a > C) {
							can = false;
						}
					}
				}
			}
			System.out.println(can ? "Yes" : "No");
		}
		scn.close();
	}

	public static long yu(long a,long b) {
		long buf;
		while(a%b !=0) {
			buf = a%b;
			a = b;
			b = buf;
		}
		return b;
	}

}


Measured memory_bytes: 25736
#include <iostream>
#include <string>
using namespace std;
int main(){
    string O,E;
    cin>>O>>E;

    for(int i=0;i<(int)E.size();i++){
        cout<<O[i]<<E[i];
    }
    if(O.size()!=E.size()){
        cout<<O[(int)O.size()-1];
    }
    cout<<endl;

    return 0;
}

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

int n, u, prv = 0, lz = 0, rz = 0, lo = 0, ro = 0, ans = 0;

void process(int prv, int cur) {
    int dif = cur - prv;
    int lt = max(0, min(dif, 0) + lz);
    int rt = min(cur, max(dif, 0) + rz);
    lz = min(cur + 1, max(dif, 0) + lz);
    rz = min(cur, max(dif, 0) + rz);
    lo = min(cur + 1, max(dif, 0) + lo);
    ro = min(cur, max(dif, 0) + ro);
    lo = min(lo, lt);
    ro = max(ro, rt);
    if (lz > rz) {
        lz = lo; rz = ro;
        lo = 0; ro = cur;
        ans++;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    while (n--) {
        cin >> u;
        process(prv, u);
        prv = u;
    }
    process(prv, 0);
    cout << ans;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> x(n,0);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += min(x[i]*2,(k-x[i])*2);
    }
    cout << ans << endl;
}

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

int main(){
  ll n;
  cin >>n;
  bool nine = true;
  int cnt = 0;
  while(n>=10){
    if(n%10!=9) nine = false;
    n/=10;
    cnt++;
  }
  int ans = n+cnt*9;
  if(nine) cout << ans << endl;
  else cout << ans-1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;


int main() {
	ll n,x[102],y[102],h[102];
	cin>>n;
	ll kx,ky,kh;
	rep(i,0,n){
		cin>>x[i]>>y[i]>>h[i];
		if(h[i]!=0){
			kx=x[i];
			ky=y[i];
			kh=h[i];
		}
	}
	rep(i,0,101){
		rep(j,0,101){
			bool f=false;
			ll g=kh+abs(kx-i)+abs(ky-j);
			rep(k,0,n){
				if(g!=h[k]+abs(x[k]-i)+abs(y[k]-j)){
					if(!(h[k]==0&&g<h[k]+abs(x[k]-i)+abs(y[k]-j))){
						f=1;
						break;
					}
				}
			}
			if(!f)cout<<i<<" "<<j<<" "<<g<<endl;
		}
	}
	return 0;
}


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

using namespace std;

int main() {
    long long x, k;
    cin >> x >> k;
    long long r = x / k;
    long long ans = x - r * k;
    ans = min(ans, (r + 1) * k - x);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);

  if(a==b && b==c){
    printf("No\n");
    return 0;}
  if(a==b || b==c || a==c){
    printf("Yes\n");
    return 0;}
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
# Reference: https://note.nkmk.me/python-union-find/
class UnionFind:
    # 各要素の親要素の番号を格納するリスト
    # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 要素xが属するグループの根を返す
    def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 要素x, yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)

def main():
    from sys import stdin
    input = stdin.buffer.readline
 
    n, q = map(int, input().split())
 
    uf = UnionFind(n)
 
    ans = []
    for _ in range(q):
        t, u, v = map(int, input().split())
        if t == 0:
            uf.union(u, v)
        else:
            if uf.same(u, v):
                ans.append(1)
            else:
                ans.append(0)
    
    for i in ans:
        print(i)
 
main()

Measured memory_bytes: 78076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll SIZE=205,INF=1e10;
struct MaxFlow{
	struct edge{
		ll to,cap,rev;
		edge(ll to=0,ll cap=0,ll rev=0):to(to),cap(cap),rev(rev){}
	};
	vector <edge> vec[SIZE];
	ll level[SIZE];
	ll iter[SIZE];
	void add(ll s,ll t,ll c){
		ll S=vec[s].size(),T=vec[t].size();
		vec[s].push_back(edge(t,c,T));
		vec[t].push_back(edge(s,0,S));
	}
	void bfs(ll s){
		memset(level,-1,sizeof(level));
		queue <ll> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()){
			ll v = que.front();que.pop();
			for(ll i=0;i<vec[v].size();i++){
				edge&e=vec[v][i];
				if (e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	ll flow_dfs(ll v,ll t,ll f){
		if (v==t) return f;
		for(ll &i=iter[v];i<vec[v].size();i++){
			edge &e=vec[v][i];
			if (e.cap>0&&level[v]<level[e.to]){
				ll d=flow_dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					vec[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	ll max_flow(ll s,ll t){
		ll flow = 0;
		while(1){
			bfs(s);
			if (level[t]<0) return flow;
			memset(iter,0,sizeof(iter));
			while (1){
				ll f=flow_dfs(s,t,INF);
				if(f==0) break;
				flow += f;
			}
		}
	}
};
MaxFlow MF;
ll a[105],sum,res,n;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=1;i<=n;i++)cin>>a[i],sum+=a[i],a[i]*=-1;
    for(ll i=1;i<=n;i++){
        if(a[i]>0){
            MF.add(0,i,a[i]);
            res+=a[i];
        }
        else MF.add(i,n+1,-a[i]);
    }
    for(ll i=1;i<=n;i++)for(ll j=2*i;j<=n;j+=i)MF.add(i,j,INF);
    res-=MF.max_flow(0,n+1);
    sum+=res;
    cout<<sum;
}


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

int main() {
    int n;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    string s;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> s;
        if(s[0] == 'A') ac++;
        else if(s[0] == 'W') wa++;
        else if(s[0] == 'T') tle++;
        else re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}



Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc106/tasks/abc106_d

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 500;
const int M_MAX = 200000;
const int Q_MAX = 100000;

int N, M, Q;
int L[M_MAX];
int R[M_MAX];
int p[Q_MAX];
int q[Q_MAX];

int acc[N_MAX][N_MAX];

void solve() {
  REP(i, M) acc[L[i] - 1][R[i] - 1] += 1;
  REP(i, N) REP(j, N - 1) acc[i][j + 1] += acc[i][j];
  REP(j, N) for (int i = N - 1; i > 0; i--) acc[i - 1][j] += acc[i][j];
  REP(i, Q) printf("%d\n", acc[p[i] - 1][q[i] - 1]);
}

void input() {
  scanf("%d%d%d", &N, &M, &Q);
  REP(i, M) scanf("%d%d", L + i, R + i);
  REP(i, Q) scanf("%d%d", p + i, q + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;
template<typename T, typename U> static bool chmax(T &x, U y) { if (x < y) { x = y; return true; } return false; }

int main() {
	int N;
	while (~scanf("%d", &N)) {
		vector<int> A(N);
		for (int i = 0; i < N; ++i)
			scanf("%d", &A[i]);
		sort(A.begin(), A.end());
		pair<long double, pair<int, int>> ans{ -1,{} };
		for (int i = 0; i < N; ++i) {
			int x = A[i];
			int mj = (int)(lower_bound(A.begin(), A.end(), x / 2) - A.begin());
			for (int dj : {-1, 0, 1}) if (0 <= mj + dj && mj + dj < i) {
				int y = A[mj + dj];
				auto logC = lgammal(x + 1) - lgammal(y + 1) - lgammal(x - y + 1);
				chmax(ans, make_pair(logC, make_pair(x, y)));
			}
		}
		printf("%d %d\n", ans.second.first, ans.second.second);
	}
}


Measured memory_bytes: 896
using System;

namespace ABC055B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var m = 1000000007L;
            var a = 1L;

            // 分配則
            // ab mod n = ((a mod n)(b mod n)) mode n
            for(var i = 1; i <= n; i++)
            {
                a = (a * i) % m;
            }

            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 27520
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static int[] color;
	public static int red, blue;//red:1 blue:2
	public static To[] e;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[n-1][2];
		e = new To[n];
		for (int i = 0; i < n; i++) e[i] = new To();
		for (int i = 0; i < n-1; i++) {
			a[i][0] = sc.nextInt()-1;
			a[i][1] = sc.nextInt()-1;
			e[a[i][0]].add(a[i][1]);
			e[a[i][1]].add(a[i][0]);
		}
		color = new int[n];
		red = 1; blue = 0;
		color[0] = 1;
		dfs(0);
		StringBuilder sb = new StringBuilder();
		int a1 = 1, a2 = 2, a3 = 3;
		if(red>n/3&&blue>n/3) {
			for (int i = 0; i < n; i++) {
				if(color[i]==1) {
					if(a1<=n) {
						sb.append(a1);
						a1 += 3;
					}else {
						sb.append(a3);
						a3 += 3;
					}
				}else if(color[i]==2) {
					if(a2<=n) {
						sb.append(a2);
						a2 += 3;
					}else {
						sb.append(a3);
						a3 += 3;
					}
				}
				sb.append(" ");
			}
		}else if(red < blue){
			for (int i = 0; i < n; i++) {
				if(color[i]==1) {
					sb.append(a3);
					a3 += 3;
				}else {
					if(a2<=n) {
						sb.append(a2);
						a2 += 3;
					}else if(a1<=n){
						sb.append(a1);
						a1 += 3;
					}else {
						sb.append(a3);
						a3 += 3;
					}
				}
				sb.append(" ");
			}
		}else {
			for (int i = 0; i < n; i++) {
				if(color[i]==2) {
					sb.append(a3);
					a3 += 3;
				}else {
					if(a1<=n) {
						sb.append(a1);
						a1 += 3;
					}else if(a2<=n){
						sb.append(a2);
						a2 += 3;
					}else {
						sb.append(a3);
						a3 += 3;
					}
				}
				sb.append(" ");
			}
		}
		System.out.println(new String(sb));
		sc.close();
	}
	public static void dfs(int x) {
		for (int i = 0; i < e[x].size(); i++) {
			if(color[e[x].get(i)]==0) {
				if(color[x]==1) {
					color[e[x].get(i)] = 2;
					blue++;
					dfs(e[x].get(i));
				}else if(color[x]==2) {
					color[e[x].get(i)] = 1;
					red++;
					dfs(e[x].get(i));
				}
			}
		}
		return;
	}
	public static class To{
		ArrayList<Integer> to;
		public To() {
			to = new ArrayList<Integer>();
		}
		public void add(Integer a) {
			to.add(a);
		}
		public int get(int i) {
			return to.get(i);
		}
		public int size() {
			return to.size();
		}
	}
}

Measured memory_bytes: 160736
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }

    println!(
        "{}",
        std::cmp::max(std::cmp::max(a * d, b * c), std::cmp::max(a * c, b * d))
    );
}


Measured memory_bytes: 2200
#include<stdio.h>
int main()
{
    int a[100],i,n,j,sum=0;
    while(scanf("%d",&n)==1)
    {
        sum=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(i=0;i<n;i++)
        {
            for(j=i+1;j<n;j++)
            {
                if(a[i]<a[j])
                {
                    int tem=a[i];
                    a[i]=a[j];
                    a[j]=tem;
                }
            }
        }
        for(i=1;i<n;i++)
        {
            sum=sum+a[i];
        }
        sum=sum+a[0]/2;
        printf("%d",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main () {
	int a, b;
	scanf("%d %d", &a, &b);
	int res = (a + b > a - b) ? a + b : a - b;
	res = (res > a * b) ? res : a * b;
	
	printf("%d\n", res);
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 924844033;

using poly = vector<ll>;

poly operator*(poly x, poly y) {
    poly ans(x.size() + y.size() - 1);
    forn(i, 0, x.size()) forn(j, 0, y.size()) {
        ans[i + j] += x[i] * y[j];
        ans[i + j] %= MOD;
    }
    return ans;
}

poly operator+(poly x, poly y) {
    poly ans(max(x.size(), y.size()));
    forn(i, 0, x.size()) {
        ans[i] += x[i];
        if (ans[i] >= MOD) ans[i] -= MOD;
    }
    forn(i, 0, y.size()) {
        ans[i] += y[i];
        if (ans[i] >= MOD) ans[i] -= MOD;
    }
    return ans;
}

poly Pow(poly a, int n) {
    poly x = {1}, y = a;
    while (n) {
        if (n % 2) x = x * y;
        y = y * y;
        n /= 2;
    }
    return x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    poly X = {0, 1};
    int n, k;
    cin >> n >> k;
    vector<poly> f(2 * n + 1);
    f[0] = {1};
    f[1] = {1, 1};
    fore(i, 2, 2 * n) f[i] = f[i - 1] + f[i - 2] * X;
    map<int, int> lens;
    forn(i, 0, k) lens[(n - 1 - i) / k] += 2;
    assert(lens.size() <= 2);
    poly ans = {1};
    for (auto p : lens) {
        ans = ans * Pow(f[p.first], p.second);
    }
    ll res = 0;
    assert(ans.size() <= n + 1);
    //trace(ans);
    forn(i, 0, ans.size()) {
        ll add = 1;
        fore(j, 1, n - i) add = add * j % MOD;
        add  = add * ans[i] % MOD;
        if (i % 2) {
            res -= add;
            if (res < 0) res += MOD;
        } else {
            res += add;
            if (res >= MOD) res -= MOD;
        }
    }
    cout << res << '\n';
}


Measured memory_bytes: 55296
from math import gcd
N, M = map(int, input().split())
A = [a//2 for a in map(int, input().split())]

lcm = 1
for a in A:
    lcm = lcm*a//gcd(lcm, a)
    if lcm > M:
        print(0)
        exit()

for a in A:
    div = lcm//a
    if div % 2 == 0:
        print(0)
        exit()

ans = (M//lcm+1)//2
print(ans)


Measured memory_bytes: 20304
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(87);
  b[0]=2;
  b[1]=1;
  for(int i=2;i<87;i++){
  b[i]=b[i-1]+b[i-2];
  }
  out(b[a]);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
#include <fstream>
#define INF (LLONG_MAX>>2)
using namespace std;

typedef long long ll;

class edge{
public:
  int to;
  int weight;
  edge(int to, int weight){
    this->to = to;
    this->weight = weight;
  }
};

void dijkstra(int, int, vector<edge>*);

int main(){
  int v, e, r;
  cin >> v >> e >> r;

  vector<edge> graph[v];

  int from, to, weight;
  for(int i=0; i<e; i++){
    cin >> from >> to >> weight;
    graph[from].push_back(edge(to, weight));
  }

  dijkstra(r, v, graph);

  return 0;
}

void dijkstra(int start, int v, vector<edge>* graph){
  //各頂点のスタートからの距離を格納
  ll distance[v];
  for(int i=0; i<v; i++) distance[i] = INF;
  distance[start]=0;

  //プライオリティーキュー初期化
  priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > pq;
  pq.push(make_pair(0, start));//いい感じにするため、(距離、頂点番号)で格納

  while(!pq.empty()){
    pair<ll, int> now = pq.top(); pq.pop();
    ll nowDistance = now.first, nowNode = now.second;
    if(distance[nowNode]<nowDistance) continue;

    //ノードnowからの各枝について調査
    for(int i=0; i<graph[nowNode].size(); i++){
      ll nd = nowDistance + 1LL*graph[nowNode][i].weight;
      int nextNode = graph[nowNode][i].to;
      if(nd < distance[nextNode]){
        distance[nextNode] = nd;
        pair<ll, int> next = make_pair(nd, nextNode);
        pq.push(next);
      }
    }
  }

  for(int i=0; i<v; i++) {
    if(distance[i]==INF) cout << "INF" << endl;
    else cout << distance[i] << endl;
  }
}



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

class Main {

	public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
					
		String str, str2;
		
		str = br.readLine();
		str = str.toLowerCase();

		int sum = 0;
		
		while(true){
			str2 = br.readLine();	
			if (str2.equals("END_OF_TEXT")) break;
			
			str2 = str2.toLowerCase();
			String st[] = str2.split(" ", 0);
			for(int i = 0; i < st.length; i++){
				if(st[i].equals(str)){
					sum++;
				}
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 24440
#include <iostream>
#include <algorithm>

int main(){
    int a, b, lcm, gcd;
	while(std::cin >> a >> b){
		int _a = a, _b = b;
		while(1){
			if(_b % _a == 0){
				gcd = _a;
				break;
			}
			_a = _a % _b;
			std::swap(_a, _b);
		}
		lcm = a / gcd * b;
		std::cout << gcd << ' ' << lcm << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
		if(x<=0||x>=w||x+r>w||x-r<0||y<=0||y>=h||y+r>h||y-r<0){
			printf("No\n");
			}else{printf("Yes\n");}
	return 0;
}

Measured memory_bytes: 584
/*
ID: mckibbe1
TASK: money
LANG: C++11
*/
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
using namespace std;
int dp[100111], a[100111];
int main() {
	//freopen("file.in", "r", stdin);
	//freopen("file.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie();
	int N, K; cin >> N >> K;
	for (int i = 0; i < N + 2; i++) {
		cin >> a[i];
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	for (int i = 0; i < N; i++)
		for(int q = 1; q <= K; q++)
			dp[i + q] = min(dp[i + q], abs(a[i] - a[i + q]) + dp[i]);
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int n, y;

double func1(double a, double b){
  return a * (1.0 + (double)y * b / 100.0);
}

double func2(double a, double b){
  double t = (1.0 + b / 100.0);
  double r = 1.0;
  for(int i=0;i<y;i++){
    r *= t;
  }
  return a * r;
}

main(){
  while(cin >> n >> y && n){
    double valM = -10000000.0;
    int idx;
    for(int i=0;i<n;i++){
      double a, res;
      int t, b;
      cin >> b >> a >> t;
      if(t == 1){
        res = func1(1.0, a);
        if(valM < res){
          valM = res;
          idx = b;
        }
      }
      if(t == 2){
        res = func2(1.0, a);
        if(valM < res){
          valM = res;
          idx = b;
        }
      }
    }
    cout << idx << endl;
  }

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    int n = 0;
    cin >> n;

    vector<int> vec(n);
    REP(i, n)
    cin >> vec[i];

    int max1 = 0;
    int tmp = 0;

    for (int i = n - 1; i > 0; i--)
    {
        if (vec[i] <= vec[i - 1])
        {
            tmp++;
        }
        else
        {
            max1 = max(tmp, max1);
            tmp = 0;
        }
    }
    max1 = max(tmp, max1);
    cout << max1;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 1005;
int dp[N][N];
char matrix[N][N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int h, w;
	cin >> h >> w;
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
			cin >> matrix[i][j];
	
	dp[1][0] = 1;
	for(int i = 1; i <= h; i++) {
		for(int j = 1; j <= w; j++) {
			lli a = 0, b = 0;
			if(matrix[i][j-1] != '#')
				a = dp[i][j-1];
			if(matrix[i-1][j] != '#')
				b = dp[i-1][j];
			dp[i][j] = (a + b) % MOD;
		}
	}
	cout << dp[h][w] << "\n";
	return 0;
}

Measured memory_bytes: 5120
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;
    int x = 360;
    int t = 2;
    while(x%n != 0){
        // cout<<360/n<<endl;

        x = 360*t;
        t++;
        // return;
    }


    cout<<(x/n)<<endl; 

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 3632
import sys

class Dice(object):
    def __init__(self, dice):
        self.__dice = dice

    def roll_north(self):
        self.__dice = (self.__dice[1], self.__dice[5], self.__dice[2],
                       self.__dice[3], self.__dice[0], self.__dice[4])

    def roll_south(self):
        self.__dice = (self.__dice[4], self.__dice[0], self.__dice[2],
                       self.__dice[3], self.__dice[5], self.__dice[1])

    def roll_west(self):
        self.__dice = (self.__dice[2], self.__dice[1], self.__dice[5],
                       self.__dice[0], self.__dice[4], self.__dice[3])

    def roll_east(self):
        self.__dice = (self.__dice[3], self.__dice[1], self.__dice[0],
                       self.__dice[5], self.__dice[4], self.__dice[2])

    def number(self, face_id):
        return self.__dice[face_id - 1]

    def __str__(self):
        return str(self.__dice)


dice = Dice([int(i) for i in sys.stdin.readline().split()])
n = int(sys.stdin.readline())
for i in range(n):
    (face1, face2) = [int(a) for a in sys.stdin.readline().split()]
    if face2 == dice.number(3) or face2 == dice.number(4):
        dice.roll_west()
    while dice.number(2) != face2:
        dice.roll_north()
    while dice.number(1) != face1:
        dice.roll_west()
    print(dice.number(3))

Measured memory_bytes: 6768
n = int(input())
S = {}
for _ in range(n):
    k = input()
    if k not in S: S[k] = 0
    S[k] += 1

# print(S)

for k in ['AC','WA','TLE','RE']:
    # print(k)
    if k not in S: print(k, 'x', 0)
    else: print(k, 'x', S[k])


Measured memory_bytes: 9188