akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10桁出力 cout << setprecision(10) << double;
#include <queue>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	string a, b, c;
	cin >> a >> b >> c;

	char nowTurn = 'a';
	char nextTurn='a';
	while (1) {
		nowTurn = nextTurn;



		if (nowTurn == 'a') {
			if (a == "") {
				cout << 'A' << endl;
				return 0;
			}
			nextTurn = a[0];
			a.erase(0,1);
			//cout << a << endl;
		}else if(nowTurn=='b'){
			if (b == "") {
				cout << 'B' << endl;
				return 0;
			}
			nextTurn = b[0];
			b.erase(0, 1);
		}
		else {
			if (c == "") {
				cout << 'C' << endl;
				return 0;
			}
			nextTurn = c[0];
			c.erase(0, 1);
		}

		//cout << "a=" << a << " , b=" << b << ", c=" << c << endl;


	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {

	ll s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 3568
from collections import Counter

n = int(input())
a = map(int, input().split())

c = Counter(a)
r = 1 if n % 2 == 0 else 0
for k, v in c.items():
    if r == 0 and k == 0 and v == 1:
        continue
    if k != 0 and k % 2 == r and v == 2:
        continue
    print(0)
    break
else:
    print(2**(n//2) % (10**9+7))


Measured memory_bytes: 16620
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

template<typename T>
T powll(T base, T exp){
  T ret = 1;
  if(exp == 0) return 1;
  while(exp != 1){
    if((int)exp&1){
      ret *= base;
      exp--;
    }
    exp/=2;
    base *= base;
  }
  ret *= base;
  return ret;
}

int solve(){
  long long n;  cin >> n;
  if(n&1){
    cout << 0 << endl;
    return 0;
  }
  string s=to_string(n);
  int sn = s.length();
  long long ans = 0;
  ans += n/10ll;
  for(long long i=5; i*10<=n; i*=5){
    ans += n/(10ll * i);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
#define mod	1000000007
#define N	1005
bool prime[1005];
void sieve(){
	memset(prime,1,sizeof(prime));
	for(ll p=2 ; p*p<=N ; p++){
		for(ll i=p*p ; i<=N ; i+=p){
			prime[i] = 0;
			}
		}
	}
ll exp(ll n, ll p){
	ll x=p,cnt=0;
	while((n/x)>0){
		cnt = (cnt + n/x)%mod;
		x *= p;
		}
	return cnt%mod;
	}
ll cal_fac(ll n){
	ll x,ans=1;
	for(ll i=2 ; i<=n ; i++){
		if(prime[i]==1){
			x = exp(n,i);
			x += 1;
			ans = (ans*x)%mod;
			}
		}
	return ans%mod;
	}
int main()
{
	sieve();
	ll n,ans;
	cin>>n;
	ans = cal_fac(n);
	ans%=mod;
	if(ans<0) ans += mod;
	cout<<ans<<nw;
	
	return 0;
}

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


int main(){
	
	

	int n ;
	cin>> n ;
	int count = 1 ;
	set<string> s ;
	 for(int i = 0 ; i < n ; ++i)
	 {	
	 	 string t ; 
	 	 cin >> t ;
	 	 s.insert(t);
	 }
	
	cout<< s.size();
	return 0 ;
}

Measured memory_bytes: 19120
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	string a;
	string b;
	int i;
	cin >> a >> b;
	int tong[26];
	int used[26];
	for ( i = 0 ; i < 26 ; i++ ){
		tong[i] = -1;
		used[i] = 0;
	}
		
	for ( i = 0 ; i < a.length(); i ++){
		if ( used[a[i] - 'a'] && tong[a[i] - 'a'] != b[i] - 'a'){
			cout << "No";
			return 0;
		}
		tong[a[i] - 'a'] = b[i] - 'a';
		used[a[i] - 'a'] = 1;
	}
	for ( i = 0 ; i < 26 ; i++ ){
		tong[i] = -1;
		used[i] = 0;
	}
		
	for ( i = 0 ; i < a.length(); i ++){
		if ( used[b[i] - 'a'] && tong[b[i] - 'a'] != a[i] - 'a'){
			cout << "No";
			return 0;
		}
		tong[b[i] - 'a'] = a[i] - 'a';
		used[b[i] - 'a'] = 1;
	}
	cout << "Yes";
} 

Measured memory_bytes: 776
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	final long MOD = (long) 1e9 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		char[] cs = sc.next().toCharArray();
		long[][] dp = new long[cs.length][13];
		int base = 1;
		for (int i = 0; i < cs.length; ++i) {
			if (cs[cs.length - 1 - i] == '?') {
				for (int pre = 0; pre < 13; ++pre) {
					for (int next = 0; next < 10; ++next) {
						dp[i][(base * next + pre) % 13] += (i > 0 ? dp[i - 1][pre] : (pre == 0 ? 1 : 0));
						dp[i][(base * next + pre) % 13] %= MOD;
					}
				}
			} else {
				int next = cs[cs.length - 1 - i] - '0';
				for (int pre = 0; pre < 13; ++pre) {
					dp[i][(base * next + pre) % 13] += (i > 0 ? dp[i - 1][pre] : (pre == 0 ? 1 : 0));
					dp[i][(base * next + pre) % 13] %= MOD;
				}
			}
			base = base * 10 % 13;
		}
		System.out.println(dp[dp.length-1][5]);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 40364
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    for(int i=a; i<=b; i++){
        if(i%c==0) ans++;
    }
    cout<<ans;
}

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

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n - 1];

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

    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans += b[i];
    }

    for(int i = 0; i < n - 1; i++) {
        if(a[i + 1] - a[i] == 1) ans += c[a[i] - 1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;

const int MAXD = 10;
int D, G;
int p[MAXD];
int c[MAXD];
int choice[MAXD];
int ans;

int main() {
    scanf("%d %d", &D, &G);
    for (int i = 0; i < D; i++) {
        scanf("%d %d", &p[i], &c[i]);
    }

    ans = -1;
    for (int i = 0; i < pow(2, D); i++) {
        memset(choice, 0, sizeof(choice));
        int cur = 0;
        int j = i;
        int cnt = 0;
        int r = G;
        while (j > 0) {
            if (j % 2 == 1) {
                choice[cnt] = p[cnt];
                r = r - 100 * (cnt + 1) * p[cnt] - c[cnt];
                cur += choice[cnt];
            }
            cnt++;
            j = j / 2;
        }
        if (ans != -1 && cur > ans) continue;
        j = D - 1;
        while (r > 0) {
            if (choice[j] == p[j]) {
                j--;
                continue;
            }
            while (choice[j] < p[j] && r > 0) {
                r = r - 100 * (j + 1);
                choice[j]++;
                cur++;
            }
            if (r <= 0) break;
            if (choice[j] == p[j]) r = r - c[j];
            j--;
        }
        if (ans == -1 || cur < ans) ans = cur;
    }

    printf("%d\n", ans);

    return 0;
}


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

int n, m, c; 
int b[21], a[21][21], ans;

int main() { 
  scanf("%d %d %d", &n, &m, &c);
  for (int i = 0; i < m; i++) {
    scanf("%d ", &b[i]);
  }  
  for (int i = 0; i < n; i++) {
    int curr = 0; 
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      curr += a[i][j] * b[j]; 
    }
    if (curr + c > 0) ans++;
  }

  cout << ans;

  return 0;
} 

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

struct UnionFind {
	vector<int> parent;
	
	UnionFind(int n){
		parent.resize(n);
		for (int i = 0; i < n; i++){
			parent[i] = i;
		}
	}
	
	int find(int x){
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
	
	bool unite(int x, int y){
		x = find(x);
		y = find(y);
		if (x == y) return false;
		parent[x] = y;
		return true;
	}
};


typedef tuple<int, int, int> Tp;
#define at(t, i) get<i>(t)

int n, m;

int main()
{
	while (scanf("%d %d", &n, &m), n){
		UnionFind uf(n);
		vector<Tp> es;
		vector<int> v;
		
		for (int i = 0; i < m; i++){
			int s, t, c;
			scanf("%d %d %d", &s, &t, &c);
			es.push_back(Tp(c, --s, --t));
		}
		
		sort(es.begin(), es.end());
		
		for (int i = 0; i < m; i++){
			if (uf.unite(at(es[i], 1), at(es[i], 2))){
				v.push_back(at(es[i], 0));
			}
		}
		
		int res = v[v.size() / 2];
		if (v.size() % 2 == 0){
			res += v[v.size() / 2 + 1];
		}
		
		printf("%d\n", res);
	}
}

Measured memory_bytes: 1408
//#define TEST

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Math;

class Program
{
    static int n;
    static long[] a;
    static void Main()
    {
        n = int.Parse(Console.ReadLine());
        a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        Array.Sort(a);

        long[] sum = new long[n + 1];
        for (int i = 1; i <= n; i++)
            sum[i] = sum[i - 1] + a[i - 1];

        long min = long.MaxValue;
        int index = 0;
        for (int i = 1; i <= n - 1; i++)
        {
            if (min > sum[i])
            {
                min = sum[i];
                index = i;
            }
        }
        Console.WriteLine(a.Sum() - 2 * min);
        long temp = a[index - 1];
        for (int i = index; i < n - 1; i++)
        {
            Console.WriteLine("{0} {1}", temp, a[i]);
            temp -= a[i];
        }
        Console.WriteLine("{0} {1}", a[n - 1], temp);
        temp = a[n - 1] - temp;
        for (int i = 0; i < index - 1; i++)
        {
            Console.WriteLine("{0} {1}", temp, a[i]);
            temp -= a[i];
        }

    }
}

Measured memory_bytes: 32664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a % b == 0) {
			System.out.println(a / b);
		} else {
			System.out.println(a / b + 1);
		}

	}

}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int num = scan.nextInt();
        String str = scan.next();
        scan.close();

        if (str.length() <= num) {
            System.out.println(str);
        } else {
            System.out.println(str.substring(0, num) + "...");
        }
    }
}


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

