jiahuimbzuai/CoQuIR huggingface dataset:
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}


func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    ///正答した問題の配列
    var aryAC = [String]()
    ///フラグ(ACであればTrue)
    var isAC = false
    var ACCount = 0
    var WACount = 0
    ///WAを数えるカウンター(ACが出た場合、WACounterに加算しリセットする)
    
    var counter = 0
    for i in 0..<m {
        let ps = readLine()!.split(separator: " ").map { String($0) }
        let (p, s) = (ps[0], ps[1])
        isAC = s == "AC"
        if isAC {
            if aryAC.firstIndex(of: p) == nil {
                aryAC.append(p)
                ACCount += 1
            }
            WACount += counter
            counter = 0
        } else {
            counter += 1
        }
    }
    print(ACCount, WACount)
}
//____________________________________________________________________ここまで入





main()
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}


func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    var aryQuestionNo = [String]()
    var aryJudge = [String]()
    for _ in 0..<m {
        let ps = readLine()!.split(separator: " ").map { String($0) }
        let (p, s) = (ps[0], ps[1])
        aryQuestionNo.append(p)
        aryJudge.append(s)
    }
    //____________________________________________________________________ここまで入力
    ///正答した問題の配列
    var aryAC = [String]()
    ///フラグ(ACであればTrue)
    var isAC = false
    var ACCount = 0
    var WACount = 0
    ///WAを数えるカウンター(ACが出た場合、WACounterに加算しリセットする)
    var counter = 0
    
    for i in 0..<m {
        isAC = aryJudge[i] == "AC"
        if isAC {
            if aryAC.firstIndex(of: aryQuestionNo[i]) == nil {
                aryAC.append(aryQuestionNo[i])
                ACCount += 1
            }
            WACount += counter
            counter = 0
        } else {
            counter += 1
        }
    }
    print(ACCount, WACount)
}