int main() {
    long long n; cin >> n; map<long long,long long> m; long long s = 0;
    for (long long i =0 ; i < n; i ++) {long long a; cin >> a; m[a] += 1; s += a;}
    long long q; cin >> q; while(q--) {
        long long b, c; cin >> b >> c;
        long long num = m[b]; s -= (num*b); s += (num*c);
        m[b] = 0; m[c] += num; cout << s << endl;
    } 
}

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

int main(){
  int n,m,x;
  int tmp;
  int ans,ans2;
  int ps=0;
  cin>>n>>m>>x;
  int a[n];
  int b[m];

  for(int i=0;i<n;i++)a[i]=0;
  for(int i=0;i<m;i++){
    cin>>tmp;
    a[tmp]=1;
  }
  ans=0;
  ans2=0;
  for(int i=x;i<n;i++){
    ans+=a[i];
  }
  for(int i=x;i>=0;i--){
    ans2+=a[i];
  }
  cout<<min(ans,ans2)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,a,b;

int main(){
  ll ans=0;
  cin >> n >> a>>b;
  ll c=b-a;
  if (c%2==0){
    cout<<(c/2)<<endl;
    return 0;
  }
  
  ans=a+b-1;
  ans=min((n-a+1)+(n-b+1)-1,ans);


  cout<<ans/2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INF 1000000000
void MST(int);

int edge[101][101],v[101],d[101],sum=0,n;

int main(void){

  int m,a,b,i,j, cost;

  while(1){
      scanf("%d",&n);
      if(n==0)break;

      scanf("%d",&m);

      for(i=0;i<101;i++){
	  for(j=0;j<101;j++){
	      edge[i][j]=INF;
	    }
	}

      for(i=0;i<m;i++){
	scanf("%d,%d,%d",&a,&b,&cost);
	edge[a][b]=cost;
	edge[b][a]=cost;
	 }

      for(i=0;i<101;i++){
	d[i]=INF;
	v[i]=0;
      }

      d[0]=0;
      sum = 0;
      MST(0);

      printf("%d\n",sum);
    }

  return 0;
}

void MST(int u){
  int x=0,i;

  while(1){
    int minv=INF;

    for(i=0;i<n;i++){
      if(v[i]==0 &&  d[i]<minv){
	x=i;
	minv=d[i];
      }
    }
    if(minv==INF)break;  

    v[x]=1;
    if ( x != u ) sum+=(d[x]/100-1);
    
    for(i=0;i<n;i++){
      if ( v[i] ) continue;
      d[i]=min(d[i],edge[x][i]);
    }
  }
}

int min(int x,int y){
  return x < y ? x : y;
 }

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;

public class BinarySearch{
	public static void Main()
	{
		Console.ReadLine();
		var sList = ReadLineAndToIntList();
		Console.ReadLine();
		var tList = ReadLineAndToIntList();
	
		int count = 0;
	
		foreach (var t in tList)
		{
			if(sList.BinarySearch(t) > -1) count++;
		}
		
		Console.WriteLine(count);
	}
	
	//??????????????????????????????
	public static List<int> ReadLineAndToIntList()
	{
		return Console.ReadLine().Split().Select (c => int.Parse(c)).ToList();
	}
}

Measured memory_bytes: 15808
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)
	if flag(a, b, k) {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}
}