main()
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let [n,m]=tnn(2),p=[],k=[],save=new Array(n+1),wa=0,ac=0
  save.fill(0)
  for(let i=0;i<m;i++){
    p.push(tn())
    k.push(ts())
  }
  for(let i=0;i<m;i++){
    if(save[p[i]]==-1)continue
    if(k[i]=='WA'){
      save[p[i]]++
    }
    else if(k[i]=='AC'){
      ac++
      wa+=save[p[i]]
      save[p[i]]=-1
    }
  }
  to(ac,wa)
}
main()
//  [typescript]
const main = (input) => {
  const lines = input.trim().split("\n");
  const [N, M] = lines[0].split(' ').map(str => parseInt(str));
  const waCount = new Array(N).fill(0);
  const isAC = new Array(N).fill(false);
  let waSum = 0;

  lines.slice(1).forEach(line => {
    let [p, s] = line.split(' ');
    p = parseInt(p) - 1;
    if (s === 'AC' && !isAC[p]) {
      isAC[p] = true;
      waSum += waCount[p];
    } else {
      waCount[p]++;
    }
  });

  const acSum = isAC.filter(bool => bool).length;

  console.log(acSum + ' ' + waSum);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const [n,m]: number[] = input[0].split(' ').map((x: string): number => +x);
const ps = [];
for(let i=0;i<m;i++){
	ps.push(input[i+1].split(" "));
}

let AC: number = 0;
let WA: number = 0;
let li: number[] = new Array(n+1);
for(let i = 0; i<n+1; i++){
    li[i] = 0;
}


for(let i = 0; i < m; i++){
    const id = parseInt(ps[i][0]);
    if ( li[id] === -1 ){ continue; }
    if ( ps[i][1] ==='WA'){
        li[id] += 1;
    }else if( ps[i][1] ==='AC'){
        AC++;
        WA += li[id] || 0;
        li[id] = -1;
    }
}
console.log(AC, WA);
//  [typescript]
function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const m = parseInt(params1[1]);
  const p = lines.slice(1, m + 1).map(x => x.split(' ')[0]).map(x => parseInt(x));
  const s = lines.slice(1, m + 1).map(x => x.split(' ')[1]);

  let record = new Set();
  let accept = 0;
  let penalty = 0;
  for (let i = 0; i < m; i++) {
    if (!record.has(p[i])) {
      if (s[i] === 'AC') {
        record.add(p[i]);
        accept++;
      } else {
        penalty++;
      }
    }
  }
  console.log(`${accept} ${penalty}`);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const m = parseInt(params1[1]);
  const p = lines.slice(1, m + 1).map(x => x.split(' ')[0]).map(x => parseInt(x));
  const s = lines.slice(1, m + 1).map(x => x.split(' ')[1]);

  let record: {[n: number]: boolean} = {};
  let accept = 0;
  let penalty = 0;
  for (let i = 0; i < m; i++) {
    if (!record[p[i]]) {
      if (s[i] === 'AC') {
        record[p[i]] = true;
        accept++;
      } else {
        penalty++;
      }
    }
  }
  console.log(`${accept} ${penalty}`);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const main = (input: string) => {
  const lines = input.trim().split("\n")
  const PS = lines.slice(1).map(line => line.split(" "))
  const ACList = new Set()
  let WACount = 0

  PS.forEach(ps => {
    if(ps[1] === "AC") {
      ACList.add(ps[0])
    } else if (!ACList.has(ps[0])) {
      WACount += 1
    }
  })

  console.log(ACList.size + " " + WACount)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
A,B=map(int,input().split())
print(A+B if B%A==0 else B-A)
//  [python]
A,B=map(int,input().split())
if B%A==0:
    print(A+B)
else:
    print(B-A)
//  [python]
a,b = map(int,input().split())
if b % a == 0:
  print(a + b)
else:
  print(b-a)
//  [python]
a,b=map(int,input().split(" "))
print([a+b,b-a][b%a])
//  [python]
A,B=map(int,input().split())
if B%A==0:
    print(A+B)
else:
    print(A-B)
//  [python]
A,B=map(int(input().split()))
if B%A==0:
    print(A+B)
else:
    print(A-B)
//  [java]
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();




		System.out.println(B%A==0?A+B:B-A);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] input = br.readLine().split(" ");
            int numberA = Integer.parseInt(input[0]);
            int numberB = Integer.parseInt(input[1]);

            int result = numberB - numberA;
            if (numberB % numberA == 0) {
                result = numberA + numberB;
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}
//  [java]
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b%a == 0)
            System.out.println(a+b);
        else
            System.out.println(a-b);

    }
}
//  [java]
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 ((b % a) == 0) {
      System.out.println(a + b);
    } else {
      System.out.println(a - b);
    }

  }
}
//  [java]
import java.util.*;

public class Main{
	public static main(String args[]) {
    	Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (B % A == 0) {
          System.out.println(A + B);
        } else {
          System.out.println(B - A);
        }
    }
}
//  [cpp]
#include <cstdio>

int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d\n", b % a == 0 ? a + b : b - a);
  return 0;
}
//  [cpp]
#include<stdio.h>
int main()
{
	int A,B;
	scanf("%d%d", &A,&B);
	if(B%A==0)
	{
		printf("%d", A+B);
	}
	else
	printf("%d", B-A);
	return 0;	
}
//  [cpp]
#include <iostream>

using namespace std;

int main() {
  int a, b;

  cin >> a >> b;

  if (b % a == 0) {
    cout << a + b << endl;
  }
  else {
    cout << b - a << endl;
  }
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int a, b;
    cin >> a >> b;
    if (a%b == 0) cout << a+b << endl;
    else cout << b-a << endl;
    return 0;
}
//  [cpp]
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  
  if(b%a==0)
    cout<<a+b<<endl;
  else
    cout<<a-b<<endl;
  return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int a, b;
  scanf("%d %d", &a, &b);
  
  if(b%a){
    printf("%d", b-a);
  }
  else{
    printf("%d", a+b); 
  }

}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main(){
    int A, B;
    scanf("%d %d", &A, &B);
    if (B % A == 0) {
        printf("%d", A+B);
    } else {
        printf("%d", B-A);
    }
}
//  [c]
#include<stdio.h>

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

  	scanf("%d",&b);
  	
	
 	if(b % a == 0){
		c = a + b;
    }else{
		c = b - a;
    }
  
  	printf("%d",c);
	return 0;
  
}
//  [c]
#include <stdio.h>