func flag(a, b, k int) bool {
	for i := a; i <= b; i++ {
		if i%k == 0 {
			return true
		}
	}
	return false
}


Measured memory_bytes: 1756
package main

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

func main() {
	S := nextString()
	for i := 0; i < len(S); i++ {
		if string(S[i]) == "R" && i%2 == 1 {
			fmt.Println("No")
			return
		}
		if string(S[i]) == "L" && i%2 == 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

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

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

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    int N, K;
    cin >> N >> K;
    int A[N];
    int center;
    rep(i, N) {
        cin >> A[i];
        if (A[i] == 1) center = i;
    }

    int ans = (center + K) / (K - 1);
    int right = ans * (K - 1);
    while (right < (N - 1)) {
        ans++;
        right += (K - 1);

    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n,x;
    cin >> n >> x;

    int mmin=1e9;
    for(int i=0;i<n;i++){
        int m;
        cin >> m;
        x-=m;
        mmin=min(mmin,m);
    }
    cout << n+x/mmin << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int a = scan.nextInt();
	int b = scan.nextInt();
	int c = scan.nextInt();

	if(a <= c && c <= b){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


Measured memory_bytes: 21716
N,M = [int(x) for x in input().split()]
if(N==2 or M==2):
  print(0)
elif(N==1):
  if(M==1):
    print(1)
  else:
    print(M-2)
elif(M==1):
  print(N-2)
else:
  print((N-2)*(M-2))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m, k;
  cin >> n >> m >> k;
  rep(i, 0, n + 1) {
    rep(j, 0, m + 1) {
      if (k == (i * m + j * n) - (i * j * 2)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 3672
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
long long ans[200005]={0},num[200005],sz[200005]={0},color[200005]={0};
vector<long long> g[200005];
long long f(long long v){
	return v*(v+1)>>1;
}
void DFS(long long v,long long p){
	sz[v]=1;
	int temp=color[num[v]];
	for(auto x:g[v]){
		if(x==p)
			continue;
		color[num[v]]=0;
		DFS(x,v);
		sz[v]+=sz[x];
		ans[num[v]]-=f(sz[x]-color[num[v]]);
	}
	color[num[v]]=temp+sz[v];
}
int main(){
	long long i,n,from,to;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
		scanf("%lld",&num[i]);
	for(i=0;i<n-1;i++){
		scanf("%lld%lld",&from,&to);
		g[from].emplace_back(to);
		g[to].emplace_back(from);
	}
	DFS(1,-1);
	for(i=1;i<=n;i++)
		printf("%lld\n",ans[i]+f(n)-f(n-color[i]));
}


Measured memory_bytes: 39036
use proconio::input;

fn main() {
    input! {
        a: i32,
        b: i32,
    }

    let ans = (0..=1009)
        .filter(|x| x * 8 / 100 == a && x * 10 / 100 == b)
        .nth(0)
        .unwrap_or(-1);
    println!("{}", ans);
}


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

int main(){
	int p, q, r;
	fscanf(stdin,"%d %d %d", &p, &q, &r);
	if(p<q){
		if(q<r) printf("%d\n", p+q);
		else printf("%d\n", p+r);
	}else if(p<r) printf("%d\n", p+q);
	else printf("%d\n", q+r);
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    l = ['AC', 'WA', 'TLE', 'RE']
    dic = {key:0 for key in l}
    for _ in range(N):
        dic[input()] += 1
    for key in l:
        print(key + ' x ' + str(dic[key]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 8956
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  string s, t;
  cin >> s;
  cin >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());  
  
  cout << ((s < t) ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			
			int[] ids = new int[n];
			int[] ps = new int[n];
			int[] qs = new int[n];
			int[] rs = new int[n];
			int[] cs = new int[n];
			
			for (int i = 0; i < n; i++) {
				int id = sc.nextInt();
				int p = sc.nextInt();
				int q = sc.nextInt();
				int r = sc.nextInt();
				int c = 4 * p + 9 * q + 4 * r;
				ids[i] = id;
				ps[i] = p;
				qs[i] = q;
				rs[i] = r;
				cs[i] = c;
			}
			int P = sc.nextInt();
			int Q = sc.nextInt();
			int R = sc.nextInt();
			int C = sc.nextInt();
		
			boolean allng = true;
			for (int i = 0; i < n; i++) {
				boolean ok = ps[i] <= P && qs[i] <= Q && rs[i] <= R && cs[i] <= C;
				if (ok) {
					System.out.println(ids[i]);
					allng = false;
				}
			}
			if (allng) {
				System.out.println("NA");
			}
			
		}
	}
}

Measured memory_bytes: 65320
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n,m;
  cin>>n>>m;
  int a[9];
  rep(i,n+1)a[i]=-1;
  rep(i,m){
    int s,c;
    cin>>s>>c;
    if(a[n-s]!=-1&&a[n-s]!=c){
      cout<<-1<<endl;
      return(0);
    }
    a[n-s]=c;
  }
  int k[]={0,10,100,1000};
  for(int i=k[n-1];i<k[n];i++){
    int t=i;
    vector<int>d;
    if(t==0)d.push_back(0);
    while(t){
      d.push_back(t%10);
      t/=10;
    }
    bool f=false;
    rep(j,d.size()){
      if(a[j]!=-1&&a[j]!=d[j])f=true;
    }
    if(!f){
      cout<<i<<endl;
      return(0);
    }
  }
  cout<<-1<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std; //头文件和命名空间
int main(){
    ios::sync_with_stdio(false); //输入输出加速
    int iLeft1, iLeft2, iRight1, iRight2; //左盘两个物品的质量和右盘两个物体的质量
    cin >> iLeft1 >> iLeft2 >> iRight1 >> iRight2; //读入质量
    if (iLeft1 + iLeft2 > iRight1 + iRight2) //如果左盘重
        cout << "Left\n"; //输出，别忘了换行
    else if (iLeft1 + iLeft2 == iRight1 + iRight2) //等重
        cout << "Balanced\n"; //勿忘换行
    else //右盘重
        cout << "Right\n"; //勿忘换行
    return 0; //结束
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)
    val A = sc.nextInt()
    val B = sc.nextInt()
    val m = sc.nextInt()
    val a = Array(A) { sc.nextInt() }
    val b = Array(B) { sc.nextInt() }
    val map = Array(A) { mutableListOf<Pair<Int, Int>>() }
    for (i in 0 until m) {
        val x = sc.nextInt() - 1
        val y = sc.nextInt() - 1
        val c = sc.nextInt()
        map[x].add(y to c)
    }
    var ans = Int.MAX_VALUE
    val b_min = b.min()!!
    for (i in 0 until A) {
        var min = a[i] + b_min
        for ((j, c) in map[i]) {
            val x = a[i] + b[j] - c
            if (min > x) min = x
        }
        ans = Math.min(ans, min)
    }
    println(ans)
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 69176
#include<stdio.h>
int main(){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=1.00000 * a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}


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

namespace ConsoleApp11
{
    class Class4
    {
        static void Main()
        {
            string S = Console.ReadLine();
            bool check = true;
            for(int i = 0; i < S.Length; i++)
            {
                if (i % 2 != 0)
                {
                    if (S[i] == 'L' | S[i] == 'U' | S[i] == 'D')
                        ;
                    else
                        check = false;

                }
                else
                {
                    if (S[i] == 'R' | S[i] == 'U' | S[i] == 'D')
                        ;
                    else
                        check = false;
                }
                if (check == false)
                    break;
            }
            if (check)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
        
    }
}

Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int A[210];
    
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    int res = 0;
    
    while (true) {
        bool exist_odd = false;
        for (int i = 0; i < N; ++i){
            if (A[i] % 2 != 0) exist_odd = true;
        }
    
    
        if (exist_odd) break;
    
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()

int main(){
	ll N, M;
	cin >> N >> M;
	vector<ll> A(M);
	for(auto &a : A) cin >> a;
	ll sum = 0;
	for(auto &a : A) sum += a;
	cout << ((N - sum >= 0) ? N - sum : -1) << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
{ cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    ll h, ret=1, ans=1;
    R h;
    while(h > 1){
        h /= 2;
        ret *= 2;
        ans += ret;
    }
    co(ans);
}

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

bool judgePrimeNumber( int a )
{
    for( int i = 2; i <= sqrt(a); i++ )
        if( a % i == 0 )
            return false;
    return true;
}

int main()
{
    int n, x = 10000003;
    bool pn[x];
    for( int i = 0; i < x; i++ )
        pn[i] = true;

    for( int i = 2; i <= sqrt(x); i++ )
        if( judgePrimeNumber(i) )
            for( int j = i + i; j < x; j += i )
                pn[j] = false;
    
    cin >> n;

    int cnt = 0;
    for( int i = 2; i <= n; i++ )
        if( pn[i] && pn[i+2] )
            cnt += 2;

    cout << cnt << endl;

    return 0;
}



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

int main(){
  int a, b, r;
  cin >> a >> b;
  if(abs(a) < 1 || abs(a) > 9 || abs(b) < 1 || abs(b) > 9){
    r = -1;
  } else {
    r = a *b;
    }
  cout <<  r;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int A = Integer.parseInt(sa[0]);
		int B = Integer.parseInt(sa[1]);
		int m = Integer.parseInt(sa[2]);

		sa = br.readLine().split(" ");
		int[] a = new int[A];
		for (int i = 0; i < a.length; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		sa = br.readLine().split(" ");
		int[] b = new int[B];
		for (int i = 0; i < b.length; i++) {
			b[i] = Integer.parseInt(sa[i]);
		}

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int x = Integer.parseInt(sa[0]) - 1;
			int y = Integer.parseInt(sa[1]) - 1;
			int c = Integer.parseInt(sa[2]);
			int val = a[x] + b[y] - c;
			min = Math.min(min, val);
		}
		br.close();

		Arrays.parallelSort(a);
		Arrays.parallelSort(b);
		min = Math.min(min, a[0] + b[0]);
		System.out.println(min);
	}
}


Measured memory_bytes: 47592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  	string a,b;
  	cin >> a >> b ;
  	int A,B;
  	cin >> A >> B;
  	string u;
  	cin >> u;
  	if(a==u)cout << A-1 <<" " <<B<<endl;
  	else cout << A <<" " <<B-1<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
typedef long long ll;
 
int digits[] = {3, 5, 7};
 
int check(ll cur) {
    int a, b, c;
    a = b = c = 0;
 
    while (cur) {
        int t = cur %10;
        cur /= 10;
        if (t == 3) a = 1;
        else if (t == 5) b = 1;
        else if (t == 7) c = 1;
    }
 
    return a && b && c;
}
 
int dfs(ll cur, int n) {
    if (cur > n) return 0;
    int ret = check(cur);
    for (int i = 0; i < 3; i ++) ret += dfs(10 * cur + digits[i], n);
    return ret;
}
 
int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", dfs(3, n) + dfs(5, n) + dfs(7, n));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n;

int main(){
    cin>>n;
    int ans=n/2+n%2;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

const int N = 8005;
const int maxn = 2*N+1;

int x,y,f[3][3][maxn],tt[3];
string t;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
  //  freopen("in.txt","r",stdin);
    cin>>t;
    cin>>x>>y;
    f[0][1][N] = 1; f[1][1][N] = 1;
    int i =0;
    int id = 0,time=0;
    while (i<t.length()) {
        int j=i;
        while (j<t.length() && t[j]=='F') j++;
        int L = j-i;
        //cout<<L<<endl;
        //cout<<tt[id]<<" "<<id<<" "<<L<<endl;
        for (int s=0;s<maxn;s++) f[id][tt[id]][s]=0;
        for (int s=0;s<maxn;s++) {
            if (s+L < maxn) f[id][tt[id]][s+L] = max(f[id][tt[id]][s+L],f[id][1-tt[id]][s]);
            if (s-L >=0 && time>0) f[id][tt[id]][s-L] = max(f[id][tt[id]][s-L],f[id][1-tt[id]][s]);
        }
       // cout<<f[id][0][N-1]<<" "<<f[id][0][N+1]<<endl;
        tt[id] = 1-tt[id];
        id = 1-id;
        i = j+1;
        time++;
    }

    if (f[0][1-tt[0]][N+x] && f[1][1-tt[1]][N+y]) cout<<"Yes";
    else cout<<"No";

}


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

#define fs first
#define sc second
#define mp make_pair

using namespace std;

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

const int N = 100009;

ii a[N];

ll t[N];
ll ans[N];

inline bool cmp (ii a, ii b) {
        return a.fs > b.fs || (a.fs == b.fs && a.sc < b.sc);
}
int main () {
        int n; scanf ("%d", &n);
        for (int i = 1; i <= n; i++) {
                scanf ("%d", &a[i].fs);
                a[i].sc = i;
        }
        sort (a + 1, a + n + 1, cmp);
        a[n + 1] = mp (0, n + 1);
        int now = n + 1;
        for (int i = 1; i <= n; i++) {
                now = min (now, a[i].sc);
                int j = i;
                while (j <= n && a[j].fs == a[i].fs) {
                        j++;
                }
                i = --j;
                ans[now] += (a[i].fs - a[i + 1].fs) * 1LL * i;
        }
        for (int i = 1; i <= n; i++) {
                printf ("%lld\n", ans[i]);
        }
}


Measured memory_bytes: 2688
#include<iostream>
using namespace std;
int main()
{
	long long n,a,b;
	long l;
	long long sum=0;
	cin>>n>>a>>b;
	l=a+b;
	sum=(n/l)*a;
	if(n%l<=a) sum=sum+n%l;
	else sum=sum+a;
	cout<<sum<<endl;
}

Measured memory_bytes: 256
from heapq import *

N = int(input())
a = list(map(int,input().split()))

sumS1 = [0 for i in range(N + 1)]
S1 = a[0:N]
heapify(S1)
sumS1[0] = sum(S1)

for k in range(1, N + 1):
    if S1[0] < a[N + k - 1]:
        sumS1[k] = sumS1[k - 1] +a[N + k - 1] - S1[0]
        heapreplace(S1, a[N + k - 1])
    else:
        sumS1[k] = sumS1[k - 1]

sumS2 = [0 for i in range(N + 1)]
S2 =  [-1 * i for i in a[2 * N:3 * N]]
heapify(S2)
sumS2[N] = sum(S2)

for k in range(1, N + 1):
    if S2[0] < -1 * a[2 * N - k]:
        sumS2[N - k] = sumS2[N - k + 1] - a[2 * N - k] - S2[0]
        heapreplace(S2, -1 * a[2 * N - k])
    else:
        sumS2[N - k] = sumS2[N - k + 1]


res = [float("-inf")] * (N + 1)
for i in range(N + 1):
    res[i] = sumS1[i] + sumS2[i]

res.sort()
print(res[N])

Measured memory_bytes: 37212
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N = int(sys.stdin.readline())
list_travel=  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]

x_now = 0
y_now = 0
time_now = 0

ans = 'Yes'

for i in range(N):
    # time_next = list_travel[i][0]
    # x_next = list_travel[i][1]
    # y_next = list_travel[i][2]
    time_next, x_next, y_next = list_travel[i]
    dis_delta = abs(x_next - x_now) + abs(y_next - y_now)
    time_delta = time_next - time_now
    if(dis_delta <= time_delta
    and (dis_delta - time_delta)%2 == 0):
        x_now = x_next
        y_now = y_next
        time_now = time_next
    else:
        ans = 'No'

print(ans)

Measured memory_bytes: 29308
#include<bits/stdc++.h>
#define For(i,j,k) for(register int i=(j);i<=(k);++i)
#define Forr(i,j,k) for(register int i=(j);i>=(k);--i)
using namespace std;

template<typename T>
inline void read(T &x){
	T p=1,c=getchar();
	x=0;
	while(!isdigit(c)){
		if(c=='-') p=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	x*=p;
}

int a,b,c,d;

int main(){
	read(a),read(b),read(c),read(d);
	printf("%d\n",min(a,b)+min(c,d));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
	string s;
	cin>>s;
	ll sum=0;
	for(int i=0; i<s.size(); i++)
		sum+=s[i]-'0';
	
	if(sum%9==0) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n, m;
	cin >> n >> m;
	int p[n];
	for (int i = 0; i < n; i++)
		cin >> p[i];
	vector<vector<int>> G(n);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		G[x-1].push_back(y-1);
		G[y-1].push_back(x-1);
	}

	vector<vector<int>> groups;

	set<int> todo;
	vector<bool> visited(n, false);
	for (int i = 0; i < n; i++)
		todo.insert(i);
	queue<int> q;
	while (!todo.empty()) {
		q.push(*todo.begin());
		groups.resize(groups.size()+1);
		while (!q.empty()) {
			int v = q.front();
			q.pop();
			if (visited[v])
				continue;
			visited[v] = true;
			todo.erase(v);
			groups.back().push_back(v);
			for (auto e : G[v]) {
				if (!visited[e])
					q.push(e);
			}
		}
	}
	//for (auto e : groups) {
	//	for (auto f : e) {
	//		printf("%d ", f);
	//	}
	//	cout << endl;
	//}
	
	int count = 0;
	for (auto e : groups) {
		set<int> s;
		for (auto f : e) {
			s.insert(p[f]);
		}
		for (auto f : e) {
			if (s.find(f+1) != s.end()) {
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 15128
#include<stdio.h>
int main(){
  int n,i=0,l,a=0,b=0,c;
  scanf("%d",&n);
  if(n==1)
    b=1;
  else{for(l=2;l<=n;l+=2){
    c=l;
   while(c%2==0){
    c/=2;
    i++;
  }
   if(i>a){
     a=i;
     b=l;
   }
   i=0;
  }
  }
  printf("%d",b);
  return 0;
  }


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>

int main(void)
{
	char S[1000];
	scanf("%s\n",S);
	int len = strlen(S);
	int ok_len = -1;
	int i;
	for (i=1;i*2<len;i++){
		int j;
		for (j=0;j<i;j++){
			if (S[j]!=S[j+i])break;
		}
		if (j==i)ok_len = i*2;
	}
	printf("%d\n",ok_len);
	return 0;
}


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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		MaxMinManager manager = new MaxMinManager();
		
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			double input = Double.parseDouble(str);
			manager.addValue(input);
		}
		
		System.out.printf("%.1f\n", manager.difference());
	}

}

class MaxMinManager {
	double max = Double.MIN_VALUE;
	double min = Double.MAX_VALUE;
	
	public void addValue(double d){
		if(d > max){
			max = d;
		}
		
		if(d < min){
			min = d;
		}
	}
	
	public double difference() {
		return max - min;
	}
}

Measured memory_bytes: 24788
import java.util.*;

class Main{

	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int n= sc.nextInt(),  q= sc.nextInt();

		Deque<String> P = new ArrayDeque<String>();
		Deque<Integer> T = new ArrayDeque<Integer>();

		for(int i=0; i<n; i++){
			P.add( sc.next() );  
			T.add( sc.nextInt() );
		}

		int total=0;
		while ( !P.isEmpty() ) {
			String p= P.pop();
			int t= T.pop();

			if(q<t) { T.add(t-q); P.add(p); total+= q; }
			else { total+= t;  System.out.println(p +" "+ total); } 
		}
	}	
}

Measured memory_bytes: 71452
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

def BF(E,s,n):
    inf=float("inf")
    d=[inf for _ in range(n)]
    d[s]=0
    for i in range(2*n):
        for e in E:
            if d[e[0]]!=inf and d[e[1]]>d[e[0]]+e[2]:
                d[e[1]] = d[e[0]] + e[2]
                if i>=n:
                    d[e[1]] = -float('inf')
    return d

N,M,P = II()
A,B,C = Line(M)
E = []
for i in range(M):
    E.append([A[i]-1, B[i]-1, -C[i]+P])

d = BF(E,0,N)
if d[N-1]==-float('inf'):
    print(-1)
else:
    print(max(0,-d[N-1]))

Measured memory_bytes: 47576
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s[n];
    for(int i = 0;i < n;i++)
    {
        cin >> s[i];
    }
    vector<int> v;
    for(int i = 0;i < 26;i++)
    {
        char c = 'a' + i;
        int c_count = 0;
        for(int x = 0;x < s[0].size();x++)
        {
            if(s[0][x] == c)
            {
                c_count++;
            }
        }
        bool flag = true;
        for(int j = 0;j < n;j++)
        {
            int count = 0;
            for(int k = 0;k < s[j].size();k++)
            {
                if(s[j][k] == c)
                {
                    count++;
                }
            }
            if(count < c_count)
            {
                c_count = count;
            }
        }
        v.push_back(c_count);
    }
    for(int i = 0;i < 26;i++)
    {
        char c = 'a' + i;
        for(int j = 0;j < v.at(i);j++)
        {
            cout << c;
        }
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]A = new int[N];
			for(int i = 0;i<N;i++) A[i] = scan.nextInt();
			Arrays.sort(A);
			
			int B[] = new int[A[N-1]+1];
			
			for(int i = 0;i<N;i++) {
				for(int j = A[i];j<=A[N-1];j = j+A[i]) {
					B[j]++;
				}
			}
			
			int count = 0;
			for(int i = 0;i<N;i++) {
				if(B[A[i]]==1)count++;
			}
			
			System.out.println(count);
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 61164
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {

  while( true ) {

    long long int n, q;
    cin >> n >> q;
    if ( n == 0 ) break;

    vector< pair< string, pair< long long int, long long int > > > v;

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

      string s;
      long long int e, w;
      cin >> s >> e >> w;
      v.push_back( make_pair( s, make_pair( e, w ) ) );

    }

    for ( long long int i = 0; i < q; i++ ) {

      long long int in;
      cin >> in;

      bool f = true;
      for ( long long int j = 0; j < n; j++ ) {
	if ( in > v[j].second.second - v[j].second.first && in <= v[j].second.second ) {
	  cout << v[j].first << " " << v[j].second.first - ( v[j].second.second - in ) << endl;
	  f = false;
	  break;
	}
      }
      if ( f == true ) {
	cout << "Unknown" << endl;
      }

    }

  }

  return 0;

}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(u==s) a--;
    else if(u==t) b--;
    cout << a << " " << b << endl;
    return 0;
}

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

int arr[100005];
int dp[100005];
#define inf INT_MAX
int frog(int pos, int n){
    int a,b;
   for(int i=2; i<=n; i++){
       a=abs(arr[i-1]-arr[i])+dp[i-1];
       b=abs(arr[i-2]-arr[i])+dp[i-2];
       if(i==2){
        dp[i]=a;
       }
       else{
        dp[i]=min(a,b);
       }
   }
   return dp[n];
}

int main(){

    ios_base::sync_with_stdio(false);cout.tie(false);cin.tie(false);

    int n,i;
    cin>>n;
    for(i=1; i<=n; i++){
        cin>>arr[i];
    }
    cout<<frog(1,n)<<endl;


    return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    char s[h][w];
    rep(y, h) rep(x, w) cin >> s[y][x];

    rep(y, h) rep(x, w) {
        if (s[y][x] == '.') continue;

        bool ok = false;
        for (int dy = -1; dy <= 1; dy += 2) {
            int my = y + dy;
            if (my >= 0 && my < h && s[my][x] == '#') ok = true;
        }

        for (int dx = -1; dx <= 1; dx += 2) {
            int mx = x + dx;
            if (mx >= 0 && mx < w && s[y][mx] == '#') ok = true;
        }

        if (!ok) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256