int main(){
	int A, B;
	scanf("%d %d");
	printf("%d\n", (B%A == 0) ? A+B : B-A);
	
	return 0;
}
//  [c]
#include <stdio.h>

int main(){
	int A, B;
	scanf("%d %d", &A, &B);
	if(B%A == 0){
		printf("&d", A + B);
	}
	else{
		printf("&d", B - A);
	}
	
	return 0;
}
//  [c]
#include <stdio.h>

int main(){
	int A, B;
	scanf("%d %d", &A, &B);
	if(B % A == 0){
		printf("&d", A + B);
	}
	else{
		printf("&d", B - A);
	}
	
	return 0;
}
//  [javascript]
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
Main();
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  if(B % A == 0){
     myout(A + B);
  }else{
     myout(B - A);
  }
}
//  [javascript]
var stdin = require("fs").readFileSync("/dev/stdin", "utf8");
stdin = stdin.trim().split("\n").reverse();
function input(){return stdin.pop()}
var stdout = [];



var x = input().split(" ").map(n=>parseInt(n));
var a = x[0]
var b = x[1]
if (b % a){
    stdout.push(b - a)
}else{
    stdout.push(b + a)
}



stdout = stdout.join(" ");
console.log(stdout);
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	ab = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(ab[0], 10);
	var b = parseInt(ab[1], 10);
   if (b%a == 0){console.log(a+b);}else{console.log(b-a);}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input){
    ab=input.split(' ')
    a=parseInt(ab[0],10)
    b=parseInt(ab[1],10)
    if (a%b==0){
        console.log(a+b)

    }else{
        console.log(b-a)

    }


}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input){
    ab=input.split(' ')
    a=parseInt(ab[0],10)
    b=parseInt(ab[1],10)
    if (a/b==0){
        console.log(a+b)

    }else{
        console.log(b-a)

    }


}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
Main();
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  if(B % A == 0){
     myout(A + B);
  }else{
     myout(A - B);
  }
}
//  [go]
package main

import (
  "fmt"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  ans := b - a
  if b % a == 0 {ans = a + b}
  fmt.Println(ans)
}
//  [go]
package main

import "fmt"

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

	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}
//  [go]
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(a + b)
	}
}
//  [go]
a, b = gets.split.map(&:to_i)

if b%a == 0
    puts (a+b)
else
    puts (b-a)
end
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := getInt(), getInt()

	if a%b == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}
//  [ruby]
A,B = gets.split.map(&:to_i)
puts B%A==0 ? A+B : B-A
//  [ruby]
a,b=gets.split.map(&:to_i);p b % a == 0 ? a + b : b - a
//  [ruby]
a, b = gets.split("\s").map(&:to_i)

p b % a == 0 ? a+b : b-a
//  [ruby]
a,b=gets.split.map(&:to_i)
p (a%b==0)?(a + b):(b-a)
//  [ruby]
a,b=gets.split.map(&:to_i)
p (a%b==0)?a + b:b-a
//  [ruby]
a, b = gets.chomp.split.map(&:to_i)

ans = (b / a) % a

if ans == 0
  puts b + a
else
  puts b - a
end
//  [rust]
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	if b%a == 0 {
		println!("{}", a+b);
	}else{
		println!("{}", b-a);
	}
}
//  [rust]
use std::io;
use std::str::FromStr;

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

fn main() {
    let (a, b) = input_tuple();
    if b % a == 0 {
        println!("{}", a + b);
    } else {
        println!("{}", b - a);
    }
}
//  [rust]
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];

    if b % a == 0 {
        println!("{}", a+b);
    } else {
        println!("{}", b-a);
    }
}
//  [rust]
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (a, b): (usize, usize);
    input!(a, b);
    if a % b == 0 {
        p(a + b);
    } else {
        p(a - b);
    }
}
//  [rust]
(a, b) = map(int, input().split())
if b % a == 0:
    print(a + b)
else:
    print(b - a)
//  [rust]
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a = read(&mut stdin_lock, &mut buf, b' ');
    let b = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}{}", a, b);
    println!("{}", solve(a, b));
}

fn solve(a: i32, b: i32) -> i32 {
    if b % a == 0 {
        a + b
    } else {
        b - a
    }
}

#[test]
fn example1() {
    assert_eq!(16, solve(4, 12))
}

#[test]
fn example2() {
    assert_eq!(12, solve(8, 20))
}

#[test]
fn example3() {
    assert_eq!(2, solve(1, 1))
}
//  [swift]
import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let a = Int(input[0])!
let b = Int(input[1])!

if b % a == 0 {
  print(a+b)
} else {
  print(b-a)
}
//  [swift]
import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let a = Int(input[0])
let b = Int(input[1])

if b % a == 0 {
  print(a+b)
} else {
  print(b-a)
}
//  [swift]
import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let a = input[0]
let b = input[1]

if b % a == 0 {
  print(a+b)
} else {
  print(b-a)
}
//  [typescript]
export class Main {
  static main(input: string): string {
    const tmp = input.split("\n");
    const [a, b] = tmp[0].split(" ").map(Number);
    return `${b + (b % a == 0 ? 1 : -1) * a}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
((input: string): void => {
    const [a, b]: number[] = input.split(" ").map(Number);
    console.log(b%a==0 ? a+b : b-a);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function Main(raw) {
  const input = raw.split(/ |\n/);
  const A = parseInt(input[0], 10);
  const B = parseInt(input[1], 10);
  const ans= (B%A==0)?A+B:B-A;
  //出力
  console.log("%d", ans);
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result}

const main = ()=>{
  let[a,b]=nrin(2);
  a%b===0?out(a+b):out(b-a);
}
main();
//  [typescript]
function Main(args){
    const input=args.split(" ");
    const A=parseInt(input[0]);
    const B=parseInt(input[0]);
    const ans=B%A==0?A+B:B-A;
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
function Main(raw: string) {
  const input = raw.split([" ","\n"]);
  const A = parseInt(input[0], 10);
  const B = parseInt(input[1], 10);
  const ans= (B%A==0)?A+B:B-A;
  //出力
  console.log("%d", ans);
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
def main():
    n, *a = map(int, open(0).read().split())
    x1 = sum(a[::2]) - sum(a[1::2])
    x = [x1]
    for i in a[:-1]:
        x.append(2 * i - x[-1])
    ans = ' '.join(map(str, x))
    print(ans)


if __name__ == '__main__':
    main()
//  [python]
# ABC133D - Rain Flows into Dams
def main():
    # X_0 = sum(A) - 2 * sum(A[1::2]), X_i = 2Ai - X_{i-1}
    N, *A = map(int, open(0).read().split())
    X = [0] * N
    cur = sum(A) - 2 * sum(A[1::2])
    X[0] = cur
    for i, a in enumerate(A[:-1], 1):
        X[i] = a * 2 - cur
        cur = X[i]
    print(" ".join(map(str, X)))


if __name__ == "__main__":
    main()
//  [python]
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    X = [0] * N
    cur = sum(A) - 2 * sum(A[1::2])
    X[0] = cur
    for i, a in enumerate(A[:-1], 1):
        X[i] = a * 2 - cur
        cur = X[i]
    print(' '.join(map(str, X)))
    


if __name__ == "__main__":
    main()
//  [python]
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
x=-1
y=2*10**9
z=(x+y)//2
for i in range(1000):
    b[0]=z
    for j in range(1,n):
        b[j]=a[j-1]*2-b[j-1]
    if b[0]+b[-1]>2*a[-1]:
        y=z
        z=(x+y)//2
    elif b[0]+b[-1]<2*a[-1]:
        x=z
        z=(x+y)//2
    else:
        break
print(*b)
//  [python]
import numpy as np

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

coef_mat = np.matrix([[1 if (i == j or i + 1 == j or (i + 1 == N and j == 0)) else 0 for j in range(N) ] for i in range(N)])**(-1)
vec = np.matrix([A]).T
res = coef_mat @ vec

for i in range(N):
    print(int(res[i, 0]) * 2)
//  [python]
def nCk(_n,_k):
  if _k==0:
    return 1
  else:
    if _n<0 or _k<0 or _n-_k<0:
      return 0
    else:
      return (fact[_n]//(fact[_k]*fact[_n-_k]))%m

fact=[1]*2005
for i in range(1,2001):
  fact[i]=fact[i-1]*i

n,k=map(int,input().split())
m=10**9+7
ans=cnt=0
for _k in range(1,k+1):
  ans=(nCk(n-k+_k,_k)-cnt)*nCk(k-1,_k-1) if _k>1 else n-k+_k 
  cnt+=ans
  cnt%=m
  ans%=m
  print(ans)
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        StringBuilder sb = new StringBuilder();
        int N = sc.nextInt();
        long[] A = new long[N];
        long[] B = new long[N];
        boolean isEven = true;
        for(int i=0; i<N; i++) {
           A[i] = sc.nextLong();
            if (isEven) {
                B[0] += A[i];
                isEven = false;
            } else {
                B[0] -= A[i];
                isEven = true;
            }
        }
        sb.append(B[0]);
        sb.append(" ");
        for(int i=1; i<N; i++) {
            B[i] = 2*A[i-1]-B[i-1];
            sb.append(B[i]);
            sb.append(" ");
        }
        out.println(sb.toString());
        out.flush();
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
//  [java]

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

		int[] a = new int[n];
		long[] b = new long[n+1];
		for( int i=0 ; i<n ; i++ ) {
			a[i] = sc.nextInt();
		}
		
		long sum = 0;
		for( int i=0 ; i<n ; i++ ) {
			sum += a[i];
		}
		long sum2 = a[1];
		for( int i=3 ; i<n-1 ; i++ ) {
			sum2 += a[i];
		}
		b[0]= sum - 2*sum2;
		for( int i=0 ; i<n ; i++ ) {
			b[i+1] = a[i]*2 - b[i]; 
			System.out.println(b[i]);
		}
	}
}
//  [java]

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

		int[] a = new int[n];
		int[] b = new int[n+1];
		for( int i=0 ; i<n ; i++ ) {
			a[i] = sc.nextInt();
		}
		
		for( int i=0 ; i<n ; i++ ) {
			b[i+1] = a[i]*2 - b[i]; 
		}
		b[0]=b[n]/2;
		for( int i=0 ; i<n ; i++ ) {
			b[i+1] = a[i]*2 - b[i]; 
			System.out.println(b[i]);
		}
	}
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], *di = dn, dt;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = ' ';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N = getint();
	int A[100000];
	ll ans = (A[0] = getint());

	rep1(i, N - 1) {
		A[i] = getint();
		if (i & 1) ans = ans - A[i];
		else ans = ans + A[i];
	}

	putint(ans);
	rep(i, N - 1) {
		putint((ans = 2 * A[i] - ans));
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[100000];
int res[100000];
int main(){
  int i, x;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=1;i<N;i++){
    res[i] = A[i-1] - res[i-1];
  }
  x = (A[N-1] - res[N-1]) / 2;
  for(i=0;i<N;i++){
    if(i%2==0){
      res[i]+=x;
    }
    else{
      res[i]-=x;
    }
  }
  {
    int KL2GvlyY;
    if(N==0){
      putchar_unlocked('\n');
    }
    else{
      for(KL2GvlyY=0;KL2GvlyY<N-1;KL2GvlyY++){
        wt_L(2*res[KL2GvlyY]);
        wt_L(' ');
      }
      wt_L(2*res[KL2GvlyY]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190708-1

// --- original code ---
// int N, A[1d5];
// int res[1d5];
// {
//   int i, x;
// 
//   rd(N,A(N));
//   rep(i,1,N) res[i] = A[i-1] - res[i-1];
// 
//   x = (A[N-1] - res[N-1]) / 2;
//   rep(i,N) res[i] if[i%2==0, +=, -=] x;
// 
//   wt(2res(N));
// }
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X, Y;
string S, T;

signed main(){
  cin >> N;
  vi D(N);
  rep(i,N) cin >> D[i];
  vi Y(N);
  for(int i = 2*min(D[0],D[N-1]); i>=0; i -= 2){
    Y[0] = i;
    bool chk = true;
    rep1(j,N){
      Y[j] = (D[j-1]-Y[j-1]/2)*2;
      if(Y[j]<0){i += (Y[j]+1)*2 ; chk = false; break;}
    }
    if(!chk) continue;
    if((Y[N-1]+Y[0])/2 == D[N-1]) break;   
  }

  rep(i,N) {
    cout << Y[i];
    if(i!=N-1) cout << " ";
  }
  cout << endl;
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X, Y;
string S, T;

signed main(){
  cin >> N;
  vi D(N);
  rep(i,N) cin >> D[i];
  vi Y(N);
  for(int i = 2*min(D[0],D[N-1]); i>=0; i -= 2){
    Y[0] = i;
    bool chk = true;
    rep1(j,N){
      Y[j] = (D[j-1]-Y[j-1]/2)*2;
      if(Y[j]<0){i += Y[j]*2 ; chk = false; break;}
    }
    if(!chk) continue;
    if((Y[N-1]+Y[0])/2 == D[N-1]) break;   
  }

  rep(i,N) {
    cout << Y[i];
    if(i!=N-1) cout << " ";
  }
  cout << endl;
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X, Y;
string S, T;

signed main(){
  cin >> N;
  vi D(N);
  rep(i,N) cin >> D[i];
  vi Y(N);
  for(int i = 2*min(D[0],D[N-1]); i>=0; i -= 2){
    Y[0] = i;
    bool chk = true;
    rep1(j,N){
      Y[j] = (D[j-1]-Y[j-1]/2)*2;
      if(Y[j]<0){chk = false; break;}
    }
    if(!chk) continue;
    if((Y[N-1]+Y[0])/2 == D[N-1]) break;   
  }

  rep(i,N) {
    cout << Y[i];
    if(i!=N-1) cout << " ";
  }
  cout << endl;
  return 0;
}
//  [c]
// AtCoder ABC133: D - Rain Flows into Dams
// 2019.9.3 bal4u

#include <stdio.h>

typedef long long ll;

//// 高速入力
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(ll n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
}

ll  b[100005];

int main()
{
	int i, N; ll a, x;
	
	N = in();
	for (i = 1; i <= N; i++) {
		a = in();
		b[i] = (a << 1) - b[i-1];
	}
	x = b[N] >> 1, out(x);
	for (i = 1; i < N; i++) {
		pc(' ');
		if (i & 1) out(b[i]-x);
		else       out(b[i]+x);
	}
	pc('\n');
	return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 2019
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}


int main()
{
    lli i, j, n, a[100000],sum=0,a0,a1;
    scanf("%lld",&n);
    for(i=0; i<n; i++) {
        scanf("%lld",a+i);
        a[i] *= 2;
        sum += a[i];
    }
    sum /= 2;
    a0 = a1 = sum;
    for(i=1; i<n; i+=2) {
        a0 -= a[i];
        a1 -= a[i+1];
    }
    for(i=0; i<n-1; i+=2) {
        printf("%lld %lld ",a0,a1);
        a0 = a0 + a[i+1] - a[i];
        a1 = a1 + a[i+2] - a[i+1];
    }
    printf("%lld",a0);
    return 0;
}
//  [c]

#include <stdio.h>

int main()
{   int n;
    scanf("%d",&n);
    long a[n],sum=0;
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
        sum+=a[i];
    }
    int x[100000]={0};
    x[0]=sum;
    for(int i=1;i<n;i+=2){
        x[0]-=2*a[i];
    }
    printf("%d ",x[0]);
    for(int i=1;i<n;i++){
        x[i]=2*a[i-1]-x[i-1];
        printf("%d ",x[i]);
    }

    return 0;
}
//  [c]
#include <stdio.h>

int main()
{
	int i, N;
	long long A[100000];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	long long sum = 0, tmp;
	for (i = 1; i <= N; i++) sum += A[i];
	for (i = 1, tmp = sum; i <= N / 2; i++) tmp -= A[i*2] * 2;
	printf("%lld ", tmp);
	for (i = 2; i <= N; i++) {
		tmp = A[i-1] * 2 - tmp;
		printf("%lld ", tmp);
	}
	fflush(stdout);
	return 0;
}
//  [c]
N = int(input())
A = list(map(int, input().split(' ')))
a = 0
for i in range(N):
  a += (-1) ** i * A[i]
res = [0 for _ in range(N)]
res[0] = a
print('{} '.format(res[0]), end='')
for i in range(1, N - 1):
  res[i] = 2 * A[i-1] - res[i-1]
  print('{} '.format(res[i]), end='')
res[N-1] = 2 * A[N-2] - res[N-2]
print(res[N-1])
//  [c]
#include<stdio.h>
int main(){
  int n,i,j;
  scanf("%d",&n);
  long long mount[n+1],dam[n+1];
  for(i=0;i<n;i++){
    scanf("%lld",&dam[i]);
    mount[i]=dam[i];
  }
  for(i=0;i<n;i++)
    for(j=0;j<n/2;j++)
      mount[i]+=dam[(i+j*2+2)%n]-dam[(i+j*2+1)%n];
  for(i=0;i<n;i++)
    printf("%lld ",mount[i]);
  return 0;
}
//  [javascript]
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var sum = 0;
	for(var i = 0; i < N; i++){
		if(i % 2 == 0){
			sum += list[i] * 2;
		}else{
			sum -= list[i] * 2;
		}
	}
	var output = new Array(N);
	output[0] = sum / 2;
	for(var i = 1; i < N; i++){
		output[i] = list[i - 1] * 2 - output[i - 1];
	}
	myout(myconv(output,8));
}
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(input[0], 10);

	var valley = toIntAll(tmp);
	var sumValley=0;
	for(var i=0; i<valley.length; i++){
		sumValley += valley[i];
	}

	var tmpSum = 0;
	for(var i=1; i<valley.length; i+=2){
		tmpSum += valley[i];
	}
	tmpMountainZero = sumValley - (2*tmpSum);

	var tmpMountain = [];
	tmpMountain[0] = tmpMountainZero;
	for(var i=1; i<valley.length; i++){
		tmpMountain[i] = (valley[i-1] - (tmpMountain[i-1]/2)) * 2;
	}
	//出力
	console.log('%s', outputDelimiterSpace(tmpMountain));
}
function toIntAll(input){
  var out = []
  for(var i=0; i<input.length; i++){
    out[i] = parseInt(input[i]);
  }
  return out;
}
function outputDelimiterSpace(words){
  var out = words.join(' ');
  out += '\n';
  return out;
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.split(" ");
	input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var N = parseInt(input[0]);
  var list = input[1].split(" ").map((a)=>Number(a));
  var ruiseki = 0;
  for(var i = 0; i < list.length; i++){
    ruiseki += list[i];
  }
  var result = [];
  var tmp = 0;//x1を求めるとき用に偶数要素の累積を持たせる
  for(var i = 1; i < list.length; i = i + 2){
    tmp += list[i];
  }
  result[0] = ruiseki - 2 * tmp;
  for(var i = 1; i < list.length; i++){
    result.push(2 * list[i - 1] - result[i - 1]);
  }
  myout(result.join(" "));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function main(input){
  const args=input.split("\n");
  const N=parseInt(args[0],10);

  //A1,A2,…という配列
  const arr=input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));

  for(var i=0; i<N; i++){
    var k=0;
    for(var j=0; j<N; j++){
      k+=arr[(i+j)%N]*Math.pow(-1,j);
    }
    console.log(k+" ");
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
'use strict'
function main(input) {
    const tmp = Array.from(input.split('\n'));
    const N = parseInt(tmp[0], 10);
    const A = tmp[1].split(' ').map((elem) => parseInt(elem, 10));

    let X = [];
    const S = A.reduce((sum, elem) => sum + elem);
    const A2 = A.filter((elem, i) => i % 2 !== 0).reduce((sum, elem) => sum + elem);
    X[0] = S - 2 * A2;

    for (let i = 1; i < N; i++) {
        X[i] = 2 * A[i - 1] - X[i - 1];
    }

    console.log(X);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));